English

Write an Assembly Language Program to add two 16-bit numbers. The first 16-bit number is stored from memory location CO40H and CO41H. The second 16-bit number is stored from memory location CO42H - Computer Science 2

Advertisements
Advertisements

Question

Write an Assembly Language Program to add two 16-bit numbers. The first 16-bit number is stored from memory location CO40H and CO41H. The second 16-bit number is stored from memory location CO42H and CO43H. Store the three byte result starting from memory location CO50H.

Code Writing
Advertisements

Solution

Label                Mnemonics             Comments

          MVI A, 00H    ; Clear Accumulator to store Carry
          LHLD C040H    ; Load first 16-bit number into HL
          XCHG          ; Move first number to DE pair
          LHLD C042H    ; Load second 16-bit number into HL
          DAD D         ; Add DE to HL (Result in HL, Carry in CY flag)
          
          JNC next      ; If no carry, skip increment
          INR A         ; If carry generated, set A = 01H
          
next:     SHLD C050H    ; Store 16-bit sum at C050H and C051H
          STA C052H     ; Store carry (from A) at C052H
          HLT           ; Stop program
shaalaa.com
  Is there an error in this question or solution?
2023-2024 (July) Official Board Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×