def METHOD_NAME(f, opcodes):
    sorted_opcodes = []
    for op in opcodes.values ():
        sorted_opcodes.append (op)
    sorted_opcodes.sort (key=lambda op: op.num)
    f.write ("/* File automatically generated by genmdesc.py, don't change */\n\n")
    # Write desc table
    f.write ("const MonoInstSpec mono_{0} [] = {{\n".format (symbol_name))
    f.write ("  {{")
    for i in range(MONO_INST_MAX):
        f.write ("   0")
        if i != MONO_INST_MAX - 1:
            f.write (", ")
    f.write ("}}, // null entry\n")
    idx = 1
    row = 40
    for op in sorted_opcodes:
        if not op.used:
            continue
        try:
            if row == 40:
                f.write("//  dest  src1  src2  src3   len  clob\n");
                f.write("// ----- ----- ----- ----  ----- -----\n");
                row = 0
            else:
                 row += 1
            f.write ("  {{")
            j = 0
            for c in op.spec[:MONO_INST_MAX]:
                j += 1
                if c == "":
                    f.write ("   0")
                elif c.isalnum () and ord (c) < 0x80:
                    f.write (" '%c'" % c)
                elif ord (c) >= 0 and ord (c) <= 9:
                    f.write ("   %d" % ord (c))
                else:
                    f.write ("0x%02x" % ord (c))
                if j < MONO_INST_MAX:
                    f.write (", ")
            f.write ("}}, // %s\n" % op.name)
            op.desc_idx = idx
            idx += 1
        except:
            print ("Error emitting opcode '{0}': '{1}'.".format (op.name, sys.exc_info()))
    f.write ("};\n")
    # Write index table
    f.write ("const guint16 mono_{0}_idx [] = {{\n".format (symbol_name))
    for op in sorted_opcodes:
        if not op.used:
            f.write ("  0,  // {0}\n".format (op.name))
        else:
            f.write ("  {0}, // {1}\n".format (op.desc_idx, op.name))
    f.write ("};\n\n")