diff options
author | obscuren <geffobscura@gmail.com> | 2014-04-09 20:08:18 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-04-09 20:08:18 +0800 |
commit | c0a030ef0a3ce8342fda2a53cdafd50a271b4837 (patch) | |
tree | d3e5c71b4d1c4ef405a25f5ddd512687d01685ec /ethchain/vm.go | |
parent | 90bb512f420f204f50ba451a4a25682ca8443746 (diff) | |
download | go-tangerine-c0a030ef0a3ce8342fda2a53cdafd50a271b4837.tar go-tangerine-c0a030ef0a3ce8342fda2a53cdafd50a271b4837.tar.gz go-tangerine-c0a030ef0a3ce8342fda2a53cdafd50a271b4837.tar.bz2 go-tangerine-c0a030ef0a3ce8342fda2a53cdafd50a271b4837.tar.lz go-tangerine-c0a030ef0a3ce8342fda2a53cdafd50a271b4837.tar.xz go-tangerine-c0a030ef0a3ce8342fda2a53cdafd50a271b4837.tar.zst go-tangerine-c0a030ef0a3ce8342fda2a53cdafd50a271b4837.zip |
Added new insruction methods
Diffstat (limited to 'ethchain/vm.go')
-rw-r--r-- | ethchain/vm.go | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/ethchain/vm.go b/ethchain/vm.go index 98aaa603a..b4b2177bf 100644 --- a/ethchain/vm.go +++ b/ethchain/vm.go @@ -72,7 +72,7 @@ func (vm *Vm) RunClosure(closure *Closure) []byte { for { step++ // Get the memory location of pc - val := closure.GetMem(pc) + val := closure.GetInstr(pc) // Get the opcode (it must be an opcode!) op := OpCode(val.Uint()) if ethutil.Config.Debug { @@ -233,13 +233,37 @@ func (vm *Vm) RunClosure(closure *Closure) []byte { // 0x10 range case oAND: + x, y := stack.Popn() + if (x.Cmp(ethutil.BigTrue) >= 0) && (y.Cmp(ethutil.BigTrue) >= 0) { + stack.Push(ethutil.BigTrue) + } else { + stack.Push(ethutil.BigFalse) + } + case oOR: + x, y := stack.Popn() + if (x.Cmp(ethutil.BigInt0) >= 0) || (y.Cmp(ethutil.BigInt0) >= 0) { + stack.Push(ethutil.BigTrue) + } else { + stack.Push(ethutil.BigFalse) + } case oXOR: + x, y := stack.Popn() + stack.Push(base.Xor(x, y)) case oBYTE: + val, th := stack.Popn() + if th.Cmp(big.NewInt(32)) < 0 { + stack.Push(big.NewInt(int64(len(val.Bytes())-1) - th.Int64())) + } else { + stack.Push(ethutil.BigFalse) + } // 0x20 range case oSHA3: + size, offset := stack.Popn() + data := mem.Get(offset.Int64(), size.Int64()) + stack.Push(ethutil.BigD(data)) // 0x30 range case oADDRESS: stack.Push(ethutil.BigD(closure.Object().Address())) |