Solved

How to call an external compiler for inline ASM in gcc

Posted on 2008-06-15
7
509 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
sumHeights2  challenge 7 78
Setting nameservers after res_init fails doing res_query 2 77
countX 22 70
endX challenge 2 50
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
This is about my first experience with programming Arduino.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

760 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

23 Experts available now in Live!

Get 1:1 Help Now