Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

1/31/2024

Topic-III

80x86 Addressing Modes

T1. Barry B Brey, The Intel Microprocessors. Pearson, Eight Ed. 2009. Chapter 3, 4

Lecture 7

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

MOD = 00 Memory operand with no displacement

Examples

MOV AX,[2A45]

MOV AX,[DI]

1/31/2024 27

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

1
1/31/2024

MOD = 00 Memory operand with no displacement

MOV [BX],CL

- w = 0 because we are dealing with a byte


d = 0 because REG to R/M
- therefore first byte is (1000 1000) = 88H

- since no displacement,
- we can use MOD=00 REG=001 and R/M=111 = 0000 1111
= 0FH

1/31/2024
result: 88 0F 28

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

MOD = 01 Memory operand with 8 bits displacement

Examples

MOV AX,[BP+2]

MOV DX,[BX+DI+4]

MOV [BX-4],AX

1/31/2024 29

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

2
1/31/2024

MOD = 01 Memory operand with 8 bits displacement

Examples
MOV [BX+10h],CL
- w = 0 because we are dealing with a byte
- d = 0 because REG to R/M
- therefore first byte is (1000 1000) = 88H

- since 10H can be encoded as an 8-bit displacement, we can


use MOD=01 REG=001 and R/M=111 = 0100 1111 = 4FH

and the last byte is 10H

result: 88 4F 10

1/31/2024 Note: MOV [BX+10H],CX = 89 4F 10 30

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

MOD = 10 Memory operand with 16 bits displacement

Examples

ADD AX,[BX+1000H]

MOV [BX+10h],CL with a 16-bit displacement,

(MOD 10)

88 8F 10 00

1/31/2024 31

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

3
1/31/2024

MOD = 11 Register operand

Examples

MOV AX, BX

- w = 1 because we are dealing with words


MOD = 11 because it is register-register

- if d = 0 then REG = source (BX) and R/M = dest (AX)


= 1000 1001 1101 1000 (89 D8)

- if d = 1 then REG = source (AX) and R/M = dest (BX)


= 1000 1011 1010 0011 (8B C3)
1/31/2024 32

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

Instruction set using addressing modes

1/31/2024 33

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

4
1/31/2024

Addressing Modes

• Register Addressing
• Immediate Addressing
• Direct Addressing
• Register Indirect Addressing
• Base-plus-index Addressing
• Register Relative Addressing
• Base relative -plus-indexed Addressing
• Scaled Indexed Addressing

These data-addressing modes are found with all versions of the


Intel microprocessor. except for the scaled-index-addressing
mode, found only in 80386 through Core2
1/31/2024 34

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

INSTRUCTION FORMAT
BYTE 1 BYTE 2 BYTE 3 BYTE 4

LOW HIGH
OPCODE D W MOD REG R/M DISP. DISP.

BYTE 1 BYTE 2 BYTE 3


1 BIT 3 BITS
LOW DISP. HIGH DISP.
OPCODE W REG

35

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

5
1/31/2024

Register Addressing

MOV AX,BX ; Copies contents of BX to AX register

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

Register Addressing

MOV AX,BX

1/31/2024 37

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

6
1/31/2024

Immediate Addressing
• Transfers the source-immediate byte or word of data into the
destination register or memory location.

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

Immediate Addressing

MOV AH, 4CH

 (AH ) ← 0100 1100

 Before Execution AX = 9844H


 After Execution AX = 4C44H

1/31/2024 39

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

7
1/31/2024

Immediate Addressing

MOV AH, 4CH - 1011 W REG


BYTE 1 BYTE 2 BYTE 3
1 BIT 3 BITS
LOW DISP. HIGH DISP.
OPCODE W REG

1/31/2024 40

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

Immediate Addressing

MOV CX, AD4CH

(CX ) ← 1010 1101 0100 1100

 Before Execution CX = 9844H


 After Execution CX = AD4CH

1/31/2024 41

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

8
1/31/2024

Immediate Addressing

MOV CX, AD4CH -1011 W REG

1/31/2024 42

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

Little vs Big Endian

Little vs Big Endian (5627)


00000 27 00000 56
00001 56 00001 27

1/31/2024 43

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

9
1/31/2024

Direct Addressing:

MOV [1234H], AX

(M) AX

M = DS: 1234H (AL)


M = DS: 1235H (AH)

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

Direct Addressing
MOV AX, [1234H]

(AX ) ← DS:1234

 DS = 0100H
 ADDRESS = 01000+1234=02234
 02234H 54
 02235H 82

 AX = 8254H

1/31/2024 45

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

10
1/31/2024

Direct Addressing

MOV AX, [1234H]

MOV [1234H], AL
1 0 0 0 1 0 0 0 00 000 110

88 06 34 12
1/31/2024 46

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

End of Lecture 7

1/31/2024 47

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

11

You might also like