Ok, easy to explain.
When a particular bank is selected with the RP0 and RP1 bits in the STATUS register, any opcode trying to access that bank is limited to 128 bytes. So, $20, $A0, $120 and $1A0 all point to a location that is 32 bytes into their respective BANK. The Variable declarations wsave1-3 are set that way to reserve the same locations in each bank.
That way you don't need to worry which bank you are in. The "MOVWF W_TEMP" always puts the byte in the correct location, no matter which bank is selected.
Then, notice that the STATUS register is restored prior to restoring the W register. That way you always have the same bank selected that was used to save the W reg. to begin with.
HTH,
Darrel
Bookmarks