Problem with the stack on m68k
Art Berggreen
art@acc.com
Wed May 17 11:43:00 GMT 2000
Noah Aklilu wrote:
>
> Hi
> I writing code for a 68306 board using m68k cross compiler,
> and I was getting bus and address errors from my code, not always
> in the same location. It seems to be related to problems with the
> stack, I have noticed that the compiler allocates portions of the
> stack using "link" (e.g. link a6,#$FFEF) to create space for
> variables. How does one control the maximum stack size?
> Some of the errors seem to be related to corrupt files being
> read back from the variable spaced allocated with "link". I
> have tested my memory to make sure it is fine.
> Having written a few perl programs lately, my main function
> ended up being a little large (about 200 lines). As a result it seems
> to allocate a large chunk of (about 0xffff) of the stack as variable
> space. I have another
> program that I tested and it is much smaller (about 20 lines)
> and it runs to finish without any problems.
>
>
> I want to check another thing. When calling assembly routines
> from c code, my routine assumes the first value it pops from the
> stack is the return address, and the next two values, its input
> parameters. So I pop off the return address, save it in a0 (which I
> believe I can use as scratch space), and push it back onto the
> stack before returning using rts.
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
------
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