lect 4: instruction set and addressing modes. 386 instruction set (3.4) basic instruction set :...

9
Lect 4: Instruction Set and Address ing Modes

Upload: maud-armstrong

Post on 23-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lect 4: Instruction Set and Addressing Modes. 386 Instruction Set (3.4)  Basic Instruction Set : 8086/8088 instruction set  Extended Instruction Set

Lect 4: Instruction Set and Addressing Modes

Page 2: Lect 4: Instruction Set and Addressing Modes. 386 Instruction Set (3.4)  Basic Instruction Set : 8086/8088 instruction set  Extended Instruction Set

386 Instruction Set (3.4)

Basic Instruction Set : 8086/8088 instruction set Extended Instruction Set : 80286; several new instructions and additional addressing modes 80386 specific instruction set: See page 62, Fig 3.6

Addressing Modes of 386DX (3.5)

Addressing Modes: a method of specifying an operand• Operands : in REG, Memory, I/O ports, and within Instruction

* Control Transfer : direct, indirect addressing the modes available

register addressing : REG

immediate addressing: within Instruction

direct addressing

register indirect addressing

based addressing

indexed addressing

based indexed addressing

MEM or I/O

Page 3: Lect 4: Instruction Set and Addressing Modes. 386 Instruction Set (3.4)  Basic Instruction Set : 8086/8088 instruction set  Extended Instruction Set

Addressing Modes

Register Operand Addressing Mode

• can be accessed in byte, word, or double word sizes.

• MOV AX, BX

• Byte: AL, AH, BL, BH, CL, CH, DL, DH

Word: AX, BX, CX, DX, SP, BP, SI, DI, CS, DS, SS, ES, FS, GS

Double Word: EAX, EBX, ECX, EDX, ESP, EBP, ESI, EDI

• See Fig 3.8 in page 64 Immediate Operand Addressing

• an operand is part of the instruction

• MOV AL, 15H

• 8 bits, 16 bits, and 32 bits in length

• See Fig 3.10 in page 67

16-bit Memory Operand Addressing Modes 16-bit addressing modes and 32-bit addressing modes Physical address = Segment Base: EA(effective address)

• Segment Base Address(SBA) : the starting location of the segment

• EA : the offset of the operand from the beginning of the segment of memory

EA = Base + Index + Displacement

Base = BX or BP, Index = SI or DI, displacement = 8-bit or 16-bit

Page 4: Lect 4: Instruction Set and Addressing Modes. 386 Instruction Set (3.4)  Basic Instruction Set : 8086/8088 instruction set  Extended Instruction Set

16-bit Memory Operand Addressing

Direct Addressing Mode

• PA = Segment Base : Direct Address

• MOV CX, [1234H]

• See fig 3.13

MOV CX, [1234H]

IP

CS

DSSSESFSGS

AXBXCXDX

SPBPSI

DI

0100001001010020100301004

8B0E3412XX

0000

01000200

XXXX

03234 ED03235 BE

BEED

Page 5: Lect 4: Instruction Set and Addressing Modes. 386 Instruction Set (3.4)  Basic Instruction Set : 8086/8088 instruction set  Extended Instruction Set

16-bit Memory Operand Addressing

Register Indirect Addressing Mode

• PA = Segment Base : Indirect Address {BX,BP,SI,DI}

• example : MOV AX, [SI]

MOV AX,[SI]

IP

CS

DSSSESFSGS

AXBXCXDX

SPBPSI

DI

0100001001010020100301004

8B04XXXXXX

0000

01000200

XXXX

03234 ED03235 BE

BEED1234

Page 6: Lect 4: Instruction Set and Addressing Modes. 386 Instruction Set (3.4)  Basic Instruction Set : 8086/8088 instruction set  Extended Instruction Set

16-bit Memory Operand Addressing

Based Addressing Mode

• PA = Segment Base : {BX or BP} + {8-bit or 16-bit displacement}

• Base register : the beginning of a data structure

• See Fig 3.16 (b) in page 74

• Example: MOV [BX]+1234H, AL

MOV [BX]+1234H, AL

IP

CS

DSSSESFSGS

AXBXCXDX

SPBPSI

DI

0100001001010020100301004

88073412XX

0000

01000200

04234 04235

1234

ED1000

Displacement

Base Register

+

Element 0

Element 1

Data Structure

Element n-1

Page 7: Lect 4: Instruction Set and Addressing Modes. 386 Instruction Set (3.4)  Basic Instruction Set : 8086/8088 instruction set  Extended Instruction Set

16-bit Memory Operand Addressing

Indexed Addressing Mode

• PA = Segment Base : {SI, DI}+{8-bit or 16-bit displacement}

• Displacement : the starting address of an array; Index: selects the specific element in the array

• Example: MOV AL, [SI]+2000H

Index Register

Displacement

+

Element 0

Element 1

Array of data

Element n-1

IP

CS

DSSSESFSGS

AXBXCXDX

SPBPSI

DI

0100001001010020100301004

8A443412XX

0000

01000200

05234 05235

2000

XX1000

MOV AL, [SI]+1234H

BE

Page 8: Lect 4: Instruction Set and Addressing Modes. 386 Instruction Set (3.4)  Basic Instruction Set : 8086/8088 instruction set  Extended Instruction Set

16-bit Memory Operand Addressing

Based-Indexed Addressing Mode

• PA= Seg Base: {BX, BP}+{SI,DI}+{8-bit or 16-bit displacement}

• to access complex data structures

• See fig 3.20 in page 80

• Example: MOV AH, [BX][SI]+1234H

opcode : 8A 44 34 12

Page 9: Lect 4: Instruction Set and Addressing Modes. 386 Instruction Set (3.4)  Basic Instruction Set : 8086/8088 instruction set  Extended Instruction Set

32-bit Memory Operand Addressing Modes

Enhanced in two ways

• Scale factor : EA = base + (index x scale factor) + displacement

• PA = Segment Base: EA

• See fig 3.23 in page 83: change 16-bit displacement to 32-bit displacement

• How can we specify the 32-bit extension modes?

– Default (D) bit in the code segment descriptor

– 2 prefixes to the instruction set

Operand size prefix

Address size prefix

ntdisplacemebit -32

ntdisplacemebit 8

8

4

2

1

DI

SI

BP

DX

CX

BX

AX

DI

SI

BP

SP

DX

CX

BX

AX

:

GS

FS

ES

DS

SS

CS

PA