Skip to content

Commit

Permalink
Implement SHL and SHR
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Jan 30, 2018
1 parent d64f916 commit b0398e5
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/opFns.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,29 @@ module.exports = {

return new BN(word[pos])
},
SHL: function (a, b, runState) {
if (a.gten(256)) {
return new BN(0)
}
return b.shln(a.toNumber())
},
SHR: function (a, b, runState) {
if (a.gten(256)) {
return new BN(0)
}
return b.shrn(a.toNumber())
},
SAR: function (a, b, runState) {
b = b.fromTwos(256)
if (a.gten(256)) {
if (b.ltn(0)) {
return new BN(-1).toTwos(256)
} else {
return new BN(0)
}
}
// FIXME: implement
},
// 0x20 range - crypto
SHA3: function (offset, length, runState) {
var data = memLoad(runState, offset, length)
Expand Down

0 comments on commit b0398e5

Please sign in to comment.