Friday, November 27, 2015

Method Body Byte Stream Disassembly

Been taking a break from the Parser aspects only to parse data of a different flavor.

L_00000: /*                    No Operation (0000) */ nop
L_00001: /*                       Load Arg0 (0002) */ ldarg.0
L_00002: /*  Load Int32 Constant Short Form (001F) */ ldc.i4.s 0x14
L_00004: /*  Branch If Less Than Short Form (0032) */ blt.s L_0000A
L_00006: /*  Load Int32 Constant Short Form (001F) */ ldc.i4.s 0x14
L_00008: /* Unconditional Branch Short Form (002B) */ br.s L_0000C
L_0000A: /*  Load Int32 Constant Short Form (001F) */ ldc.i4.s 0x9
L_0000C: /*                    No Operation (0000) */ nop
L_0000D: /*                     Call Method (0028) */ call MemberReference: Name = WriteLine, Signature = void (int32), Class=TypeRef: Name = Console, Namespace = System
L_00012: /*                    No Operation (0000) */ nop
L_00013: /*                          Return (002A) */ ret
Above is the results of finalizing what I started in 2011, the parsing of the method body IL into its actual structure.  I likely won't take it further than the above, but it's still neat that it basically mirrors what you see in IlDasm and .NET Reflector in IL mode.  Notable exception to how it denotes method/member references as I didn't see the need to break it down further.

This will help me in determining whether the output of the next phase is accurate: the linker/compiler.

I have a lot to learn still, but the quickest way to learn it is to do it.