MICRO133 Prelim Lecture 4 5 Intel P Addressing Modes and Instruction Encoding and Decoding
MICRO133 Prelim Lecture 4 5 Intel P Addressing Modes and Instruction Encoding and Decoding
INTEL P ADDRESSING
MODES, AND
INSTRUCTION ENCODING
AND DECODING
Lecture’s Objectives
Intel P Addressing Modes, and Instruction Encoding and
Decoding
Microprocessor’s
Addressing Modes
Introduction
Microprocessor’s Addressing Modes
Addressing Modes
refer to a set, of the number of ways, in which the data used by a
program can be accessed by a CPU.
C = A + B
Choice of addressing mode used depends upon the type of data being
accessed.
A constant,
A variable piece of information or
An item within an array of data.
8088/8086 Instruction
Syntax
Microprocessor’s Addressing Modes
Instruction
Opcode [operand 1], [operand 2]
Mnemonic Destination Source
8088/8086 Instruction
Syntax
Microprocessor’s Addressing Modes
Operands
These are destination address and source address of data.
It uses the name of a register to identify the location of data – the
data is held in the register.
Copy the content source register to a destination register
8 Working Registers – AX, BX, CX, DX, SI, DI, BP, SP – 16 bit wide.
Four of the registers – AX, BX, CX, DX can be thought of as single
16 bit registers or dual 8 bit registers.
Length of the registers must match
ITEM1 EQU0F3h
ITEM2 EQU01110101000010b
ITEM3 EQU0
Note: EQU directive assigns names to constant numbers and does not save memory space
Data Addressing Modes
Microprocessor’s Addressing Modes
Variables
These are names of an address in memory
However, a program reference to the variable name, as an operand, will use the contents of
address
VAR1 DW 0ABCDH
…
MOV AX,VAR1
MOV VAR1,BX
Memory Addressing Modes
Microprocessor’s Addressing Modes
Base-Relative-plus-Index Addressing
Mode (More Complex Array)
MOV [EBX+2*ECX], AX
MOV EAX, [EBP+8*ECX]
RIP Relative Addressing Modes
Microprocessor’s Addressing Modes
When executed it pushes IP and the return segment (for FAR calls) onto the stack, then
executes a jump to the call address
CALL to a NEAR address – Only Offset (IP) specified, segment assumed to be the same
CALL to a FAR address – New Segment and Offset (IP) specified
RET (RETurn) instruction causes the CPU to pop the RETURN address off the stack (IP or
Segment and IP) and execute a jump back to it
CALL 0200
CALL 1029:0200
NEAR vs. FAR Subroutine
Directives
Microprocessor’s Addressing Modes
Microprocessor’s
Instruction Encoding
and Decoding
Overview
Intel µP Instruction Encoding and Decoding
Figure 3. The scaled-index byte and REX prefix for 64-bit operations.
8088 or 8086 Instruction
Format
Intel µP Instruction Encoding and Decoding
Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6
Override Prefixes
It is the first 2 bytes of a 32-bit instruction format
These bytes are not always used
Divided in Two Parts:
○ Address Size (AS) – modifies the size of the
address used the instruction and this byte is equal to
67h if in used.
If the 80386/80486 is operating as 16-bit instruction mode
machine (real or protected mode) and 32-bit instruction, byte
is equal to 67h
If the 80386/80486 is operating as 32-bit instruction mode
machine (real or protected mode) and 32-bit instruction, byte
is removed.
Instruction Encoding
Intel µP Instruction Encoding and Decoding
Figure 6 – 16- and 32-bit R/M field, segment register field, and
scaled factor.
Instruction Encoding
Intel µP Instruction Encoding and Decoding
Figure 7 – 8-, 16-, and 32-bit REG field and MEM field
Instruction Encoding (64-bit Mode)
Intel µP Instruction Encoding and Decoding
Register Addressing
It uses the R/M field to specify a register instead of memory location
1. 0x8B923412
2. 0x81C17856
3. 0x2326