MULTIPLICATION OF TWO 8-BIT NUMBERS

ALGORITHM:
1. Start.
2. First 8-bit number is at memory address 0000h which is loaded to register B.
3. Second 8-bit number is at memory address 0001h which is loaded to register C.
4. Register C is assigned as counter i.e. we add B register value C times. This is called repeated addition method.
5. For the product to save, register A (accumulator) is used for lower 8-bit while register D, if necessary, for higher 8-bit value.
6. So, register A and D are initialized 0.
7. We add B value in loop until C reaches 0.
8. Register A value is stored to 0005h and register D value to 0006h.
9. End.
PROGRAM:
MVI D,0
MVI A,0
LXI H,0000h
MOV B,M
INX H
MOV C,M
LOOP: ADD B
JNC NEXT
INR D
NEXT: DCR C
JNZ LOOP
STA 0005h
MOV A,D
STA 0006h
HLT

No comments:

Post a Comment