how to use CALL and RTC instructions?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to use CALL and RTC instructions?

516 Views
waltbill
Contributor I

hi,

The CPU of 9S12 Family has special access to read and write  PPAGE register directly during execution of CALL and RTC instructions. I refer  to some examples , some CPU write and read PPAGE directly, or some JSR and RTS instruction given by a array of mechine code. I'm not skilled at mechine codes, So  I hope  to get some guidance.

It's much better to give  examples  in writte PPAGE register by CALL and RTC instructions.

0 Kudos
1 Reply

365 Views
miduo
NXP Employee
NXP Employee

Hi,

First I am thinking that you should post this issue in 16 bit community but not here the Kinetis community. Anyway, I would like try to answer the question:

Call is similar to JSR; microcontrollers with expanded memory treat 16 Kbytes of addresses from $8000 to $BFFF as a memory window.  The PPAGE register is the one that switches memory pages.

In the case of the call, the two bytes of the return address are stacked, after stacking this two bytes, the microcontroller saves the actual PPAGE register in the stack, then it writes in the PPAGE register the value of the new page supplied by the instruction and then transfers to the PC the address of the subroutine. When the subroutine is terminated by the RTC instruction, the microcontroller is able to restore the address and the PPAGE register from the stack.

So if you are switching the code execution between pages, you have to use the CALL instruction, remembering that expanded-memory subroutines must be terminated by an RTC. But, if you are jumping to places within the same memory page, it's not necessary to change all the JMP or JSR for CALL.

In the case of the JSR, it's very much like the call, but the difference is that this instruction does not stack the value of the PPAGE register, so again, if you want to jump to a subroutine that is in other memory page, you have to use the call. If they are on the same page, you can still use the JSR.

0 Kudos