Jump to content



Photo
- - - - -

Stack Overflow Check In Sdk C Compiler - Fx-9860g


  • Please log in to reply
4 replies to this topic

#1 neptune45

neptune45

    Casio Fan

  • Members
  • PipPip
  • 44 posts
  • Gender:Male
  • Location:Madrid (Spain)

  • Calculators:
    fx-9860g Slim

Posted 21 December 2008 - 12:42 PM

Hello Guys,

Does anyone know if the SDK C compiler for FX-9860G has a compiler switch or command line option to force a stack overflow check?

I do not know if that was the problem but I had many local variables declared inside a function and I was experiencing weird memory problems (with the subsequent headache... :banghead: ) such as global variables being overwriten. So I think it could be because I was going outside of the compiler limits. Do we have a limit for the size of the local variable data area declared inside a function? Can we check somehow that we are going outside this area?

Thanks for your help.
Diego.

#2 SimLo

SimLo

    Casio Addict

  • Members
  • PipPipPip
  • 52 posts
  • Gender:Male
  • Location:Germany

  • Calculators:
    FX-9860G/FX-9860G SD

Posted 21 December 2008 - 04:57 PM

The FX9860G's total stack size is 16 kByte (address range 0x88020000 - 0x88024000).

If the stack pointer reaches 0x88020000, the stack is exhausted.

If you want to check the current stack pointer,
you could use a function like GetStackPtr below:

const int GetStackPtrCode = 0x000B60F3;
 const int (*internalGetStackPtr)(void) = (void*)&GetStackPtrCode;
 int GetStackPtr( void ){ return (*internalGetStackPtr)(); }
/* for reference
000B 33 RTS
60F3 34 MOV R15, R0
*/

#3 neptune45

neptune45

    Casio Fan

  • Members
  • PipPip
  • 44 posts
  • Gender:Male
  • Location:Madrid (Spain)

  • Calculators:
    fx-9860g Slim

Posted 21 December 2008 - 06:03 PM

Thank you, SimLo :)

Do you know if local variables of a C function are stored in the stack? Just to be sure what was my problem.
I decreased the size of local variable data and my problem was gone (I had big array), so it seems that I have the problem under control.
However I want to know if the problem was most likely due to the available stack size.

Edited by neptune45, 21 December 2008 - 06:07 PM.


#4 SimLo

SimLo

    Casio Addict

  • Members
  • PipPipPip
  • 52 posts
  • Gender:Male
  • Location:Germany

  • Calculators:
    FX-9860G/FX-9860G SD

Posted 21 December 2008 - 06:44 PM

It partly depends on the size of required local variable space.
If possible, the compiler uses registers, else it uses stack.
Arrays generally need stack.

Though, if you instruct the compiler to use non-stack-RAM (f. i. with "static"), it uses non-stack-RAM, even if you declare a variable inside a function body.

#5 neptune45

neptune45

    Casio Fan

  • Members
  • PipPip
  • 44 posts
  • Gender:Male
  • Location:Madrid (Spain)

  • Calculators:
    fx-9860g Slim

Posted 21 December 2008 - 09:06 PM

Thank you, that helps me a lot. ^_^




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users