ASM: manipulate stack for calling in 16bit mode (.code16gcc)
Posted: Sun Apr 06, 2008 10:54 pm
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
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