HC12 sections and pages

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

HC12 sections and pages

Jump to solution
1,943 Views
Ghibli
Contributor I
Hi,
may be somebody can support me with flw. problem.
I' ve to convert old assembler code written for HC11, to support now
a 9S12XDP512 controller. The assembler code is more than 20kB large and so does not
fit in one section for HCS12. I'm using relocatable model and build three sections, one for data, one for code and one for constants. I paged the code (>10kB) to Page FE and the constants (9kB) to Page FC. Now I've flw. problem, if I want to load an address from a constant like
LDX #CONSTANT and then LDD 0,X the program crash, due to wrong address and wrong contents.
So I do some like that:
LDX #GLOBAL(CONSTANT)
LDAB #GLOBAL_PAGE(CONSTANT)
STAB GPAGE
and then GLDD 0,X.
But this is not very practical, because I've to lookout every point there is an load to a constant and 10kB assembler code is a lot. Further sometimes in the code there are constructions like
LDX #CONSTANT
STX ADDRESSCONSTANT

LDX ADDRESSCONSTANT
LDD 0,X
STD DATACONST
to calculate a field address inside macros from the constant section. And here I can't use above mentioned GLOBAL identifier.
So my question. Is there another way to handle code and constants if the size of both does not fit on one page? Thanks for the support.

Message Edited by CrasyCat on 2007-04-13 11:14 AM

Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
686 Views
Lundin
Senior Contributor IV
Note that you've got 32k of non-paged memory located at 4000-7FFF and from C000 to FFFF. When you try to access data from those addresses, the value in PPAGE is irrelevant. So unless you have more than 32k of constant data, you won't have to worry about PPAGE. Where the code using the constants is located doesn't matter.

What you do need to be careful with though, is the use of JSR/CALL and RTS/RTC, but that's another topic.

View solution in original post

0 Kudos
Reply
2 Replies
687 Views
Lundin
Senior Contributor IV
Note that you've got 32k of non-paged memory located at 4000-7FFF and from C000 to FFFF. When you try to access data from those addresses, the value in PPAGE is irrelevant. So unless you have more than 32k of constant data, you won't have to worry about PPAGE. Where the code using the constants is located doesn't matter.

What you do need to be careful with though, is the use of JSR/CALL and RTS/RTC, but that's another topic.
0 Kudos
Reply
686 Views
Ghibli
Contributor I
Hi Lundin,
thanks for your answer, this was a great help.
Sometimes it is like: You can't see the trees, while you're standing in the forest.
best regards Ghibli
0 Kudos
Reply