Re: Question about GCC and stack

James Colannino <[email protected]>
Newsgroups org.kernel.vger.linux-assembly
Message-ID <[email protected]>
Brian Raiter wrote:

>>The subl instruction is pointless, I dont know why it's inserted. It
>>could be just generic stub code that gcc always inserts for
>>allocating stack variables, but as in this case you dont use any, it
>>allocates $0 bytes...I'm sure someone will correct me if there's a
>>good reason for it :)
>>    
>>
>
>I expect that the instructions obtained by the original poster were
>created by gcc without optimization. Run gcc with -O2 or so would
>probably yield a simpler set of instructions.
>  
>

It was without -O2, but when I used -O2, the code was pretty much the 
same.  The only difference was that instead of moving the value 0 into 
eax, xor eax, eax was used to mask out all the bits (equalling 0, and 
I'm assuming that's probably slightly more efficient than moving a value 
into a register.)  Also, instead of the leave instruction, the ebp and 
esp were manipulated manually, I guess because maybe the leave 
instruction, like the enter instruction, is slower?

James

-- 
My blog: http://www.crazydrclaw.com/
My homepage: http://james.colannino.org/

"You can only find truth with logic if you have already found truth without it." --G. K. Chesterton
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.