Professional Documents
Culture Documents
Gaurav Kumar
19075031
CSE(B.Tech.)
Code:
jmp start
;data
;Example Multiply two numbers 25 and 26
;Multiplicand is 25 and multiplier is 26
;25*26 = 650
;code
start: nop
LHLD 1000H ;Get Multiplicand in H-L pair. 25 in L[1000] and 00 in H[1001] register
XCHG ;it exchanges the content of H and L register with D and E registers.
LDA 1002H ;Get Multiplier in accumulator i.e A = 26
LXI H,0000H ;Initial product in HL = 0000
MVI C,08H ;Count=08 in register C
up: DAD H ;it adds the content of H and L register to itself
RAL ;Rotate multiplier(Accumulator) to left by 1 bit.
jnc down ;if no carry then jump
DAD D ;Product = Product + Multiplicand
down: DCR C ;Decrement Count
JNZ up ;Jump until C=0
SHLD 1003H ;It copies the data from H and L.L goes to 1003h and H goes to 1004h
hlt ;Terminate Program Execution
Screenshots:
Code:
jmp start
;data
;Example Divide 10 by 3
;code
start: nop
Divisor = 3 (1000h → 3)
Dividend = 10 (1001h → 10)
Screenshots: