All instructions use modrm encoding for encoding memory operands, except for A0/A1/A2/A3, where the address is a constant encoded immediately after the instruction (“moffs”).
x86 has a single-byte encoding for INC esp (increment stack pointer by one).
POP [ptr] (pop a dword from the stack and move it to the specified address in memory) updates espbefore resolving ptr (which can contain esp). In some sense it mixes decoding of the instruction and execution.
LEA reg, [ptr] is an instruction that computes ptr and stores it in a register without referencing memory. Pointer arithmetic is very flexible in x86, being able to add a register with a shift, another register and a constant offset. For example, it can encode a = b + c -1 in a single instruction. LEA is also the only instruction that fails when encoded with a register operand (because LEA reg1, reg2 is invalid) but never fails when encoded with a memory operand.
There are two ways to encode OP reg1, reg2 for most instructions.
XCHG eax, r is encoded as 0x90+r, NOP is 0x90 or XCHG eax, eax.
Most arithmetic instructions also compute the parity flag, which is the parity of the lowest byte of the result.
Most arithmetic instructions also compute the adjust flag, which is set when an overflow happens from the 4th bit of the result.
Due to a bug in Windows NT, CPUID reports some bits differently depending configuration registers. Search for “bug” in http://sandpile.org/x86/cpuid.htm.
Fun facts:
INC esp(increment stack pointer by one).POP [ptr](pop a dword from the stack and move it to the specified address in memory) updatesespbefore resolvingptr(which can containesp). In some sense it mixes decoding of the instruction and execution.LEA reg, [ptr]is an instruction that computesptrand stores it in a register without referencing memory. Pointer arithmetic is very flexible in x86, being able to add a register with a shift, another register and a constant offset. For example, it can encodea = b + c -1in a single instruction.LEAis also the only instruction that fails when encoded with a register operand (becauseLEA reg1, reg2is invalid) but never fails when encoded with a memory operand.OP reg1, reg2for most instructions.XCHG eax, ris encoded as0x90+r,NOPis0x90orXCHG eax, eax.NOPhasn’t beenXCHG EAX,EAXsince the 80386—it causes an unnecessary dependency onEAXso it’s been special coded for quite a long time.Related and useful links: