diff --git a/EIPS/eip-663.md b/EIPS/eip-663.md index b8ae76e96466d..b33029063303b 100644 --- a/EIPS/eip-663.md +++ b/EIPS/eip-663.md @@ -36,14 +36,18 @@ If the code is legacy bytecode, both of these instructions result in an *excepti If the code is valid EOF1, the following execution rules apply: -These instructions are followed by an 8-bit immediate value, which we call `imm`, and can have a value of 0 to 255. We introduce the variable `n` which equals to `imm + 1`. + 1. These instructions are followed by an 8-bit immediate value, which we call `imm`, and can have a value of 0 to 255. We introduce the variable `n` which equals to `imm + 1`. -If the current stack depth is less than `n`, then a stack underflow exception is issued. If the current stack depth is at the limit, a stack overflow exception is issued. In both of these cases the EVM stops and all gas is consumed. + 2. For `DUPN`: + - If the current stack depth is less than `n`, then a stack underflow exception is issued. + - If the current stack depth is at the limit (1024), a stack overflow exception is issued. + - Otherwise the stack item at depth `n` is duplicated at the top of the stack. -Otherwise + 3. For `SWAPN`: + - If the current stack depth is less than `n + 1`, then a stack underflow exception is ussed. + - Otherwise the stack item at depth `n + 1` is swapped with the item at depth `1` (i.e. the top item). -- for `DUPN` the stack item at depth `n - 1` is duplicated at the top of the stack -- for `SWAPN` the top stack item is swapped with the item at depth `n` +Clarification: the "stack underflow/overflow exception" means the EVM execution is halted and all gas is consumed. The gas cost for both instructions is set at 3.