public void PutByte(DataWord address, byte value) { int offset; byte[] bytes = this.GetOrCreateBlock(address, out offset); bytes[offset] = value; }
public DataWord Get(DataWord key) { if (this.state.ContainsKey(key)) { return(this.state[key]); } return(DataWord.Zero); }
public byte GetByte(DataWord address) { int offset; byte[] bytes = this.GetBlock(address, out offset); if (bytes != null) { return(bytes[offset]); } return(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)); }
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); }
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); }
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); } }
public void Push(DataWord dw) { var bytes = dw.Value.ToByteArray().Reverse().ToArray(); this.CompileAdjust(Bytecodes.Push1, bytes.Length - 1, bytes); }
public void Push(DataWord value) { this.stack.Push(value); }
public int Compare(DataWord dw) { return(BigInteger.Compare(this.Value, dw.Value)); }
public DataWord Divide(DataWord dw) { return(new DataWord(BigInteger.Divide(this.Value, dw.Value))); }
public DataWord Multiply(DataWord dw) { return(new DataWord(BigInteger.Multiply(this.Value, dw.Value))); }
public DataWord Subtract(DataWord dw) { return(new DataWord(BigInteger.Subtract(this.Value, dw.Value))); }
public DataWord Add(DataWord dw) { return(new DataWord(BigInteger.Add(this.Value, dw.Value))); }
public void Put(DataWord key, DataWord value) { this.state[key] = value; }