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 .
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 .
if you file extension ends with an ".s" or .S, gcc will know that it is an assembly and produce your binary. no "swithches"
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?
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
When you posted your question are you referring to C code with embedded asm statements or are you referring to pure assembly code?
ASKER
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
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