コード例 #1
0
ファイル: Instruction.cs プロジェクト: orf53975/quasar-sharp
        private static object ReadOperand(QuasarRam memory, ref uint address, AddressingMode am)
        {
            switch (am)
            {
            case AddressingMode.DIRECT_REGISTER:
                address++;
                return((Register)memory[address - 1]);

            case AddressingMode.CONDITION_CODE:
                address++;
                return((byte)memory[address - 1]);

            case AddressingMode.INDIRECT_REG8:
            case AddressingMode.INDIRECT_REG16:
            case AddressingMode.INDIRECT_REG32:
                Register reg   = (Register)memory[address];
                byte[]   bytes = new byte[2];
                memory.Read(address + 1, 2, 0, bytes);
                address += 3;
                return(new IndirectOffset(reg, BitConverter.ToInt16(bytes, 0)));

            case AddressingMode.IMMEDIATE_32:
                address += 4;
                return(memory.ReadInt32(address - 4));
            }
            return(null);
        }
コード例 #2
0
ファイル: Emulator.cs プロジェクト: orf53975/quasar-sharp
 public Emulator(QuasarRam memory)
 {
     Console.WriteLine(memory.Limit.ToString("x8"));
     this.memory = memory;
     this.peripheralController = new PeripheralController(this);
     this.interruptController  = new InterruptController();
     this.RegisterDevice(this.interruptController);
     this.RegisterDevice(this.peripheralController);
     this.RegisterDevice(new DeviceIntervalTimer());
 }
コード例 #3
0
ファイル: Instruction.cs プロジェクト: orf53975/quasar-sharp
        public static Instruction Fetch(QuasarRam memory, uint address)
        {
            uint           org_add     = address;
            byte           original    = memory[address++];
            Opcode         op          = (Opcode)(original & 0x7f);
            AddressingMode am1         = AddressingMode.NONE;
            AddressingMode am2         = AddressingMode.NONE;
            bool           hasOperands = ((int)original & 128) == 0;

            if (hasOperands)
            {
                byte descr = memory[address++];
                am1 = (AddressingMode)(descr & 0x0F);
                am2 = (AddressingMode)((descr & 0xF0) >> 4);
                object op1  = ReadOperand(memory, ref address, am1);
                object op2  = ReadOperand(memory, ref address, am2);
                int    size = (int)(address - org_add);
                return(new Instruction(op, size, am1, op1, am2, op2));
            }
            else
            {
                return(new Instruction(op));
            }
        }
コード例 #4
0
 public Stack(Emulator emu)
 {
     this.memory = emu.Memory;
     this.host   = emu;
 }