#0 immediate to register 1100 011w : 11 000 reg : immediate data
#1 immediate to register (alternate encoding) 1011 w reg : immediate data
#2 immediate to memory 1100 011w : mod 000 r/m : immediate data
intel machine code 果然複雜, 越新的手冊內容越多, 密密麻麻的欄位看得令人頭皮發麻。這次來看看 opcode 欄位裡頭的 w bit:
B.1.4 Special Fields
Table B-1 lists bit fields that appear in certain instructions, sometimes within the opcode bytes. All of these fields (except the d bit) occur in the general-purpose instruction formats in Table B-13. Table B-1. Special Fields Within Instruction Encodings
w Specifies if data is byte or full-sized, where full-sized is 16 or 32 bits (see Table B-6) 1
Table B-6. Encoding of Operand Size (w) Bit
w Bit
Operand Size When Operand-Size Attribute is 16 Bits
Operand Size When Operand-Size Attribute is 32 Bits
A modR/M byte follows the opcode and specifies the operand. The operand is either a general register or a memory address. If it is a memory address, the address is computed from a segment register and any of the following values: a base register, an index register, a scaling factor, a displacement.
v
Word or double word, depending on operand size attribute.
A modR/M byte follows the opcode and specifies the operand. The operand is either a general register or a memory address. If it is a memory address, the address is computed from a segment register and any of the following values: a base register, an index register, a scaling factor, a displacement.
G
The reg field of the modR/M byte selects a general register; e.g., ADD (00).
v
Word or double word, depending on operand size attribute.
感覺好像是 Ev, word 是 2 byte, double word 是 4 byte。
modrm: 35
mod: 00
reg: 110
r/m: 101
reg: 110 -> esi
mod:00
r/m: 101
結果可不是 ebp base register, 如果是 ebp base register, 那組合語言就是
之前在閱讀 IBM 80X86 組合語言實務被其複雜的定址模式搞得我好亂, 現在一次把它搞懂。這些複雜的 address mode 是針對 offset part 而來, 大概就是 base register 和 index register mode 這兩種比較複雜。而 16 bit 和 32 bit 又有點不同, 64 bit 沒研究, 就不提了。
16 bit 和 32 bit 可用來當 base/index register 的暫存器有些不同。為什麼呢?讀懂 machine code 就可以回答這問題。