Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Forums > General Electronics Chat


General Electronics Chat This forum is for general chat about electronics, eg: Dont know what a part does? Dont know how to read a circuit? Want to get an opinion?

Reply
 
LinkBack Thread Tools Display Modes
Old 24th August 2008, 11:42 AM   (permalink)
Default Assembly Language to C programming language?

Is there any software or method which can convert Assembly Language to C Programming Language???
westkid85 is offline  
Old 24th August 2008, 01:18 PM   (permalink)
Default

Quote:
Originally Posted by westkid85 View Post
Is there any software or method which can convert Assembly Language to C Programming Language???
This is like recreating the egg from the omelette - it's not possible, the information no longer exists.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now  
Old 24th August 2008, 03:45 PM   (permalink)
Default

Of cause there is. It's called a decompiler and it probably came with your compiler and assembler.

Larry
__________________
Confucius says: "One in three is a teacher."
Larry4911 is offline  
Old 24th August 2008, 05:00 PM   (permalink)
Default

Quote:
Originally Posted by Larry4911 View Post
Of cause there is. It's called a decompiler and it probably came with your compiler and assembler.
Interesting suggestion, perhaps you could give an example? - I've never seen any such thing in all the compilers I've used over the years.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now  
Old 24th August 2008, 06:01 PM   (permalink)
Default

Quote:
Originally Posted by Nigel Goodwin View Post
Interesting suggestion, perhaps you could give an example? - I've never seen any such thing in all the compilers I've used over the years.
That would make for a hacker's wonderland wouldn't it?
Space Varmint is offline  
Old 24th August 2008, 09:03 PM   (permalink)
Default

Decompilers exist for many different architectures and languages. However, the output is likely to be worse code than the input. You'd learn more just doing the conversion the old-fashioned way: reading the asm and writing the corresponding C yourself.

Among other things, symbol names and some other information is lost. The output will be very literal and probably not particularly easy to read.

http://www.embeddedrelated.com/usene...ow/27425-1.php

http://en.wikibooks.org/wiki/Reverse_Engineering/Tools

Again, the tools are not perfect and it's usually easier just to learn to read the assembly.


Torben
__________________
Curiosity was framed. Ignorance killed the cat.
Torben is offline  
Old 24th August 2008, 10:07 PM   (permalink)
Default

Quote:
Originally Posted by Nigel Goodwin View Post
Interesting suggestion, perhaps you could give an example? - I've never seen any such thing in all the compilers I've used over the years.
It's not IN a compiler. It's a separate program that you feed the asm to and you get out a very confusing compiler version. The output generally does not use headers and includes so you get out ALL the code needed to assemble the asm.

It's most confusing and like Torben said it would be much easier to learn ASM.

Larry
__________________
Confucius says: "One in three is a teacher."
Larry4911 is offline  
Old 24th August 2008, 10:27 PM   (permalink)
Default

I've read many 'asm to C' attempts to decompile in a sensible symbolism, all of them are at best half-assed. They usually use simple proper noun replacement to try
to help native understanding of the converted code, and it's always bad.

Bob is my uncle, my uncle is 3.1415926 positive times in relation to itself and his father is 3 less than his mother is 1 more than her daughters last mood change.

If you just want to use the ASM code in a C environment use an inline ASM argument, most C copilers support this if the ASM memory/code structure is known.
__________________
"Because I be what I be. I would tell you what you want to know if I
could, mum, but I be a cat, and no cat anywhere ever gave anyone a
straight answer, har har."
Sceadwian is offline  
Old 25th August 2008, 01:55 AM   (permalink)
Default

Thats tough to do. There are so many assembly combinations out there for a set of C instructions, that it makes this very difficult. If you want it done right, you're best off doing it yourself.
__________________
www.salgat.net
Salgat is offline  
Old 25th August 2008, 12:02 PM   (permalink)
Default

Quote:
Originally Posted by Larry4911 View Post
It's not IN a compiler. It's a separate program that you feed the asm to and you get out a very confusing compiler version. The output generally does not use headers and includes so you get out ALL the code needed to assemble the asm.
I never suggested it was internal to the compiler, just included (or rather not) in the compiler package.

I'll ask again - can you give an example of any such compiler package?.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now  
Old 25th August 2008, 12:09 PM   (permalink)
Default

Just Google it. There are loads of them.


Larry
__________________
Confucius says: "One in three is a teacher."
Larry4911 is offline  
Old 25th August 2008, 01:57 PM   (permalink)
Default

Really all program languages are built from machine code which directly correlates to the assembly language mnemonics. You would have to reverse engineer it yourself. I suggest getting "WinDbg.exe".

here's a one link: http://bytes.com/forum/thread657053.html
Space Varmint is offline  
Old 25th August 2008, 03:38 PM   (permalink)
Default

Salgat is right. There is not a 1:1 mapping between source code and the asm generated from it. Things get even worse if the code is optimized.
3v0 is online now  
Old 25th August 2008, 04:41 PM   (permalink)
Default

Quote:
Originally Posted by 3v0 View Post
Salgat is right. There is not a 1:1 mapping between source code and the asm generated from it. Things get even worse if the code is optimized.

Olly Debug is pretty good
Space Varmint is offline  
Old 25th August 2008, 07:00 PM   (permalink)
Default

Quote:
Originally Posted by Larry4911 View Post
Just Google it. There are loads of them.


Larry
That's just lazy. Earlier you stated that:

Quote:
Originally Posted by Larry4911
Of cause there is. It's called a decompiler and it probably came with your compiler and assembler.

Larry
I'm with Nigel. While decompilers exist and while there are examples of compiler/decompiler packages, they are not the norm and the statement that "it probably came with your compiler and assembler" is not true.

Unless of course you feel like providing some links to back up your statement. It's not our job to defend your position. If you can't be bothered to, why should anyone else?


Torben
__________________
Curiosity was framed. Ignorance killed the cat.
Torben is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
assembly and c language baftab Electronic Projects Design/Ideas/Reviews 4 15th April 2006 02:03 AM
LCD programming and connection with assembly language microzone Micro Controllers 5 10th February 2006 04:14 PM
assembly language soohino Micro Controllers 3 31st December 2004 06:35 AM
Assembly Language??? amady Micro Controllers 58 27th October 2004 10:27 AM
Learning Assembly Programming Language Johnson777717 Micro Controllers 4 22nd March 2004 03:00 PM



All times are GMT. The time now is 05:33 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker