mirror of https://github.com/status-im/op-geth.git
Removed old S(DIV/MOD)
This commit is contained in:
parent
7ee49c32b7
commit
54f9ea14e1
43
ethvm/vm.go
43
ethvm/vm.go
|
@ -282,20 +282,15 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
|
||||||
case SDIV:
|
case SDIV:
|
||||||
require(2)
|
require(2)
|
||||||
x, y := stack.Popn()
|
x, y := stack.Popn()
|
||||||
// n > 2**255
|
self.Printf(" %v / %v", y, x)
|
||||||
if x.Cmp(Pow256) > 0 {
|
|
||||||
x.Sub(Pow256, x)
|
if x.Cmp(ethutil.Big0) != 0 {
|
||||||
|
base.Div(y, x)
|
||||||
}
|
}
|
||||||
if y.Cmp(Pow256) > 0 {
|
|
||||||
y.Sub(Pow256, y)
|
self.Printf(" = %v", base)
|
||||||
}
|
// Pop result back on the stack
|
||||||
z := new(big.Int)
|
stack.Push(base)
|
||||||
z.Div(x, y)
|
|
||||||
if z.Cmp(Pow256) > 0 {
|
|
||||||
z.Sub(Pow256, z)
|
|
||||||
}
|
|
||||||
// Push result on to the stack
|
|
||||||
stack.Push(z)
|
|
||||||
case MOD:
|
case MOD:
|
||||||
require(2)
|
require(2)
|
||||||
x, y := stack.Popn()
|
x, y := stack.Popn()
|
||||||
|
@ -309,20 +304,14 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
|
||||||
case SMOD:
|
case SMOD:
|
||||||
require(2)
|
require(2)
|
||||||
x, y := stack.Popn()
|
x, y := stack.Popn()
|
||||||
// n > 2**255
|
|
||||||
if x.Cmp(Pow256) > 0 {
|
self.Printf(" %v %% %v", y, x)
|
||||||
x.Sub(Pow256, x)
|
|
||||||
}
|
base.Mod(y, x)
|
||||||
if y.Cmp(Pow256) > 0 {
|
|
||||||
y.Sub(Pow256, y)
|
self.Printf(" = %v", base)
|
||||||
}
|
stack.Push(base)
|
||||||
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)
|
|
||||||
case EXP:
|
case EXP:
|
||||||
require(2)
|
require(2)
|
||||||
x, y := stack.Popn()
|
x, y := stack.Popn()
|
||||||
|
|
Loading…
Reference in New Issue