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) do the same thing, that is executing "func). But actually while (1) works OK, (2) crashs. So confused!!
Perhaps because "pushw" pushs 4 bytes into stack instead of 2 bytes with .code16gcc??? (sorry I only guess after reading the Intel manual, but cannot verify it!)
Many thanks,
Jun
------
.code16gcc
call func // (1)
pushw $1f
jmp func // (2)
1:
....
func:
ret
ASM: manipulate stack for calling in 16bit mode (.code16gcc)
I didn't try but maybe this works
Code: Select all
.code16gcc
call func // (1)
pushl $1f
jmp func // (2)
1:
....
func:
retl
Yes, this works! The reason is that .code16gcc treats "ret" like normal 32bit code, that is it pops 32bit address from stack rather than 16bit. So "pushl $1f" is the key here!devel wrote:I didn't try but maybe this worksCode: Select all
.code16gcc call func // (1) pushl $1f jmp func // (2) 1: .... func: retl
Thanks so much,
J