Solved

assembly code using GCC

Posted on 2001-07-15
8
531 Views
Last Modified: 2012-06-27
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 .

0
Comment
Question by:effectstudios
8 Comments
 
LVL 5

Expert Comment

by:garboua
ID: 6285777
if you file extension ends with an ".s" or .S, gcc will know that it is an assembly and produce your binary.  no "swithches"
0
 
LVL 1

Author Comment

by:effectstudios
ID: 6286965
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?
0
 
LVL 5

Expert Comment

by:garboua
ID: 6287364
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.
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 3

Accepted Solution

by:
superschlonz earned 15 total points
ID: 6287898
0
 
LVL 4

Expert Comment

by:newmang
ID: 6287901
When you posted your question are you referring to C code with embedded asm statements or are you referring to pure assembly code?
0
 
LVL 1

Author Comment

by:effectstudios
ID: 6290909
i am refering to a c program with some assmebly code embedded in it using the "asm" keyword
 
0
 
LVL 20

Expert Comment

by:jmcg
ID: 9871626
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
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
automating commands in linux on start up 2 47
specifying dependencies for an rpm 2 53
Linux Search 3 67
improve Shell script 5 155
Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

831 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