0% found this document useful (0 votes)
12 views13 pages

Lecture 6 29th Jan 2024

Uploaded by

Anmol Murti
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)
12 views13 pages

Lecture 6 29th Jan 2024

Uploaded by

Anmol Murti
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/ 13

1/31/2024

Topic-III

80x86 Addressing Modes

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

Lecture 6

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

Types of Instructions

• Data Transfer Instructions

• Arithmetic Instructions

• Logical Instructions

• Branch and Program control Instructions

1/31/2024 2

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

1
1/31/2024

Addressing Modes

Instruction = Opcode, Operand

Opcode/ Operation Field - the type of operation which


is to be performed by processor

Operand – the data on which the operation is going to


be performed

1/31/2024 3

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

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 4

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

2
1/31/2024

MOV Instruction

• MOV destination, source

1/31/2024 5

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

Data Transfer Instructions

• MOV DST, SRC

 Copies the content of source to destination


 No Flags Affected
 Size of source and destination must be the same

1/31/2024 6

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

3
1/31/2024

Different MOV options

R ←M

M←R

R ←R

M← I

R ← I
1/31/2024 7

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

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

1/31/2024 8

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

4
1/31/2024

Addressing Modes

• Register Addressing
 MOV AX, BX

• Immediate Addressing
 MOV AX, 1420H

1/31/2024 9

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

Addressing Modes

• Direct Addressing
 MOV AX, [2340H]

• Register Indirect Addressing


 MOV AX, [BX]

1/31/2024 10

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

5
1/31/2024

Addressing Modes

• Base-plus-index Addressing
 MOV AX, [BX+SI]

• Register Relative Addressing


 MOV AX, [BX+40]

1/31/2024 11

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

Addressing Modes

• Base relative-plus-indexed Addressing


 MOV AX, [BX+SI+10]

• Scaled Indexed Addressing

1/31/2024 12

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

6
1/31/2024

Addressing Modes
• The microprocessor contains these 8-bit register names
used with register addressing: AH, AL, BH, BL, CH, CL,
DH, and DL.

• 16-bit register names: AX, BX, CX, DX, SP, BP, SI, and DI.

• In 80386 & above, extended 32-bit register names are:


EAX, EBX, ECX, EDX, ESP, EBP, EDI, and ESI.

• 64-bit mode register names are: RAX, RBX, RCX, RDX,


RSP, RBP, RDI, RSI, and R8 through R15.

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

• Important for instructions

If hexadecimal data begin with a letter, the assembler requires the


data start with a 0.
– to represent a hexadecimal F2, 0F2H is used
in assembly language

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

7
1/31/2024

• The source register’s contents do not change.

• the destination register’s contents do change

• The contents of the destination register or destination memory


location change for all instructions except the CMP and TEST
instructions.

• The MOV BL, CL instruction does not affect the leftmost 8 bits of
register BX.

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

• In some cases, indirect addressing requires specifying the size of


the data by the special assembler directive BYTE PTR, WORD
PTR, DWORD PTR, or QWORD PTR.

– these directives indicate the size of the memory data


addressed by the memory pointer (PTR)

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

8
1/31/2024

Encoding of 8086 Instructions

 8086 Instructions are represented as binary numbers.


 In 8086, Instructions size can be in between 1 to 6 bytes

This is the general instruction format used by the majority of 2-operand


instructions
ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

Addressing Modes in 8086

D=0 (Direction from Register)


D=1 (Direction to Register)

W=0 (Data-byte)
W=1 (Data-word)

MOD+ R/M - Addressing Modes


1/31/2024 18

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

9
1/31/2024

Addressing Mode Byte 1


W (word/byte)

W (word/byte) specifies operand size

W = 1 data is word.

W = 0 data is byte.
W (word/byte) in 80386 (32 bit processor)

W (word/byte) specifies operand size

W = 1 data is 32 bit.

W = 0 data is byte.
1/31/2024 19

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

Addressing Mode Byte 2

Contains three fields

Mod 2 Bits (mode; determines how R/M field is interpreted)

Reg 3 Bits (register) or SREG (Seg register)

R/M 3 Bits (register/memory)

1/31/2024 20

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

10
1/31/2024

Addressing Mode Byte 2

MOD (2 bits)

MOD = 00 Memory operand with no displacement

MOD = 01 Memory operand with 8 bit displacement

MOD = 10 Memory operand with 16 bit displacement


MOD = 11 Register operand
1/31/2024 21

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

MOD with R/M (16 BITS)

22

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

11
1/31/2024

MOD with R/M (32 BITS)

11
MOD
(R/M) 00 01 10 W=0 W=1

000 EAX EAX +D8 EAX +D32 AL EAX

001 ECX ECX +D8 ECX +D32 CL ECX

010 EDX EDX +D8 EDX +D32 DL EDX


EBX +D8 EBX +D32
011 EBX BL EBX
SCALED SCALED
SCALED INDEX+D8 INDEX+D32
100 INDEX AH ESP

101 D32 EBP+D8 EBP+D32 CH EBP

110 ESI ESI+D8 ESI+D32 DH ESI

111 EDI EDI+D8 EDI+D32 BH EDI


23

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

Registers

EAX/AX/AL 000 ESP/SP/AH 100


EBX/BX/BL 011 EBP/BP/CH 101
ECX/CX/CL 001 ESI/SI/DH 110
EDX/DX/DL 010 EDI/DI/BH 111

1/31/2024 24

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

12
1/31/2024

End of Lecture 6

1/31/2024 25

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

13

You might also like