Instruction interpretation starts here
491059
def execute_DynamicJump
      method =  get_register(@instruction.register)
      pos = Position.get(method.binary)
      log.debug "Jump to binary at: #{pos} #{method.name}:#{method.binary.class}"
      raise "Invalid position for #{method.name}" unless pos.valid?
      pos = pos + Parfait::BinaryCode.byte_offset
      set_pc( pos )
      false
    end
1065080
public void scan(byte[] instructionList, Callback callback) {

        boolean wide = false;

        for (int index = 0; index < instructionList.length;) {
            short opcode = unsignedValueOf(instructionList[index]);
            callback.handleInstruction(opcode, index);

            if (DEBUG) {
                System.out.println(index + ": " + Const.getOpcodeName(opcode));
            }

            switch (opcode) {

            // Single byte instructions.
            case Const.NOP:
            case Const.ACONST_NULL:
            case Const.ICONST_M1:
            case Const.ICONST_0:
            case Const.ICONST_1:
            case Const.ICONST_2:
            case Const.ICONST_3:
            case Const.ICONST_4:
            case Const.ICONST_5:
            case Const.LCONST_0:
            case Const.LCONST_1:
            case Const.FCONST_0:
            case Const.FCONST_1:
            case Const.FCONST_2:
            case Const.DCONST_0:
            case Const.DCONST_1:
            case Const.ILOAD_0:
            case Const.ILOAD_1:
            case Const.ILOAD_2:
            case Const.ILOAD_3:
            case Const.LLOAD_0:
            case Const.LLOAD_1:
            case Const.LLOAD_2:
            case Const.LLOAD_3:
            case Const.FLOAD_0:
            case Const.FLOAD_1:
            case Const.FLOAD_2:
            case Const.FLOAD_3:
            case Const.DLOAD_0:
            case Const.DLOAD_1:
            case Const.DLOAD_2:
            case Const.DLOAD_3:
            case Const.ALOAD_0:
            case Const.ALOAD_1:
            case Const.ALOAD_2:
            case Const.ALOAD_3:
            case Const.IALOAD:
            case Const.LALOAD:
            case Const.FALOAD:
            case Const.DALOAD:
            case Const.AALOAD:
            case Const.BALOAD:
            case Const.CALOAD:
            case Const.SALOAD:
            case Const.ISTORE_0:
            case Const.ISTORE_1:
            case Const.ISTORE_2:
            case Const.ISTORE_3:
            case Const.LSTORE_0:
            case Const.LSTORE_1:
            case Const.LSTORE_2:
            case Const.LSTORE_3:
            case Const.FSTORE_0:
            case Const.FSTORE_1:
            case Const.FSTORE_2:
            case Const.FSTORE_3:
            case Const.DSTORE_0:
            case Const.DSTORE_1:
            case Const.DSTORE_2:
            case Const.DSTORE_3:
            case Const.ASTORE_0:
            case Const.ASTORE_1:
            case Const.ASTORE_2:
            case Const.ASTORE_3:
            case Const.IASTORE:
            case Const.LASTORE:
            case Const.FASTORE:
            case Const.DASTORE:
            case Const.AASTORE:
            case Const.BASTORE:
            case Const.CASTORE:
            case Const.SASTORE:
            case Const.POP:
            case Const.POP2:
            case Const.DUP:
            case Const.DUP_X1:
            case Const.DUP_X2:
            case Const.DUP2:
            case Const.DUP2_X1:
            case Const.DUP2_X2:
            case Const.SWAP:
            case Const.IADD:
            case Const.LADD:
            case Const.FADD:
            case Const.DADD:
            case Const.ISUB:
            case Const.LSUB:
            case Const.FSUB:
            case Const.DSUB:
            case Const.IMUL:
            case Const.LMUL:
            case Const.FMUL:
            case Const.DMUL:
            case Const.IDIV:
            case Const.LDIV:
            case Const.FDIV:
            case Const.DDIV:
            case Const.IREM:
            case Const.LREM:
            case Const.FREM:
            case Const.DREM:
            case Const.INEG:
            case Const.LNEG:
            case Const.FNEG:
            case Const.DNEG:
            case Const.ISHL:
            case Const.LSHL:
            case Const.ISHR:
            case Const.LSHR:
            case Const.IUSHR:
            case Const.LUSHR:
            case Const.IAND:
            case Const.LAND:
            case Const.IOR:
            case Const.LOR:
            case Const.IXOR:
            case Const.LXOR:
            case Const.I2L:
            case Const.I2F:
            case Const.I2D:
            case Const.L2I:
            case Const.L2F:
            case Const.L2D:
            case Const.F2I:
            case Const.F2L:
            case Const.F2D:
            case Const.D2I:
            case Const.D2L:
            case Const.D2F:
            case Const.I2B:
            case Const.I2C:
            case Const.I2S:
            case Const.LCMP:
            case Const.FCMPL:
            case Const.FCMPG:
            case Const.DCMPL:
            case Const.DCMPG:
            case Const.IRETURN:
            case Const.LRETURN:
            case Const.FRETURN:
            case Const.DRETURN:
            case Const.ARETURN:
            case Const.RETURN:
            case Const.ARRAYLENGTH:
            case Const.ATHROW:
            case Const.MONITORENTER:
            case Const.MONITOREXIT:
                ++index;
                break;

                // Two byte instructions.
            case Const.BIPUSH:
            case Const.LDC:
            case Const.NEWARRAY:
                index += 2;
                break;

                // Instructions that can be used with the WIDE prefix.
            case Const.ILOAD:
            case Const.LLOAD:
            case Const.FLOAD:
            case Const.DLOAD:
            case Const.ALOAD:
            case Const.ISTORE:
            case Const.LSTORE:
            case Const.FSTORE:
            case Const.DSTORE:
            case Const.ASTORE:
            case Const.RET:
                if (wide) {
                    // Skip opcode and two immediate bytes.
                    index += 3;
                    wide = false;
                } else {
                    // Skip opcode and one immediate byte.
                    index += 2;
                }
                break;

                // IINC is a special case Const.for WIDE handling
            case Const.IINC:
                if (wide) {
                    // Skip opcode, two byte index, and two byte immediate
                    // value.
                    index += 5;
                    wide = false;
                } else {
                    // Skip opcode, one byte index, and one byte immedate value.
                    index += 3;
                }
                break;

                // Three byte instructions.
            case Const.SIPUSH:
            case Const.LDC_W:
            case Const.LDC2_W:
            case Const.IFEQ:
            case Const.IFNE:
            case Const.IFLT:
            case Const.IFGE:
            case Const.IFGT:
            case Const.IFLE:
            case Const.IF_ICMPEQ:
            case Const.IF_ICMPNE:
            case Const.IF_ICMPLT:
            case Const.IF_ICMPGE:
            case Const.IF_ICMPGT:
            case Const.IF_ICMPLE:
            case Const.IF_ACMPEQ:
            case Const.IF_ACMPNE:
            case Const.GOTO:
            case Const.JSR:
            case Const.GETSTATIC:
            case Const.PUTSTATIC:
            case Const.GETFIELD:
            case Const.PUTFIELD:
            case Const.INVOKEVIRTUAL:
            case Const.INVOKESPECIAL:
            case Const.INVOKESTATIC:
            case Const.NEW:
            case Const.ANEWARRAY:
            case Const.CHECKCAST:
            case Const.INSTANCEOF:
            case Const.IFNULL:
            case Const.IFNONNULL:
                index += 3;
                break;

                // Four byte instructions.
            case Const.MULTIANEWARRAY:
                index += 4;
                break;

                // Five byte instructions.
            case Const.INVOKEINTERFACE:
            case Const.INVOKEDYNAMIC:
            case Const.GOTO_W:
            case Const.JSR_W:
                index += 5;
                break;

                // TABLESWITCH - variable length.
            case Const.TABLESWITCH: {
                // Skip padding.
                int offset = index + 1; // skip the opcode
                offset += PAD[offset & 3];
                assert (offset & 3) == 0;

                // offset should now be posited at the default value

                // Extract min and max values.
                int low = extractInt(instructionList, offset + 4);
                int high = extractInt(instructionList, offset + 8);
                int tableSize = (high - low) + 1;
                if (DEBUG) {
                    System.out.println("tableswitch: low=" + low + ", high=" + high + ", tableSize=" + tableSize);
                }

                // Skip to next instruction.
                index = offset + 12 + (tableSize * 4);
            }
            break;

            // LOOKUPSWITCH - variable length.
            case Const.LOOKUPSWITCH: {
                // Skip padding.
                int offset = index + 1; // skip the opcode
                offset += PAD[offset & 3];
                assert (offset & 3) == 0;

                // offset should now be posited at the default value

                // Extract number of value/offset pairs.
                int numPairs = extractInt(instructionList, offset + 4);
                if (DEBUG) {
                    System.out.println("lookupswitch: numPairs=" + numPairs);
                }

                // Skip to next instruction.
                index = offset + 8 + (numPairs * 8);
            }
            break;

            // Wide prefix.
            case Const.WIDE:
                wide = true;
                ++index;
                break;

            default:
                throw new IllegalArgumentException("Bad opcode " + opcode + " at offset " + index);
            }

            if (index < 0) {
                throw new IllegalStateException("index=" + index + ", opcode=" + opcode);
            }

        }
    }
