Swap Two Numbers in Assembly Language


Write and run a program using 8086 assembly language that interchanges the values stored in two different memory locations. [June 2015, Set-3]

DATA SEGMENT
VALUE1 DB 10H
VALUE2 DB 5H
DATA ENDS

CODE SEGMENT
START:

ASSUME CS:CODE, DS:DATA
MOV AX, DATA
MOV DS, AX

MOV AL, VALUE1
XCHG VALUE2,AL
MOV VALUE1,AL

MOV AX, 4C00H
INT 21H
CODE ENDS

END START