Lib and Obj in MPASM

Thread Starter

TCOP

Joined Apr 27, 2011
94
I've decided to make a obj file with some routines I've made (rellocatable code) and to call them from my main asm file. I've noticed that even though I only mention only a couple of those routines in my main asm file using EXTERN , the final hex file contains all the code of the .o file. I did some research that drove me into the conlcusion that this should be normal and in order to avoid it I should make a lib file and so I did. The problem is that still I get a Hex file with all the code of the core asm + the lib file.
Do you have any suggestions?
I am stuck almost a day trying to figure out what's wrong.
 
Last edited:

ErnieM

Joined Apr 24, 2011
8,171
This is the natural result of putting everything into one file. So the linker's only choice is to use the entire file, or not.

Break the file up into many atomic routines. This will produce lots of smaller files so the linker can pick and choose just what pieces are needed.

If you look thru the source for a lbrary (there may be some under your Microchip folder, there is in mine) you can see each routine gets it's own dot C file, thought he same thing applies to asm files.
 

Thread Starter

TCOP

Joined Apr 27, 2011
94
Thanks a lot ErnieM.
Just checked it and you are so right!
Damn! I lost a day trying to figure out what i was doing wrong.
 
Top