Ups, that's bad news. Also for me as I have to write a bit much.
The _LOAD_FAR_16, _GET_PAGE_REG and other runtime routines are called by the compiler for the HC12/HCS12 processors (note that I did not mention HCS12X) to access the constants on other flash pages. Basically you cannot set PPAGE while you are running from the PPAGE area. So the compiler calls a runtime routine in a non paged area which then handles the PPAGE access and restores the old PPAGE before it returns.
There are now two ways for you to solve this.
1- also put the page access runtines into your non erased, always available area. This implies that your area must be unpaged. Normally, boot loaders and similar things have to control the vectors (reset vector) anyway, so they are usually located at the top of the 0xc000..0xFFFF page. The data page runtime routines are all located in datapage.c
1.5 Oh, I almost forgot. If you know you are running from a non paged area, you can allow that the compiler does some accesses without runtime call with the -CpPPAGE option. I'm not sure it will do it for your case tough.
2- Use the HCS12X..... (and tell it to the compiler)
What I mean is that the compiler is only using the runtime routines when it generates code for the HC12/HCS12, not when it generates code for the HCS12X!
So you apparently did not specify -CpuHCS12X. Well the HC12X is compatible in this respect with the HCS12, the code just runs fine. But it does not take advantage of the additional features of the HCS12X.
However for you, there is one trap in switching from the HC12 to the HCS12X code. The HCS12X architecture did introduce a new way of accessing the memory, called global access. This memory access is done by the HCS12X for far pointers.
The advantage: no runtime routines (so its what you are looking for!)
The trap: It uses different address values. To say it in another word, the (logical) address 0xFF8000'L matches the global address 0x7F8000'G. Its not the same page and (in general at least) not the 16 bit offset address.
Fortunately, the HCS12X C Compiler does help you. Use the __pptr pointer qualifier whenever you use logical addresses (as you did for the HCS12, and as your assembly routine expects!) and use __far pointer to actually do the memory accesses without runtime call.
E.g.
unsigned char* __pptr flashPageStart= (unsigned char* __pptr)0xFF8000;
..... Call assembly code with flashPageStart.
unsigned char* __far globalFlashPageStart= flashPageStart; // conversion inserted by the compiler
if (*globalFlashPageStart != 0xFF) { ...flash not erased...
Hmm. I just noted that this conversion will also use code from datapage.c. So make sure this code is not getting erased.
Daniel
Message Edited by CompilerGuru on 03-11-200603:22 PM