> Date: Mon, 28 Apr 1997 17:47:34 -0400 (EDT)
> From: "Richard B. Johnson" <email@example.com>
> If I push the damn flags onto the stack, they damn-well be
> there when I pop them off. Not so with the GCC Compiler. It
> looks as though it secretly "levels" the stack and I don't
> know why. If so, it is broken and should be fixed instead
> of work-arounds everywhere in the code.
> Gcc must know precisely how the stack is layed out in order to know
> where local values on the stack are, and where it can stick
> temporaries for when register contention is larger than can fit
> completely in the register set during a block of code.
> If you change the stack pointer (which pushfl and popfl both do) you
> change where all those offsets are. Currently there is no way to tell
> GCC "I changed the stack behind your back, please change your offsets
> so you can still get to the variable slots on there"
> It is not a trivial thing to implement either. GCC would have to do
> basic block analysis for all code paths from a pushfl to a popfl and
> vice versa, make sure it does the adjustments in all the right places
> etc. Consider the complexity of outputting the correct code for:
> do some
> if(some other condition not known at time 'a' is run)
> You can code up millions of examples like this, the "I changed the
> stack" GCC extension you'd have to write would need to handle all of
> them. At best, the above example would require two, yes two, versions
> of the code path between "a" and "b" to be output, how could this be
> more efficient than just doing it the way it is done now? It isn't.
> If anything the Intel is broken for not providing any other way to get
> the EFLAGS other than the one which exists and changes the stack frame
> on you.
Well that's what BP is for in the intel machines. But I forgot that
GCC thinks Intel is backwards and pretends everything is a 68000.
Intel even has built-in MACROS called ENTER and LEAVE. You get the
necessary SUB ESP,length_of_local_data for free, i.e., no clock
cycles. Of course the kernel is compiled with -fomit-frame-pointer so
there goes that.
Normally one would do:
; access local variables as
MOV EAX,DWORD PTR [EBP - wherever_it_is_on_the_stack]
Or use the ENTER and LEAVE built-in.
Richard B. Johnson
Voice : (508) 977-3000 ext. 3754
Fax : (508) 532-6097
Modem : (508) 977-6870
Ftp : firstname.lastname@example.org
Email : email@example.com, firstname.lastname@example.org
Penguin : Linux version 2.1.35 on an i586 machine (66.15 BogoMips).
Warning : I read unsolicited mail for $350.00 per hour. Supply billing address.