English

Write an Assembly Language Program to add two BCD number stored at location 2500H and 2501H. Place the BCD result in location 2502H and onward starting with LSB. - Computer Science 2

Advertisements
Advertisements

Question

Write an Assembly Language Program to add two BCD number stored at location 2500H and 2501H. Place the BCD result in location 2502H and onward starting with LSB.

Code Writing
Advertisements

Solution

        LDA 2500H        ; A = 1st BCD number
        MOV B, A

        LDA 2501H        ; A = 2nd BCD number
        ADD B            ; A = binary sum
        DAA              ; Adjust result to BCD

        STA 2502H        ; Store LSB (BCD result)

        MVI A, 00H       ; Prepare to store carry
        ADC A            ; A = 01H if CY = 1 else 00H
        STA 2503H        ; Store carry as next digit

        HLT
shaalaa.com
  Is there an error in this question or solution?
2021-2022 (March) Set 1

APPEARS IN

Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×