1023170
def p_fn(self, p):
        

        fn = getattr(self, 'fn_{0}'.format(p[1]))
        p[0] = Instruction('fn(*[x.execute() if isinstance(x, Instruction) else x for x in args])', context={
            'fn': fn,
            'args': p[3],
            'Instruction': Instruction
        })
423986
def assemble(io)
      rn , operand , right , immediate = @rn ,  @operand ,  @from , 1

      case right
      when Numeric
        operand = numeric_operand(right)
      when Risc::RegisterValue
        operand = reg_code(right)
        immediate = 0                # ie not immediate is register
      else
        raise "invalid operand argument #{right.class} , #{self.class}"
      end
      op =  shift_handling
      val = shift(operand , 0)
      val |= shift(op , 0) # any barrel action, is already shifted
      val |= shift(reg_code(@to) ,            12)
      val |= shift(reg_code(rn) ,            12 + 4)
      val |= shift(@attributes[:update_status] , 12 + 4 + 4)#20
      val |= shift(op_bit_code ,        12 + 4 + 4  + 1)
      val |= shift(immediate ,          12 + 4 + 4  + 1 + 4)
      val |= instruction_code
      val |= condition_code
      io.write_unsigned_int_32 val
    end
1206034
def _instruction_getter(self, name, env_replace):
        
        if name != 'LABEL' and name != 'ENV':
            raise ValueError("Unsupported instruction '%s'", name)
        instructions = {}
        envs = {}

        for instruction_desc in self.structure:
            this_instruction = instruction_desc['instruction']
            if this_instruction == 'FROM':
                instructions.clear()
                envs = self.parent_env.copy()
            elif this_instruction in (name, 'ENV'):
                logger.debug("%s value: %r", name.lower(), instruction_desc['value'])
                key_val_list = extract_labels_or_envs(env_replace=env_replace,
                                                      envs=envs,
                                                      instruction_value=instruction_desc['value'])
                for key, value in key_val_list:
                    if this_instruction == name:
                        instructions[key] = value
                        logger.debug("new %s %r=%r", name.lower(), key, value)
                    if this_instruction == 'ENV':
                        envs[key] = value

        logger.debug("instructions: %r", instructions)
        return Labels(instructions, self) if name == 'LABEL' else Envs(instructions, self)
