Problem with the stack on m68k

Scott Howard scott.howard@windriver.com
Wed May 17 12:12:00 GMT 2000


Your asm routine is removing the parameters from the stack (ie increments
the stack pointer after loading the values). Don't do this. This is the
responsibility of the calling routine, not the called routine.

Try this instead:

#include "asm.h"

	.title "rotate.S for gizmo"


/* Function specifer */

	.global	SYM(rotateright)

SYM(rotateright):

/* Load input variables from stack */
	move.l	(4,%sp),d0
	move.l	(8,%sp),d1

/* Rotate value and save in d0 */
	ror.l	%d1,%d0

/* Return to call function */
	rts

Scott

-----Original Message-----
From: crossgcc-owner@sourceware.cygnus.com
[ mailto:crossgcc-owner@sourceware.cygnus.com]On Behalf Of Aklilu Noah
Sent: Wednesday, May 17, 2000 11:55 AM
To: crossgcc@sourceware.cygnus.com
Subject: Re: Problem with the stack on m68k


On Wed, 17 May 2000, Art Berggreen wrote:

>
> Is your called function popping the passed arguments off the stack?
> In the standard C calling interface, it is the caller's responsibility
> to clean arguments off the stack.  If your subroutine doesn't return the
> stack pointer where the calling function expects, things will break.
>
> Art
>

Probably best explained if I past in my assembly routine

#include "asm.h"

	.title "rotate.S for gizmo"


/* Function specifer */

	.global	SYM(rotateright)

SYM(rotateright):

/* Load input variables from stack */
	move.l	(sp)+,a0
	move.l	(sp)+,d0
	move.l	(sp)+,d1

/* Rotate value and save in d0 */
	ror.l	d1,d0

/* Return to call function */
	move.l a0,-(sp)

	rts

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.

Noah Aklilu
aklilu@nyquist.ee.ualberta.ca
http://www.ee.ualberta.ca/~aklilu/
"Integrity is something you do when no one is looking"



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



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



More information about the crossgcc mailing list