Subject: Re: More m68k Asm
To: Andy Finnell <andyf@vei.net>
From: David Huggins-Daines <bn711@ncf.ca>
List: port-mac68k
Date: 06/19/1999 19:53:41
On Sat, Jun 19, 1999 at 06:52:36PM -0400, Andy Finnell wrote:
> First off, so I don't have to keep sending asm questions to this group,
> does anyone know where I can find the m68k Programmer's Manual from
> Motorola?  I've searched their website for it, but I can't even find a

http://www.mot.com/SPS/HPESD/prod/gen/frames/68k.html

They also have a literature ordering service where you can order hard-copy
of various manuals, or have them fax it to you (eek!).  Unfortunately their
stock seems to vary, and I think the MC68000PM/AD has gone out of print
altogether.  But you can still get the PDF above.

> Secondly,  I have a specific m68k asm question.  What are the calling
> conventions for 68k asm, assuming I want a C function?  I need to be
> able to get the only parameter that was passed into me, and use it as an
> address to a block of data on the stack.

All arguments are passed on the stack, and return values go in %d0.  The
stack pointer is %a7, and the frame pointer is %a6 (though gas lets you use
%sp and %fp for these).  I can't remember offhand which registers are saved
by whom.  But a C function like this:

int foo(char* bar)
{
	printf(bar + 2);
	return 42;
}

would come out somewhat like this:

foo:
	link	%a6,#0
	movea.l	4(%a6),%a0
	addq.l	#2,%a0
	pea	%a0
	jsr	printf
	addq.l	#4,%a7
	move.l  #42,%d0
	unlk	%a6
	rts

The best way to get a feel for these things is to use the -S flag to gcc
then look at the .s files it generates.

-- 
You do{} stuff.  Then it's $done.  Then you die().