.....
.....
.....
This can take a long time. Looong time, I don't know why but I'm sure you will copy the one I did - and the reason is pretty obvious anh? -
Well, we are almost done with this second step! All you need to do now is to serialize this table in a way that can be loaded by your code-length-disassembler algorithm. I decided to take the result array and build a .h file containing the code to load the table in memory all automatic, so we can make the call to my program in the build process, before starting reading the main .cpp file.
And this will be saved in a header file that will be used by our disassembler source code in compile time. Got the idea? I made a little EXE that takes two arguments, the input and output file. The input file has all the opcode entries like I described up there. The outfile file for my program looks like this:
#IFNDEF TableContent_H
#DEFINE TableContent_H
char TableContent[] = {
0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x01, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x03, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x03, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
0x01, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
0x01, 0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00,
0x01, 0x01, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00,
0x01, 0x01, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x52, 0x00,
...
...
...
...
0x01, 0x01, 0x00, 0x01, 0x04, 0xFF, 0x00, 0x00, 0x90, 0xF9,
0x01, 0x01, 0x00, 0x01, 0x05, 0xFF, 0x00, 0x00, 0x20, 0xFA,
};
#ENDIF
Woff.. after a long trip of writing the table compiler (btw, what's woff? o.O) it's time to take this table and use to find a given code-length.