protected void decode_first_half() { int opcode; int optype, optypes; int optypes2 = 0; /* It takes a kludge to handle a kludge */ int optypebytes; int isextended = 0; opcode = zm.get_code_byte() & 0xFF; if (opcode == OP_EXTENDED) { isextended = 0xC0; } switch (isextended | opcode & 0xC0) { case 0xC0: /* variable form */ if (isextended != 0xC0) { opnum = opcode; } else { opnum = (0x100 | (zm.get_code_byte() & 0xFF)); } if ((opcode & 0x20) == 0) { /* 2OP */ /* * note that variable-form je can have more than two arguments, though * it is a 2OP */ opnum = opcode & 0x1F; } count = 0; optypes = zm.get_code_byte(); if ((opnum == OP_CALL_VS2) || (opnum == OP_CALL_VN2)) { optypebytes = 2; optypes2 = zm.get_code_byte(); } else optypebytes = 1; while (optypebytes-- != 0) { optype = (optypes & 0xC0) >> 6; if (optype == zm.OP_OMITTED) break; operands[count++] = zm.get_operand(optype); optype = (optypes & 0x30) >> 4; if (optype == zm.OP_OMITTED) break; operands[count++] = zm.get_operand(optype); optype = (optypes & 0x0C) >> 2; if (optype == zm.OP_OMITTED) break; operands[count++] = zm.get_operand(optype); optype = (optypes & 0x03); if (optype == zm.OP_OMITTED) break; operands[count++] = zm.get_operand(optype); optypes = optypes2; } break; case 0x80: /* short form */ optype = (opcode & 0x30) >> 4; if (optype == zm.OP_OMITTED) { /* 0OP */ opnum = opcode; count = 0; } else { /* 1OP */ opnum = opcode & 0x8F; count = 1; operands[0] = zm.get_operand(optype); } break; default: /* long form */ /* always 2OP */ opnum = opcode & 0x1F; count = 2; optype = ((opcode & 0x40) >> 6) + 1; operands[0] = zm.get_operand(optype); optype = ((opcode & 0x20) >> 5) + 1; operands[1] = zm.get_operand(optype); } }