Advertisements
Advertisements
Question
Write an assembly language program to multiply two 1-byte data stored at memory locations C600 H and C601 H respectively. Store the 16-bit result at locations C602 H and C603 H beginning with lower order byte of the result.
Short Answer
Solution
Label | Mnemonics code | Comments |
LXI H, C600H | ; Load HL pair | |
; immediately | ||
; with C600H | ||
MOV D, M | ; Move contents | |
; of memory to | ||
; register D | ||
INX H | ; Go to next memory | |
MOV E, M | ; Move contents of | |
; this memory into | ||
; register E | ||
XRA A | ; Clear content of | |
; Accumulator, (A) = 00H | ||
MOV B, A | ; Copy (A) to (B) | |
Back: | ADD D | ; Process of multiplication begins by |
; Adding 1st data into | ||
; Accumulator | ||
JNC skipcy | ; Jump if cy - 0 | |
INR B | ; count cy in B | |
Skip cy | DCR E | ; decrement loop |
; counter E, 2nd data | ||
JNZ back | ; IF counter E ≠ 0 | |
; Jump 'back' to | ||
; Continue multiplication | ||
INX H | ; Go to next memory | |
MOV M, A | ; Copy lower data | |
; byte of product | ||
INX H | ; Go to next memory | |
MOV M, B | ; Copy higher data | |
; byte of product | ||
HLT | ; Halt all process |
Note: Instead of HLT, RST 01 can be used and awarded equal credit.
shaalaa.com
Is there an error in this question or solution?
2023-2024 (March) Official