[Mono-list] ilasm/runtime question

Sandy Dunlop sandy.dunlop at gmail.com
Thu Mar 1 16:18:26 EST 2007


Hi,

I have the following IL file, and when compiler by either Microsoft's
or Mono's ILAsm, it fails to run on my G4 iBook under any version of
Mono with this exception:

marvin-2:~/cobol/src sandyd$ mono test.exe

Unhandled Exception: System.InvalidProgramException: Invalid IL code
in __CobolProgram:MAIN_PARAGRAPH (): IL_0061: stloc.0


  at <0x00000> <unknown method>
  at <Module>.main () [0x00000]
  at <Module>.main () [0x00000]


On my Macmini, it works fine. Re-installing Mono makes no difference.
I was wondering if anyone's come across anything like this before?

The code is like this:

.assembly extern mscorlib
{
  .ver 2:0:0:0
  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
}
.assembly extern System
{
  .ver 2:0:0:0
  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
}
.assembly 'test'
{
  .custom instance void class
[mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor()
=  (
		01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78   // ....T..WrapNonEx
		63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01       ) // ceptionThrows.

  .hash algorithm 0x00008004
  .ver  0:0:0:0
}

.class private auto ansi beforefieldinit __CobolProgram
       extends [mscorlib]System.Object
{
    .field public string TEXT_OUT
    .field public string TEXT_IN
    .field public int32 NUMBER_A

    .method public hidebysig specialname rtspecialname
    instance void .ctor() cil managed
    {
        .maxstack 6
        ldarg.0
        ldstr "Hello "
        stfld string __CobolProgram::TEXT_OUT
        ldarg.0
        ldstr ""
        stfld string __CobolProgram::TEXT_IN
        ldarg.0
        ldc.i4.s 0x00000000
        stfld int32 __CobolProgram::NUMBER_A
        ret
    }
    .method public void MAIN_PARAGRAPH() cil managed
    {
        .maxstack 8
        .locals init (
                string __cobolInputTemp)
        IL_0000: ldstr "{0}"
        IL_0005: ldstr "Backwards loop test:"
        IL_000a: call void class
[mscorlib]System.Console::WriteLine(string, object)
        IL_000f: ldarg.0
        IL_0010: ldc.i4.s 0x0000000a
        IL_0012: stfld int32 __CobolProgram::NUMBER_A
        IL_0017: ldarg.0
        IL_0018: dup
        IL_0019: ldfld int32 __CobolProgram::NUMBER_A
        IL_001e: ldc.i4.s 0xffffffff
        IL_0020: sub
        IL_0021: stfld int32 __CobolProgram::NUMBER_A
        IL_0026: br IL_0054
        IL_002b: ldarg.0
        IL_002c: dup
        IL_002d: ldfld int32 __CobolProgram::NUMBER_A
        IL_0032: ldc.i4.s 0xffffffff
        IL_0034: add
        IL_0035: stfld int32 __CobolProgram::NUMBER_A
        IL_003a: ldstr "{0}{1}"
        IL_003f: ldstr "  "
        IL_0044: ldarg.0
        IL_0045: ldfld int32 __CobolProgram::NUMBER_A
        IL_004a: box [mscorlib]System.Int32
        IL_004f: call void class
[mscorlib]System.Console::WriteLine(string, object, object)
        IL_0054: ldarg.0
        IL_0055: ldfld int32 __CobolProgram::NUMBER_A
        IL_005a: ldc.i4.s 0x00000001
        IL_005c: ceq
        IL_005e: ldc.i4.0
        IL_005f: ceq
        IL_0061: stloc.0
        IL_0062: ldloc.0
        IL_0063: brtrue IL_002b
        IL_0068: ldstr "{0}"
        IL_006d: ldstr "Input test:"
        IL_0072: call void class
[mscorlib]System.Console::WriteLine(string, object)
        IL_0077: ldarg.0
        IL_0078: call instance void class __CobolProgram::PARA2()

        IL_007d: ret
    }

    .method public void PARA2() cil managed
    {
        .maxstack 8
        .locals init (
                string __cobolInputTemp)
        IL_0000: ldarg.0
        IL_0001: call string class [mscorlib]System.Console::ReadLine()
        IL_0006: stfld string __CobolProgram::TEXT_IN
        IL_000b: ldstr "{0}{1}"
        IL_0010: ldarg.0
        IL_0011: ldfld string __CobolProgram::TEXT_OUT
        IL_0016: ldarg.0
        IL_0017: ldfld string __CobolProgram::TEXT_IN
        IL_001c: call void class
[mscorlib]System.Console::WriteLine(string, object, object)
        IL_0021: ldarg.0
        IL_0022: ldarg.0
        IL_0023: ldfld string __CobolProgram::TEXT_OUT
        IL_0028: ldstr " "
        IL_002d: ldarg.0
        IL_002e: ldflda string __CobolProgram::TEXT_IN
        IL_0033: ldc.i4.s 0xFFFFFFFF
        IL_0035: call instance void class
__CobolProgram::__CobolString(string, string, [out] string&, int32)
        IL_003b: ldstr "{0}"
        IL_0040: ldarg.0
        IL_0041: ldfld string __CobolProgram::TEXT_IN
        IL_0046: call void class
[mscorlib]System.Console::WriteLine(string, object)

        IL_004b: ret
    }

    .method private hidebysig
           instance default void __CobolString (string from, string
delimiter, string& 'to', int32 ptr)  cil managed
    {
        .maxstack 20
        .locals init (
          string	V_0,
          int32	V_1,
          string	V_2,
          string	V_3)
        IL_0000:  ldarg.1
        IL_0001:  ldarg.2
        IL_0002:  callvirt instance int32 string::IndexOf(string)
        IL_0007:  stloc.1
        IL_0008:  ldloc.1
        IL_0009:  ldc.i4.m1
        IL_000a:  bne.un IL_0016
        IL_000f:  ldarg.1
        IL_0010:  stloc.0
        IL_0011:  br IL_001f
        IL_0016:  ldarg.1
        IL_0017:  ldc.i4.0
        IL_0018:  ldloc.1
        IL_0019:  callvirt instance string string::Substring(int32, int32)
        IL_001e:  stloc.0
        IL_001f:  ldarg.s 4
        IL_0021:  ldc.i4.m1
        IL_0022:  beq IL_007d
        IL_0027:  ldarg.s 4
        IL_0029:  ldc.i4.1
        IL_002a:  sub
        IL_002b:  starg.s 4
        IL_002d:  ldnull
        IL_002e:  stloc.2
        IL_002f:  ldarg.3
        IL_0030:  ldind.ref
        IL_0031:  ldc.i4.0
        IL_0032:  ldarg.s 4
        IL_0034:  callvirt instance string string::Substring(int32, int32)
        IL_0039:  stloc.3
        IL_003a:  ldarg.s 4
        IL_003c:  ldloc.0
        IL_003d:  callvirt instance int32 string::get_Length()
        IL_0042:  add
        IL_0043:  ldarg.3
        IL_0044:  ldind.ref
        IL_0045:  callvirt instance int32 string::get_Length()
        IL_004a:  blt IL_005d
        IL_004f:  ldarg.3
        IL_0050:  ldloc.3
        IL_0051:  ldloc.0
        IL_0052:  call string string::Concat(string, string)
        IL_0057:  stind.ref
        IL_0058:  br IL_0078
        IL_005d:  ldarg.3
        IL_005e:  ldind.ref
        IL_005f:  ldarg.s 4
        IL_0061:  ldloc.0
        IL_0062:  callvirt instance int32 string::get_Length()
        IL_0067:  add
        IL_0068:  callvirt instance string string::Substring(int32)
        IL_006d:  stloc.2
        IL_006e:  ldarg.3
        IL_006f:  ldloc.3
        IL_0070:  ldloc.0
        IL_0071:  ldloc.2
        IL_0072:  call string string::Concat(string, string, string)
        IL_0077:  stind.ref
        IL_0078:  br IL_0080
        IL_007d:  ldarg.3
        IL_007e:  ldloc.0
        IL_007f:  stind.ref
        IL_0080:  ret
    }

}

.method static public void main() il managed
{
    .entrypoint
    .maxstack 8
    newobj instance void __CobolProgram::.ctor()
    call instance void __CobolProgram::MAIN_PARAGRAPH()
    ret
}


More information about the Mono-list mailing list