??? 07/12/05 14:37 Read: times Msg Score: +2 +2 Good Answer/Helpful |
#97149 - I should know Responding to: ???'s previous message |
I never spent much time on this site, but this made me register and answer. I'm one of SDCC's developers and therefor should know the answer to this question.
SDCC currently supports only two memory models: small and large. Small means that all variables without storage class (f.e. idata) are allocated in directly addressable "data" memory which is limited to 128 bytes minus the used register banks. This is the fastest possible access method. Large means that all variables without storage class are allocated in xdata. If you do specify a storage class in the variable definition it is allocated there. So if you want variables to end up in the indirectly addressable only memory (the upper 128 bytes of internal ram) you must tell the compiler so. By default all functions are non-reentrant because all variables are allocated to some static address (by the linker). When you make a function reentrant all automatic variables (parameters and local variables) are allocated on the stack which is always indirectly accessed and therefor can use all internal memory. SDCC tries to keep intermediate results in registers but when it runs out of them it spills them to data memory as that is the fastest memory available. Especially variables in xdata are cached in registers or spill locations for the sheer speed of access. Spilling to xdata is ridiculous. But when the function is reentrant it must spill to the stack to ensure reentrancy. The reason why SDCC needs so much spill locations is that is not smart enough in optimizing and it's linker is not very good at overlaying the variables. SDCC's compiler doesn't know when it runs out of room as many sources get linked later on by the linker. And then it is too late to change the generated asm. One option maybe would be to introduce more memory models which use different default memory for static and/or automatic variables. Also better optimization and a better overlaying linker would help. Finally an option to set the spill memory might help as well, allthough I'm not keen on that. Greets, Maarten |
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 |