English

Write, an Assembly Language Program to find absolute difference of two hex numbers stored in memory locations 2500 H and 2501 H. Store the result at 2502H. - Computer Science 2

Advertisements
Advertisements

Question

Write, an Assembly Language Program to find absolute difference of two hex numbers stored in memory locations 2500 H and 2501 H. Store the result at 2502H.

Code Writing
Advertisements

Solution

Label           Mnemonics                                   Comments

       LXI H, 2500H     ; Set H-L pointer to 2500H
       MOV A, M         ; Move 1st number into Accumulator
       INX H            ; Increment H-L pair
       SUB M            ; Subtract 2nd number from 1st number
       JP GO            ; If result is positive, jump to GO
       MOV A, M         ; Move 2nd number into Accumulator
       DCX H            ; Decrement H-L pair
       SUB M            ; Subtract 1st number from 2nd number

GO:    STA 2502H        ; Store result at 2502H
       HLT              ; Stop execution
shaalaa.com
  Is there an error in this question or solution?
2022-2023 (March) Official
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×