How to convert Assembly langugae to Executable in c language
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Re: How to convert Assembly langugae to Executable in c language
Quote:
Originally posted by ssg14j How to convert assembly to executable in c programming..
gcc -c file.s
You should get file.o and link it with all other .o files you need to make executable. Or, if that's the only file:
gcc -o executable_name file.s
C doesn't matter at this stage.
Quote:
And also tell me how to view the c program opcode............
gcc -S program.c
It converts your C program to assembly code.
symantically 3gl's (c, c++, java...) are compiled down into machine code (hex).
assembly interprets opcodes into machine code.
so based on how efficient the compiler is, it should be similar to the machine code created by the assembler. (i.e.- a binary executable is a binary executable regardless of being sourced by c, c++, python...)
that is why you can view the machine code and it's generated opcodes while stepping through an instruction using dbx or gdb.
however, the machine code and respective assembly will be different according to which processor is used (primerilly moto 68k or intel x86)
Just one thing to add, Java and Python scripting language are not exactly compiled. That is until the parser receives the Python script or the JRE receives the byte code. Java is semi compiled and optimized for the Java interpreter, it is binary, but not the executable kind for your architecture. These wrappers (JRE and Python) compile and execute just-in-time. Assembler, C and C++ can be compiled into true executable binaries.
Also, hex is just a way of READing or interpreting the bits, it is still binary. Just thought I would mention, what I think you probably already know (just in case).
Anyhow, you could also use a ASM wrapper in your C/C++ IDE. I would do these when writting 68K ASM for palm pilots in codewarrior. It was a more elegant solution than having both the ASM and C code separate.
How to convert assembly to executable in c programming..
And also tell me how to view the c program opcode............
There are two connections between C and assembler:
1.) use C code with embedded assembler source (consult your C compiler docs for details)
2.) write an assembler in C, and run it against your assembler source code.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.