Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 13:50 14 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Microchip XC8 assembler and psects

Author Message
trippyben

Regular Member

Joined: 26/06/2011
Location: Australia
Posts: 91
Posted: 11:21am 16 Aug 2020
Copy link to clipboard 
Print this post

Hi all. I've been porting a PIC assembly program from MPASM to the newer XC8 assembler and I am struggling with the whole psect thing - I've never used them and the microchip documentation is spinning my head in circles.

Here's a summary of the program:
PIC16F648A processor
4 separate files of code
In file 1 :
 A jump at address 0 to Initialisation code (File 2) to be located past the end of the interrupt code (File 3)
 More code to end of file - located after the initialisation code (File 2)
In File 2:
 Initialisation code
In File 3:
 Interrupt code at address 0x04
In File 4:
 Code and lookup table in Page 1 memory space.

Previously I had used ORG statements to define where i wanted each piece of code to be located and then included the next file in-line as needed, but according to the XC8 documentation that's not the way to do it. From the MPLABŪ XC8 PICŪ Assembler User's Guide "Note: The much-abused ORG directive does not move the location counter to the absolute address you specify." I guess I was abusing it.....

So, I have this prior to the initial jump in File 1

psect resetVec,class=CODE,delta=2
resetVec:


And this before the interrupt code in file 3

psect code
  org 0x004


And this before the other sections of code In file 1 and 2

psect code


And this before the page 1 code in file 4

psect code
   org 0x800   ;page 1 program memory space


I know I need to define some sort of reference for the end of each psect that the next one can link from, but I have no idea how to do that as I either can't understand the microchip documentation, or it assumes everyone is a seasoned programmer who has been taught psects somewhere else.
Question is, how do I define the sequence of the psects of code, without actually structuring the code in one file in the order I want. As it stands, the linker chucks errors because it tries to put the code somewhere that only has 0x30 words (no idea where that might be in a '648) - as this error appears for each psect in the source code.

:0:: error: (1347) can't find 0x425 words (0x425 withtotal) for psect "code" in class "CODE" (largest unused contiguous range 0x30)
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025