0% found this document useful (0 votes)
76 views8 pages

Assem 2

The document discusses various addressing modes used in 80x86 assembly language programming, including: - Base-plus-index addressing which uses a base and index register to access memory locations. - Base relative-plus-index addressing which is similar but also includes a constant displacement. - Scaled-index addressing which multiplies the index register by a constant before adding. - Register relative addressing which uses a base register and constant displacement. - Code addressing modes such as direct jumps, PC-relative jumps, and indirect jumps through a register. - Stack addressing modes using push and pop instructions.

Uploaded by

Danish Faizan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views8 pages

Assem 2

The document discusses various addressing modes used in 80x86 assembly language programming, including: - Base-plus-index addressing which uses a base and index register to access memory locations. - Base relative-plus-index addressing which is similar but also includes a constant displacement. - Scaled-index addressing which multiplies the index register by a constant before adding. - Register relative addressing which uses a base register and constant displacement. - Code addressing modes such as direct jumps, PC-relative jumps, and indirect jumps through a register. - Stack addressing modes using push and pop instructions.

Uploaded by

Danish Faizan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

IVERSITY O

YLAND BA
L

1966

U M B C

AR

UMBC

mov ecx,[ebx+edi]
mov ch, [ebp+esi]
mov dl, [eax+ebx]

CMPE 310

(Feb. 9, 2002)

;Data segment copy.


;Stack segment copy.
;EAX as base, EBX as index.

Index registers: Holds offset location.


edi
esi
Any 32-bit register except esp.

Base registers: Holds starting location of an array.


ebp (stack)
ebx (data)
Any 32-bit register except esp.

Data Addressing Modes


Base-Plus-Index addressing:
Effective address computed as:
seg_base + base + index.

Systems Design & Programming 80x86 Assembly II

MO

UN

TI

RE COUNT
Y

ecx

ebx

eax

YLAND BA
L

1966

U M B C

AR

ss

ds
es

cs

esi

edi

ebp

esp

edx

IVERSITY O
F

UMBC

0 1 0 0

F 0 1 2

0 0 0 0

Seg
Base
Trans.

0 0 1 0

A B 0 3

1 0 0 0

Paging

1010H

mov edx, [ebx+edi]

Data Addressing Modes


Base-Plus-Index addressing:

Systems Design & Programming 80x86 Assembly II

MO

UN

TI

RE COUNT
Y

(Feb. 9, 2002)

Physical Address

F012AB03

Memory

CMPE 310

IVERSITY O
F

CMPE 310

YLAND BA
L

1966

U M B C

AR

UMBC

(Feb. 9, 2002)

Designed to be used as a mechanism to address a two-dimensional array.

Base Relative-Plus-Index addressing:


Effective address computed as:
seg_base + base + index + constant.
mov dh, [ebx+edi+20H]
;Data segment copy.
mov ax, [FILE+ebx+edi]
;Constant is FILE.
mov [LIST+ebp+esi+4], dh
;Stack segment copy.
mov eax, [FILE+ebx+ecx+2] ;32-bit transfer.

Same default segment rules apply with respect to ebp, ebx, edi and esi.
Displacement constant is any 32-bit signed value.

Data Addressing Modes


Register Relative addressing:
Effective address computed as:
seg_base + base + constant.
mov eax, [ebx+1000H] ;Data segment copy.
mov [ARRAY+esi], BL
;Constant is ARRAY.
mov edx, [LIST+esi+2] ;Both LIST and 2 are constants.
mov edx, [LIST+esi-2] ;Subtraction.

Systems Design & Programming 80x86 Assembly II

MO

UN

TI

RE COUNT
Y

ecx

ebx

eax

YLAND BA
L

1966

U M B C

AR

ss

ds
es

cs

esi

edi

ebp

esp

edx

IVERSITY O
F

UMBC

1 0 0 0

0 0 0 0

Seg
Base
Trans.

100H

0 0 1 0

A 3 1 6
0 0 2 0

1030H

Paging

MOV ax, [ebx+esi+100H]

Data Addressing Modes


Base Relative-Plus-Index addressing:

Systems Design & Programming 80x86 Assembly II

MO

UN

TI

RE COUNT
Y

(Feb. 9, 2002)

A316

Memory

CMPE 310

;Data segment DWORD copy.


;Whow !
;Std array addressing.

mov [eax+2*edi-100H], cx

mov eax, [ARRAY+4*ecx]

YLAND BA
L

1966

U M B C

AR

UMBC

(Feb. 9, 2002)

Direct:
Absolute jump address is stored in the instruction following the
opcode.

Code Memory-Addressing Modes:


Used in jmp and call instructions.
Three forms:
Direct
PC-Relative
Indirect

IVERSITY O
F

CMPE 310

mov eax, [ebx+4*ecx]

Data/Code Addressing Modes


Scaled-Index addressing:
Effective address computed as:
seg_base + base + constant*index.

Systems Design & Programming 80x86 Assembly II

MO

UN

TI

RE COUNT
Y

IVERSITY O
F

1966

00

10

UMBC

(Feb. 9, 2002)

Intrasegment jumps:
Short jumps use a 1-byte signed displacement.
Near jumps use a 4-byte signed displacement.
The assembler usually computes the displacement and selects the appropriate form.

PC-Relative:
A displacement is added to the EIP register.
This constant is encoded into the instruction itself, as above.

YLAND BA
L

U M B C

AR

0000

0000

E A

Segment(low) Segment(high)

CMPE 310

This far jmp instruction loads cs with 1000H and eip with 00000000H.
A far call instruction is similar.

Offset (high)

Offset (low)

Opcode

Code Addressing Modes


An intersegment jump:

Systems Design & Programming 80x86 Assembly II

MO

UN

TI

RE COUNT
Y

IVERSITY O
F

CMPE 310

YLAND BA
L

1966

U M B C

AR

;Jump within the code seg.

UMBC

jmp [TABLE+ebx]
jmp [edi+2]

Register Relative:

jmp [ebx]

;Jump table.

(Feb. 9, 2002)

;Jump address in data seg.

Register Indirect:
Intrasegment jumps can also be stored in the data segment.

jmp eax

Code Addressing Modes


Indirect:
Jump location is specified by a register.
There are three forms:
Register:
Any register can be used: eax, ebx, ecx, edx, esp, ebp, edi or esi.

Systems Design & Programming 80x86 Assembly II

MO

UN

TI

RE COUNT
Y

IVERSITY O
F

CMPE 310

YLAND BA
L

1966

U M B C

AR

UMBC

(Feb. 9, 2002)

;Pop doubleword for stack to EFLAG.


popfd
;Pushes EFLAG register.
pushfd
;Pushes 1234H.
push 1234H
push dword [ebx] ;Pushes double word in data seg.
;eax,ecx,edx,ebx,esp,ebp,esi,edi
pushad
;Pops 4 bytes.
pop eax

Two registers maintain the stack, esp and ss.


A LIFO (Last-in, First-out) policy is used.
The stack grows toward lower address.
Data may be pushed from any of the registers or segment registers.
Data may be popped into any register except cs.

Stack Addressing Modes


The stack is used to hold temporary variables and stores return addresses for
procedures.
push and pop instructions are used to manipulate it.
call and ret also refer to the stack implicitly.

Systems Design & Programming 80x86 Assembly II

MO

UN

TI

RE COUNT
Y

You might also like