Top Banner

of 16

x86-session03.ppt

Oct 05, 2015

Download

Documents

ArunKumarAK
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • X86 Session_03Instructions in X86Addressing modes

    Property of Accel Technologies Ltd., Copyright protected

  • Addressing ModesImmediate addressing mode An 8 bit or a 16 bit operand is placed immediately following the instruction. The destination can be a register or a memory location E.g.: MOV CX,437Bh MOV DL,48h

    Property of Accel Technologies Ltd., Copyright protected

  • Addressing ModesRegister Addressing Mode A register is the source of an operand for an instruction E.g.: MOV CX,AX MOV DL,ALNote: source type and the destination type should be the same

    Property of Accel Technologies Ltd., Copyright protected

  • Addressing ModesDirect Addressing Mode E.g.: MOV BL,[4374h]If DS register contains 2000, then DS : 2 0 0 0 0 EA : 4 3 7 4physical address:2 4 3 7 4Hard wired zero

    Property of Accel Technologies Ltd., Copyright protected

  • Addressing ModesDirect Addressing Mode E.g.: MOV BX,[4374h] If DS register contains 2000, then DS : 2 0 0 0 0 EA : 4 3 7 4physical address:2 4 3 7 4

    Property of Accel Technologies Ltd., Copyright protected

  • Addressing ModesRegister Indirect Addressing Mode E.g.: MOV [DI],BX The EA is specified in a pointer(BX or BP) or an index register(SI or DI). If DS register contains 5004 and DI=0020 then DS : 5 0 0 4 0 DI : 0 0 2 0 physical address:5 0 0 6 0 It copies 16 bit content from BX into 50060 and 50061.

    Property of Accel Technologies Ltd., Copyright protected

  • Addressing ModesBased Addressing Mode E.g.: MOV AL,START[BX] MOV AL,[BX+START]; an other assembler version The EA is obtained by adding a signed 8 bit or unsigned 16 bit value to the contents of BX or BP. The segment registers used are DS and SS. For a memory access BX and DS are used. For a stack access BP and SS are used.

    Property of Accel Technologies Ltd., Copyright protected

  • Addressing ModesIndexed Addressing Mode E.g.: MOV BH,START[SI] EA =Reference Address + Modifier is used to get the EA ;DS can be the segment register Here, RA is part of the instruction (a sign-extended 8 bit or unsigned 16 bit value) and M is contained in SI or DI

    Property of Accel Technologies Ltd., Copyright protected

  • Addressing ModesBased Indexed Addressing Mode EA = [BX or BP]+ [SI or DI]+a displacement. The displacement can be a sign-extended 8 bit or unsigned 16 bit value E.g.: MOV ALPHA [SI][BX],CL If [BX] = 0200h ;ALPHA=08h;[SI]=1000h [DS] =3000h,then physical address : 31208h

    Property of Accel Technologies Ltd., Copyright protected

  • Addressing ModesString Addressing Mode Uses index registers SI and the DI as pointers Uses DS for the source(can be overridden) and the ES for the destination(cannot be overridden) E.g.: MOVS BYTE If [DF] =0,[DS]=2000,[SI]=0500,[ES]=4000 [DI]=0300,[20500]=38 and [40300]=45 then after execution, [40300]=38,[SI]=0501 and [DI]=0301

    Property of Accel Technologies Ltd., Copyright protected

  • Addressing ModesModes for addressing I/O Ports Direct : OUT 05h,AL will output [AL] to 8 bit port 05h Indirect : IN AL,DX If [DX]=5040, then the 8 bit content of port 5040 will be transferred into AL. IN AX,DX will input 8 bit contents of ports 5040 and 5041 into AL and AH

    Property of Accel Technologies Ltd., Copyright protected

  • Addressing ModesRelative addressing mode The operand is specified as a signed 8 bit displacement relative to the PC. E.g: JNC START If carry is zero,then PC is loaded with current PC contents plus the 8 bit signed value of START ;Otherwise the next instruction is executed

    Property of Accel Technologies Ltd., Copyright protected

  • Addressing Modes

    Implied addressing mode Instructions that use this mode do not have operands explicitly mentioned E.g: CLC : clears the carry flag

    Property of Accel Technologies Ltd., Copyright protected

  • Branching Instructions1. Intrasegment DirectThe effective branch address is the sum of an 8 bit or 16 bit displacement and the current contents of IP.When the displacement is 8 bits,it is referred to as short jump.It can be used with conditional or unconditional branching but a conditional branch can have only an 8 bit displacement

    2. Intrasegment indirect The effective branch address is the contents of a register or a memory location

    Property of Accel Technologies Ltd., Copyright protected

  • Branching Instructions3. Intersegment Direct Replaces both IP and CS.used when a jump is required to be performed from one code segment to another

    2. Intersegment indirect Replaces both IP and CS with the contents of two consecutive words in memory that are referenced using any of the above data related addressing modes except the immediate and the register modesused when a jump is required to be performed from one code segment to another

    Property of Accel Technologies Ltd., Copyright protected

  • SummaryDisplacementCS 0000DS 0000ES 0000BXBP++++Physical Address +orSIorDIEffective addressSS 0000BX

    BPSI

    DIoror or

    Property of Accel Technologies Ltd., Copyright protected