lojix/wam_prolog/src/main/com/thesett/aima/logic/fol/wam/compiler/WAMInstruction.java
public static SizeableList<WAMInstruction> disassemble(int start, int length, ByteBuffer codeBuf,
        VariableAndFunctorInterner interner, WAMCodeView codeView)
    {
        SizeableList<WAMInstruction> result = new SizeableLinkedList<WAMInstruction>();
        int ip = start;

        while (ip < (start + length))
        {
            // Decode the instruction and its arguments.
            byte iCode = codeBuf.get(ip);

            WAMInstruction instruction = new WAMInstruction(iCode);
            instruction.mnemonic.disassembleArguments(instruction, ip, codeBuf, interner);

            // Restore any label on the instruction.
            Integer label = codeView.getNameForAddress(ip);

            if (label != null)
            {
                FunctorName name = interner.getDeinternedFunctorName(label);

                if (name instanceof WAMLabel)
                {
                    instruction.label = (WAMLabel) name;
                }
            }

            result.add(instruction);

            ip += instruction.mnemonic.length();
        }

        return result;
    }
public static SizeableList<WAMInstruction> disassemble(int start, int length, ByteBuffer codeBuf,
        VariableAndFunctorInterner interner, WAMCodeView codeView)
    {
        SizeableList<WAMInstruction> result = new SizeableLinkedList<WAMInstruction>();
        int ip = start;

        while (ip < (start + length))
        {
            // Decode the instruction and its arguments.
            byte iCode = codeBuf.get(ip);

            WAMInstruction instruction = new WAMInstruction(iCode);
            instruction.mnemonic.disassembleArguments(instruction, ip, codeBuf, interner);

            // Restore any label on the instruction.
            Integer label = codeView.getNameForAddress(ip);

            if (label != null)
            {
                FunctorName name = interner.getDeinternedFunctorName(label);

                if (name instanceof WAMLabel)
                {
                    instruction.label = (WAMLabel) name;
                }
            }

            result.add(instruction);

            ip += instruction.mnemonic.length();
        }

        return result;
    }
Disassembles the instructions from the specified byte buffer, starting at a given location (ip). An interner for
the functor names encountered in the instruction buffer must also be supplied, in order to look up the functor
names by encoded value.

@param  start    The start offset into the buffer to disassemble.
@param  length   The length of data in the buffer to disassemble.
@param  codeBuf  The code buffer.
@param  interner The interner to look up interned names with.
@param  codeView A view onto the machines code buffer.

@return A list of instructions disassembles from the code buffer.