示例#1
0
        public static MacroInstruction GetInstruction(MacroType type, byte opcode)
        {
            MacroInstruction inst = Invalid;

            switch (type)
            {
            case MacroType.Mesa:
                inst = _mesaInstructionTable[opcode];
                break;

            case MacroType.Lisp:
                inst = _lispInstructionTable[opcode];
                break;
            }

            return(inst);
        }
示例#2
0
        private void PrintMesaStatus()
        {
            int pc = ((((_system.CP.RH[5] & 0xf) << 16) | _system.CP.ALU.R[5]) << 1) | (_system.CP.PC16 ? 1 : 0);

            WriteLine(String.Format("Mesa PC=0x{0:x5} (physical address 0x{1:x5})",
                                    pc,
                                    pc >> 1));

            StringBuilder stackString = new StringBuilder();

            // By convention, R0 is TOS in Mesa.
            stackString.AppendFormat("0x{0:x4} ", _system.CP.ALU.R[0]);
            for (int i = _system.CP.StackP; i > 0; i--)
            {
                stackString.AppendFormat("0x{0:x4} ", _system.CP.U[i]);
            }

            WriteLine(String.Format(" stackP=0x{0:x1} stack: {1}", _system.CP.StackP, stackString));

            WriteLine(String.Format(
                          " ibPtr={0} ibFront=0x{1:x2} ib[0]=0x{2:x2} ib[1]=0x{3:x2}",
                          _system.CP.IBPtr,
                          _system.CP.IBFront,
                          _system.CP.IB[0],
                          _system.CP.IB[1]));

            // Since this breakpoint should always happen the microinstruction after an IBDisp has taken place,
            // the TPC is always pointing to the dispatch address for the bytecode, which is not coincidentally
            // the bytecode itself.  (The value of ibFront that caused the dispatch has since been discarded, or
            // we'd use that.)
            byte             byteCode = (byte)(_system.CP.TPC[(int)TaskType.Emulator]);
            MacroInstruction mInst    = MacroInstruction.GetInstruction(MacroType.Lisp, byteCode);

            string operand = string.Empty;

            switch (mInst.Operand)
            {
            case MacroOperand.None:
                // No operands.
                break;

            case MacroOperand.Byte:
                operand = String.Format("0x{0:x2}", _system.CP.IBFront);
                break;

            case MacroOperand.SignedByte:
                operand = String.Format("{0}", (sbyte)_system.CP.IBFront);
                break;

            case MacroOperand.Pair:
                operand = String.Format("0x{0:x1},,0x{1:x1}", _system.CP.IBFront >> 4, _system.CP.IBFront & 0xf);
                break;

            case MacroOperand.TwoByte:
                operand = String.Format("0x{0:x2},,0x{1:x2}",
                                        _system.CP.IBFront,
                                        _system.CP.IBPtr == IBState.Word ? _system.CP.IB[1] : _system.CP.IB[0]);
                break;

            case MacroOperand.Word:
                operand = String.Format("0x{0:x4}",
                                        (_system.CP.IBFront << 8) | (_system.CP.IBPtr == IBState.Word ? _system.CP.IB[1] : _system.CP.IB[0]));
                break;
            }

            WriteLine(String.Format("Bytecode 0x{0:x2} - {1} {2}", byteCode, mInst.Mnemonic, operand));
        }