Reverse Engineering the IDF Compiler

So as mentioned in previous posts, the IDF Compiler is a 16 bit application, and consequently does not run on 64bit windows operating systems. Therefore, we must write a new IDF Compiler for 64bit windows!

I originally started out analysing the decompiled assembly, but as those of you who have written application in the old segmented architecture will know, it doesn't make for pleasant reading. I did however work out the basic structure of the compiler, and there wasn't anything in there that looked too difficult. So to write a new compiler, instead of doing in depth analysis of the assembly it will be faster so simply learn by observation. An IDF Calc is made up of one statement in infix notation. The compiler then converts this to reverse polish notation (RPN), and presents it in a text form, where the operators and functions are mapped to opcodes. Thus the code:

a = b + c

is converted to RPN

a b c + =

which is then mapped into a custom representation

0, "b"
0, "c"
2, "0"
1, "a"

Note that the order of the RPN tokens and the custom representation is the same, except that the assignment operator is treated slightly differently.

Therefore, all we need is the map of all the function codes to op codes (this can be generated by observation of the 16 bit compiler), and we are set!

| May 11th, 2013 | Posted in Foxboro, SCADA |

Leave a Reply