Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }