A tool that automatically converts an assembly to C is a kind of decompiler. There are several decompilers for x86 assembler. Although I did not use it, I heard that the IDA, an interactive disassembler, has a decompilation option in C and supports the Microchip PIC assembly language.
People who know the PIC assembly can do a pretty good job of manually moving the code from the PIC assembly to C. The first step is to copy the contents of the .asm file to the ".c" file and complete it using the "asm" keyword. With the SDCC syntax, the resulting file looks something like this:
__asm
; some assembler code
goto $0056
__endasm;
You must compile this “.c” file and use “diff” to confirm that it compiles into an identical executable. Sometimes a person can translate assembler pieces into C functions that are compiled into an identical executable (using "diff" for comparison). The next step often looks something like this:
__asm
; some assembler code
__endasm;
int main(void){
for(;;){
__asm
; more assembler code
__endasm;
};
}
__asm
; yet more assembler code
goto $0056
__endasm;
Two ways can be distinguished from here:
- C 16F877A, , - C for(). , , asm C, , , - C. .
- , ".c" . C , , .