Exemple #1
0
        /// <summary>
        /// Reads the next instruction from memory.
        /// </summary>
        /// <returns>The disassembled instruction.</returns>
        public void ReadInstruction(ref ushort location, Z80Instruction outInstruction)
        {
            ushort offset = location;
            byte   code   = _memory.ReadByte(location++);

            var opcode = code != Z80OpCodes.ExtendedTableOpcode
                ? Z80OpCodes.SingleByteOpCodes[code]
                : Z80OpCodes.PrefixedOpCodes[_memory.ReadByte(location++)];

            var operands = _memory.ReadBytes(location, opcode.OperandLength);

            location += (ushort)operands.Length;

            outInstruction.Set(offset, opcode, operands);
        }
Exemple #2
0
        /// <summary>
        /// Reads the next instruction from memory.
        /// </summary>
        /// <returns>The disassembled instruction.</returns>
        public Z80Instruction ReadNextInstruction()
        {
            ushort offset = Position;
            byte   code   = _memory.ReadByte(Position++);

            var opcode = code != 0xCB
                ? Z80OpCodes.SingleByteOpCodes[code]
                : Z80OpCodes.PrefixedOpCodes[_memory.ReadByte(Position++)];

            byte[] operand = _memory.ReadBytes(Position, opcode.OperandLength);
            Position += (ushort)operand.Length;

            var instruction = new Z80Instruction(offset, opcode, operand);

            return(instruction);
        }