summaryrefslogtreecommitdiff
path: root/TASK2.asm
diff options
context:
space:
mode:
Diffstat (limited to 'TASK2.asm')
-rw-r--r--TASK2.asm22
1 files changed, 22 insertions, 0 deletions
diff --git a/TASK2.asm b/TASK2.asm
new file mode 100644
index 0000000..7ebd238
--- /dev/null
+++ b/TASK2.asm
@@ -0,0 +1,22 @@
+; MULTIPLY TWO NUMBERS TOGETHER, STORE IN MEMORY AT 00H
+; MULTIPLICATION IS NOTHING MORE THAN REPEATED ADDITION
+
+JMP START
+N1: EQU 05H ; MULTIPLICAND
+N2: EQU 03H ; MULTIPLIER
+N3: EQU 00H ; MEMORY LOCATION TO STORE RESULT
+START: LXI H,N3 ; H AS MEMORY POINTER TO OUTPUT LOCATION 00H
+ MVI C,0 ; CLEAR C
+ MOV B,C ; CLEAR B
+ MOV A,B ; CLEAR A
+ MVI C,N2 ; MOVE N2 INTO C, THIS IS OUR COUNTER
+ADD: MOV B,A ; STORE A IN B
+ MVI A,00H ; STORE 00H IN A
+ CMP C ; COMPARE C TO A
+ MOV A,B ; PUT B BACK INTO A
+ JZ END ; IF C == 0 JUMP TO END
+ ADI N1 ; ADD N1 TO A
+ DCR C ; DECREMENT C
+ JMP ADD ; JUMP TO ADD
+END: STA N3 ; STORE A
+ HLT ; HALT \ No newline at end of file