Author Topic: [68k] - Stack limit ?  (Read 2940 times)

0 Members and 1 Guest are viewing this topic.

Offline Torio

  • LV3 Member (Next: 100)
  • ***
  • Posts: 83
  • Rating: +22/-0
    • View Profile
[68k] - Stack limit ?
« on: August 24, 2012, 09:05:42 am »
Hello,
I'm writing a C program (with GCC4TI) in which many functions are called inside an other, etc...
It seems I've reached a point where too many functions are stacked and the program crashes, throwing sometimes (but not always) a memory error.

Is it possible to increase the size of the stack in C ?
Thank you in advance,
Torio.
Sorry about my mistakes, I'm French.

Projects :  Pokemon TI-89 | Ti-Tank

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: [68k] - Stack limit ?
« Reply #1 on: August 24, 2012, 09:20:04 am »
Quote
Is it possible to increase the size of the stack in C ?
Basically, no.
The user portion of the stack goes from 0x4200 to 0x400 downwards, and the OS uses some of that itself.

What you need to do is reduce stack usage by eliminating SAVE_STACK (saving/restoring the screen yourself, in an allocated memory block or through the method used by the Home Screen Restore program), reducing call nesting, and potentially by using the registers to pass parameters (__attribute__((__regparm__)) on single functions, -mregparm=5 compiler switch).
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline Torio

  • LV3 Member (Next: 100)
  • ***
  • Posts: 83
  • Rating: +22/-0
    • View Profile
Re: [68k] - Stack limit ?
« Reply #2 on: August 24, 2012, 09:40:38 am »
I de-checked the Save/Restore LCD Contents box in Program Options and saved the home screen in an allocated memory block, and the problem dissapeared.
I hope that I won't have to reduce stack usage again, because that :

Quote
potentially by using the registers to pass parameters (__attribute__((__regparm__)) on single functions, -mregparm=5 compiler switch).

I didn't understand it at all.  :banghead:

Thank you again, Lionel, for your always-useful answers.
Torio
Sorry about my mistakes, I'm French.

Projects :  Pokemon TI-89 | Ti-Tank