Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (116.9 KB, 10 trang )
<span class='text_page_counter'>(1)</span><div class='page_container' data-page=1>
• x86 Instruction Format Reference
• x86 Opcode Sizes
• x86 ADD Instruction Opcode
• Encoding x86 Instruction Operands, MOD-REG-R/M Byte
• REG Field of the MOD-REG-R/M Byte
• MOD R/M Byte and Addressing Modes
• SIB (Scaled Index Byte)
• Encoding ADD ECX, EAX Instruction
• Encoding ADD EDX, DISPLACEMENT Instruction
• Encoding ADD EDI, [EBX] Instruction
instruction format of the x86 CPU family.
• They don't call the x86 CPU a Complex Instruction Set
Computer (CISC) for nothing!
• Although more complex instruction encodings exist, no
<b>Prefix Bytes</b>
0 to 4 special
prefix values
that affect the
operation of
instruction.
One or Two byte
Instruction <i>opcode</i>
(two bytes if the
special <b>0Fh</b> <i>opcode</i>
expansion prefix is
present)
<b>“mod-reg-r/m” </b>byte that
spcifies the addressing
mode and Instruction
operand size.
This byte is only required if
the instruction supports
register or memory
operands.
Optional Scaled
Index Byte if the
instruction uses a
scaled index memory
addressing mode.
<b>Displacement. </b>This is
0,1, 2, or 4 byte value
that specifies a memory
address displacement
for the instruction.
Imm./Constant data.
• Although the diagram seems to imply that instructions
can be up to 16 bytes long, in actuality the x86 will not
allow instructions greater than 15 bytes in length.
• The prefix bytes <b>are not</b> the <i>opcode expansion prefix</i>
<b>Instruction </b>
<b>Prefix</b>
<b></b>
<b>Address-Size Prefix</b>
<b></b>
<b>Operand-Size Prefix</b>
<b>Segment </b>
<b>Override</b>
<b>Number 0 or 1 0 or 1 0 or 1 0 or 1</b>
<b>of Bytes </b>
<b>Number 0 or 1 0 or 1 0 or 1 0, 1, 2 or 4 0, 1, 2 or 4</b>
<b>of Bytes </b> <b><sub>OpCode</sub></b> <b><sub>Mod-R/M</sub></b> <b><sub>SIB</sub></b> <b><sub>Displacement</sub></b> <b><sub>Immediate</sub></b>
Scale Index Base
<b> 7 6 5 4 3 2 1 0</b>
Mod Reg/OpCode R/M
<b> 7 6 5 4 3 2 1 0</b>
Bits
•
– <b>instruction prefix </b>– sets certain options
– <b>opcode </b>- specifies the operation to perform
– <b>Mod R/M </b>- specifies addressing mode/operands
– <b>SIB (scale index base) </b>- used for array index
– <b>address displacement </b>- used for addressing
memory
•
•
– it could be a <b>relative address</b> like the 8-bit value
used for jumping forward or backward from the
current location in the code segment
– or it could be the location of a <b>variable</b> in the data
segment
– or it could be a <b>FAR</b> reference to code or data in
•
•
•
•