Exemple #1
0
        public void PutByte(DataWord address, byte value)
        {
            int offset;

            byte[] bytes = this.GetOrCreateBlock(address, out offset);

            bytes[offset] = value;
        }
Exemple #2
0
        public DataWord Get(DataWord key)
        {
            if (this.state.ContainsKey(key))
            {
                return(this.state[key]);
            }

            return(DataWord.Zero);
        }
Exemple #3
0
        public byte GetByte(DataWord address)
        {
            int offset;

            byte[] bytes = this.GetBlock(address, out offset);

            if (bytes != null)
            {
                return(bytes[offset]);
            }

            return(0);
        }
Exemple #4
0
        public DataWord Xor(DataWord dw)
        {
            var bytes1 = this.Bytes;
            var bytes2 = dw.Bytes;

            var newbytes = new byte[32];

            for (int k = 0; k < 32; k++)
            {
                newbytes[k] = (byte)(bytes1[k] ^ bytes2[k]);
            }

            return(new DataWord(newbytes));
        }
Exemple #5
0
        private byte[] GetBlock(DataWord address, out int offset)
        {
            var        value     = address.Value;
            BigInteger remainder = 0;
            var        div       = BigInteger.DivRem(value, this.blocksize, out remainder);

            offset = (int)remainder;

            if (this.blocks.ContainsKey(div))
            {
                return(this.blocks[div]);
            }

            return(null);
        }
Exemple #6
0
        public DataWord GetDataWord(DataWord address)
        {
            int offset;

            byte[] bytes = this.GetBlock(address, out offset);

            if (bytes != null)
            {
                var dbytes = new byte[32];
                Array.Copy(bytes, offset, dbytes, 0, 32);
                return(new DataWord(dbytes));
            }

            return(DataWord.Zero);
        }
Exemple #7
0
        public void PutBytes(DataWord address, byte[] values)
        {
            int offset;

            byte[] bytes = this.GetOrCreateBlock(address, out offset);

            if (values.Length > this.blocksize - offset)
            {
                int l = (int)this.blocksize - offset;
                Array.Copy(values, 0, bytes, offset, l);
                bytes = this.GetOrCreateBlock(address.Add(new DataWord(l)), out offset);
                Array.Copy(values, l, bytes, offset, values.Length - l);
            }
            else
            {
                Array.Copy(values, 0, bytes, offset, values.Length);
            }
        }
Exemple #8
0
 public int Compare(DataWord dw)
 {
     return(BigInteger.Compare(this.Value, dw.Value));
 }
Exemple #9
0
 public DataWord Divide(DataWord dw)
 {
     return(new DataWord(BigInteger.Divide(this.Value, dw.Value)));
 }
Exemple #10
0
 public DataWord Multiply(DataWord dw)
 {
     return(new DataWord(BigInteger.Multiply(this.Value, dw.Value)));
 }
Exemple #11
0
 public DataWord Subtract(DataWord dw)
 {
     return(new DataWord(BigInteger.Subtract(this.Value, dw.Value)));
 }
Exemple #12
0
 public DataWord Add(DataWord dw)
 {
     return(new DataWord(BigInteger.Add(this.Value, dw.Value)));
 }
Exemple #13
0
 public void Put(DataWord key, DataWord value)
 {
     this.state[key] = value;
 }
Exemple #14
0
        public void Push(DataWord dw)
        {
            var bytes = dw.Value.ToByteArray().Reverse().ToArray();

            this.CompileAdjust(Bytecodes.Push1, bytes.Length - 1, bytes);
        }
Exemple #15
0
 public void Push(DataWord value)
 {
     this.stack.Push(value);
 }