fix SIGNEXTEND opcode
This commit is contained in:
parent
1bc8f41b87
commit
592fa5df7e
|
@ -121,10 +121,11 @@ op signExtend, inline = false, bits, value:
|
||||||
var res: UInt256
|
var res: UInt256
|
||||||
if bits <= 31.u256:
|
if bits <= 31.u256:
|
||||||
let
|
let
|
||||||
|
one = 1.u256
|
||||||
testBit = bits.toInt * 8 + 7
|
testBit = bits.toInt * 8 + 7
|
||||||
bitPos = (1 shl testBit)
|
bitPos = one shl testBit
|
||||||
mask = u256(bitPos - 1)
|
mask = bitPos - one
|
||||||
if not isZero(value and bitPos.u256):
|
if not isZero(value and bitPos):
|
||||||
res = value or (not mask)
|
res = value or (not mask)
|
||||||
else:
|
else:
|
||||||
res = value and mask
|
res = value and mask
|
||||||
|
|
|
@ -341,3 +341,12 @@ suite "Arithmetic Opcodes":
|
||||||
SMOD
|
SMOD
|
||||||
success: false
|
success: false
|
||||||
stack: "0x000000000000000000000000000000000000000000000000000000000000001E"
|
stack: "0x000000000000000000000000000000000000000000000000000000000000001E"
|
||||||
|
|
||||||
|
# real case, EVM bug, integer over flow
|
||||||
|
assembler: # SIGNEXTEND OP
|
||||||
|
title: "SIGNEXTEND_1"
|
||||||
|
code:
|
||||||
|
PUSH32 "0x000000000000000000000000000000003f9b347132d29b62d161117bca8c7307"
|
||||||
|
PUSH1 "0x0F"
|
||||||
|
SIGNEXTEND
|
||||||
|
stack: "0x000000000000000000000000000000003f9b347132d29b62d161117bca8c7307"
|
||||||
|
|
|
@ -280,8 +280,6 @@ suite "Environmental Information Opcodes":
|
||||||
"0x5E"
|
"0x5E"
|
||||||
"0x07"
|
"0x07"
|
||||||
|
|
||||||
# macro_assembler automatically insert STOP instruction at the end,
|
|
||||||
# so codesize become 63, not 62 like ethereumj
|
|
||||||
assembler: # CODESIZE OP
|
assembler: # CODESIZE OP
|
||||||
title: "CODESIZE_1"
|
title: "CODESIZE_1"
|
||||||
code:
|
code:
|
||||||
|
@ -289,7 +287,7 @@ suite "Environmental Information Opcodes":
|
||||||
"0x602001600a5254516040016014525451606001601e5254516080016028525460"
|
"0x602001600a5254516040016014525451606001601e5254516080016028525460"
|
||||||
"0xa052546016604860003960166000f26000603f556103e75660005460005360200235"
|
"0xa052546016604860003960166000f26000603f556103e75660005460005360200235"
|
||||||
stack:
|
stack:
|
||||||
"0x0000000000000000000000000000000000000000000000000000000000000063"
|
"0x0000000000000000000000000000000000000000000000000000000000000062"
|
||||||
success: false
|
success: false
|
||||||
|
|
||||||
# 0x94 == 148 bytes
|
# 0x94 == 148 bytes
|
||||||
|
|
Loading…
Reference in New Issue