As it is possible to access directly to microprocessor, assembly language is the most powerful computer programming language available and it gives programmers the insight required to write effective code in high-level languages.All writing codes of high-level programming languages converting to Assembly language, with this way computer can determine what the written program means.
When executing an instruction a special function is performed on data, These data are called operands.
e.g. MOV AX,BX –> “AX&BX” are operands
These operands may
- Reside in one of the MP(MicroProcessor)’s registers
- Stored at an address in memory
- Held at an I/O(Input/Output) port
To access these different types of operands, various addressing modes are provided.
Addressing Modes Catagories
- Register Operand Addressing
- Immediate Operand Addressing
- Memory Operand Addressing
- Direct Addressing Mode
- Register Indirect Addressing Mode
- Based Addressing Mode
- Indexed Addressing Mode
- Based Indexed Addressing Mode
1.Register Operand Addressing
Data registers can be accessed in byte, word or double-word sizes.
e.g. MOV AX,BX –>”AX&BX”, both operands are registers
Note: AH or AL –>Byte
2.Immediate Operand Addressing
Data is coded directly into the instruction.It can be in byte, word or double-word in size.
e.g. MOV AL,15 –> “15” is constant data
3.Memory Operand Addressing
Following points must be kept in mind in order to understand Memory Operand Addressing
- Program data is kept in DS(Data Segment)&ES(Extra Segment), code is in CS(Code Segment) & stack is in SS(Stack Segment).
- SP(Stack Pointer) & BP(Base Pointer) is used as offset of SS.
- IP(Instruction Pointer) is used as offset of CS.
- BX, SI & DI is used as offset of DS.
- If SI & DI is used together with SP & BP then SI & DI will be part of offset for SS.
3.1.Direct Addressing Mode
Contents of a memory location is the second operand.
MOV CX,[location] –> “[location]” is indicates, contents of given location as memory address.That location is converted into physical address by microprocessor.
e.g. Let say our DS(Data Segment) is 200H.
Memory values 3234 have ED and 3235 have BE.
MOV CX,[1234H] –> “CX” is 16 bit, “[1234H]” is memory address
Memory location that, MP(Micro Processor) move it’s contents
DS is 200H and in register DS is 0200H, we need multiply with 10 from here 0200×10=02000H is came.
For phsical address sum 02000H with 1234H from here 02000H+1234H=3234H
We have phsical address 3234H in memory and this memory’s values transferred to CX register.
CX register have BEED values.
3.2.Register Indirect Addressing Mode
Takes the contents of an indicated register and use it as memory address.
e.g. MOV AX[SI] –> “[SI]” contents of given register as memory address.
DS have 0200H values, SI have 1234H values.
Physical address 3234 have ED and 3235 have BE.
AX register have BEED values.
3.3.Based Addressing Mode(Relative Addressing Mode)
Takes the base address from BX and address displacement on it.By this way finds memory location that desired register content will be moved.
MOV [BX]+location,AX –> “[BX]” SI&DI registers can also be used BUT it’s name will be Indexed Addressing.
“AX” register may change to another register but always A register must be used.
BX includes the base address(starting) point of data segment & location is displacement.
e.g. MOV [BX]+1234,AX
For Physical memory location calculation DS=200Hx10H=2000H+1000H+1234H=4234H
After execution in memory 4234 have ED value and 4235 have BE value.
3.4.Indexed Addressing Mode
Indexed addressing mode works the same as the relative addressing mode.
Remember, in based addressing mode it was
Expect the registers DI and SI holds the offset address.
e.g. MOV DX,[SI]+5 –> Physical Address=DS(& 0000)+SI+5
MOV CL,[DI]+20 –> PA=DS(& 0000)+DI+20
3.5.Based Indexed Addressing Mode
The combination of the based and indexed addressing modes.
One base register and one index register are used.
e.g.MOV CL,[BX][DI]+8 –>PA=DS(& 0000)+BX+DI+8
MOV CH,[BX][SI]+20 –>PA=DS(& 0000)+BX+SI+20
MOV AH,[BP][DI]+12 –>PA=SS(& 0000)+BP+DI+12
MOV AL,[BP][SI]+29 –>PA=SS(& 0000)+BP+SI+29