Advertisements
Advertisements
Question
Write an Assembly Language Program to find the product of two numbers stored in memory location C005H and C006H. Store the result in C000H and C001H.
Code Writing
Advertisements
Solution
LDA C005H ; A = multiplicand
MOV B, A ; B = multiplicand
LDA C006H ; A = multiplier
MOV C, A ; C = multiplier (counter)
LXI H, 0000H ; HL = 0000 (16-bit result)
LOOP: MOV A, L ; Add multiplicand to L
ADD B
MOV L, A
JNC NEXT ; If no carry, skip increment
INR H ; If carry, increment high byte
NEXT: DCR C ; Decrease multiplier count
JNZ LOOP ; Repeat till C = 0
MOV A, L ; Store result low byte
STA C000H
MOV A, H ; Store result high byte
STA C001H
HLTshaalaa.com
Is there an error in this question or solution?
