Hi Bastian,
You are right. Address 0x7F_BFFE is global address and your code works only with lower 16 bits = 0xBFFE.
So, loading address will work only in case when PPAGE register will be set to value 0xFE.
Despite of fact, that S12XE core contains instruction for work with global addresses, the core still works in default 16bit address space (program counter is 16bit).
So, you have three basic options:
1. Typically we place application starting point into unbanked memory. For example:
AppResetVect: equ $effe ; here is stored reset vector of user application
ldx AppResetVect
jmp 0,x ; jump to the application
2. We could leave application reset vector in paged memory, but we have to ensure that PPAGE register will be correctly set for reading right value. In case when bootloader code is executed from non-banked area, we could simply write 0xFE into PPAGE register prior we read from address #0xBFFE. If bootloader code is executed from paged memory, situation is slightly more complicated and you should use routine for safe reading from far address (see datapage.c file).
3. We could leave application reset vector in paged memory, but we will use global address and global instructions for reading vector value. In that case we should (optionally save GPAGE register), set GPAGE to 0x7F value, use GLDX instruction for reading vector value (optionally , restore GPAGE register value) and jump to application.
I am just curious, why you use instruction ldx D, x;?
Do you have more application reset vectors than one and you use offset in D accumulator for distinguish between applications?
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------