Hi Matt,
So it looks like your INC instruction was incrementing location $00 (an I/O port) instead of location $100. Glad you found it.
What we are doing differently is that I am writing relocatable assembly language, whereas you are writing absolute assembly language. So you are using ORGs and I am using SECTIONS. I only mentioned it so that you would know that I wasn't that familiar with absolute assembly.
You should just use "ORG Z_RAMStart", as you said. That appears to me to be the correct way for absolute assembly. Your understanding of page-zero being from $00 to $FF is correct. But I don't think you need the concept of page 1 or any other page. There is page-zero, and then there is everything else. That is all the silicon cares about.
The main advantage of relocatable assembly language is that you can make use of object-libraries. But there is more work involved, especially for the linker.
But to answer some of your "section" questions:
I use three "default" section statements a lot: BSCT (for page-zero data), DSCT (for non-page-zero data) and PSCT (for program instructions). I also create other sections, but 80% of my code is in those three.
When you declare a SECTION, you could explicitly make it refer to page-zero with the "short" keyword:
TableSct: section short
As for interrupt vectors, I've created a section called ".vect". Here is the code in the .asm file:
;;********************************** ** Interrupt Vectors ** **********************************;;.vect: section ;MC9S08gb60 Hardware Interrupt Vectors xdef vectors;;vectors: fdb IICnextPage ;Real-Time Interrupt vector (Lowest Priority) fdb ICCservice ;IIC interrupt vector fdb Nope ;ATD convertor interrupt vector fdb Nope ;Keyboard interrupt vector fdb Nope ;SCI2 Transmitter interrupt vector fdb Nope ;SCI2 Receiver interrupt vector fdb Nope ;SCI2 Error interrupt vector fdb Response ;SCI1 Transmitter interrupt vector fdb Command ;SCI1 Receiver interrupt vector fdb CommErr ;SCI1 Error interrupt vector fdb Nope ;SPI interrupt vector fdb Overflow2 ;Timer 2 Overflow interrupt vector fdb Nope ;Timer 2 Channel 4 interrupt vector fdb Nope ;Timer 2 Channel 3 interrupt vector fdb ClinTrig ;Timer 2 Channel 2 interrupt vector fdb Temp1in ;Timer 2 Channel 1 interrupt vector fdb Temp2in ;Timer 2 Channel 0 interrupt vector fdb Overflow1 ;Timer 1 Overflow interrupt vector fdb Nope ;Timer 1 Channel 2 interrupt vector fdb Nope ;Timer 1 Channel 1 interrupt vector fdb Nope ;Timer 1 Channel 0 interrupt vector fdb ICGintr ;Internal Clock Generator interrupt vector fdb LVDintr ;Low Voltage Detect interrupt vector fdb DSPintr ;IRQ pin interrupt vector from DSP fdb Nope ;Software interrupt vector fdb Boot ;Reset vector (Highest Priority)
And the it is placed at the appropriate addresses by the linker with these lines in the .prm file:
SEGMENTS . . . Vectors = READ_ONLY 0xFFcc TO 0xFFff; . . .ENDPLACEMENT . . . .vect INTO Vectors; . . .END