Ejemplo n.º 1
0
        public long GetResult(Punchcard pc)
        {
            switch (Mode)
            {
            case Mode.Position:
                return(pc.GetAddress(Value));

            case Mode.Immediate:
                return(Value);

            case Mode.Relative:
                int newAdd = RelativeBase + (int)Value;
                return(pc.GetAddress(newAdd));

            default: return(-999);
            }
        }
Ejemplo n.º 2
0
        private List <Parameter> GetParameters(Operator op, string opCode)
        {
            List <Parameter> param = new List <Parameter>();
            string           modes = string.Empty;

            if (PC.GetAddress(Pointer).ToString().Length > 2)
            {
                modes = opCode.Substring(0, opCode.Length - 2);
            }

            for (int i = 0; i < op.ParamCount; i++)
            {
                param.Add(new Parameter(PC.GetAddress(Pointer + i + 1), RelativeBase));
            }

            if (modes != string.Empty)
            {
                modes = modes.PadLeft(3, '0');
                Stack <int> stack = new Stack <int>();
                for (int x = 0; x < 3; x++)
                {
                    int mode;
                    if (x < modes.Length)
                    {
                        mode = modes[x];
                    }
                    else
                    {
                        mode = '0';
                    }
                    //if (op.OpCode == OpCode.EqualTo)
                    //	mode = '0';
                    stack.Push(mode - '0');
                }

                foreach (var par in param)
                {
                    par.SetMode(stack.Pop());
                }
            }

            return(param);
        }