Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Assembly x86 > Re: manipulate ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 4 Topic 4606 of 4822
Post > Topic >>

Re: manipulate stack for calling in 16bit mode (.code16gcc)

by Cyril Novikov <spamtrap@[EMAIL PROTECTED] > Apr 6, 2008 at 11:54 PM

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
 




 4 Posts in Topic:
manipulate stack for calling in 16bit mode (.code16gcc)
junkoi <spamtrap@[EMA  2008-04-06 21:49:39 
Re: manipulate stack for calling in 16bit mode (.code16gcc)
Cyril Novikov <spamtr  2008-04-06 23:54:19 
Re: manipulate stack for calling in 16bit mode (.code16gcc)
junkoi <spamtrap@[EMA  2008-04-07 01:59:16 
Re: manipulate stack for calling in 16bit mode (.code16gcc)
Frank Kotler <spamtra  2008-04-07 18:22:42 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 7 12:27:18 CDT 2008.