Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to add libary files to project in MPLAB C18 compiler

Status
Not open for further replies.

3BABY

Member level 5
Joined
Jan 14, 2011
Messages
91
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
New Zealand
Activity points
2,252
how to add libary files to project in MPLAB ASM compiler

Hi Guys,

im pulling my hair out here.. as my source file is getting terribly long with subroutines i use throughout and across all my projects, how do i create a Delay_2Secs routine (for use by multiple projects) and link it into an existing project, so every time i call DELAY_2SECS it will call the libary'd subroutine? ive googled and read all the Microchip datasheets i can find.. but im not getting an answer.. im using the MPASM compiler and everything is written in Assembly..


thanks
 
Last edited:

See MPLAB IDE help (Getting Started)..

In their first example they had provided how to call one assembly file from another.
 

Re: how to add libary files to project in MPLAB ASM compiler

When you create a new project, A project window will be there. That contains folders like source files, header files. But i am not sure about the name. You can simply right click and add library to your project.
 

See MPLAB IDE help (Getting Started)..

In their first example they had provided how to call one assembly file from another.

thanks.. i have lookd for and found what i think is the document u mention above.. however i cannot find what you suggested.. i have now added two .asm files to my project, and ive added the 18f1445_g.lkr file under the linker script header.. but i cannot find out how to change from absolute to relocatable (once the project was previously built using absolute - ive looked through the menu etc and cannot find anything.. even googleing around).. and im still getting errors saying "Symbol not previously defined (DELAY_2SECS)" which is my other .asm file.. any clearer instructions?

---------- Post added at 16:49 ---------- Previous post was at 15:54 ----------

When you create a new project, A project window will be there. That contains folders like source files, header files. But i am not sure about the name. You can simply right click and add library to your project.

yes.. but i dont understand how to make the library file with the subroutine DELAY_2SECS inside it that my main.asm can know about and use ??
 

Sorry i didn't get you. You mean you have to add library files to main.asm right? I think this procedure is only used for C so that we can create several library files and add it to the main program. What is the need of libraries in assembly language? Please refer here. This is a discussion on how to compiling .c and and .ASM file together:)
 

first, you need to understand the requirements and differences between a single file assembler source and multiple file assembler source (with linking script)

once you get your DELAY_2SECS routine (and related subroutines) in a different Assembler file, (and of course make them all works WITHOUT using INCLUDE), you can create a new project and get an assembler library file (in options, you mark it to "Build library target (invoke MPLIB)"

then in your original project just add the generated library file,

read the MPASM help file to know how to make good library-routines, and how to call library (EXTERN) routines from your ASM application
 

Sorry i didn't get you. You mean you have to add library files to main.asm right? I think this procedure is only used for C so that we can create several library files and add it to the main program. What is the need of libraries in assembly language? Please refer here. This is a discussion on how to compiling .c and and .ASM file together:)

Hi there,

im not necessarily trying to create libary file.. i have a subroutine "DELAY_2SECS" and a main program.asm.. i just want to put the DELAY_2SECS subroutine in an libary, or inc or .o or whatever file so i can just "include/link" it in to any new project i create.. instead of adding the entire DELAY_2SECS subroutine code to my main.asm everytime i need a 2 seccond delay in a project i create..
 

Hi there,

im not necessarily trying to create libary file.. i have a subroutine "DELAY_2SECS" and a main program.asm.. i just want to put the DELAY_2SECS subroutine in an libary, or inc or .o or whatever file so i can just "include/link" it in to any new project i create.. instead of adding the entire DELAY_2SECS subroutine code to my main.asm everytime i need a 2 seccond delay in a project i create..

ok, so why don't you put your subroutine in another ASM file, say: DELAY_2SECS.inc and JUST ' include DELAY_2SEC.inc ' once in your main ASM program???? (i would set it at the end of my ASM file)
 

first, you need to understand the requirements and differences between a single file assembler source and multiple file assembler source (with linking script)

once you get your DELAY_2SECS routine (and related subroutines) in a different Assembler file, (and of course make them all works WITHOUT using INCLUDE), you can create a new project and get an assembler library file (in options, you mark it to "Build library target (invoke MPLIB)"

then in your original project just add the generated library file,

read the MPASM help file to know how to make good library-routines, and how to call library (EXTERN) routines from your ASM application

Thanks.,. but im still having trouble.. i tell you what i have done:

i have created a project called "delay_2secs" and in that project an .asm file with my DELAY_2SECS subroutine in it.. i have then gone to build options selected "Build library target (invoke MPLIB)" and it has created a .lib file..

then i have created a secconds project called "TEST" and in it i have a tst.asm that calls DELAY_2SECS, i have put my delay_2secs.lib file under the "Library Files" header.. tried to build the project but i keep getting error "Symbol not previously defined (DELAY_2SECS)"

---------- Post added at 18:03 ---------- Previous post was at 17:56 ----------

ok, so why don't you put your subroutine in another ASM file, say: DELAY_2SECS.inc and JUST ' include DELAY_2SEC.inc ' once in your main ASM program???? (i would set it at the end of my ASM file)

ok so now.. literally in the last 1min - i have copied and pasted my DELAY_2SECS.asm.. and renamed it DELAY_2SECS.inc (and taken the #include<p18f4550.inc> out of it) then i have added it my project under the Header files .. and recompiled.. AND IT WORKED!! why did it not work before when i done this? was it because i was in an alrady compiled project that was using absolute.. not relocatable?

---------- Post added at 18:27 ---------- Previous post was at 18:03 ----------

what about if i need to create a library file from a lot of .o files from projects written in both ASM and C ? page 19 of microchips 33014 datasheet has this in block diagram..
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top