コード例 #1
0
 //Pull from memory to a register
 public void Pull(Register8 register)
 {
     systemMemory.StackRead(register, internalRegister);
     if (register.Get() == 0)
     {
         statusRegister.SetZero();
     }
     Decrement();
 }
コード例 #2
0
        //Read from memory into an 8 bit register

        public bool Read(Register8 register, ushort location)
        {
            if (location > 0xffff)
            {
                //Sets the overflow flag on the status register
                statusRegister.SetOverflow();
                return(false);
            }

            register.Set(memory[location]);
            return(true);
        }
コード例 #3
0
        //Push the contents of a register to the stack
        public void Push(Register8 register)
        {
            //The current push function always ignores location 0xff
            //Effectively reducing the stack space available by one byte
            //TODO: Fix this, making location 0xff usable
            Increment();
            systemMemory.StackWrite(register, internalRegister);

            //Sets the zero flag on the status register
            if (register.Get() == 0)
            {
                statusRegister.SetZero();
            }
        }
コード例 #4
0
        //Write the contents of an 8-bit register to memory

        public bool Write(Register8 register, ushort location)
        {
            //If the operation is a write to the stack, the write fails.
            if (IsWriteToStack(location))
            {
                return(false);
            }
            if (location > 0xffff)
            {
                //Sets the overflow flag on the status register
                statusRegister.SetOverflow();
                return(false);
            }

            memory[location] = register.Get();

            return(true);
        }
コード例 #5
0
 //Function for the Stack Pointer to write to memory
 public bool StackWrite(Register8 register, ushort location)
 {
     memory[location] = register.Get();
     return(true);
 }
コード例 #6
0
 //Function for the Stack Pointer to read from memory
 //Probably not needed as reads from stack are fine
 //with normal Read, but here for symmetry
 public bool StackRead(Register8 register, ushort location)
 {
     register.Set(memory[location]);
     return(true);
 }