simple MPLAB quest

Hi All.
My program is getting big and hard to overview. I want to add more files to my project so that each file can contain one or a few of my subroutines.
This should be easy stuff i figured but I have been surfing around a lot over the last couple of hours without getting anywere.
So could someone just give a short description on how to get two .asm files compiled and linked together in one project, or point me in the right direction?

Any help, much much apreciated.



you will need to manually add the files using “add file” or copy and paste to new files. Then, you will need to use #include statements to get it all together. This is something I don’t understand very well, so google “making C header files”. That should work out for you.

If you really want to make it easy, just copy one of the .c files (and it’s relevent .h) that is just a few subroutines, gut it, rename it, and put what you want in it.

I’m not sure if it’s good practice, but I’ve saved some time doing that before.

Thanks for the answers. Thing is that I do not use C at all. I do everything in Assembler. Is there a way to do this with asm? Do you know of any simple sample code for me to look at… found some PIC USB protocol that had multiple asm files but it was quite a hassle to go thrugh.
I know how to program C, so I have tried a lot of ways with the #include statement but I get errors, so i figured i was on the wrong path…
Again, any further help is much much appreciated.

Be good.


In C, I believe the include statements are;
#include “file.h”

I’m not 100% sure, I’ve been doingmore mechanical stuff recently (but like to keep in touch with my good friend C). you could check the code on to see some examples.

EDIT: I got your post completely backwards, I thought you meant you needed to do it in C.

Hmmm, 99% of the time I have a syntax problem or don’t know how to code something, I google it and it usualy comes up.

assembly programming include

or something like that.


LINK yourfile.asm

I have googled alot…
The “LINK” command does not seams to work…
Maybe I should post some code here to clarify things:
My first file: agraal08.asm

list p=16f819 ; list directive to define processor
#include <> ; processor specific variable definition
#include <test.asm>
errorlevel -302 ; suppress message 302 from list file

ORG 0x0000 ;här ska vi börja vid reset.
goto Init ; go to beginning of program

Init ORG 0x0005
call Sub_Test
clrf PORTA
goto Init
END ; directive ‘end of program’

and my second file with the subrotine: test.asm

list p=16f819 ; list directive to define processor
#include <> ; processor specific variable definitions
movlw .99
movwf PORTA

I am using MPLAB and have no C compiler (and would preferably keep it this way).

If you could modify the code so that this works (one way or the other) I would be off with a smile.


Ok, sorted it myself… hehe
If I rename the “test.asm” to “” and include this by: #include <> in the beginning of the “agraal08.asm” file. Then put a ORG statment on the Sub_Test routine:
Sub_Test ORG 0x0050

and remove the “END” of the .inc file then it seams to work. Have not tried it much but it looks like it behave the way I want. Tomorrow (its quater past 1 at night here… sould go home form work really…)

Thanks to you trying to help me (probably I am just too novice on this to make your suggestion work for me…).