コード例 #1
0
        public static int Cast(Processor proc, ProgramReader reader)
        {
            TypeFlag returnType = (TypeFlag)reader.NextInt();
            uint     addr       = reader.NextPtr();

            object v1 = BytesToNative(proc.Registers.TypeRegisters[0], proc.Registers.OperationRegisters[0]);

            byte[] b = null;

            switch (returnType)
            {
            case TypeFlag.Char:
                v1 = Conversions.ToChar(v1);
                break;

            case TypeFlag.Int:
                v1 = Conversions.ToInteger(v1);
                break;

            case TypeFlag.Float:
                v1 = Conversions.ToSingle(v1);
                break;
            }

            b = Convert(v1, returnType);

            MemoryWriter w = MemoryWriter.GetWriter(2, proc, addr);

            w.Write(b);

            return(reader.Elapsed());
        }
コード例 #2
0
        public static int Set(Processor proc, ProgramReader reader)
        {
            int sourceSize = reader.NextInt();

            byte[] source = reader.NextArray(sourceSize);
            uint   dest   = reader.NextPtr();

            MemoryReader r = MemoryReader.GetReader(0, proc, source, sourceSize);
            MemoryWriter w = MemoryWriter.GetWriter(1, proc, dest);

            w.Write(r.Data);

            return(reader.Elapsed());
        }