Add two 4-digit BCD numbers

Statement: Add two 4 digit BCD numbers in HL and DE register pairs and store result in memory locations, 2300H and 2301H. 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
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.

Flowchart for Program
46-Add two 4-digit BCD numbers

Post a Comment

1 Comments

  1. Question 1
    Write 8085 Assembly Language Program to classify the numbers into positive, negative, odd and even
    numbers. The list of numbers is stored from A001h and the amount of number is stored in A000h. The
    result of classification is stored starting from the corresponding memory location:
    – Positive number: A011h
    – Negative number: A021h
    – Odd number: A031h
    – Even number: A041h
    Note: Assume the amount of number is less than 10 and 2's complement.

    ReplyDelete
Emoji
(y)
:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
x-)
(k)

Close Menu