9. Code flow transformation


As part of the translation process, Relogix seeks to convert assembler-style code flow (using conditional and unconditional branches), into a structured-control layout appropriate to C. This means that translated code will use if..else, switch, for, do and while wherever possible. In most cases, it will achieve this without having to fall back on goto.

As part of the code-flow transformation, Relogix may move code around or change the sense of comparison operations. Sometimes, in order to untangle complex 'spaghetti' code, it will use Boolean local variables to control the code flow, or duplicate short sections of code.

In our example subroutine, the code flow is fairly simple, and Relogix has been able to present the flow in a single do.. while loop and two if statements.

It is interesting to note that Relogix has not transformed the loop in our example into a for loop. The reason for this is that the loop counter D0 (ECX in the x86 version) may not contain a positive integer at the start of the loop. In cases where the loop bounds are clear, Relogix would use a for loop for an example like this.