I think there are two main types of instruction:
All other types of instructions aren't very important right now. And to make it even simple I expect that the proc contains only of not call assignment instructions. Now I would like to make a general form if these instructions having a Source and a Target. For example mov eax, ecx, has a target eax and as source ecx. But we also must support xor eax, ecx, which has a target eax, and as source ecx xor eax. So how do make the Source and Target. I think about one basic Source class with descendent for the following types:
With these sources I think we covered the most important thing. Because I already have the source for a disassembler, It wasn't hard to write some code that converted a instruction into a AssignInstruction, but because I'm lazy I did write just a very small part which can easily be extended. I only also need something to make identify a Ret instruction. Now that we can convert an procedure to an row of assign instructions. I would like to be able to append some of these instructions as explained with the following example:
Assembler | Assign instructions | Append assign instructions |
---|---|---|
mov eax, [eax] |
eax := PDWord(eax)^ eax := PDWord(eax)^ |
eax := PDWord(PDWord(eax)^)^ |
So what exactly do I want:
I want to replace two successive assign instructions with one instruction in
which is the same as the last instruction only with the the Target of the first
replaced with the Source of the first instruction.
I came with the following requirements for appending two successive instructions:
Having all this, it is just a matter of implementing it.