Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

How to convert Motorola ASM code to C code?

Status
Not open for further replies.

snsriram79

Member level 4
Joined
May 8, 2001
Messages
71
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Activity points
513
is there any application to convert motorola ASM to C.

i am having a 68hc11 assembly code written by sum1 and it is very difficult to do the reverse engineering.so i thought if there is any software for converting assembly to C

bye
 

pardal

Member level 5
Joined
Dec 29, 2001
Messages
81
Helped
4
Reputation
8
Reaction score
2
Trophy points
1,288
Activity points
587
assembler to c conversion

I read once some where an explanation on why what you are asking is totally impossible. I don't racall the arguments (something how about compiler optimizations works), only the end statement. Forget it.
 

ME

Advanced Member level 4
Joined
Mar 14, 2002
Messages
1,309
Helped
55
Reputation
112
Reaction score
40
Trophy points
1,328
Activity points
14,861
+assembly to c

I agree with pardal.
I have never heard of an application to convert from assembly to C.
To me, it sounds impossible to make such software.
Several different C statements can generate the same assembly code, so it's impossible to go back from assembly to C.
 

Hero

Full Member level 2
Joined
Mar 6, 2002
Messages
145
Helped
4
Reputation
8
Reaction score
2
Trophy points
1,298
Activity points
1,608
asm to c translator

Hi,

I think that this is very interesting topic for discussion.

There is no need to convert any assembly routine to any HLL (high level language).

When you write and compile some HLL routine you get object code. With linker you link all object files to binary executable. Linker use only object files not HLL routine or assembly source.

You can interface any HLL program with assembly routine using compiled assembly source and function/procedure declaration in HLL program.

In C you can interface assembly routine without passing arguments and return value ussing declaration.

extern void assembly_routine_name()

If you want to convert whole assembly program to C I suggest this code

extern void assembly_start_label();

void main()
{
assembly_start_label();
}

In your assembly source declare program origin assembly_start_label as public to other modules.

assembly_start_label:
.
.
.
end

You need to compile c source and asm source and link object files. So this is whole conversion.

Instead C or Assembly it is better to think about functions and routines.
When you use functions from standard C libraries you don't use sources only function prototypes.

For example you don't know how is char *strcpy(char *s1, char *s2) implemented? Is it C or assembly?It is standard C string function and it's implementation varies from platform to platform.

From programmers point of view it is always same strcpy function.

If you want to convert your assembly program to C to make it portable it is not simple task. If you don't need portability there is no need for any conversion.

Regards
 

Hero

Full Member level 2
Joined
Mar 6, 2002
Messages
145
Helped
4
Reputation
8
Reaction score
2
Trophy points
1,298
Activity points
1,608
asm68c

Hi,

I think that this is very interesting topic for discussion.

There is no need to convert any assembly routine to any HLL (high level language).

When you write and compile some HLL routine you get object code. With linker you link all object files to binary executable. Linker use only object files not HLL routine or assembly source.

You can interface any HLL program with assembly routine using compiled assembly source and function/procedure declaration in HLL program.

In C you can interface assembly routine without passing arguments and return value ussing declaration.

extern void assembly_routine_name()

If you want to convert whole assembly program to C I suggest this code

extern void assembly_start_label();

void main()
{
assembly_start_label();
}

In your assembly source declare program origin assembly_start_label as public to other modules.

assembly_start_label:
.
.
.
end

You need to compile c source and asm source and link object files. So this is whole conversion.

Instead C or Assembly it is better to think about functions and routines.
When you use functions from standard C libraries you don't use sources only function prototypes.

For example you don't know how is char *strcpy(char *s1, char *s2) implemented? Is it C or assembly?It is standard C string function and it's implementation varies from platform to platform.

From programmers point of view it is always same strcpy function.

If you want to convert your assembly program to C to make it portable it is not simple task. If you don't need portability there is no need for any conversion.

Regards
 

pardal

Member level 5
Joined
Dec 29, 2001
Messages
81
Helped
4
Reputation
8
Reaction score
2
Trophy points
1,288
Activity points
587
reverse string assembly motorola

Well, Hero
Regarding my programing capabilities you jumped a bit further than I can follow. Although i learned something.
The point is that your view of convert assembly to C is very different of what snsriram79 has asked.
He wants an imaginary tool to help him to reverse engeneering his target, but if it was that easy all existing and worthing software would have been already reversed engeneered.
Imagine the consequences of this.
 

snsriram79

Member level 4
Joined
May 8, 2001
Messages
71
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Activity points
513
convert assembly code to c

hi pardal

thanks for the reply

i asked this doubt after going thru this site

http://www.mpsinc.com/index2.html

kindly go thru this site and tell me ur comments

i think i remeber seeing a translator for asm to C

if this is not that means then forgive me. i just wanted to know if this is a possibility and if possible would like to hav the tool

bye
 

pardal

Member level 5
Joined
Dec 29, 2001
Messages
81
Helped
4
Reputation
8
Reaction score
2
Trophy points
1,288
Activity points
587
assembler to c conversion procedure

snsriram79 thanks for your confidence but I'm afraid I have to disapoint you.
I don't have enough knowledge to help you on this. I read their description and in fact they claim that the assembler to C conversion is possible with their products, but there is no way to test it (exept asking them to do it).
Other, more pro, incoms on this subject are wellcome. I got curious.
 

eltonjohn

Advanced Member level 4
Joined
Feb 22, 2002
Messages
1,435
Helped
64
Reputation
126
Reaction score
28
Trophy points
1,328
Activity points
16,328
interface asm and c

It is allways possible to convert assambler to c .. is a matter of graphs

the questions is wiil the code look like the original code ...

the algorithm that produced the assamblee code is still there ..in the equivalent form ..but is machine dependant .. it was reduced to fit
the machine where it runs ..so there is a lot of junk with it, and also
a lot now missing .Because probably the machine instructions set implements some instructions very powerfully .But still is always possible
to produce the a program that will reverse engineer the code. but once again this program will be machine dependant ..
In other words a decompiler for SPARC will look very diffrent from a
decompiler for a X86 .. and probably nobody will be interested in producing
one for the motorola microntroller .
There is a program called dcc a doctorate thesis that explains it all
i have played a lot with this and i see a lot of opportunities here for crime
see dcc seminal paper
at
http://www.itee.uq.edu.au/~csmweb/dcc.html
 

ME

Advanced Member level 4
Joined
Mar 14, 2002
Messages
1,309
Helped
55
Reputation
112
Reaction score
40
Trophy points
1,328
Activity points
14,861

stephenl

Newbie level 6
Joined
Mar 28, 2002
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Cambridge, UK
Activity points
28
strcpy in asm

Possibly not useful, but...

back in 1996 I wrote a disassembler for 68hc11.

May be of use. Let me know if it is, and I'll upload the source.
 

ME

Advanced Member level 4
Joined
Mar 14, 2002
Messages
1,309
Helped
55
Reputation
112
Reaction score
40
Trophy points
1,328
Activity points
14,861
convert assembler and c

snsriram79 was asking for a decompiler and not a disassembler, since he already have the assembly code and need to convert this to C.
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top