aboutsummaryrefslogtreecommitdiffstats
path: root/ethvm
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-07-25 15:57:47 +0800
committerobscuren <geffobscura@gmail.com>2014-07-25 15:57:47 +0800
commit54f9ea14e197ad805f24592153f1b9e69f3bc5c3 (patch)
tree6fe0805649ddf38b2b90e77c5fb2000a4bdab536 /ethvm
parent7ee49c32b70b0bd3e9709865c0b9c43d16c8f18c (diff)
downloadgo-tangerine-54f9ea14e197ad805f24592153f1b9e69f3bc5c3.tar
go-tangerine-54f9ea14e197ad805f24592153f1b9e69f3bc5c3.tar.gz
go-tangerine-54f9ea14e197ad805f24592153f1b9e69f3bc5c3.tar.bz2
go-tangerine-54f9ea14e197ad805f24592153f1b9e69f3bc5c3.tar.lz
go-tangerine-54f9ea14e197ad805f24592153f1b9e69f3bc5c3.tar.xz
go-tangerine-54f9ea14e197ad805f24592153f1b9e69f3bc5c3.tar.zst
go-tangerine-54f9ea14e197ad805f24592153f1b9e69f3bc5c3.zip
Removed old S(DIV/MOD)
Diffstat (limited to 'ethvm')
-rw-r--r--ethvm/vm.go43
1 files changed, 16 insertions, 27 deletions
diff --git a/ethvm/vm.go b/ethvm/vm.go
index b81c8a189..a93b56e60 100644
--- a/ethvm/vm.go
+++ b/ethvm/vm.go
@@ -282,20 +282,15 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
case SDIV:
require(2)
x, y := stack.Popn()
- // n > 2**255
- if x.Cmp(Pow256) > 0 {
- x.Sub(Pow256, x)
- }
- if y.Cmp(Pow256) > 0 {
- y.Sub(Pow256, y)
- }
- z := new(big.Int)
- z.Div(x, y)
- if z.Cmp(Pow256) > 0 {
- z.Sub(Pow256, z)
+ self.Printf(" %v / %v", y, x)
+
+ if x.Cmp(ethutil.Big0) != 0 {
+ base.Div(y, x)
}
- // Push result on to the stack
- stack.Push(z)
+
+ self.Printf(" = %v", base)
+ // Pop result back on the stack
+ stack.Push(base)
case MOD:
require(2)
x, y := stack.Popn()
@@ -309,20 +304,14 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
case SMOD:
require(2)
x, y := stack.Popn()
- // n > 2**255
- if x.Cmp(Pow256) > 0 {
- x.Sub(Pow256, x)
- }
- if y.Cmp(Pow256) > 0 {
- y.Sub(Pow256, y)
- }
- z := new(big.Int)
- z.Mod(x, y)
- if z.Cmp(Pow256) > 0 {
- z.Sub(Pow256, z)
- }
- // Push result on to the stack
- stack.Push(z)
+
+ self.Printf(" %v %% %v", y, x)
+
+ base.Mod(y, x)
+
+ self.Printf(" = %v", base)
+ stack.Push(base)
+
case EXP:
require(2)
x, y := stack.Popn()