Re: Structs pushed on stack backwards?
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com On Apr 29, 2007, at 7:18 AM, Uli Kusterer wrote: struct PseudoPoint { float x; float y; }; and it gets passed as a parameter on the stack as: y x -Eric _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... 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 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, %eax, x ends up as 0(%eax) and y is 4(%eax). This email sent to site_archiver@lists.apple.com
participants (1)
-
Eric Albert