OPERAND ADDRESSING
CALCULATING PHYSICAL MEMORY
• The 8086 memory addresses are calculated
by adding the segment register contents to an
offset address.
• The offset address calculation depends on the
addressing mode.
• The total number of address lines in 8086 is
20 and segment register is 16 bits.
• The segment register contents are multiplied
by 10H, shifting the contents to the lefts by 4
bits.
Contd..
• This result in the starting address of the
segment in the memory.
• The offset address is calculated . The offset
address is basically the offset of the actual
memory location.
• Calculation of offset value depends on the
addressing modes.
• The offset address is added to the starting
address of the segment to get the effective
address (i.e.,) Physical memory location.
Contd..
• Starting address of code segment =
3250H*10H = 32500H
• offset address = contents of IP= 0245H
• Effective address of instruction = 32500H
+0245H = 32745H.
• The explanation of the above is shown in the
upcoming slide.
Fig : Instruction Addressing
ADDRESSING MODES IN 8086
• Register Addressing Mode
• Immediate Addressing mode
• Direct memory addressing mode
• Register indirect addressing mode
• Base plus index register addressing mode
• Register relative addressing mode
• Base plus index register relative addressing
mode
• String addressing mode
REGISTER ADDRESSING MODES
• Both destination and source operands
resides in registers. Its is known as register
addressing modes.
MOV AX,BX ( Contents in BX will move to AX)
AND AL,BL ( AND the contents of AL reg with
the BL reg)
IMMEDIATE ADDRESSING MODE
• One of the operands is part of the instruction
the addressing mode is know as immediate
addressing mode.
MOV CX,2364H ( copy in to CX the 16 bit data)
SUB AL,24H ( Sub 24H from the contents of AL
reg and result is stored in the AL reg)
DIRECT MEMORY ADDRESSING MODE
• In this mode the 16 bit offset address is part of
the instruction as displacement field.
• It is stored as 16bit unsigned or 8 bit signed
extended number immediately following the
instruction opcode.
MOV (4625H),DX ( Copy the contents of DX
reg in to memory locations)
OR AL,(3030H) ( Refer fig)
Contd..
• If AL contains 70H before instruction
execution and DS contains 3745H then the
memory location of operand
= ( DS)*10H+3030H
= 37450H + 3030H = 3A480H
If the memory location 3A480H has 57H as
contents, then
(AL) 57H OR 70H
(AL) = 77H
Fig : Execution of direct memory addressed
instruction OR AL (303H)
REGISTER INDIRECT ADDRESSING MODES
• In this addressing mode , the offset address is
specified through pointer register or index
register.
• For index register, the SI ( source index ) or DI
(destination index) register may be used.
• For pointer register BX ( Base register) or BP
(Base pointer) register may be used.
XOR (DI),CL
Contd..
• Perform XOR operation between the contents
of CL register and the contents of memory
location and address is calculated using the
offset stored in DI register and DS register.
• The result is stored in the memory location.
If DS contains 1400H , DI contains 0056H and
CL contains 7FH, then
(DS)*10H+(DI)=14000H+0056H
= 14056H
Contd..
• If the memory location 14056H contains 43H
then
43H XOR 7FH = 3CH
3CH is stored in memory location 14056H.
The below fig show the function of the above
mentioned opcode..
Fig : Execution of Register indirect
addressing mode XOR (DI), CL
BASE PLUS INDEX REGISTER ADDRESSING
MODE
• The main utility of this addressing mode is
when an array of data is to be addressed .
• It is the extension of register indirect
addressing mode.
• In this mode both base register ( BP or BX)
and index register ( SI or DI) are used to
indirectly address the memory location.
MOV (BX+DI),AL
Contd..
• If DS contains 1000H, BX contains 0500H, DI
contains 0 and AL contains 24H, we get
• (DS) * 10H + (BX) = 10000H+0500H=10500H
• Since DI contains 0 , the actual memory
location address (i.e.,) effective address =
10500H .
• Thus 24H is copied to memory location
10500H. If DI was made 1 , 24H will be copied
to the next memory location.
Fig : Execution of base plus index register
addressing mode instruction MOV (BX+DI),AL
REGISTER RELATIVE ADDRESSING MODE
• This mode is similar to base plus index
addressing mode.
• In this mode the offset is calculated using
either a base register (BP,BX) or an index
register (SI,DI)
• And the displacement is specified as an 8 or
16 bit number as a part of instruction.
• The displacement is specified for addition or
subtraction like BX+3 , DI*-0050H, etc.,
Contd..
• Similar to base plus index addressing mode,
the register relative addressing mode can also
be used to access different elements of the
array.
• Displacement indicates the distance of the
array element to be accessed from the
beginning or the end of the array.
Contd..
MOV AX,(DI+06) ( Copy to AL the contents of
memory location whose address is calculated
using DS ( Data segment) , DI ( Destination
index) register with displacement of 06, and
copy to AH the contents of the next higher
memory location)
(DS) * 10H = 1000H
(DS)*10H + (DI) = 10500H
(DS) *10H + (DI) + 06H = 10506H
Lower byte = 10506H, Higher byte = 10507H
Fig : Execution of register relative addressing
mode instruction MOV AX,(DI +06)
BASE PLUS INDEX REGISTER RELATIVE
ADDRESSING MODE
• This addressing mode is basically the
combination of base plus index register
addressing mode and register relative
addressing mode.
• To find the address of the operand in
memory a base register (Bp or BX) an index
register (DI or SI) is used.
• The following opcode is the example for the
above mentioned addressing mode.
Contd..
MOV (BX+DI+2),CL ( Copy the contents of the
CL register to the memory location whose
address is calculated using DS ( Data segment),
BX ( Base register) and DI (Destination Index)
register and 02 as displacement)
If DS contains 0500H , BX contains 0050H , DI
contains 0007H , we get
Contd..
(DS) * 10H = 05000H
(BX) + (DI) + 2 = 0050H +0007H + 02 H
= 0059H
((DS) * 10H + (BX) + (DI) + 2) = 05059H
If CL contains FFH , this value will be copied to
memory location 05059H.
The below fig shows the illustration of the
above mentioned opcode.
Fig : Execution of base plus index register relative
addressing mode instruction MOV (BX+DI+2),CL
STRING ADDRESSING MODE
• The accessing of the string operands is
different from that of the other operands.
• There are special instructions for string
operations
• In this string addressing the segment register
(DS) and the index register (SI) are used as
source string.
• Segment register (ES) and index register (DI)
are used as destination string.
Contd..
• The direction flag bit DF in flag register plays
an important role in string instructions .
• If DF=0 both SI and DI are incremented.
• If DF=1 both SI and DI are decremented.
• Thus SI and DI point to the next byte of the
string.
• As example is given below.
Contd..
MOV SB (Copy the byte from source string
location determined by DS and SI to the
destination string location determined by ES
and DI).
If (DS) = 0500H ,(SI)=0000H,
(ES)=0F00H,(DI)=0000H and (DF)=0
Source location= (DS)*10H+SI
= 0500H +0000=05000H
Destination location = (ES)*10H+(DI)
= 0F00H+0000=0F000H
Contd..
• If 96H is contained in location 05000H, it will be
copied to location 0F0000H .
• Both SI and DI will be incremented by 1
Fig : Execution of string addressing mode
MOVSB

