Advertisement Remove all ads

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

Answer in Brief

Write an Assembly Language Program to find absolute difference of two hex numbers stored in memory locations 5000H and 5001H. Store the result at 5002 H.

Advertisement Remove all ads

Solution

Label Opcode Operand Comments
LOOP: LXI, H, 5000 H ; Initialise HL pair to memory address 5000 H
MOV A, M ; Move memory Content to accumulator
INX H ; Increment HL pair by 1
SUB M ; Subtract memory Content from accumulator
JP LOOP ; If result is positive jump to LOOP
CMA ; Complement the contents of accumulator
ADI 01 ; Take 2’s complement by adding 1.
INX H ; Increment HL pair by 1
MOV M, A ; Store the result in memory location
RST 1 ; Restart
Concept: Instruction Set and Programming of 8085
  Is there an error in this question or solution?
Advertisement Remove all ads
Advertisement Remove all ads
Advertisement Remove all ads
Share
Notifications

View all notifications


      Forgot password?
View in app×