Problem with the stack on m68k

Peter Barada
Wed May 17 12:10:00 GMT 2000

>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:

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

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

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

Hope this helps,

Peter Barada                   
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,
Want to unsubscribe? Send a note to

More information about the crossgcc mailing list