??? 07/11/05 21:12 Read: times |
#97094 - Who knows Responding to: ???'s previous message |
Jez Smith said:
Is it me or does sdcc behave in a very odd fasion when its working with variable storage in reentrant functions? It's not just you. Ive read the manual as as far as I understand it in re-entrant functions automatic and static variables are placed on the stack in the upper 128 bytes of internal ram rather than the normal action of placing them in the lower 128 bytes of internal ram.So why doesnt sdcc use the indirect ram for static varibles in non-rentrant functions as it seems that would be the sensible thing to do.Theres prolly some ver good reason why it doesnt do that which someone will now point out to me. If someone can explain it, I'd be very interested in hearing it. I recently worked on a project that I decided to try in SDCC. I succeeded, but not without some pain related to this very issue. Apparently, SDCC requires certain working variables to be stored in internal RAM and refuses to use XRAM for such variables. Time and time again I ran into an error "Couldn't get XX bytes allocated in IRAM/DSEG" (where XX is some number). For some reason, it insisted on putting certain values in the lower 128 bytes of IRAM. I got no good answer out of the SDCC forum and eventually stumbled on a strange work-around: Make some of my functions re-entrant even though I didn't need reentrancy. Doing so allowed the program to use the stack (and thus the upper 128 bytes of IRAM) for the temporary working variables. I have no idea why it doesn't do this automatically when it runs out of room or, for that matter, why it doesn't do it across the board. I'm a little nervous about the solution but I was tempted to declare all my functions reentrant just to solve that problem once and for all. I don't see any other way to get SDCC to efficiently reuse IRAM and except for some probable loss of speed in dealing with stack-based variables, I haven't noticed any negative side-effects. Regards, Craig Steiner |
Topic | Author | Date |
reentrant functions in sdcc | 01/01/70 00:00 | |
Eh??? | 01/01/70 00:00 | |
ooops | 01/01/70 00:00 | |
what i mean is... | 01/01/70 00:00 | |
Who knows | 01/01/70 00:00 | |
I should know | 01/01/70 00:00 | |
sounds like a good reason | 01/01/70 00:00 | |
Thanks | 01/01/70 00:00 | |
stack-auto![]() | 01/01/70 00:00 | |
Thanks Craig | 01/01/70 00:00 | |
although.... | 01/01/70 00:00 | |
WIP | 01/01/70 00:00 |