1 / 18

Chapter four 80x86 Instruction Set ( 2 ) 8086 Addressing Modes

Chapter four 80x86 Instruction Set ( 2 ) 8086 Addressing Modes. What is the Addressing Mode ?. add dest, source ; dest +source →dest add ax,bx ; ax +bx →ax The addressing mode means where and how the CPU gets the operands when the instruction is executed.

zora
Download Presentation

Chapter four 80x86 Instruction Set ( 2 ) 8086 Addressing Modes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter four80x86 Instruction Set(2)8086 Addressing Modes 2014年8月14日1

  2. What is the Addressing Mode ? add dest, source ; dest +source→dest add ax,bx ; ax +bx→ax The addressing mode means where and how the CPU gets the operands when the instruction is executed. 2014年8月14日2

  3. Three types of 8086 addressing modes • Immediate Addressing Mode ---CPU gets the operand from the instruction • Register Addressing Mode ---CPU gets the operand from one of the internal registers • Memory Addressing Mode ---CPU gets the operand from the memory location(s) 2014年8月14日3

  4. Instruction Queue AH AL Instruction Queue AL 80H 12 34 B8 MACHINE CODE MACHINE CODE B0H 34H 34 80H 80H 12 12H 1. Immediate Addressing Mode Exp: MOV AL, 80H Machine code:B080H MOV AX, 1234H Machine code:B83412H CPU gets the operand from the instruction queue 2014年8月14日4

  5. 2. Register Addressing Mode Exp:MOV AX, CX Memory AX 89 CX Machine code C1 CPU gets the operands from the registers 2014年8月14日5

  6. 3. Memory Addressing Mode CPU gets the operand from the memory location(s) • Specify an offset address (effective address) using expressions of the form (different parts of expression are optional): • [ Base Register + Index Register+ Displacement] • 1) Base Register---BX, BP • 2) Index Register---SI, DI • 3) Displacement ---constant value • Example: 1) add ax,[20h] 2) add ax,[bx] 3) add ax,[bx+20h] 4) add ax, [bx+si] 5) add ax, [bx+si+20h] please note how the effective addresses are given for the source operands in all these 5 instructions!!! 2014年8月14日6

  7. 3. Memory Addressing Mode ⑴ Direct Addressing Mode Exp: MOV AL, [1064H] Machine code:A06410H • The offset address of the operand is provided in the instruction directly; • The physical address can be calculated using the content of DS and the offset : PA = (DS)*10H+Offset 2014年8月14日7

  8. A0 Code Segment 64 + 1064H 10 AL 45 Data Segment … 21064H 45 45 ⑴ Direct Addressing Mode Example: MOV AL, [1064h] ;Assume (DS)=2000H Machine code: A06410H (DS)*10H=20000H 21064H 20000H 2014年8月14日8

  9. 3. Memory Addressing Mode ⑵ Register Indirect Addressing Mode • The address of memory location is in a register (SI,DI,or BX only) • The physical address is calculated using the content of DS and the register(SI,DI,BX) PA = (DS)*10H+(SI)/(DI)/(BX) 2014年8月14日9

  10. (DS)*10H=30000H (DS)*10h= 30000H M M + + 32000H 31000H … … 30000H 30000H AX AL 40 50 64H 64H … … 32000H 31000H 50 50 64H 40 40 MOV AX, [SI] MOV [BX], AL ⑵ Register Indirect Addressing Mode ASSUME: (DS)=3000H, (SI)=2000H, (BX)=1000H (SI)= 2000H (BX)= 1000H 2014年8月14日10

  11. (BX) (BP) (DI) (SI) Displacement EA= + ⑶ Register Relative Addressing For physical address calculation: DS is used for BX,DI,SI; SS is used for BP PA=(DS)*10H+(BX)/(DI)/(SI)+Disp OR PA=(SS)*10H+(BP)+Disp 2014年8月14日11

  12. 8A Code Segment 8F 64 (DS)*10h= 20000H 10 (BX)= 1000H + 1064H 22064H 20000H … 45 Data Segment 21000H CL 22064H … 45 45 PA=(ds)*10h+(bx)+1064h ⑶ Register Relative Addressing MOV CL, [BX+1064H];assume: (DS)=2000h, (bx)=1000h ;Machine Code: 8A8F6410 2014年8月14日12

  13. (BX) (BP) (DI) (SI) EA= + ⑷ Based Indexed Addressing • Base register(bx or bp) determines which segment(data or stack) the operand is stored; • if using BX, the operand is defaultly located in Data segment,then: • PA=(DS)*10H+(BX)+(DI)/(SI) • if using BP, the operand is defaultlylocated in stacksegment,then: • PA=(SS)*10H+(BP)+(DI)/(SI) 2014年8月14日13

  14. M + (SS)*10H= 40000H … 43200H AH 56H … 40000H 56H 56H 43200H ⑷ Based Indexed Addressing Example: MOV AH, [BP][SI];Assume(ss)=4000h,(bp)=2000h,(si)=1200h PA=(ss)*10h+(bp)+(si) (BP)= 2000H (SI)= 1200H 2014年8月14日14

  15. (BX) (BP) (DI) (SI) EA= + Displacement + ⑸ Based Indexed Relative Addressing if using BX, the operand is defaultly located in Data segment,then: PA=(DS)*10H+(BX)+(DI)/(SI)+disp if using BP, the operand is defaultlylocated in stacksegment,then: PA=(SS)*10H+(BP)+(DI)/(SI)+disp 2014年8月14日15

  16. 88 Code segment A1 34 12 + (DS)*10H=40000H 40000H 1234H 41444H … Data segment AH 45 45 … 41444H 45 ⑸ Based Indexed Relative Addressing MOV [BX+DI+1234H], AH ;assume (ds)=4000h,(bx)=0200h,(di)=0010h ;machine code:88A13412h (BX)= 0200H (DI)= 0010H 2014年8月14日16

  17. Summary on the 8086 memory addressing modes operand offset address Default Overridden (effective address)Segment Register Segment Register 1. Direct Addressing [disp] disp DS CS ES SS 2. Register [BX]/[SI] /[DI] Content of the R DS CS ES SS Indirect Addressing 3. Register [SI/DI/BX/BP+disp] (SI)/(DI)/(BX)/(BP)+dispDS CS ES SS Relative Addressing 4. Based Indexed [BX+SI/DI] (BX)+dispDS CS ES SS Addressing [BP+SI/DI] (BP)+disp SS CS ES DS 5. Based Indexed [BX+SI/DI+disp] (BX)+(SI)/(DI)+disp DS CS ES SS Relative Addressing [BP+SI/DI+disp] (BP)+(SI)/(DI)+dispSS CS ES DS 2014年8月14日17

  18. Examples: Assume: (BX)=6000H, (BP)=4000H, (SI)=2000H, (DS)=3000H, (ES)=3500H, (SS)=5000H Instruction addressinglogical physical modeaddress address 3000:0520 30520H 1. MOV AX, [0520H] Direct Addressing 2. MOV AX, [BX] Register Indirect Addressing 3000:6000 36000H 3. MOV AX, [SI+1000H] Register Relative Addressing 3000:3000 33000H 4. MOV AX, [BP+6060H] Register Relative Addressing 5000:A060 5A060H 5. MOV AX, ES: [BX+SI+0050H] Based Indexed Relative Addressing 3500:8050 3D050H 2014年8月14日18

More Related