ASM: operand size prefix

Programming, for all ages and all languages.
Post Reply
junkoi
Member
Member
Posts: 63
Joined: Wed Jan 23, 2008 8:55 pm

ASM: operand size prefix

Post 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
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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...
junkoi
Member
Member
Posts: 63
Joined: Wed Jan 23, 2008 8:55 pm

Post 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
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post 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...
Every good solution is obvious once you've found it.
User avatar
binutils
Member
Member
Posts: 214
Joined: Thu Apr 05, 2007 6:07 am

Post by binutils »

Post Reply