1481
1481
• MOV AX,BX; This instruction transfers the word contents of the source-
register(BX) into the destination register(AX).
• The source never changes, but the destination always changes.
• This instruction always copies the source-data into the destination.
• This instruction never actually picks up the data and moves it.
• Memory-to-memory transfers are not allowed by any instruction except for the
MOVS instruction.
• The source & destination are called operands (ex: contents of AX, BX, LOC)
• An opcode(operation code) tells microprocessor which operation to perform
(Ex : ADD, MOV, SUB).
8086 Data Addressing Modes
Addressing Modes
Register Addressing
• This transfers a copy of a byte(or word) from the source-register or
contents of a memory-location to the destination-register or memory-
location.
• Example: MOV CX, DX; This instruction copies word-sized contents
of register DX into register CX.
Immediate Addressing
• This transfers an immediate byte/word of source-data into the
destination-register or memory-location.
• For example, MOV AL, 22H ;This instruction copies a byte-sized 22H
into register AL.
Direct Addressing
• This moves a byte(or word) between a memory-location and a register.
• For example, MOV CX, LIST ;This instruction copies the word-sized
contents of memory-location LIST into register CX.
• Memory-to-memory transfers are not allowed by any instruction except
for the MOVS instruction.
Register Indirect Addressing
• This transfers a byte between a register and a memory-location
addressed by base-register.
• The index & base registers are BP, BX, DI and SI.
• For example, MOV [BP], DL ;This instruction copies the byte-sized
contents of register DL into the memory location addressed by BP.
Base Plus Index Addressing
• This transfers a byte between a register and the memory-location
addressed by a base-register (BP or BX) plus an index-register (DI or SI).
• For example, MOV [BX+DI], CL ;this instruction copies the byte-sized
contents of register CL into the memory location addressed by BX plus
DI.
Register Relative Addressing
• This moves byte between a register and memory-location addressed by
an index-or base-register plus a displacement.
• For example, MOV AX, [BX+4] ;This instruction loads AX from
memory-location addressed by BX+4.
Base-Relative-Plus Index Addressing
• This transfers a byte between a register and the memory-location
addressed by a base- and an index-register plus a displacement.
• For example, MOV AX,[BX+DI+4] ;This instruction loads AX
from memory-location addressed by BX+DI+4.
Scaled Index Addressing
• The second register of a pair of registers is modified by the scale
factor of 2*, 4* to generate the operand memory address.
• For example, MOV EDX, [EAX+4*EBX] ;This instruction loads
EDX from memory-location addressed by EAX plus four times EBX.
• Scaling allows access to word(2*), doubleword(4*) memory array-
data.
RIP Relative Addressing
• This mode allows access to any location in the memory by adding a
32-bit displacement to the 64-bit contents of the 64-bit instruction
pointer.
Register Addressing
• The microprocessor contains the following 8-bit registers used with
register addressing: AH, AL, BH, BL, CH, CL, DH and DL.
• Also present the following 16-bit registers: AX, BX, CX, DX, SP, BP,
SI and DI.
• Some MOV instructions and the PUSH/POP instructions also use the
16-bit segment registers: CS, ES, DS, SS, FS and GS.
• Any instruction should use registers that are of same size {(AL,CL),
(AX,CX)}. Never mix an 8-bit register with a 16-bit register because this
is not allowed by the microprocessor and results in an error. A few
instructions such as SHL DX, CL are exceptions to this rule.
• None of the MOV instructions affect the flag bits. The flag bits are
normally modified by arithmetic or logic instructions (ADD, SUB, INC)
• A segment-to-segment register MOV instruction is not allowed.
• The contents of the destination-register (or memory-location) change
for all instructions except the CMP and TEST instructions.
Examples of register-addressed instructions
The effect of executing the MOV BX,CX instruction at the
point just before the BX register changes.
Note : That only the rightmost 16bits of register EBX
change
Examples :
MOV AX, BX ; copy contents of BX into AX
MOV CL, DH ; copy contents of DH into CL
MOV AX, CS ; copy CS into DS (2 steps)
MOV DS, AX ;
MOV CS, AX ; copy AX into CS (causes problem)
Immediate Addressing
• The term ‘immediate’ implies that the data immediately follow the
opcode in the memory.
• Immediate-data are constant-data, whereas data transferred from a
register( or memory-location) are variable-data.
• This addressing operates upon a byte or word of data.
• MOV immediate instruction transfers a copy of immediate-data
into a register or a memory-location.
• The symbolic assembler shows immediate-data in many ways.
The letter H appends hexadecimal data.
The letter B appends binary data.
Examples of immediate addressing using the MOV
instruction
Operation of the MOV EAX,13456H instruction.
This instruction copies immediate data(13456) into EAX
Each statement in an assembly language program consists of 4 parts:
1) Label is used to store a symbolic-name for the memory-location that it
represents. A label may be of any length from 1 to 35 characters.
2) Opcode-field is used to hold the instruction or opcode
3) Operand-field contains information used by the opcode
4) Comment-field contains a comment about an instruction or a group of
instructions. A comment always begins with a semicolon (;)
Direct Data Addressing
• There are 2 basic forms of direct data addressing:
1) Direct addressing applies to a MOV between a memory-location
and the AL or AX (accumulator)
2) Displacement addressing applies to almost any instruction in the
instruction set
• In either case, the effective-address(EA) is formed by adding the
displacement to the default data-segment address.
(ex: if DS=1000 and BP=200, then
EA=DS*10+BP=1000*10+200=10200H)
Direct Addressing
• Direct addressing with a MOV instruction transfers data between a memory-
location, located within the data segment and the AL or AX register.
• A MOV instruction is usually a 3-byte long instruction.
• The MOV AL,DATA ;This instruction loads AL from the memory-location
DATA(1234H)
• Memory location ‘DATA’ is a symbolic memory location, while the 1234H is
the actual hexadecimal location.
• MOV AL, [1234H] ;This instruction transfers a copy of the byte-sized
contents of memory-location 11234H into AL.
The effective address is formed by adding 1234H(offset address) and
10000H(data segment address of 1000H ties 10H) in a system operating in the
real mode.
The operation of the MOV AL,[1234H] instruction when DS=1000H