Write a program IN EMU 8086
Write a program that swaps two numbers if A > B.
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
Comments
Leave a comment