i'm in the middle of adding 386 and protected mode support to my PC emulator, and i had a question about the mode/reg/rm byte in 32-bit mode...
when operating in 16-bit mode, if the mode field = 1 then there is an 8-bit displacement byte following the mode/reg/rm byte that gets sign-extended to 16-bits.
what i need to know is when operating in 32-bit mode, is the displacement data after the mode/reg/rm byte a 16-bit word that gets sign-extended to 32-bits? or, is it actually a 32-bit dword that is directly read and used without sign-extending?
my best guess is that it's 16-bits sign-extended to 32-bits if the mode is 1, and it's an actual full dword if mode is 2 but i want to be sure about this. some of you guys really know your stuff, so this is the best place i can think to ask.
thanks! i'm hoping to get my emu booting a linux kernel in the near future.
running DOS can only be so exciting...
32-bit Mode/Reg/RM byte displacement question
Re: 32-bit Mode/Reg/RM byte displacement question
in 32-bit mode, the 01 MOD encoding uses a 8-bit displacement sign-extended to 32bits --- there is no encoding for 16bit displacement sign-extended to 32bits
MOD 10 is a 32bit displacement (in 16bit mode, its a 16bit displacement), as you correctly surmised
this is very clearly answered in the intel manuals... intel 2A:2.1.5 -- aptly named "addressing-mode encoding of ModR/M and SIB bytes" -- checkout tables 2-1 (for 16bit mode) and 2-2 (for 32bit mode) they clearly define all possible ModR/M encoding
if you dont have the intel manuals, you can download them from the link in my signature
MOD 10 is a 32bit displacement (in 16bit mode, its a 16bit displacement), as you correctly surmised
this is very clearly answered in the intel manuals... intel 2A:2.1.5 -- aptly named "addressing-mode encoding of ModR/M and SIB bytes" -- checkout tables 2-1 (for 16bit mode) and 2-2 (for 32bit mode) they clearly define all possible ModR/M encoding
if you dont have the intel manuals, you can download them from the link in my signature