Al - Data Transfer
Al - Data Transfer
mov x, 42
mov y, 24
add z, x
add z, y
BX = 0041
MOV Instruction
• The mov instruction also allows us to copy
contents of one register into another register.
• Register operands
– A move involving only registers is the fastest
type.
– Registers should be used when an instruction
must execute quickly.
– Any registers may be used as a source operand,
and any register except CS and IP may be
destination operands,
• Mov ax,bx
• Mov dl, al
• Mov bx,cs
MOV Instruction
• Example:
mov bx, 2
mov cx, bx
• Another example:
mov bx, 4; copy number 4 into register bx
mov ax, bx; copy contents of bx into ax
mov cx, ax; copy contents of ax into cx
Limitations of MOV
• An immediate value cannot be moved into a
segment register directly (ie mov ds, 10)
• Segment registers cannot be copied directly (ie
mov es, ds)
• A memory location cannot be copied into another
memory location
(ie mov aNumber, aDigit).
• CS and IP cannot be destination operands
• The source and destination operands must be the
same size.
• If the source is immediate data, it must not exceed
255(FFh) for an 8-bit destination or 65,535
(FFFFh) for a 16-bit destination.
XCHG Instruction
• Swaps two values . The general form is
xchg operand1, operand2
• Can be in the following form:
xchg reg, mem
xchg reg, reg
• The order of the operand is not important
ie xchg ax, bx == xchg bx, ax
• xchg instruction does not modify any flags
XCHG Instruction