write a program for 8086 for adding two multiple byte numbers.(8BYTES LONG)
Answers
Algorithm –
Load data from offset 500 to register AL (first number)
Load data from offset 501 to register BL (second number)
Add these two numbers (contents of register AL and register BL)
Apply DAA instruction (decimal adjust)
Store the result (content of register AL) to offset 600
Set register AL to 00
Add contents of register AL to itself with carry
Store the result (content of register AL) to offset 601
Stop
Program –
MEMORY ADDRESS MNEMONICS COMMENT
400 MOV AL, [500] AL<-[500]
404 MOV BL, [501] BL<-[501]
408 ADD AL, BL AL<-AL+BL
40A DAA DECIMAL ADJUST AL
40B MOV [600], AL AL->[600]
40F MOV AL, 00 AL<-00
411 ADC AL, AL AL<-AL+AL+cy(prev)
413 MOV [601], AL AL->[601]
417 HLT END
Explanation –
MOV AL, [500]: load data from offset 500 to register AL
MOV BL, [501]: load data from offset 501 to register BL
ADD AL, BL: ADD contents of registers AL AND BL
DAA: decimal adjust AL
MOV [600], AL: store data from register AL to offset 600
MOV AL, 00: set value of register AL to 00
ADC AL, AL: add contents of register AL to AL with carry
MOV [601], AL: store data from register AL to offset 601