874189
private List<Instruction> reduceInstructionsInternal(final List<Instruction> instructions) {
        final List<Instruction> visitedInstructions = new LinkedList<>();
        final Set<Integer> visitedInstructionPositions = new HashSet<>();
        final Set<Integer> handledLoadIndexes = new HashSet<>();
        final Set<Integer> backtrackPositions = new LinkedHashSet<>(findSortedBacktrackPositions());

        while (!visitedInstructionPositions.containsAll(backtrackPositions)) {

            // unvisited backtrack position
            final int backtrackPosition = backtrackPositions.stream().filter(pos -> !visitedInstructionPositions.contains(pos))
                    .findFirst().orElseThrow(IllegalStateException::new);

            final List<Integer> lastVisitedPositions = stackSizeSimulator.simulateStatementBackwards(backtrackPosition);
            final List<Instruction> lastVisitedInstructions = lastVisitedPositions.stream().map(instructions::get).collect(Collectors.toList());

            visitedInstructionPositions.addAll(lastVisitedPositions);
            visitedInstructions.addAll(lastVisitedInstructions);

            // unhandled load indexes
            final Set<Integer> unhandledLoadIndexes = findUnhandledLoadIndexes(handledLoadIndexes, lastVisitedInstructions);

            // for each load occurrence index -> find load/store backtrack positions (reverse order matters here)
            final SortedSet<Integer> loadStoreBacktrackPositions = findLoadStoreBacktrackPositions(unhandledLoadIndexes);

            handledLoadIndexes.addAll(unhandledLoadIndexes);

            loadStoreBacktrackPositions.stream().forEach(backtrackPositions::add);
        }

        // sort in method natural order
        Collections.reverse(visitedInstructions);

        return visitedInstructions;
    }
516431
def instruction_list_to_easm(instruction_list: list) -> str:
    
    result = ""

    for instruction in instruction_list:
        result += "{} {}".format(instruction["address"], instruction["opcode"])
        if "argument" in instruction:
            result += " " + instruction["argument"]
        result += "\n"

    return result
