summaryrefslogtreecommitdiff
path: root/as/opcodes.go
diff options
context:
space:
mode:
authorstefan <stefan@s00.xyz>2023-05-24 22:29:46 -0400
committerstefan <stefan@s00.xyz>2023-05-24 22:29:46 -0400
commit20621e073562ee5d423b636fae8b6aa8e38275fa (patch)
tree4a81bde039e58602e44a213cfb8d91a65f1dadd9 /as/opcodes.go
parentba2b9c8a1bb1876b6eb4c9783fde798b19de4418 (diff)
downloadevm-20621e073562ee5d423b636fae8b6aa8e38275fa.tar.gz
readme and cleanup
Diffstat (limited to 'as/opcodes.go')
-rw-r--r--as/opcodes.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/as/opcodes.go b/as/opcodes.go
index 94c2e2b..be04d19 100644
--- a/as/opcodes.go
+++ b/as/opcodes.go
@@ -49,9 +49,10 @@ const (
PUSH30 = 0x7d
PUSH31 = 0x7e
PUSH32 = 0x7f
+ RETURN = 0xf3
)
-var OpcodeStrings = map[string]byte {
+var OpcodeStrings = map[string]Opcode {
"STOP": STOP,
"ADD": ADD,
"MUL": MUL,
@@ -66,6 +67,7 @@ var OpcodeStrings = map[string]byte {
"MLOAD": MLOAD,
"MSTORE": MSTORE,
"MSTORE8": MSTORE8,
+ "PUSH": PUSH1,
"PUSH1": PUSH1,
"PUSH2": PUSH2,
"PUSH3": PUSH3,
@@ -98,4 +100,14 @@ var OpcodeStrings = map[string]byte {
"PUSH30": PUSH30,
"PUSH31": PUSH31,
"PUSH32": PUSH32,
+ "RETURN": RETURN,
+}
+
+// returns 0 if not push, otherwise returns number of bytes
+func (o *Opcode) IsPush() byte {
+ d := *o - PUSH1
+ if d >= 0 && d < 31 {
+ return byte(d) + 1
+ }
+ return 0
}