Skip to content

Commit

Permalink
dupn and bury
Browse files Browse the repository at this point in the history
Also, a lot of cleanup of type tracking with frame_*

And, caught some examples of us not testing opcodes in "nonsense"
tests because the opcode was a substring of another opcode, like & is
a substring of &&. (Caught, because "bury" is a substring of
"frame_bury")

This means there is a change to the "old" compiled constants.  This is
normally not done, but here we added to an old nonsense test, we added
the corresponding bytes to the compiled output.
  • Loading branch information
jannotti committed Sep 19, 2022
1 parent 153a732 commit 3d4c884
Show file tree
Hide file tree
Showing 14 changed files with 611 additions and 195 deletions.
2 changes: 2 additions & 0 deletions data/transactions/logic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,9 @@ Account fields used in the `acct_params_get` opcode.
| `pushn n` | Push N 0s onto the stack |
| `dup` | duplicate A |
| `dup2` | duplicate A and B |
| `dupn n` | duplicate A, N times |
| `dig n` | Nth value from the top of the stack. dig 0 is equivalent to dup |
| `bury n` | Replace the Nth value from the top of the stack. bury 0 fails. |
| `cover n` | remove top of stack, and place it deeper in the stack such that N elements are above it. Fails if stack depth <= N. |
| `uncover n` | remove the value at depth N in the stack and shift above items down so the Nth deep value is on top of the stack. Fails if stack depth <= N. |
| `frame_dig i` | Nth (signed) value from the frame pointer. |
Expand Down
38 changes: 26 additions & 12 deletions data/transactions/logic/TEAL_opcodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,27 @@ See `bnz` for details on how branches work. `b` always jumps to the offset.
- immediately fail unless A is a non-zero number
- Availability: v3

## pushn n

- Opcode: 0x45 {uint8 stack depth}
- Stack: ... &rarr; ..., [N zeros]
- Push N 0s onto the stack
- Availability: v8

## popn n

- Opcode: 0x46 {uint8 stack depth}
- Stack: ..., [N items] &rarr; ...
- Remove N values from the top of the stack
- Availability: v8

## dupn n

- Opcode: 0x47 {uint8 copy count}
- Stack: ..., A &rarr; ..., A, b[N copies of A]
- duplicate A, N times
- Availability: v8

## pop

- Opcode: 0x48
Expand Down Expand Up @@ -790,7 +811,7 @@ When A is a uint64, index 0 is the least significant bit. Setting bit 3 to 1 on

## json_ref r

- Opcode: 0x5f {string return type}
- Opcode: 0x5f {uint8 return type}
- Stack: ..., A: []byte, B: []byte &rarr; ..., any
- key B's value, of type R, from a [valid](jsonspec.md) utf-8 encoded json object A
- **Cost**: 25 + 2 per 7 bytes of A
Expand Down Expand Up @@ -1442,16 +1463,9 @@ Fails unless the last instruction executed was a `callsub`.
- Replace the Nth (signed) value from the frame pointer in the stack
- Availability: v8

## pushn n

- Opcode: 0xf3 {uint8 stack depth}
- Stack: ... &rarr; ..., [N zeros]
- Push N 0s onto the stack
- Availability: v8

## popn n
## bury n

- Opcode: 0xf4 {uint8 stack depth}
- Stack: ..., [N items] &rarr; ...
- Remove N values from the top of the stack
- Opcode: 0xf3 {uint8 depth}
- Stack: ..., A &rarr; ...
- Replace the Nth value from the top of the stack. bury 0 fails.
- Availability: v8
Loading

0 comments on commit 3d4c884

Please sign in to comment.