junkoi wrote:
> Hi,
>
> I am writing some code in 16bit mode, using .code16gcc directive, and
> compile with gcc 4.1. In the below code, I expect that (1) and (2) are
> doing the same thing, that is executing "func). But actually while (1)
> works OK, (2) crashs. So confused!!
[skip]
> .code16gcc
>
> call func // (1)
>
> pushw $1f
> jmp func // (2)
> 1:
>
> ....
> func:
> ret
>
duh! In .code16gcc mode, all call's and ret's are treated by the
assembler as 32-bit. This is to make sure function argument references
off %ebp do the right thing. Remember that as far as GCC knows, it's
producing 32 bit code. So, it will look for the first argument on stack
at [%ebp+8], and there's nothing GNU assembler can do about it. Change
pushw into pushl and that should do the trick.
--
Cyril


|