Write a program in assembly language to swap two variables.
DATA SEGMENT
NUM_A DB 35H
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 ; AL=NUM_A
MOV BL, NUM_B ; BL=NUM_B
; SWAP
MOV NUM_B,AL
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