Exemplo n.º 1
0
        public void SET(Executable caller) // sets data to determined position - len: 4
        {
            uint        data;
            var         instrSet = (FGMSECInstructionSet)(caller.usingInstructionSet);
            List <uint> args     = new List <uint>();

            args.Add(args32[0]);
            args.Add(args32[1]);
            data = returnValue(args32, instrSet, caller, out int shift);
            if (isRegister(args32[2 + shift]))
            {
                instrSet.CPU.SetRegData(BitConverter.GetBytes(args32[3 + shift])[3], data);
            }
            else if (isPointer(args32[2 + shift]))
            {
                List <uint> _args = new List <uint>();
                for (int i = 3 + shift; i < args32.Count; i++)
                {
                    _args.Add(args32[i]);
                }
                caller.Memory.WriteInt32(GetPointerAddress(_args, instrSet, caller, out _), (int)data);
            }
        }
Exemplo n.º 2
0
        public void POP(Executable caller)
        {
            var instrSet = (FGMSECInstructionSet)(caller.usingInstructionSet);

            if (isRegister(args32[0]))
            {
                byte reg  = BitConverter.GetBytes(args32[1])[3];
                int  data = 0;

                caller.Memory.Stack.Try_Pop(ref data);
                instrSet.CPU.SetRegData(reg, (uint)(data));
            }
            else if (isPointer(args32[0]))
            {
                List <uint> _args = new List <uint>();
                for (int i = 1; i < args32.Count; i++)
                {
                    _args.Add(args32[i]);
                }
                int data = 0;
                caller.Memory.Stack.Try_Pop(ref data);
                caller.Memory.WriteInt32(GetPointerAddress(_args, instrSet, caller, out _), data);
            }
        }
Exemplo n.º 3
0
        private static uint returnValueFromAddress(List <uint> args, FGMSECInstructionSet instrSet, Executable caller, out int shift)
        {
            uint data = 0x00;

            shift = 0;
            if (isRegister(args[0]))
            {
                data = instrSet.CPU.GetRegData(BitConverter.GetBytes(args[1])[3]);
            }
            else if (isPointer(args[0]))
            {
                List <uint> _args = new List <uint>();
                for (int i = 1; i < args.Count; i++)
                {
                    _args.Add(args[i]);
                }
                int addr = GetPointerAddress(_args, instrSet, caller, out shift);
                data = (uint)caller.Memory.ReadInt32(addr);
            }
            else
            {
                throw new Exception("Cannot retrive value of one or more elements");
            }
            return(data);
        }
Exemplo n.º 4
0
 public void END(Executable caller) // terminates the execution of the specified program
 {
     caller.running = false;
 }
Exemplo n.º 5
0
        private static int GetPointerAddress(List <uint> args, FGMSECInstructionSet instrSet, Executable caller, out int shift)
        {
            int addr = 0;

            shift = 1;
            if (isRegister(args[0]))
            {
                addr = (int)instrSet.CPU.GetRegData(BitConverter.GetBytes(args[1])[3]);
            }
            else if (isData(args[0]))
            {
                addr = (int)args[1];
            }
            else if (isPointer(args[0]))
            {
                List <uint> _args = new List <uint>();
                for (int i = 1; i < args.Count; i++)
                {
                    _args.Add(args[i]);
                }
                addr   = caller.Memory.ReadInt32(GetPointerAddress(_args, instrSet, caller, out int addShift));
                shift += addShift;
            }
            else
            {
                global::System.Console.WriteLine($"No way to set address found ({args[0]})");
                addr = 0;
                instrSet.CPU.SetRegData((byte)FGMSECpu.FGMSERegisters.C1, 0xFF00FFA1);
            }
            return(addr);
        }