Add two 4-digit BCD numbers (8085)

1 comment
Statement : Add two 4 digit BCD numbers in HL and DE register pairs and store result in memory locations, 2300H. Ignore carry after 16 bit.

Sample Problem:

(HL)  =3629
(DE)  =4738
Step 1  :  29 + 38 = 61 and auxiliary carry flag = 1
: .add  06
61 + 06 = 67
Step 2  : 36 + 47 + 0 (carry of LSB) = 7D
Lower nibble of addition is greater than 9, so add 6.
7D + 06 = 83
Result = 8367

Microprocessor Programs

Source program:

MOV  A,  L    : Get lower 2 digits of no. 1
ADD  E     : Add two lower digits
DAA     : Adjust result to valid BCD
STA  2300H  : Store partial result
MOV  A,  H   : Get most significant 2 digits of number
ADC  D         : Add two most significant digits
DAA              : Adjust result to valid BCD
STA    2301H : Store partial result
HLT  : Terminate program execution.

1 comment :

Subscribe

Milan Panda
Admin
About Me | Contact
Copyright 2023-2024 © Programming1011 . 🎀 Developed and Design By- Milan Panda. Happy Holi All Of You 🎀