Thursday, 9 March 2017

Addressing Modes

      Addressing Modes:- 
       The access of memory and IOs can be calculated in several different ways, normally referred as Addressing Mode.
      These addressing modes greatly extend flexibility and convenience of instruction set.
80386 supports eleven addressing modes.
1.     Immediate addressing mode.
2.     Register addressing mode.
3.     Direct addressing mode.
4.     Register Indirect addressing mode.
5.     Based Relative addressing mode.
6.     Direct Indexed addressing mode.
7.     Base Indexed addressing with or without displacement
8.     Scaling ( Scaled Indexed, Based Scaled Indexed, Based Scaled Indexed with displacement.)
9.     Bit addressing.

Implied addressing mode
No address field.
Operand is implied by the instruction.
A fixed and unvarying address.
Example instruction:  Opcode
E.g.             CMC        ; complement carry
STC         ; set carry
CLD         ; clear  DF=0
AAS
DAA


Immediate addressing mode
It transfers an immediate byte or word data, into the destination register or memory location.
E.g.  MOV AX,00      
 MOV AL,04

Register addressing
Transfers a copy of byte or word from source register or memory location to the destination register or memory location.
e.g. MOV CX, DX

Direct addressing-
It moves a byte or word between a memory location and a register.
Eg.  MOV CX,LIST
        MOV [1234H],AX

Register Indirect addressing-
It transfers a byte or word between a register or memory location addressed by an index or base register.
e.g. MOV AX, [BX]
       MOV [DI], CL

Base Plus index addressing-
Base plus index addressing transfers a byte or word between a register and the memory location addressed by Base( BP or BX) plus an index register (SI or DI).
e.g. MOV [BX+DI], CL
       MOV DX, [BP+SI]

Register Relative addressing-
It moves a byte or word between a register and the memory location addressed by an index or base register plus a displacement.
e.g. MOV AX, [ECX+4]
       MOV BX, [BX+4]

Base relative plus index addressing-
It transfers a byte or word between a register and memory location
 addressed by a base and an index register plus a displacement.
e.g.  MOV AX, [BX+DI+4]
        MOV EBX, ARRAY[EBX+ECX]

Scaled Index addressing-
It is available only in 80386 or above microprocessors. The second register of a pair of registers is modified by the scale factor of 2X, 4X,  8X to generate the operand memory address.
Eg. MOV EDX, [EAX+4*ESI]
        MOV AL, [EBX+1*EDI]

Program Memory addressing Modes-
It is used with the JMP (jump) and CALL instructions. It consist of 3 distinct forms:
1.    Direct
2.    Indirect
3.    Relative

Direct Program Memory addressing-
It store the address with the opcode. The Direct Jump is also called as far Jump. The other instruction is far CALL instruction.
e.g.  JMP  [10000H]
        CALL DISPLAY
        JMP BACK

Indirect Program Memory addressing-
A register is used to hold the address. It uses any 16 bit register (AX, BX, CX, DX, SP, BP, SI, or DI) any relative register ([BX] ,[BP], [SI], [DI]) and any relative register with a displacement.
e.g.  JMP  EAX
If register is 16 bit, the Jump is near.
e.g. If BX=1000H  and   JMP BX ,  the microprocessor jumps to offset address 1000H  in the current code segment.
JMP  [BX]  refers to the memory location within the data segment at the offset address contained in BX. At this offset address is a 16 bit number that is used as the offset address in the intrasegment jump. This type of jump is sometimes called an double indirect jump.

Relative Program memory addressing-
Relative means “relative to the instruction pointer (IP).
e.g.        JMP [2]
JMP instruction is a one-byte instruction, with a one-byte or two byte displacement that adds to the instruction pointer.
Relative JMP and CALL instructions contain either an 8bit or a 16bit signed displacement that allows a forward memory reference or a reverse memory reference.

Stack Memory addressing modes-
Data are placed onto the stack with a PUSH instruction and removed with a POP instruction.
The stack memory is maintained by two registers: the stack pointer (SP or ESP) and the stack segment register (SS).
PUSH and POP store or retrieve words of data –never bytes.
            PUSHA and POPA instructions either push or pop all of the registers, except segment 
             registers, onto the stack.

No comments:

Post a Comment