Page 1 of 1

ASM: operand size prefix

Posted: Wed Apr 09, 2008 11:32 pm
by junkoi
Hi,

My code is *16bit*, compiled with gcc using ".code16gcc". The "far ret" instruction is compiled like this (reversed using ndisasm):

66CB o32 retf

In which "66" is operand size prefix, "CB" is opcode of "retf".

The question is: Is this true that in this case, "retf" will take *32bit* address from the top of stack as returned address?? (normally 16bit code only takes 16bit returned address from stack)

Thanks,
J

Posted: Thu Apr 10, 2008 5:26 am
by JamesM
I did say to be careful creating 16 bit code using gcc - it really was *not* designed for it. It has no idea of segment:offset pairs, along with a few other things...

Posted: Thu Apr 10, 2008 11:34 pm
by junkoi
hi James,

Yes, programming 16bit code with gcc is tricky, but I think it is worth that.

1. gcc is de-factor compiler, and available everywhere.
2. C code is always better than assembly in term of maintain and hack.

Some says that OpenWatcom is a good compiler for 16bit code, but I havent tried that yet.

Thanks,
J

Posted: Fri Apr 11, 2008 8:14 am
by Solar
junkoi wrote:1. gcc is de-factor compiler, and available everywhere.
2. C code is always better than assembly in term of maintain and hack.
Might be, but ".code16" is an arkane and seldom-used (thus not well-tested) feature. Expect all kinds of quirks to come from this, with little hope for help...

Posted: Fri Apr 11, 2008 9:45 am
by binutils