This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Which registers can I trash with user-defined bank switching?

Using C51 (v6.xx/7.xx) with user defined bank switching (mode 4), which registers must be preserved on the call and return?

R1-R7 must be preserved on the call & return, since these pass parameters & return values.

The carry flag must be preserved on return, since it may return a bit value.

Examining Keil code & examples, it seems that it's ok to trash ACC and DPTR.

What about R0, B and other flags?

I couldn't find anything explicit in the documentation, so have currently taken a conservative position with my (rather complicated) bank switching routine.

Parents
  • Keil must disable, or limit global register optimisation for interbank calls.

    A good point. One less charitable option is that it doesn't work in this case... That occurs to me simply because a while back we had some weird problems that we traced down to the global register optimization. Our solution was to disable it. However, maybe our bank switch stubs are trashing something they're not supposed to. Time to review that code.

Reply
  • Keil must disable, or limit global register optimisation for interbank calls.

    A good point. One less charitable option is that it doesn't work in this case... That occurs to me simply because a while back we had some weird problems that we traced down to the global register optimization. Our solution was to disable it. However, maybe our bank switch stubs are trashing something they're not supposed to. Time to review that code.

Children
No data