Data Transfer
Two most fundamental data transfer instructions in 8086 microprocessor are XCHG and MOV. Let's give illustrations of the use of these instructions.
Program 1: This program displays the difference of XCHG and MOV instructions:
DATA SEGMENT
VAL DB 5678H ; initialize variable VAL
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
MAINP: MOV AX, 1234H ; AH=12 & AL=34
XCHG AH, AL ; AH=34 & AL=12
MOV AX, 1234H ; AH=12 & AL=34
MOV BX, VAL ; BH=56 & BL=78
XCHG AX, BX ; AX=5678 & BX=1234
XCHG AH, BL ;AH=34,AL=78,BH=12,&BL=56
MOV AX, 4C00H ; Halt using INT 21h
INT 21H
CODE ENDS
END MAINP