Example #1
0
        private void AddHandler(U8Cmd cmd)
        {
            //  This instruction adds the sign-extended signed8 to the contetnts of the stack 
            //  poionter and stores the result in the stack pointer.

            //  bit 7 in signed8 is interpreted as the sign bit, so signed8 is an integer
            //  quantity between -128 and +127.
            if(U8Decoder.isNegative7Bit((byte)cmd.Op2) == 1)
                StackPtr -= U8Decoder.ABS7Bit((byte)cmd.Op2);
            else
                StackPtr += U8Decoder.ABS7Bit((byte)cmd.Op2);
        }
Example #2
0
        private void AddSpO(U8Cmd cmd)
        {
            // This inst adds the sign-extended signed8 to the contents of the stack pointer
            // and stores the result in the stack pointer
            if (U8Decoder.isNegative7Bit((byte)cmd.Op1) == 1)
            {
                this.Registers.SP -= U8Decoder.ABS7Bit((byte)cmd.Op1); // TODO: verify, may need Op2!!!
            }
            else
            {
                this.Registers.SP += U8Decoder.ABS7Bit((byte)cmd.Op1);
            }

            this.Registers.PC += 2;
        }
Example #3
0
        private void AddERegO(U8Cmd cmd)
        {
            // This inst adds the sign-extended immediate vlaue to the contents of the specified
            // word-sized register and stores the result in the register.
            var sum = 0;

            if (U8Decoder.isNegative7Bit((byte)cmd.Op2) == 1)
            {
                sum = this.Registers.GetERegisterByIndex((byte)cmd.Op1) - U8Decoder.ABS7Bit((byte)cmd.Op2);
            }
            else
            {
                sum = this.Registers.GetERegisterByIndex((byte)cmd.Op1) + U8Decoder.ABS7Bit((byte)cmd.Op2);
            }
            this.Registers.SetERegisterByIndex((byte)cmd.Op1, (ushort)sum);
            this.Registers.PC += 2;

            // TODO: this.Registers.PSW.C
            this.Registers.PSW.Z = sum == 0;
            // TODO: this.Registers.PSW.S = TRACK TOP BIT OF RESULT
            this.Registers.PSW.OV = sum > ushort.MaxValue;
            // TODO: this.Registers.PSW.HC = idk ;/
        }