OPERAND ADDRESSING MODESOPERAND ADDRESSING MODES

  • 1.
  • 2.
    CALCULATING PHYSICAL MEMORY •The 8086 memory addresses are calculated by adding the segment register contents to an offset address. • The offset address calculation depends on the addressing mode. • The total number of address lines in 8086 is 20 and segment register is 16 bits. • The segment register contents are multiplied by 10H, shifting the contents to the lefts by 4 bits.
  • 3.
    Contd.. • This resultin the starting address of the segment in the memory. • The offset address is calculated . The offset address is basically the offset of the actual memory location. • Calculation of offset value depends on the addressing modes. • The offset address is added to the starting address of the segment to get the effective address (i.e.,) Physical memory location.
  • 4.
    Contd.. • Starting addressof code segment = 3250H*10H = 32500H • offset address = contents of IP= 0245H • Effective address of instruction = 32500H +0245H = 32745H. • The explanation of the above is shown in the upcoming slide.
  • 5.
  • 6.
    ADDRESSING MODES IN8086 • Register Addressing Mode • Immediate Addressing mode • Direct memory addressing mode • Register indirect addressing mode • Base plus index register addressing mode • Register relative addressing mode • Base plus index register relative addressing mode • String addressing mode
  • 7.
    REGISTER ADDRESSING MODES •Both destination and source operands resides in registers. Its is known as register addressing modes. MOV AX,BX ( Contents in BX will move to AX) AND AL,BL ( AND the contents of AL reg with the BL reg)
  • 8.
    IMMEDIATE ADDRESSING MODE •One of the operands is part of the instruction the addressing mode is know as immediate addressing mode. MOV CX,2364H ( copy in to CX the 16 bit data) SUB AL,24H ( Sub 24H from the contents of AL reg and result is stored in the AL reg)
  • 9.
    DIRECT MEMORY ADDRESSINGMODE • In this mode the 16 bit offset address is part of the instruction as displacement field. • It is stored as 16bit unsigned or 8 bit signed extended number immediately following the instruction opcode. MOV (4625H),DX ( Copy the contents of DX reg in to memory locations) OR AL,(3030H) ( Refer fig)
  • 10.
    Contd.. • If ALcontains 70H before instruction execution and DS contains 3745H then the memory location of operand = ( DS)*10H+3030H = 37450H + 3030H = 3A480H If the memory location 3A480H has 57H as contents, then (AL) 57H OR 70H (AL) = 77H
  • 11.
    Fig : Executionof direct memory addressed instruction OR AL (303H)
  • 12.
    REGISTER INDIRECT ADDRESSINGMODES • In this addressing mode , the offset address is specified through pointer register or index register. • For index register, the SI ( source index ) or DI (destination index) register may be used. • For pointer register BX ( Base register) or BP (Base pointer) register may be used. XOR (DI),CL
  • 13.
    Contd.. • Perform XORoperation between the contents of CL register and the contents of memory location and address is calculated using the offset stored in DI register and DS register. • The result is stored in the memory location. If DS contains 1400H , DI contains 0056H and CL contains 7FH, then (DS)*10H+(DI)=14000H+0056H = 14056H
  • 14.
    Contd.. • If thememory location 14056H contains 43H then 43H XOR 7FH = 3CH 3CH is stored in memory location 14056H. The below fig show the function of the above mentioned opcode..
  • 15.
    Fig : Executionof Register indirect addressing mode XOR (DI), CL
  • 16.
    BASE PLUS INDEXREGISTER ADDRESSING MODE • The main utility of this addressing mode is when an array of data is to be addressed . • It is the extension of register indirect addressing mode. • In this mode both base register ( BP or BX) and index register ( SI or DI) are used to indirectly address the memory location. MOV (BX+DI),AL
  • 17.
    Contd.. • If DScontains 1000H, BX contains 0500H, DI contains 0 and AL contains 24H, we get • (DS) * 10H + (BX) = 10000H+0500H=10500H • Since DI contains 0 , the actual memory location address (i.e.,) effective address = 10500H . • Thus 24H is copied to memory location 10500H. If DI was made 1 , 24H will be copied to the next memory location.
  • 18.
    Fig : Executionof base plus index register addressing mode instruction MOV (BX+DI),AL
  • 19.
    REGISTER RELATIVE ADDRESSINGMODE • This mode is similar to base plus index addressing mode. • In this mode the offset is calculated using either a base register (BP,BX) or an index register (SI,DI) • And the displacement is specified as an 8 or 16 bit number as a part of instruction. • The displacement is specified for addition or subtraction like BX+3 , DI*-0050H, etc.,
  • 20.
    Contd.. • Similar tobase plus index addressing mode, the register relative addressing mode can also be used to access different elements of the array. • Displacement indicates the distance of the array element to be accessed from the beginning or the end of the array.
  • 21.
    Contd.. MOV AX,(DI+06) (Copy to AL the contents of memory location whose address is calculated using DS ( Data segment) , DI ( Destination index) register with displacement of 06, and copy to AH the contents of the next higher memory location) (DS) * 10H = 1000H (DS)*10H + (DI) = 10500H (DS) *10H + (DI) + 06H = 10506H Lower byte = 10506H, Higher byte = 10507H
  • 22.
    Fig : Executionof register relative addressing mode instruction MOV AX,(DI +06)
  • 23.
    BASE PLUS INDEXREGISTER RELATIVE ADDRESSING MODE • This addressing mode is basically the combination of base plus index register addressing mode and register relative addressing mode. • To find the address of the operand in memory a base register (Bp or BX) an index register (DI or SI) is used. • The following opcode is the example for the above mentioned addressing mode.
  • 24.
    Contd.. MOV (BX+DI+2),CL (Copy the contents of the CL register to the memory location whose address is calculated using DS ( Data segment), BX ( Base register) and DI (Destination Index) register and 02 as displacement) If DS contains 0500H , BX contains 0050H , DI contains 0007H , we get
  • 25.
    Contd.. (DS) * 10H= 05000H (BX) + (DI) + 2 = 0050H +0007H + 02 H = 0059H ((DS) * 10H + (BX) + (DI) + 2) = 05059H If CL contains FFH , this value will be copied to memory location 05059H. The below fig shows the illustration of the above mentioned opcode.
  • 26.
    Fig : Executionof base plus index register relative addressing mode instruction MOV (BX+DI+2),CL
  • 27.
    STRING ADDRESSING MODE •The accessing of the string operands is different from that of the other operands. • There are special instructions for string operations • In this string addressing the segment register (DS) and the index register (SI) are used as source string. • Segment register (ES) and index register (DI) are used as destination string.
  • 28.
    Contd.. • The directionflag bit DF in flag register plays an important role in string instructions . • If DF=0 both SI and DI are incremented. • If DF=1 both SI and DI are decremented. • Thus SI and DI point to the next byte of the string. • As example is given below.
  • 29.
    Contd.. MOV SB (Copythe byte from source string location determined by DS and SI to the destination string location determined by ES and DI). If (DS) = 0500H ,(SI)=0000H, (ES)=0F00H,(DI)=0000H and (DF)=0 Source location= (DS)*10H+SI = 0500H +0000=05000H Destination location = (ES)*10H+(DI) = 0F00H+0000=0F000H
  • 30.
    Contd.. • If 96His contained in location 05000H, it will be copied to location 0F0000H . • Both SI and DI will be incremented by 1
  • 31.
    Fig : Executionof string addressing mode MOVSB