Answer to Question #287389 in Assembler for ASDFGH

Question #287389

Write a program IN EMU 8086


Write a program that swaps two numbers if A > B.

1
Expert's answer
2022-01-15T09:18:39-0500
DATA SEGMENT
NUM_A DB 39H
NUM_B DB 37H
msgPress    db 10, 13,"Press any key... $"

DATA ENDS

CODE SEGMENT
START:
    MOV AX,DATA
    MOV DS,AX    
    MOV ES,AX
    
    MOV AL, NUM_A
    MOV BL, NUM_B  

    CMP AL, BL    ; compare a and b
    JLE exit      ; if a<=b goto exit

MOV NUM_B,AL       ; else swap
MOV NUM_A,BL
 
exit:    
    mov dx, offset msgPress
    mov ah, 9
    int 21h
    
   MOV AH,1            ; Waiting for a key press
    INT 21H    

EXIT_PROG:            ; Program is terminated
     MOV AH,4CH
     INT 21H

CODE ENDS
END START

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS