Sie sind auf Seite 1von 16

X86

Session_03

Instructions in X86
Addressing modes

Property of Accel Tec

Addressing Modes
Immediate 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 Tec

Addressing Modes
Register Addressing Mode

A register is the source of an


operand for an instruction
E.g.: MOV CX,AX
MOV DL,AL
Note: source type and the destination
type should be the same
Property of Accel Tec

Addressing Modes
Direct Addressing Mode
E.g.: MOV BL,[4374h]
If DS register contains 2000,
then
DS :

20000

Hard wired zero

EA :

4374

physical address:

24374

Property of Accel Tec

Addressing Modes
Direct Addressing Mode
E.g.: MOV BX,[4374h]
If DS register contains 2000,
then
DS :

20000

EA :

4374

physical address:

24374

Property of Accel Tec

Addressing Modes
Register 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 :
50040
DI :
0020
physical address:
50060
It copies 16 bit content from BX into
50060 and 50061.
Property of Accel Tec

Addressing Modes
Based 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 Tec

Addressing Modes
Indexed 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 Tec

Addressing Modes
Based Indexed Addressing Mode
EA = [BX or BP]+ [SI or DI]+a
displacement.
The displacement can be a signextended 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 Tec

Addressing Modes
String 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
10
and [DI]=0301Property of Accel Tec

Addressing Modes
Modes 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 Tec

11

Addressing Modes
Relative 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 Tec

12

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 Tec

13

Branching Instructions
1. Intrasegment Direct
The 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 Tec

14

Branching Instructions
3. 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 Tec

15

Summary
BX
or
or

or

BP
SI
DI

SI

BX

or

or

BP

DI
+

Displacement

CS
SS

0000
0000

DS
ES

0000
0000

+
Effective
address
+

Physical Address
Property of Accel Tec

16

Das könnte Ihnen auch gefallen