Exemplo n.º 1
0
        public void Run(IVirtualMachine Runtime, int[] args, char[] types)
        {
            if (types[0] != 0)
            {
                throw new VMException(VMFault.InvalidArgs, $"strb,参数错误");
            }
            int data = Runtime.Read(args[0]);

            int address = args[1];

            if (types[1] == 0)
            {
                address = Runtime.Read(args[1]);
            }

            int offset = args[2];

            if (types[2] == 0)
            {
                offset = Runtime.Read(args[2]);
            }

            address += offset / 4;
            int oringnal = Runtime.Read(address);
            int shift    = offset % 4;

            int tmp = ~(0x000000ff << (shift * 8));

            oringnal &= tmp;
            data      = data << (shift * 8);
            oringnal |= data;
            Runtime.Write(address, oringnal);
        }
Exemplo n.º 2
0
        public void Run(IVirtualMachine Runtime, int[] args, char[] types)
        {
            if (types[0] != 0)
            {
                throw new VMException(VMFault.InvalidArgs);
            }
            int memoryAddr;

            if (types[1] == 0)
            {
                memoryAddr = Runtime.Read(args[1]);
            }
            else
            {
                memoryAddr = args[1];
            }

            int offset = args[2];

            if (types[2] == 0)
            {
                offset = Runtime.Read(args[2]);
            }

            Runtime.Write(args[0], Runtime.Read(memoryAddr + offset));
        }
Exemplo n.º 3
0
        public void Run(IVirtualMachine Runtime, int[] args, char[] types)
        {
            int addr = 0;

            if (types[0] == 0)
            {
                addr = Runtime.Read(args[0]);
            }
            else
            {
                addr = args[0];
            }
            string result = "";

            while (true)
            {
                for (int shift = 0; shift < 4; shift++)
                {
                    int oringnal = Runtime.Read(addr);
                    int tmp      = 0x000000ff << (shift * 8);
                    oringnal &= tmp;
                    char data = (char)(oringnal >> (shift * 8));
                    if (data == '\0')
                    {
                        goto end;
                    }
                    result += data;
                }
                addr++;
            }
            end : Console.WriteLine(result);
        }
Exemplo n.º 4
0
        public void Run(IVirtualMachine Runtime, int[] args, char[] types)
        {
            if (types[0] != 0)
            {
                throw new VMException(VMFault.InvalidArgs);
            }
            int opdata1 = types[1] != 0 ? args[1] : Runtime.Read(args[1]);
            int opdata2 = types[2] != 0 ? args[2] : Runtime.Read(args[2]);

            Runtime.Write(args[0], opdata1 - opdata2);
        }
Exemplo n.º 5
0
        public void Run(IVirtualMachine Runtime, int[] args, char[] types)
        {
            if (types[0] != 0 || types[1] != 0)
            {
                throw new VMException(VMFault.InvalidArgs);
            }
            int opdata1 = Runtime.Read(args[0]);
            int opdata2 = Runtime.Read(args[1]);

            if (opdata1 >= opdata2)
            {
                Runtime.cpsr |= 0x00000001;
            }
            else
            {
                Runtime.cpsr &= ~0x00000001;
            }
        }
Exemplo n.º 6
0
        public void Run(IVirtualMachine Runtime, int[] args, char[] types)
        {
            int pcAddr = args[0];

            if (types[0] == 0)
            {
                pcAddr = Runtime.Read(args[0]);
            }
            Runtime.pc = pcAddr;
        }
Exemplo n.º 7
0
        public void Run(IVirtualMachine Runtime, int[] args, char[] types)
        {
            if (types[0] != 0)
            {
                throw new VMException(VMFault.InvalidArgs, $"pop,参数错误");
            }
            int value = Runtime.Read(--Runtime.sp);

            Runtime.Write(args[0], value);
        }
Exemplo n.º 8
0
 public void Run(IVirtualMachine Runtime, int[] args, char[] types)
 {
     if (types[0] == 0)
     {
         Console.WriteLine(Runtime.Read(args[0]));
     }
     else
     {
         Console.WriteLine(args[0]);
     }
 }
Exemplo n.º 9
0
        public void Run(IVirtualMachine Runtime, int[] args, char[] types)
        {
            if (types[0] != 0)
                throw new VMException(VMFault.InvalidArgs, $"ldrb,参数错误");
            int data;
            
            int address = args[1];
            if (types[1] == 0)
                address = Runtime.Read(args[1]);

            int offset = args[2]; 
            if (types[2] == 0)
                offset = Runtime.Read(args[2]);

            //偏移后的基地址
            address += offset / 4;
            int oringnal = Runtime.Read(address);
            int shift = offset % 4;

            int tmp = 0x000000ff << (shift * 8);
            oringnal &= tmp;
            data = oringnal >> (shift * 8);
            Runtime.Write(args[0], data);
        }
Exemplo n.º 10
0
        public void Run(IVirtualMachine Runtime, int[] args, char[] types)
        {
            int pcAddr = args[0];

            if (types[0] == 0)
            {
                pcAddr = Runtime.Read(args[0]);
            }
            IVirtualMachine vm = Runtime.CopyVM();

            Task.Run(() =>
            {
                vm.Continue(pcAddr);
            });
        }
Exemplo n.º 11
0
        public void Run(IVirtualMachine Runtime, int[] args, char[] types)
        {
            if ((Runtime.cpsr & 0x00000001) == 0)
            {
                return;
            }
            int pcAddr = args[0];

            if (types[0] == 0)
            {
                pcAddr = Runtime.Read(args[0]);
            }
            Runtime.pc    = pcAddr;
            Runtime.cpsr &= (~0x00000001);
        }
Exemplo n.º 12
0
        public void Run(IVirtualMachine Runtime, int[] args, char[] types)
        {
            if (types[0] != 0)
            {
                throw new VMException(VMFault.InvalidArgs, $"mov,参数错误");
            }
            int opdata;

            if (types[1] == 0)
            {
                opdata = Runtime.Read(args[1]);
            }
            else
            {
                opdata = args[1];
            }
            Runtime.Write(args[0], opdata);
        }