Following is assembly language for multiplying two 16 bit numbers.
LHLD 0002H ;DATA 1
SPHL
LHLD 0004H ;DATA 2
XCHG
LXI H,0000H
LXI B,0000H
NEXT:
DAD SP
JNC LOOP
INX B
LOOP:
DCX D
MOV A,E
ORA D
JNZ NEXT
SHLD 0006H ;LSB
MOV L,C
MOV H,B
SHLD 0008H ;MSB
HLT
I did not understand the instruction ORA D
. Why ORing
is done here? Please can anyone explain it. Thank You!
ORA D
is used as a test instruction. It is logically ORing the accumulator with the D register. If the result is zero, it then exits the loop. Otherwise, the JNZ instruction following it reenters the loop.The D and E registers hold a countdown for the number of loops. The overall logic is hard for me to follow: it has been 30+ years since I have used the 8085, so I need to look up most of the instructions to unravel the logic. But hopefully this answers your question.