Page 1 of 1

compiler expectations for bank select register?

Posted: Tue Jul 19, 2016 8:51 am
by Jerry Messina
I'm having some issues with a few macros I wrote, and it seems to have something to do with register banking.

Is the compiler supposed to track BSR usage through a sub/function/macro call?
If a routine (in this case a macro) modifies the BSR does the compiler expect it to be restored/zeroed when the routine exits
and returns to the caller?

Re: compiler expectations for bank select register?

Posted: Tue Jul 19, 2016 12:24 pm
by David Barker
If some user code modifies BSR, the user code is responsible for restoring it.

Re: compiler expectations for bank select register?

Posted: Tue Jul 19, 2016 12:37 pm
by Jerry Messina
Do I need to restore it to what it was on entry or can I just set it to 0?

Re: compiler expectations for bank select register?

Posted: Tue Jul 19, 2016 1:34 pm
by David Barker
It needs to be the same - the compiler does not track ANY user changes

Re: compiler expectations for bank select register?

Posted: Tue Jul 19, 2016 5:16 pm
by Jerry Messina
Thanks. That seems to have fixed it up.