Solved

How to call an external compiler for inline ASM in gcc

Posted on 2008-06-15
7
511 Views
Last Modified: 2013-11-13
I have a c program that I compile with gcc (gcc with hc12 patches).  The new CPU I'm working with has a co-processor and isn't supported in gcc-68hc12.  There is a open-source assembler for the co-processor that I would like to use(http://home.arcor.de/hotwolf/).  I'm looking for an example showing me how to instruct gcc to use this external assembler where specified in my code.

0
Comment
Question by:sean-keys
7 Comments
 
LVL 24

Assisted Solution

by:fridom
fridom earned 100 total points
ID: 21791153
Hm, that's a bit unusual. I just wonder if that really is needed. Can't you just write some assembler file and then you use the Assembler to generate the object files and then you use gcc as linker for this object file also.

Regards
Friedrich
0
 
LVL 40

Expert Comment

by:evilrix
ID: 21791208
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 21791416
The assembler is part of gcc, and I know of no way to tell gcc to use a different assembler (especially not if it's just for parts of the code).
make however can be told to use the external assembler (on a separate file like fridom said) - just add it to the build commands before linking.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:sean-keys
ID: 21794679
"use the Assembler to generate the object files and then you use gcc as linker for this object file also"

Could this be done in the make.conf file ?

0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 400 total points
ID: 21795977
Sure. You could just make a general rule that assembles files with a certain extension using your external assembler. Those object files can then be linked to the rest of the code with gcc.

Or, you could handle it on a case-by-case basis if you prefer.
0
 

Author Comment

by:sean-keys
ID: 21796159
Sounds like the solution I'm looking for.  This is a community project(http://sourceforge.net/project/showfiles.php?group_id=214452) and I would like people to be able to simply run "make" and get a usable s19 file, just as you can now.  Any chance you know of examples I can reference. I'm a bit of a noob with low level programming.

Thanks,
Sean



0
 
LVL 53

Expert Comment

by:Infinity08
ID: 21796323
Depending on how the makefile is set up, it could look something like this (assuming that the external assembler is called hsw12) :

mod.o : mod.asm
      cmd_that_compiles_mos.asm_into_mod.o_here

code.o : code.c
      gcc -c code.c

executable : code.o mod.o
      gcc code.o mod.o -o executable
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is an explanation of a simple data model to help parse a JSON feed
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now