Skip to main content
GameDev.net gamedev.net
🔒 Locked

creating c from assembly

Started by etsuja Sep 13, 2006 at 1:12 PM 1 replies 800+ views
Original Post
etsuja
etsuja
I don't know assembly but would it be possible if I did know it to read assembly and create c code that functions the same and how hard would it be?
Artist 1st - Programmer 2nd(I'll get some material linked here sometime to support these claims, haha)
Nytegard
Nytegard
Honestly, it really wouldn't be that hard (outside of special things such as interrupts). Many of the older legacy programming languages were really designed as a more readable and human friendly version of assembly.

That being said, moving asm into c isn't going to make your life easier. If you don't understand what the asm is doing, the c code isn't going to appear much easier to read (variables won't be descriptive, nor function names, etc). There's a reason why language translators, while they exist, aren't exactly viewed with much regard.

*Quick Edit*

And don't expect the code to be cross platform. Calling the OS in asm is pretty much going to stop that. You're going to be very dependent on specific libraries to accomplish what C cannot do (or have a lot of inline asm).
TheAdmiral
TheAdmiral
I suppose what you're looking for is a C decompiler. Ask [google]; there are many of them around, but they aren't the panacaea that many hope for.

Assembly language is often seen as difficult to understand, but this is usually because the speaker has only seen a disassembly of an existing program. Converting such a meaningless dead listing to C really won't help much. All you'll get is higher-level garbage.

Decompiled code is near useless for most purposes. If you ask any reverse engineer, they'll tell you that they work from assembly listings, because that is what a debugger will show you (live debugging tends to be much more informative) and that they won't get any headaches trying to decipher a peculiar code structure that turns out to be nothing more than an artifact of a confused decompiler.

Really, if you want to debug something from binary alone, learn assembly. It is dead straightforward if you already know C and you'll be able to speak to your debugger without the need for any translation. Moreover, there will be a wide range of reverse engineering tools at your disposal. OllyDbg and IDA together are far more powerful than the best decompiler imaginable, in my not exactly fleeting experience.

Regards
Admiral
Ring3 Circus - Diary of a programmer, journal of a hacker.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.