1. How Relogix™ works

In order to convert assembler to C, Relogix carries out a comprehensive analysis of the original assembler source program. After expanding macros and tokenizing the source file, it separates the semantic meaning of the assembler instructions or sequences of instructions from irrelevant side effects such as condition code updates which are not needed. It then:

  • Divides the original assembler source into blocks of code (usually but not always corresponding to assembler subroutines), which will become C functions. Where necessary, it first re-arranges the program to ensure that problematic assembler techniques such as conditional branches to external labels, or routines which change their return address, can be cleanly handled.
  • Reorganizes the program flow to use natural C constructs such as if, for and case statements, usually without recourse to goto. Even 'spaghetti' code comes out as well-structured C source!
  • Analyzes the use of register- and memory-based data to select valid C data types for local and global variables, including automatic detection of structures and unions. (You can also optionally provide it with this information).
  • Automatically deduces function prototypes in a natural C style. Parameters originally passed to assembler subroutines either in registers or on the stack become parameters to the corresponding C function, rather than being left as global variables. Again you can optionally specify your own prototype information.
  • Internally represents the assembler statements in C-like form, and then reduces these to eliminate unused variables and combine multiple assembler statements into one, readable C line.
  • Selects sensible names for variables which were originally represented in registers or on the stack. It does this by a unique algorithm which chooses names not only by analyzing the usage, type and origin of data, but also by intelligent interpretation of comments in the original source file.
  • Outputs the translated C source, intelligently carrying over comments from the assembler source, even where the code flow has been substantially changed during the translation.