Solved

assembly code using GCC

Posted on 2001-07-15
8
534 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

724 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