Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How do I compile an Assembly file and link from C code?

Status
Not open for further replies.

joeh100

Member
I know I can do inline assembly and there seems to be plenty of documentation available for that, but what I'm really looking for is how to compile an Assembly file and link to it from C code.

Can someone point me to some documentation? A basic working example would be really nice also. For example, how do I implement the example 3-3 in the C18 user guide.
 
Without looking it up:
Write you .asm file and include it in the MPLAB project,
Write the .c file that calls it and include in the MPLAB project.
Hit build

If it does not work you may need to work on the linker script but I think not

Give it a try.
 
Thanks, 3v0. Such a simple answer, you would think I could have gotten an answer in the microchip forum.

Actually that wasn't exactly what I was looking for but I'm sure you would have given me the answer after a couple more posts, when I was a little more specific about what I was asking.

Anyway, I kinda figured it out this morning. What I was basically looking for, was being able to link to precompiled code. You just add the object file (*.o) to your project. For some reason I expected it to be a lot more complicated. Mainly because I couldn't find any documentation or get an answer on other forums.
 
It is a matter of asking the right question. You did not ask how to link objects.

I expect this put a few people off

but what I'm really looking for is how to compile an Assembly file and link to it from C code.

We compile high level languages files like C or Pascal with a compiler. We assemble assembly files using an assembler.

Glad you found your answer.
 
Last edited:
I didn't know what an "object" was this morning. :) I'm new to C.

Thanks for clearing things up.
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top