blob: 7ebd238e50784de77d7f0b8328ab7a9c6d6bdb3c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
|