diff options
author | daniel-Jones <daniel@danieljon.es> | 2018-01-20 15:44:42 +1030 |
---|---|---|
committer | daniel-Jones <daniel@danieljon.es> | 2018-01-20 15:44:42 +1030 |
commit | c0b13d7fc1eeef8398f4ef4dad2b87ba34a392f4 (patch) | |
tree | 717e1485a2545163edfc03fa7a60634ea5da5d4e | |
parent | e4f040f94e27d1dbb4af3baef99b336da188938d (diff) | |
download | 8085-assembly-tasks-master.tar.gz 8085-assembly-tasks-master.zip |
-rw-r--r-- | TASK4.asm | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/TASK4.asm b/TASK4.asm new file mode 100644 index 0000000..cd32da8 --- /dev/null +++ b/TASK4.asm @@ -0,0 +1,29 @@ +; CALLING A ROUTINE AND PREPARE A MEMORY ADDRESS +; ROUTINE WILL REQUIRE 3 BYTES FIRST NUMBER -> SECOND NUMBER -> RESULT STORAGE +; ROUTINE WILL MULTIPLY M WITH M+1 AND STORE RESULT IN M+2 + +JMP START + ; DEFINE A LIST TO STORE OUR REQUIRED BYTES + ; DB = DEFINE BYTE + ; DS = DEFINE STORAGE. OPERAND IS NUMBER OF BYTES +MULTI1: DB 05H ; MULTIPLICAND + DB 03H ; MULTIPLIER + DS 01H ; RESERVES "ONE BYTE OF STORAGE +START: LXI H,MULTI1 ; LOAD HL AS POINTER TO MULTI1 LIST MEMORY ADDRESS + MVI A,0 ; CLEAR A + MOV D,M ; STORE MULTIPLICAND IN D + INX H ; INCREASE MEMORY POINTER TO GET MULTIPLIER + MOV E,M ; STORE MULTIPLIER IN E + MVI C,00H ; COUNTER SET TO 0 + CALL MULT ; CALL MULTIPLY FUNCTION + INX H ; INCREASE MEMORY POINTER TO RESULT STORAGE + MOV M,A ; STORE RESULT + HLT ; HALT +MULT: MOV B,A ; STORE A + MOV A,C ; MOVE COUNTER INTO A + CMP E ; COMPARE MULTIPLIER TO COUNTER + MOV A,B ; MOVE B STORAGE BACK INTO A + RZ ; RETURN IF ZERO FLAG SET (COUNTER == MULTIPLIER) + INR C ; INCREASE COUNTER + ADD D ; ADD MULTIPLICAND TO A + JMP MULT ; JUMP TO MULT
\ No newline at end of file |