Page 1 of 1

D flag

Posted: Sun Jan 18, 2009 6:18 pm
by sweetgum
Im reading the intel manuals and there is a chart (Table 3-3) displaying Effective Operand and Address-Size attributes
can someone explain to me what this chart is showing? I can't make heads or tails of it. The paragraph before it was hard for me to understand as well. What im really trying to understand is what the Operand-Size Prefix 66h and Address-Size Prefix 67h are tehre for

Re: D flag

Posted: Sun Jan 18, 2009 6:39 pm
by Firestryke31
The operand-size prefix lets you use eax and friends in real mode, or the real-mode versions of opcodes in pmode. I'd assume that the address-size prefix does something similar.

Technically it's 'make 16-bit opcodes behave like their 32-bit counterparts' or vice-versa (sp?).

Although someone with more familiarity with x86 ASM should comment on that, because I'm just going with what my limited experience with them has been.

Re: D flag

Posted: Sun Jan 18, 2009 7:14 pm
by CodeCat
You're more or less right. The operand size prefix allows you to use 16 bit values as operands in 32 bit mode and vice versa. It's used whenever you work with 16 bit values in 32 bit mode.

The address size prefix allows you to use 16-bit addresses in 32 bit mode or 32-bit addresses in 16-bit mode. The former is pretty much pointless, but the latter might be used in the transition from real mode to protected mode, not sure there.

Re: D flag

Posted: Mon Jan 19, 2009 3:08 pm
by bewing
From long experience as an ASM programmer:

To simplify things into the real world: You will never ever want to use the address-size prefix under any circumstances.

For the operand prefix: When you are writing code that is supposed to run in Real Mode (16 bits) -- there are occasions when you want to use "normal" 32 bit instructions (rather than the very limited 16 bit instructions). Sometimes, you want to access a 32bit memory address (load, store, or modify with a 32bit register). Sometimes you just want to access the upper word of some 32bit register (why waste them if they are there?).

In 32bit mode, when you want to access a 16bit-size memory address (load, store, or modify with a 16bit register) you will also use an operand prefix. This is especially common with things like REP MOVSW.

Re: D flag

Posted: Tue Jan 20, 2009 3:14 am
by Combuster
you will use the address size prefix when you're in unreal mode and you want to access above the 1M limit (like in a32 o32 rep movs)