This is the mail archive of the crossgcc@sourceware.cygnus.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Problem with the stack on m68k



>The calling convention I am assuming is the one described in the gnupro
>manual (on cygnus's site).  The one that I was used to was pushing
>the result onto the stack and then the return address.  If I am
>wrong in assuming this.  

I ran the following function using gcc-2.95.2 configured for a straight
68k with '-O4 -fomit-frame-pointer':


unsigned int rotateright(unsigned int a, unsigned int b)
{
  return (a << b | (a >> (32 - b)));
}

and got as output:

.text
.globl rotateright
	.type	 rotateright,@function
rotateright:
	move.l 4(%sp),%d0
	move.l 8(%sp),%d1
	rol.l %d1,%d0
	rts
	nop

As you can see, the return address is a 0(%sp), the first param(a) is at
4(%sp), and the second param(b) is at 8(%sp).  Also note that the return
value is left in %d0, and the stack pointer is not adjusted by the
callee.

If that is all your function is to do, just leave it in C...

Hope this helps,

-- 
Peter Barada                             pbarada@wavemark.com
Wizard                                   
WaveMark Technologies, Inc.              

"Real men know that you should never attempt to accomplish with words
what you can do with a flame thrower" --Bruce Ferstein

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]