Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

convert to high level language

Status
Not open for further replies.
Yes, but the code they generate takes a skilled hand to make human readable. It's almost easier to learn the lower language than interpret C code created from assembly. Exactly from what language to what language are you trying to convert?
 
Like already stated, yes its possible doing manual rewrite. I am sure you know this so I believe your question is "Is there a utility software that takes ASM input and spits out C // C++ output?"

I myself do not know. Since conversion from .hex to .asm already exist it just a matter of how much a company wants to charge you to go that extra step from .asm to .c or .asm to (.cpp, .h, .dll, .res, etc.....)
 
C++ is an object oriented extension to C and not appliciable to micro controller programing, it's too resource intensive to be used on a micro controller. As I said though, the conversion from ASM to valid C code is not human readable. It would be eaiser to learn the ASM language in question.
 
Essentially what you're wanting to do is the same as recreating the egg by starting with an omelette - with the added problem that you don't even know what an egg is supposed to look like!.
 
The OP wants to convert a program written in Assembler, or thats what he states. That should be easy.

Mike.
 
I doubt there is a program to convert it from ASM to C either. Like mentioned before, it would probably be easier to learn assembler, since the program is already done.

How large is the program?
 
Nigel Goodwin said:
Essentially what you're wanting to do is the same as recreating the egg by starting with an omelette - with the added problem that you don't even know what an egg is supposed to look like!.

This is absolutely right :D
but anyway that was just a thought and i'm convinced now to read it carefullly with ASM to know what it looks like.

thanks
 
4electros said:
This is absolutely right :D
but anyway that was just a thought and i'm convinced now to read it carefullly with ASM to know what it looks like.

Unfortunately, if the program was compiled from a high level language (particularly from C), it produces very hard to read assembler!. So it's usually pretty obvious if it was actually written in assembler originally or not.
 
Nigel Goodwin said:
Unfortunately, if the program was compiled from a high level language (particularly from C), it produces very hard to read assembler!. So it's usually pretty obvious if it was actually written in assembler originally or not.

PIC C assemblers that I've used also tend to have alot of unnecessary steps which could probably be optimized if you just wrote them out. Instead of using a counting loop for waiting, I've seen the compiled ASM just have oodles of NOP's.
 
Does the program have labels that make since? Readable?

If so it is probably assembler. Can you post a small section of code?
 
It isn't all that hard to just write C code. I mean if the ASM is readable enough that you can see what it's doing, you could probably get close to writing your own.

If you have an ASM program, why do you need to convert it? Perhaps to alter it or make it work on a different part. To do that you need readable code and a fair understanding of what it does. If you understand what it does then write new code. Or the ASM is more readable anyway if you needed to tinker with it and make it run on a part with fewer pins or whatever.
 
mramos1 said:
Does the program have labels that make since? Readable?

If so it is probably assembler. Can you post a small section of code?

BoostC compiler uses these weird labels that aren't as readable because they have random numbers (like...label2103948 or something). If they used letters like a, b, etc, that'd be better.
 
You are looking for a decompiler. They are processor dependant so you have to get one for the right processor. They do not exist for all processors. You did not say which you were using.

Chances are that you will not find the decompiler you need.

You could use a disassembler that works on machine/hex code to produce assembly code. Good disassemblers let you input/choose your own labels which results in more readable code.

Failing that you could try using a text editor to replace the machine generated labels with meaningful ones as you discover them.
 
A quick look on the web did not turn one up.

I should have mentioned this earlier but there is a good chance the generated C code would be about as ugly as the assembler.

I suggest you study the assembler version. Not only will you figure out what it does and how but you will learn the assembler too.

3v0
 
3v0 said:
A quick look on the web did not turn one up.

Can you name any processor that has a 'de-compiler' available for it?, I've never heard of such a thing? - although it was possible on some PC compilers, with all debugging options turned ON, and all optimisation turned OFF, because it then saved enough of the source code with the EXE file to reconstruct it.
 
Nigel Goodwin said:
Can you name any processor that has a 'de-compiler' available for it?, I've never heard of such a thing? - although it was possible on some PC compilers, with all debugging options turned ON, and all optimisation turned OFF, because it then saved enough of the source code with the EXE file to reconstruct it.

It is not my intent to be a smart butt. That is not my intent and I hope this does not come off that way.

I am not sure but
In general debuggers require that you compile with "all debugging options turned ON, and all optimisation turned OFF". What you refer to on the PC sounds like a debugger. Maybe DOS debug.exe. But this is a sidetrack.

I am sure the decompilers exist.

I have not used one but understand the process. They take machine code as input and, with some degree of help from the user generate more or less readable high level code.

In regards to a specific processor. It makes sense that decompilers like compilers, assemblers, and disassemblers are often written in the general sense. Opcode information and such is added as needed to target a given processor.

Google found these. It looks like boomerang might be setup to do what the poster has asked for. I am not suggesting he do so.

Salamander: a .NET decompiler that converts executable files (.EXE or .DLL) from Intermediate Language (IL, MSIL, CIL) binary format to high-level source codes, such as C#, managed C++, Visual Basic.NET, etc. $1099 per license

Boomerang: A general, open source, retargetable decompiler of machine code programs

DJ Java Decompiler: Windows 95/98/Me/NT/2000/XP decompiler and disassembler for Java that reconstructs the original source code from the compiled binary CLASS files (for example Java applets).

3v0 :)
 
De-compilers I doubt exist. If they do I doubt they work. Disassemblers do exist, but good luck with that random junk.

Imagine:

decompile -l boostC -i a_pic_program.hex
or
decompile -l microsoftC_1997era -i windows_me_kernel.exe
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top