Hi,
I want to convert ASM file to C program. is there any tools available for this. My intention is to convert assembly program of PIC 16F877A program to C program...
Hi,
I want to convert ASM file to C program. is there any tools available for this. My intention is to convert assembly program of PIC 16F877A program to C program...
A tool that automatically converts assembly to C is a kind of decompiler. There are several decompilers for x86 assembly language. While I haven't used it, I hear that IDA, the Interactive Disassembler, has a decompile-to-C option, and supports Microchip PIC assembly language.
People who know PIC assembly can do a pretty good job manually porting code from PIC assembly to C. The first step is copying the contents of the ".asm" file to a ".c" file and wrapping it with the "asm" keyword. With SDCC syntax, the resulting file looks something like:
// the_program.c
__asm
; some assembler code
goto $0056
__endasm;
You should be able to compile that ".c" file and use "diff" to confirm that it compiles to an identical executable. A person can sometimes translate pieces of assembler into C functions that compile to identical executable (using "diff" to compare). The next step often looks something like
// the_program.c
__asm
; some assembler code
__endasm;
int main(void){
for(;;){ // forever
__asm
; more assembler code
__endasm;
};
}
__asm
; yet more assembler code
goto $0056
__endasm;
From here, there are two paths you can take: