Search the web
Sign In
New User? Sign Up
gnu-m68hc11 · GNU 68HC11/HC12
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
GCC Stack Frame issue   Message List  
Reply | Forward Message #9274 of 9422 |
My CPU is a MC9S12DT256 with 12KB of RAM located at 0x1000-0x3FFF.

Code is compiled with the following flags:

GCC: -m68hc12 -g -Os -fomit-frame-pointer
LD: -nostdlib -nostartfiles

when my hardware init routine ends and calls main(), SP is point at the
top of the stack 0x3FFF.

In my linker script, I have PROVIDE(_stack = 0x3FFF ) to tell GCC where
the top of my stack is.

Now here's where the problem comes in...I discovered it when parameters
didn't get correctly passed to a function of mine.

For debug purposes currently, my main looks like this:

void main()
{
unsigned short test = 0xABCD;
asm("bgnd"); // break for debug
// remaining code following here
}

The generated code by GCC looks like this:

movw #-21299,0,sp
bgnd

So with the stack pointer as 0x3FFF, that can't possibly work and sure
enough doesn't.

Looking at the RAM, I get the AB at address 0x3FFF and the CD goes off
into nothingness. That also explains why in my test code a variable
wasn't passed to my function right because GCC was doing the same thing
there causing existing data on the stack to be overwritten.

It seems to me as if GCC is treating the stack as if it was incrementing
instead of decrementing.

Any thoughts anyone? GCC Version is 3.3.6

Thanks,

Stephan





Fri Feb 20, 2009 12:52 am

kermos2000
Offline Offline
Send Email Send Email

Forward
Message #9274 of 9422 |
Expand Messages Author Sort by Date

My CPU is a MC9S12DT256 with 12KB of RAM located at 0x1000-0x3FFF. Code is compiled with the following flags: GCC: -m68hc12 -g -Os -fomit-frame-pointer LD:...
Stephan Rose
kermos2000
Offline Send Email
Feb 20, 2009
12:52 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help