x86 modrm byte parameters displacement errors?

I'm making an emulator, but somehow the modr/m byte won't work correctly.

As far as I've noticed, the following applies:

1
2
3
- A MODR/M byte is always present at opcodes that use them.
- A Displacement depends on the OPCode size and MODR/M byte, with exception to /r OPCodes.
- With /r OPCodes, Displacement and SIB Bytes (32-bit Operand Size?) are not present.




***********************************

My conclusion:

(I'm concentrating on 16-bit mode (8086) here atm, 80386 later))

1
2
3
4
5
6
7
8
* means all other values of R/M.

MOD - RM - Displacment size
0   - 6  - 2 (Word displacment (16-bit mode) or DWord displacement (32-bit mode))
0   - *  - 0 (No displacement)
1   - *  - 1 (Byte displacement)
2   - *  - 2 (Word displacment (16-bit mode) or DWord displacement (32-bit mode))
3   - *  - 0 (No displacment)


1
2
When /r is used, there aren't SIB bytes nor a displacement.
(/r is taken from http://www.logix.cz/michal/doc/i386/chp17-03.htm#17-03) 



***********************************

Can anyone confirm what's correct, and what not?
Topic archived. No new replies allowed.