1230223
private void layout(Output dest) {
        Instruction instr;
        int instrSize, varSize;
        IntArrayList vars;  // indexes of instructions with variable length
        IntArrayList lens;  // lengths of var-len instructions
        int i, j, k, ofs;
        int shrink, len;
        boolean changes;

        instrSize = instructions.size();
        vars = new IntArrayList();
        lens = new IntArrayList();
        ofs = 0;
        for (i = 0; i < instrSize; i++) {
            instr = instructions.get(i);
            instr.ofs = ofs;
            len = instr.getMaxLength(dest);
            ofs += len;
            if (instr.type.isVariable()) {
                vars.add(i);
                lens.add(len);
            }
        }
        codeSize = ofs;
        varSize = vars.size();
        do {
            changes = false;
            shrink = 0;
            for (i = 0; i < varSize; i++) {
                j = vars.get(i);
                instr = instructions.get(j);
                len = instr.getVariableLength(this);
                if (len < lens.get(i)) {
                    changes = true;
                    shrink += (lens.get(i) - len);
                    lens.set(i, len);
                }
                if (shrink > 0) {
                    // relocate up to end or next var-instr
                    for (k = (i + 1 == varSize)? instrSize - 1 : vars.get(i + 1);  k > j; k--) {
                        instructions.get(k).ofs -= shrink;
                    }
                }
            }
            codeSize -= shrink;
        } while (changes);
    }
212966
def build_instructions(self, co):
        
        # FIXME: remove this when all subsidiary functions have been removed.
        # We should be able to get everything from the self.insts list.
        self.code = array('B', co.co_code)

        bytecode = Bytecode(co, self.opc)
        self.build_prev_op()
        self.insts = self.remove_extended_args(list(bytecode))
        self.lines = self.build_lines_data(co)
        self.offset2inst_index = {}
        for i, inst in enumerate(self.insts):
            self.offset2inst_index[inst.offset] = i

        return bytecode
1275729
private static InstructionHandle getDeepFirstInstruction(CFG cfg, BasicBlock bb) {
        InstructionHandle ih = bb.getFirstInstruction();
        if (ih != null) {
            return ih;
        }
        Iterator<Edge> iei = cfg.outgoingEdgeIterator(bb);
        while (iei.hasNext()) {
            Edge e = iei.next();
            if (EdgeTypes.FALL_THROUGH_EDGE == e.getType()) {
                return getDeepFirstInstruction(cfg, e.getTarget());
            }
        }
        return null;
    }
506151
private void extractInstructions(InstructionGroup group) {
        for (InstructionGraphNode node : group.getNodes()) {
            if (node != group.getRoot()) {
                AbstractInsnNode insn = node.getInstruction();
                method.instructions.remove(insn);
                group.getInstructions().add(insn);
            }
        }
    }
618342
def execute_lite(self, instructions, context=None):
        
        if context:
            self.__cpu.registers = dict(context)

        for instr in instructions:
            self.__execute_one(instr)

        return dict(self.__cpu.registers), self.__mem
71006
def instruction_ANDCC(self, opcode, m, register):
        
        assert register == self.cc_register

        old_cc = self.get_cc_value()
        new_cc = old_cc & m
        self.set_cc(new_cc)
170080
def instruction_PAGE(self, opcode):
        
        op_address, opcode2 = self.read_pc_byte()
        paged_opcode = opcode * 256 + opcode2
#        log.debug("$%x *** call paged opcode $%x" % (
#            self.program_counter, paged_opcode
#        ))
        self.call_instruction_func(op_address - 1, paged_opcode)
1167830
def cpu_init_init
      init = assemblers.find {|asm| asm.callable.name == :__init__}
      risc_init = Branch.new( "__initial_branch__" , init.callable.binary )
      @platform.translator.translate(risc_init)
    end
501348
public void insertBetween(Instruction _prev, Instruction _next, Instruction _newOne) {
      _newOne.setNextExpr(null);
      _newOne.setPrevExpr(null);
      if (_prev == null) {
         // this is the new head
         if (_next == null) {
            head = tail = _newOne;
         } else {
            _newOne.setNextExpr(head);
            head.setPrevExpr(_newOne);
            head = _newOne;
         }
      } else if (_next == null) {
         _newOne.setPrevExpr(tail);
         tail.setNextExpr(_newOne);
         tail = _newOne;
      } else {
         _newOne.setNextExpr(_prev.getNextExpr());
         _newOne.setPrevExpr(_next.getPrevExpr());
         _prev.setNextExpr(_newOne);
         _next.setPrevExpr(_newOne);
      }

   }
327114
def p_simple_instruction(p):
    
    p[0] = make_sentence(p[1], make_typecast(TYPE.ubyte, p[2], p.lineno(1)))