Compiling Position Independent Code - what have I missed out?

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

Compiling Position Independent Code - what have I missed out?

Jump to solution
897 Views
Stephen
Contributor III

Hi

I am working with Code Warrior for HCS12 version 5 Build 9061 

 

I am working on a project for the MC9S12DG128, but have transferred a lot of code form a project on the MC9S12A256.

 

This includes a couple of routines that are compiled as Position Independent Code (so they can be copied into RAM and run from there)

 

The function starts with the pragma declaration

#pragma CODE_SEG __PIC_SEG BOOT_CODE

 

This works fine in the first project. When I disassemble the code, the assembler uses position independent calls e.g. JSR   BT_FlashFunc,PCR

 

But in the new project, despite having the same routines with the same pragma, when I check the disassembled code it is not using position independent calls. e.g.  JSR   BT_FlashFunc

 

Is there some option I should set in the compiler settings which ensures that it will respect the pragma?

 

Many thanks

Steve 

Labels (1)
Tags (1)
0 Kudos
1 Solution
324 Views
CompilerGuru
NXP Employee
NXP Employee

There is no option I'm aware of.

 

Are the two call locations also the same? For PIC, both the function being called and the call location have to be PIC, so check that in the new project the function containing the JSR and BT_FlashFunc are defined & declared in a section with the __PIC_SEG quali. Check the preprocessor listing.

 

Daniel

View solution in original post

0 Kudos
1 Reply
325 Views
CompilerGuru
NXP Employee
NXP Employee

There is no option I'm aware of.

 

Are the two call locations also the same? For PIC, both the function being called and the call location have to be PIC, so check that in the new project the function containing the JSR and BT_FlashFunc are defined & declared in a section with the __PIC_SEG quali. Check the preprocessor listing.

 

Daniel

0 Kudos