2023-11-01 03:32:09 +00:00
|
|
|
# Nimbus
|
2024-03-20 07:35:38 +00:00
|
|
|
# Copyright (c) 2019-2024 Status Research & Development GmbH
|
2023-11-01 03:32:09 +00:00
|
|
|
# Licensed under either of
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
|
|
|
# http://opensource.org/licenses/MIT)
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except
|
|
|
|
# according to those terms.
|
|
|
|
|
2019-05-30 16:42:55 +00:00
|
|
|
import macro_assembler, unittest2
|
2019-01-30 12:29:04 +00:00
|
|
|
|
2019-09-21 05:45:23 +00:00
|
|
|
proc opArithMain*() =
|
|
|
|
suite "Arithmetic Opcodes":
|
|
|
|
assembler:
|
2024-03-20 07:35:38 +00:00
|
|
|
title: "Add_1"
|
2019-09-21 05:45:23 +00:00
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push1 "0x02"
|
|
|
|
Push1 "0x02"
|
|
|
|
Add
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x04"
|
|
|
|
|
|
|
|
assembler:
|
2024-03-20 07:35:38 +00:00
|
|
|
title: "Add_2"
|
2019-09-21 05:45:23 +00:00
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push2 "0x1002"
|
|
|
|
Push1 "0x02"
|
|
|
|
Add
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x1004"
|
|
|
|
|
|
|
|
assembler:
|
2024-03-20 07:35:38 +00:00
|
|
|
title: "Add_3"
|
2019-09-21 05:45:23 +00:00
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push2 "0x1002"
|
|
|
|
Push6 "0x123456789009"
|
|
|
|
Add
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x12345678A00B"
|
|
|
|
|
|
|
|
assembler:
|
2024-03-20 07:35:38 +00:00
|
|
|
title: "Add_4"
|
2019-09-21 05:45:23 +00:00
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push2 "0x1234"
|
|
|
|
Add
|
2019-09-21 05:45:23 +00:00
|
|
|
success: false
|
|
|
|
stack: "0x1234"
|
|
|
|
|
|
|
|
assembler:
|
2024-03-20 07:35:38 +00:00
|
|
|
title: "Addmod_1"
|
2019-09-21 05:45:23 +00:00
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push1 "0x02"
|
|
|
|
Push1 "0x02"
|
|
|
|
Push1 "0x03"
|
|
|
|
Addmod
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x01"
|
|
|
|
|
|
|
|
assembler:
|
2024-03-20 07:35:38 +00:00
|
|
|
title: "Addmod_2"
|
2019-09-21 05:45:23 +00:00
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push2 "0x1000"
|
|
|
|
Push1 "0x02"
|
|
|
|
Push2 "0x1002"
|
|
|
|
Addmod
|
|
|
|
Push1 "0x00"
|
2019-09-21 05:45:23 +00:00
|
|
|
stack:
|
|
|
|
"0x04"
|
|
|
|
"0x00"
|
|
|
|
|
|
|
|
assembler:
|
2024-03-20 07:35:38 +00:00
|
|
|
title: "Addmod_3"
|
2019-09-21 05:45:23 +00:00
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push2 "0x1002"
|
|
|
|
Push6 "0x123456789009"
|
|
|
|
Push1 "0x02"
|
|
|
|
Addmod
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x093B"
|
|
|
|
|
|
|
|
assembler:
|
2024-03-20 07:35:38 +00:00
|
|
|
title: "Addmod_4"
|
2019-09-21 05:45:23 +00:00
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push2 "0x1234"
|
|
|
|
Addmod
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x1234"
|
|
|
|
success: false
|
|
|
|
|
|
|
|
assembler:
|
|
|
|
title: "MUL_1"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push1 "0x03"
|
|
|
|
Push1 "0x02"
|
|
|
|
Mul
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x06"
|
|
|
|
|
|
|
|
assembler:
|
|
|
|
title: "MUL_2"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push3 "0x222222"
|
|
|
|
Push1 "0x03"
|
|
|
|
Mul
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x666666"
|
|
|
|
|
|
|
|
assembler:
|
|
|
|
title: "MUL_3"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push3 "0x222222"
|
|
|
|
Push3 "0x333333"
|
|
|
|
Mul
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x6D3A05F92C6"
|
|
|
|
|
|
|
|
assembler:
|
|
|
|
title: "MUL_4"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push1 "0x01"
|
|
|
|
Mul
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x01"
|
|
|
|
success: false
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Mulmod OP
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "MULMOD_2"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push3 "0x222222"
|
|
|
|
Push1 "0x03"
|
|
|
|
Push1 "0x04"
|
|
|
|
Mulmod
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x000000000000000000000000000000000000000000000000000000000000000C"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Mulmod OP
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "MULMOD_3"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push3 "0x222222"
|
|
|
|
Push3 "0x333333"
|
|
|
|
Push3 "0x444444"
|
|
|
|
Mulmod
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Mulmod OP mal
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "MULMOD_4"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push1 "0x01"
|
|
|
|
Mulmod
|
2019-09-21 05:45:23 +00:00
|
|
|
success: false
|
|
|
|
stack: "0x01"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Div OP
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "DIV_1"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push1 "0x02"
|
|
|
|
Push1 "0x04"
|
|
|
|
Div
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000000002"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Div OP
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "DIV_2"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push1 "0x33"
|
|
|
|
Push1 "0x99"
|
|
|
|
Div
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000000003"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Div OP
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "DIV_3"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push1 "0x22"
|
|
|
|
Push1 "0x99"
|
|
|
|
Div
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000000004"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Div OP
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "DIV_4"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push1 "0x15"
|
|
|
|
Push1 "0x99"
|
|
|
|
Div
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000000007"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Div OP
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "DIV_5"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push1 "0x04"
|
|
|
|
Push1 "0x07"
|
|
|
|
Div
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000000001"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Div OP
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "DIV_6"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push1 "0x07"
|
|
|
|
Div
|
2019-09-21 05:45:23 +00:00
|
|
|
success: false
|
|
|
|
stack: "0x07"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Sdiv OP
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "SDIV_1"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push2 "0x03E8"
|
|
|
|
Push32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC18"
|
|
|
|
Sdiv
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Sdiv OP
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "SDIV_2"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push1 "0xFF"
|
|
|
|
Push1 "0xFF"
|
|
|
|
Sdiv
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000000001"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Sdiv OP, Sdiv by zero should be zero
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "SDIV_3"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push1 "0x00"
|
|
|
|
Push1 "0xFF"
|
|
|
|
Sdiv
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Sdiv OP mal
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "SDIV_4"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push1 "0xFF"
|
|
|
|
Sdiv
|
2019-09-21 05:45:23 +00:00
|
|
|
success: false
|
|
|
|
stack: "0xFF"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # -2^255 Sdiv -1 = -2^255 (special case in yellow paper)
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "SDIV_5"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" # -1
|
|
|
|
Push32 "0x8000000000000000000000000000000000000000000000000000000000000000" # -2^255 == low(int256)
|
|
|
|
Sdiv
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x8000000000000000000000000000000000000000000000000000000000000000" # -2^255 == low(int256)
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # -2^255 Sdiv 1 = -2^255
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "SDIV_6"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push32 "0x0000000000000000000000000000000000000000000000000000000000000001" # 1
|
|
|
|
Push32 "0x8000000000000000000000000000000000000000000000000000000000000000" # -2^255 == low(int256)
|
|
|
|
Sdiv
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x8000000000000000000000000000000000000000000000000000000000000000" # -2^255 == low(int256)
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # -2 Sdiv 2 = -1
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "SDIV_7"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push32 "0x0000000000000000000000000000000000000000000000000000000000000002" # 2
|
|
|
|
Push32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE" # -2
|
|
|
|
Sdiv
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" # -1
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # 4 Sdiv -2 = -2
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "SDIV_8"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE" # -2
|
|
|
|
Push32 "0x0000000000000000000000000000000000000000000000000000000000000004" # 4
|
|
|
|
Sdiv
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE" # -2
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # -4 Sdiv 2 = -2
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "SDIV_9"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push32 "0x0000000000000000000000000000000000000000000000000000000000000002" # -4
|
|
|
|
Push32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC" # 2
|
|
|
|
Sdiv
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE" # -2
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # -1 Sdiv 2 = 0
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "SDIV_10"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push32 "0x0000000000000000000000000000000000000000000000000000000000000002" # 2
|
|
|
|
Push32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" # -1
|
|
|
|
Sdiv
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x00" # 0
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # low(int256) Sdiv low(int256) = 1
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "SDIV_11"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push32 "0x8000000000000000000000000000000000000000000000000000000000000000" # low(int256)
|
|
|
|
Push32 "0x8000000000000000000000000000000000000000000000000000000000000000" # low(int256)
|
|
|
|
Sdiv
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x01" # 1
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # low(int256) Sdiv 2
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "SDIV_12"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push32 "0x0000000000000000000000000000000000000000000000000000000000000002" # 2
|
|
|
|
Push32 "0x8000000000000000000000000000000000000000000000000000000000000000" # low(int256)
|
|
|
|
Sdiv
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0xC000000000000000000000000000000000000000000000000000000000000000" # negative half low(int256)
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # low(int256) Sdiv -2
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "SDIV_13"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE" # -2
|
|
|
|
Push32 "0x8000000000000000000000000000000000000000000000000000000000000000" # low(int256)
|
|
|
|
Sdiv
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x4000000000000000000000000000000000000000000000000000000000000000" # positive version of SDIV_12
|
|
|
|
|
|
|
|
assembler:
|
|
|
|
title: "SDIV_14"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push1 "0x01" # 1
|
|
|
|
Push1 "0x7F" # 127
|
|
|
|
Shl # 1 shl 127 (move the bit to the center or 128th position)
|
2019-09-21 05:45:23 +00:00
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
Push1 "0x01" # 1
|
|
|
|
Push1 "0xFF" # 255
|
|
|
|
Shl # 1 shl 255 (create low(int256))
|
2019-09-21 05:45:23 +00:00
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
Sdiv
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000000000" # half of the hi bits are set
|
2023-03-22 11:18:37 +00:00
|
|
|
fork: Constantinople
|
2019-09-21 05:45:23 +00:00
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Sub OP
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "SUB_1"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push1 "0x04"
|
|
|
|
Push1 "0x06"
|
|
|
|
Sub
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000000002"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Sub OP
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "SUB_2"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push2 "0x4444"
|
|
|
|
Push2 "0x6666"
|
|
|
|
Sub
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000002222"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Sub OP
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "SUB_3"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push2 "0x4444"
|
|
|
|
Push4 "0x99996666"
|
|
|
|
Sub
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000099992222"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Sub OP mal
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "SUB_4"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push4 "0x99996666"
|
|
|
|
Sub
|
2019-09-21 05:45:23 +00:00
|
|
|
success: false
|
|
|
|
stack: "0x99996666"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Exp OP
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "EXP_1"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push1 "0x03"
|
|
|
|
Push1 "0x02"
|
|
|
|
Exp
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000000008"
|
|
|
|
#assertEquals(4, gas);
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Exp OP
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "EXP_2"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push1 "0x00"
|
|
|
|
Push3 "0x123456"
|
|
|
|
Exp
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000000001"
|
|
|
|
#assertEquals(3, gas);
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Exp OP
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "EXP_3"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push2 "0x1122"
|
|
|
|
Push1 "0x01"
|
|
|
|
Exp
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000000001"
|
|
|
|
#assertEquals(5, gas);
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Exp OP mal
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "EXP_4"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push3 "0x123456"
|
|
|
|
Exp
|
2019-09-21 05:45:23 +00:00
|
|
|
success: false
|
|
|
|
stack: "0x123456"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Mod OP
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "MOD_1"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push1 "0x03"
|
|
|
|
Push1 "0x04"
|
|
|
|
Mod
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000000001"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Mod OP
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "MOD_2"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push2 "0x012C"
|
|
|
|
Push2 "0x01F4"
|
|
|
|
Mod
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x00000000000000000000000000000000000000000000000000000000000000C8"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Mod OP
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "MOD_3"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push1 "0x04"
|
|
|
|
Push1 "0x02"
|
|
|
|
Mod
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000000002"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Mod OP mal
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "MOD_4"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push1 "0x04"
|
|
|
|
Mod
|
2019-09-21 05:45:23 +00:00
|
|
|
success: false
|
|
|
|
stack: "0x04"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Smod OP
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "SMOD_1"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push1 "0x03"
|
|
|
|
Push1 "0x04"
|
|
|
|
Smod
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000000001"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Smod OP
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "SMOD_2"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE2" # -30
|
|
|
|
Push32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" # -170
|
|
|
|
Smod
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEC"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Smod OP
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "SMOD_3"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push32 "0x000000000000000000000000000000000000000000000000000000000000001E" # 30
|
|
|
|
Push32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" # -170
|
|
|
|
Smod
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEC"
|
|
|
|
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # Smod OP mal
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "SMOD_4"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push32 "0x000000000000000000000000000000000000000000000000000000000000001E" # 30
|
|
|
|
Smod
|
2019-09-21 05:45:23 +00:00
|
|
|
success: false
|
|
|
|
stack: "0x000000000000000000000000000000000000000000000000000000000000001E"
|
|
|
|
|
|
|
|
# real case, EVM bug, integer over flow
|
2024-03-20 07:35:38 +00:00
|
|
|
assembler: # SignExtend OP
|
2019-09-21 05:45:23 +00:00
|
|
|
title: "SIGNEXTEND_1"
|
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push32 "0x000000000000000000000000000000003f9b347132d29b62d161117bca8c7307"
|
|
|
|
Push1 "0x0F"
|
|
|
|
SignExtend
|
2019-09-21 05:45:23 +00:00
|
|
|
stack: "0x000000000000000000000000000000003f9b347132d29b62d161117bca8c7307"
|
2021-10-14 08:00:02 +00:00
|
|
|
|
2023-02-13 14:20:52 +00:00
|
|
|
assembler:
|
2024-03-20 07:35:38 +00:00
|
|
|
title: "Byte with overflow pos 1"
|
2023-02-13 14:20:52 +00:00
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push32 "0x77676767676760000000000000001002e000000000000040000000e000000000"
|
|
|
|
Push32 "0x0000000000000000000000000000000000000000000000010000000000000000"
|
|
|
|
Byte
|
2023-02-13 14:20:52 +00:00
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
|
|
|
|
|
|
|
assembler:
|
2024-03-20 07:35:38 +00:00
|
|
|
title: "Byte with overflow pos 2"
|
2023-02-13 14:20:52 +00:00
|
|
|
code:
|
2024-03-20 07:35:38 +00:00
|
|
|
Push32 "0x001f000000000000000000000000000000200000000100000000000000000000"
|
|
|
|
Push32 "0x0000000000000000000000000000000080000000000000000000000000000001"
|
|
|
|
Byte
|
2023-02-13 14:20:52 +00:00
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
|
|
|
|
2021-10-14 08:00:02 +00:00
|
|
|
when isMainModule:
|
|
|
|
opArithMain()
|