From 52a9ebae050701c090fe6771bbdfc77e1c3d28eb Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Thu, 12 Dec 2024 10:07:37 -0300 Subject: [PATCH 1/2] Change definition of EXCHANGE immediates --- spec/eof.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/eof.md b/spec/eof.md index 737d86c..3cddc89 100644 --- a/spec/eof.md +++ b/spec/eof.md @@ -256,9 +256,9 @@ The following instructions are introduced in EOF code: - `EXCHANGE (0xe8)` instruction - deduct 3 gas - read uint8 operand `imm` - - `n = imm >> 4 + 1`, `m = imm & 0x0F + 1` - - `n + 1`th stack item is swapped with `n + m + 1`th stack item (1-based). - - Stack validation: `stack_height >= n + m + 1` + - `n = imm >> 4 + 1`, `m = imm & 0x0F + n + 1` + - `n + 1`th stack item is swapped with `m + 1`th stack item (1-based). + - Stack validation: `stack_height >= m + 1` - `RETURNDATALOAD (0xf7)` instruction - deduct 3 gas - pop `offset` from the stack From 44b5781c134498586fff6ff790bb859ce9d39834 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Thu, 12 Dec 2024 11:28:16 -0300 Subject: [PATCH 2/2] define in terms of i,j intermediate vars --- spec/eof.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/eof.md b/spec/eof.md index 3cddc89..bd62695 100644 --- a/spec/eof.md +++ b/spec/eof.md @@ -256,7 +256,8 @@ The following instructions are introduced in EOF code: - `EXCHANGE (0xe8)` instruction - deduct 3 gas - read uint8 operand `imm` - - `n = imm >> 4 + 1`, `m = imm & 0x0F + n + 1` + - `i = imm >> 4`, `j = imm & 0x0F` + - `n = i + 1`, `m = j + i + 2` - `n + 1`th stack item is swapped with `m + 1`th stack item (1-based). - Stack validation: `stack_height >= m + 1` - `RETURNDATALOAD (0xf7)` instruction