Re: Structs pushed on stack backwards?
Re: Structs pushed on stack backwards?
- Subject: Re: Structs pushed on stack backwards?
- From: Eric Albert <email@hidden>
- Date: Sun, 29 Apr 2007 12:15:25 -0700
On Apr 29, 2007, at 7:18 AM, Uli Kusterer wrote:
I just had some time to get back to my current recreational
programming task: Writing a little compiler on OS X. Now, I've got
most of it working, but one thing confuses me a bit:
<http://developer.apple.com/documentation/DeveloperTools/Conceptual/
LowLevelABI/Articles/IA32.html>
has a diagram in "Passing Structures and Vectors" that shows that
small structs get passed on the stack backwards. I.e., I have a
structure
struct PseudoPoint { float x; float y; };
and it gets passed as a parameter on the stack as:
y
x
Wouldn't it be easier to leave everything in its proper order?
What's the rationale behind this?
Actually, it's easier to have it pushed this way. Here's one reason:
x is at offset 0 in the struct and y is at offset 4. When code
references this struct, it'll reference it from the base address. If
that's, say, êx, x ends up as 0(êx) and y is 4(êx).
-Eric
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden