Is there any tool to convert ASM to C for PIC 16F877A

I want to convert an ASM file to a C program. Are there any tools for this. My intention is to convert the build program of the PIC 16F877A program to the C ...

+3
source share
1 answer

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:

// the_program.c
__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:

// 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;

Two ways can be distinguished from here:

  • C 16F877A, , - C for(). , , asm C, , , - C. .
  • , ".c" . C , , .
+1

Source: https://habr.com/ru/post/1746365/


All Articles