This is not strictly a bug, but the effect
of that pessimization is rather bad.
If the interrupt handler is defined to use
some regbank other than 0, and it calls some
function that is not set to use any particular
regbank, then the compiler would save all the
regs and switch the bank to 0 before calling
the function. I define the inthandler to use
the specific regbank exactly to save some
stack space and an execution time, but the
effect is quite the reverse.
Unless I am missing something, if the function
is not set to explicitly use some regbank,
there is no need to switch the banks before
calling it. It looks like sdcc doesn't destinguish
between the function that is not set to use
a particular regbank and the function that
was set to use bank 0, which makes the problem.
It always switches to bank 0, but if the
function is not explicitly defined to use bank 0,
then there is no need to switch at all.
Attached is the simple demo program.
Looking into its assembly reveals how many
unneeded things are done, and how much memory
does this consume. It eats about 10 extra bytes
with the useless push/pops, which is way too
much for those poor MCUs with 128bytes of RAM.
Log in to post a comment.