Exemple #1
0
        /// <summary>
        /// Make instruction of format A,B,C
        /// </summary>
        /// <param name="code"></param>
        /// <param name="a"></param>
        public static Instruction MakeABC(OpCode code, int a, int b, int c)
        {
            if (IsNotValueInRange(a, 0, AMask))
            {
                throw SchemeError.RangeError("Opcode.A.B.C", "Opcode", "A", a, code, 0, AMask);
            }

            if (IsNotValueInRange(b, 0, BMask))
            {
                throw SchemeError.RangeError("Opcode.A.B.C", "Opcode", "B", b, code, 0, BMask);
            }

            if (IsNotValueInRange(c, 0, CMask))
            {
                throw SchemeError.RangeError("Opcode.A.B.C", "Opcode", "C", c, code, 0, CMask);
            }

            var inst = new Instruction();

            inst.OpCode = code;
            inst.A      = a;
            inst.B      = b;
            inst.C      = c;
            return(inst);
        }
Exemple #2
0
        /// <summary>
        /// Make instruction of format A
        /// </summary>
        /// <param name="code"></param>
        /// <param name="a"></param>
        public static Instruction MakeA(OpCode code, int a)
        {
            if (IsNotValueInRange(a, 0, AMask))
            {
                throw SchemeError.RangeError("Opcode.A", "Opcode", "A", a, code, 0, AMask);
            }

            var inst = new Instruction();

            inst.OpCode = code;
            inst.A      = a;
            return(inst);
        }
Exemple #3
0
        /// <summary>
        /// Make instruction of format A,B or SBX
        /// </summary>
        /// <param name="code"></param>
        /// <param name="a"></param>
        public static Instruction MakeASBX(OpCode code, int a, int sbx)
        {
            if (IsNotValueInRange(a, 0, AMask))
            {
                throw SchemeError.RangeError("Opcode.A.SBx", "Opcode", "A", a, code, 0, AMask);
            }

            if (IsNotValueInRange(sbx, -SBxMax, SBxMax))
            {
                throw SchemeError.RangeError("Opcode.A.SBx", "Opcode", "SBx", sbx, code, -SBxMax, SBxMax);
            }

            var inst = new Instruction();

            inst.OpCode = code;
            inst.A      = a;
            inst.SBx    = sbx;
            return(inst);
        }
Exemple #4
0
        /// <summary>
        /// Make instruction of format A,BX
        /// </summary>
        /// <param name="code"></param>
        /// <param name="a"></param>
        public static Instruction MakeABX(OpCode code, int a, int bx)
        {
            if (IsNotValueInRange(a, 0, AMask))
            {
                throw SchemeError.RangeError("Opcode.A.Bx", "Opcode", "A", a, code, 0, AMask);
            }

            if (IsNotValueInRange(bx, -BxMask, BxMask))
            {
                throw SchemeError.RangeError("Opcode.A.Bx", "Opcode", "Bx", bx, code, -BxMask, BxMask);
            }

            var inst = new Instruction();

            inst.OpCode = code;
            inst.A      = a;
            inst.Bx     = bx;
            return(inst);
        }