MO K
November 6th, 2000, 03:00
Does any one know how does the SETxx family of opcodes select their memory operands?
They are the only ones that take single operand, and a ModRegRm. The operand is m8 or r8. The register operand is retreived by looking up the value of the Reg field, in the array of one byte registers.
I have assembled a long list of varying SETxx instructions, both with register and memory operands. And I noticed that all the opcodes that take a byte of memory as an operand, are followed by a 6 (00000110).
The Mod is 00, meaning, no displacement, and the Reg is 000 meaning ESP in 32-bit. Now that is not what i coded.
If the R/M field was a 100, i would expect one more byte for SIB, but R/M is 110 !
I expect the offset of the operand to be encoded in the instruction, and indeed, I see the offset in the instruction. But when automating the disassembly, how do I differentiate between the two distinct operands. Should I stick to the 0x6 i have discovered, so when ever i parse a 6, i flag it as a memory operand, or is there a `traditional' way?
So far, i am confident about this magical 6. I have greped 30mbs worth of disassembly listings, and got the six with every memory operand for a SETxx (e.g. 0F 94 06 00 30). Where the operand is a register, only a single ModRegRm byte is given (e.g. 0F 94 0C), in the later case, only the Reg part is decoded, Mod and R/M remain intact!
Anyone has an idea?
They are the only ones that take single operand, and a ModRegRm. The operand is m8 or r8. The register operand is retreived by looking up the value of the Reg field, in the array of one byte registers.
I have assembled a long list of varying SETxx instructions, both with register and memory operands. And I noticed that all the opcodes that take a byte of memory as an operand, are followed by a 6 (00000110).
The Mod is 00, meaning, no displacement, and the Reg is 000 meaning ESP in 32-bit. Now that is not what i coded.
If the R/M field was a 100, i would expect one more byte for SIB, but R/M is 110 !
I expect the offset of the operand to be encoded in the instruction, and indeed, I see the offset in the instruction. But when automating the disassembly, how do I differentiate between the two distinct operands. Should I stick to the 0x6 i have discovered, so when ever i parse a 6, i flag it as a memory operand, or is there a `traditional' way?
So far, i am confident about this magical 6. I have greped 30mbs worth of disassembly listings, and got the six with every memory operand for a SETxx (e.g. 0F 94 06 00 30). Where the operand is a register, only a single ModRegRm byte is given (e.g. 0F 94 0C), in the later case, only the Reg part is decoded, Mod and R/M remain intact!
Anyone has an idea?