Re: Assembler Question
Re: Assembler Question
- Subject: Re: Assembler Question
- From: Terry Lambert <email@hidden>
- Date: Wed, 28 Nov 2007 17:41:33 -0800
On Nov 28, 2007, at 11:44 AM, John Scheiderer wrote:
I want to learn Assembler on the Mac Intel platform, but I'm having
a hard time finding any tutorials targeted for the Mac. I have an
iMac G5 (which I know won't work), but I did setup a Darwin x86 PC
that has the 'as' compiler, and I also installed 'nasm' (compiled
successfully) from the most recent sources. The reason I installed
'nasm', is I noticed that Leopard now includes it in the Xcode
install on my G5 machine.
I found some Hello World examples on the web, but none seem to work
- they compile and link ok, but get error messages like "Bus error",
etc.
As a test, I took an Objective-C program, and compiled it with gcc
using the -S flag, which produced assembler code. When compiling
the .s file using gcc, it produces an executable, so I suspect the
examples I'm finding aren't error free.
Search <http://developer.apple.com> for "Mac OS X ABI Function Call
Guide".
By your question, though, it sounds like you are a compiler writer,
and that may not be quite enough.
You are most likely missing the setup for your main program, which has
to push the stack base then call into itself (effectively) si the ret
is to the caller of _main(). You may also be unaware that your
linkages to libc need to be implemented as jump table entries so that
dyld, which is loaded before the code starts running and invokes the
crt1 statup code (see the "cctools" project in the Darwin sources).
This is easily visible in the assembly from a -S compile of a small
"hello world" example that just outputs and exits.
-- Terry
_______________________________________________
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