LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-01-2005, 01:49 AM   #1
ssg14j
LQ Newbie
 
Registered: Jul 2005
Posts: 12

Rep: Reputation: 0
How to convert Assembly langugae to Executable in c language


How to convert assembly to executable in c programming..

And also tell me how to view the c program opcode............
 
Old 08-01-2005, 01:59 AM   #2
tkedwards
Senior Member
 
Registered: Aug 2004
Location: Munich, Germany
Distribution: Opensuse 11.2
Posts: 1,549

Rep: Reputation: 52
Read the assembly and rewrite it in c maybe?
 
Old 08-01-2005, 12:47 PM   #3
Dave Kelly
Member
 
Registered: Aug 2004
Location: Todd Mission Texas
Distribution: Linspire
Posts: 215

Rep: Reputation: 31
Start here.

http://www.catb.org/~esr/faqs/smart-questions.html
 
Old 08-01-2005, 04:43 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
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.
 
Old 08-01-2005, 10:33 PM   #5
lowpro2k3
Member
 
Registered: Oct 2003
Location: Canada
Distribution: Slackware
Posts: 340

Rep: Reputation: 30
You can also assemble your code with the GNU as assembler, and link it with ld:

Assemble:
as -o program.o program.s

Assemble with debugging info (for gdb):
as -gstabs -o program.o program.s

Link static executable:
ld -o program program.o

Run:
./program

Last edited by lowpro2k3; 08-02-2005 at 01:18 AM.
 
Old 08-02-2005, 02:42 PM   #6
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
i agree with mara.

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)

comments?
~schneidz

Last edited by schneidz; 08-02-2005 at 02:43 PM.
 
Old 08-02-2005, 07:50 PM   #7
elyk1212
Member
 
Registered: Jan 2005
Location: Chandler, AZ USA
Distribution: Mandrake/Mandriva 10.2
Posts: 186

Rep: Reputation: 30
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.
 
Old 10-15-2008, 01:46 PM   #8
mutu26
LQ Newbie
 
Registered: Jul 2007
Posts: 3

Rep: Reputation: 0
On as regrds convert know good tool.
 
Old 10-15-2008, 01:46 PM   #9
mutu26
LQ Newbie
 
Registered: Jul 2007
Posts: 3

Rep: Reputation: 0
// Spam removed by crabboy

Last edited by crabboy; 10-15-2008 at 02:22 PM.
 
Old 10-15-2008, 01:56 PM   #10
Randux
Senior Member
 
Registered: Feb 2006
Location: Siberia
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705

Rep: Reputation: 55
Spammer reported.
 
Old 10-15-2008, 02:20 PM   #11
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
comment removed.

Last edited by ErV; 10-15-2008 at 02:21 PM. Reason: Didn't notice the date.
 
Old 10-31-2008, 06:40 AM   #12
mutu26
LQ Newbie
 
Registered: Jul 2007
Posts: 3

Rep: Reputation: 0
Why are you think that i spammer? I helped peoples,for convert my friends lately tolded me about utility- <...snip>

// spam removed

Last edited by crabboy; 11-04-2008 at 07:42 AM.
 
Old 10-31-2008, 08:09 AM   #13
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
^remind me again how outlook express email backups have to do with converting assembly language opcodes into machine language binary.

whatever your talking about has nothing to do with this thread -- reported as spam.
 
Old 10-31-2008, 08:19 AM   #14
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
Originally Posted by ssg14j View Post
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.


--- rod.

Last edited by theNbomr; 10-31-2008 at 08:21 AM.
 
Old 11-03-2008, 07:58 AM   #15
Randux
Senior Member
 
Registered: Feb 2006
Location: Siberia
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705

Rep: Reputation: 55
Mutu26 spammer reported again. Bye bye, asshole!

Last edited by Randux; 11-03-2008 at 07:59 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to do type casting in Sparc Assembly Language foxele Programming 1 10-09-2004 04:40 PM
how to convert C executable into Assembly Code indian Programming 4 10-04-2004 04:56 PM
Assembly Language on 64 Bit systems Sleevy Programming 1 09-06-2004 01:58 AM
Assembly Language, and networks grizzly Programming 5 12-11-2003 09:50 PM
SPARC assembly language jclark00001 Programming 3 02-26-2003 08:52 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration