- 1. CENG04:Microprocessor Systems Midterm Lecture 2 & 3
2. Introduction Intel P Instruction Encoding and Decoding
-
- It is the native binary code that the microprocessor
understand.
-
- It is use to translate assembly instruction to a machine
code.
-
- Selects the operation performed by the microprocessor such as
MOV, ADD, INC, JMP, & etc.
-
- It is either one or two byte in length for most machine
language instruction.
-
- It is a processes representing entire assembly instruction as a
binary value or hexadecimal format (human perspective)
-
- It is the process of converting hexadecimal format to assembly
language (machine perspective)
3.
- Figure 1 The format of the 8086 80486 Instruction a) 16-bit
instruction, b) 32-bit instruction
8086 80486 Instruction Format Intel P Instruction Encoding and
Decoding 4.
- Figure 2 8088/8086 Instruction Format
8088/8086 Instruction Format Intel P Instruction Encoding and
Decoding 5.
-
- operation (opcode) e.g. MOV
-
- operands (number depends on operation)
- Operandsspecified using addressing modes
- Addressing modemay include addressing information
Instruction Encoding Intel P Instruction Encoding and Decoding
6.
- Encodingof instruction must includes:
- Encodingis process representing entire instruction as abinary
value
-
- Number of bytes needed depends on how much information must be
encoded .
- Instructions are encoded byassembler:
-
- .OBJfile (link, then loaded by loader)
- Instructions aredecodedby processor during execution cycle
Instruction Encoding Intel P Instruction Encoding and Decoding
7.
-
- It is the first 2 bytes of a 32-bit instruction format
-
- These bytes are not always used
-
-
- Address Size modifies the size of the address used the
instruction and this byte is equal to67hif 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 to67h
-
-
-
- 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
8.
-
-
- Operand Size-modifies the size of the register.
-
-
-
- If the 80386/80486 is operating as 16-bit instruction mode
machine (real or protected mode) and 32-bit instruction, byte is
equal to66h
-
-
-
- If the 80386/80486 is operating as 32-bit instruction mode
machine (real or protected mode) and 32-bit instruction, byte is
removed.
-
- These toggle the size of the register and operand address from
16-bit to 32-bit or vice versa.
Instruction Encoding Intel P Instruction Encoding and Decoding
9.
- First byte:Opcode, Direction, & Word bits
-
- Opcode select the operation performed by the microprocessor
(use the lists of opcodes)
-
- Direction (D) indicates the flow of data
-
-
- D = 1, data flow from (R/M) field to REG field
-
-
- D = 0, if data flow from REG field to R/M field.
-
- Word (W) determine the size of data or register
-
-
- W = 1, 16- or 32-bit data width (word or dword)
-
-
- W = 0, 8-bit data width (byte)
- Note:W bit appear in most of the instruction but D bit mainly
appears withMOV and some other instructions.
Instruction Encoding Intel P Instruction Encoding and Decoding
10.
- Second Byte:Mode, Register, & Register/Memory
-
-
- This field specifies the addressing modes for selected
instruction.
-
-
- This selects the type of addressing and whether a displacement
is present or with the selected instruction.
-
-
-
- MOD = 11, selects data addressing modes
-
-
-
- MOD = 00, 01, or 10, selects memory addressing modes
-
-
- Field for register assignment
-
-
- Field for register act as a memory or memory location
assignment.
How to Encode Instructions as Binary Values?Intel P Instruction
Encoding and Decoding 11.
- Figure 3 Table for MOD field a) 16-bit, b) 32-bit
Instruction Encoding Intel P Instruction Encoding and Decoding
12.
- Figure 4 REG field for w=0 & w=1
Instruction Encoding Intel P Instruction Encoding and Decoding
13.
- Figure 5 16- and 32-bit R/M field, segment register field, and
scaled factor.
How to Encode Instructions as Binary Values?Intel P Instruction
Encoding and Decoding 14.
-
- It uses the R/M field to specify a register instead of memory
location
-
- This addressing modes occurs whenever memory data are
referenced by only the displacement mode of addressing for 16-bit
instructions.
-
-
- Indicates the additional forms of scaled-index addressing.
Instruction Encoding Intel P Instruction Encoding and Decoding
15.
- Determine the equivalent machine code of the following assembly
code:
-
- MOV DX, [BX + DI + 1234h]
Examples (Encoding) Intel P Instruction Encoding and Decoding
16.
- Given the following machine code (hex code), determine the
equivalent assembly instruction for each.
Examples (Decoding) Intel P Instruction Encoding and
Decoding