This is the first more or less reliable .IF block parser. It currently does 2 optimisations, it does not write an exit jump directly after an unconditional branch and where it can determine a .IF/.ELSEIF REG ==/!= 0 it will replace it with TEST REG, REG. It is currently only suitable for a closed test piece such as the supplied example and it has no error checking for invalid .IF block problems, else placement, closing endif etc ...
The next 2 tasks is exit jump short circuiting to prevent exit jump chains and then unused label removal. I still have to test the idea properly but I think the exit jump short circuiting can be done directly to the final jump in the IF block as long as it is not followed by a normal instruction and this involves a one instruction look ahead.
[attachment deleted by admin]
mutter,
I have already found one problem with it, if there is no .ELSEIF, the labels go out od synch.