Link to home
Start Free TrialLog in
Avatar of effectstudios
effectstudios

asked on

assembly code using GCC

how is it possible to compile programs using embedded assembly language with the "asm" keyword on the linux platform using gcc.
i tried the following options:
1) gcc -x assembler-with-cpp file.cpp
2) gcc -w file.cpp
3) gcc -asm file.cpp

none of these work.
without any switches, it gives a parse error after every function. with the above switches, it fails to recognise the references assigned to the registers using mov .

Avatar of garboua
garboua

if you file extension ends with an ".s" or .S, gcc will know that it is an assembly and produce your binary.  no "swithches"
Avatar of effectstudios

ASKER

you mean to say that i should rename the same file as:
file.s
???
Won't the compiler complain about a missing .cpp extension then?
OH NO,
the compiler will accept a preProcessed file, an object file, an assembly file, or a source code.
so ".o" ".i" ".s, .S" ".c" ".cpp" are all acceptable, BUT interperted as they mean.  so when the compiler sees the file.s, it knows it is an assembly lang file.
ASKER CERTIFIED SOLUTION
Avatar of superschlonz
superschlonz

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
When you posted your question are you referring to C code with embedded asm statements or are you referring to pure assembly code?
i am refering to a c program with some assmebly code embedded in it using the "asm" keyword
 
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: superschlonz {http:#6287898}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer