You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These two new instructions simplify manipulation of the operational
stack. Instruction `pick` + `i` moves the indicated stack element to the
top of the stack. Instruction `place` + `i` is its dual, moving the top
of the stack to the indicated position.
Copy file name to clipboardExpand all lines: specification/src/instruction-groups.md
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,8 @@ A summary of all instructions and which groups they are part of is given in the
40
40
|`pop` + `n`| x | x | x | x ||| x |||||||| x |
41
41
|`push` + `a`||| x | x ||| x | x ||||||||
42
42
|`divine` + `n`| x | x | x | x ||| x || x |||||||
43
+
|`pick` + `i`| x || x | x ||| x ||| x ||||||
44
+
|`place` + `i`| x || x | x ||| x ||| x ||||||
43
45
|`dup` + `i`| x || x | x ||| x | x ||||||||
44
46
|`swap` + `i`| x || x | x ||| x ||| x ||||||
45
47
|`nop`||| x | x || x |||| x | 0 | x ||||
@@ -86,7 +88,7 @@ In this and the following sections, a register marked with a `'` refers to the n
86
88
For example, `st0' = st0 + 2` means that stack register `st0` is incremented by 2.
87
89
An alternative view for the same concept is that registers marked with `'` are those of the next row in the table.
88
90
89
-
For instructions like `dup i`, `swap i`, `pop n`, _et cetera_, it is beneficial to have polynomials that evaluate to 1 if the instruction's argument is a specific value, and to 0 otherwise.
91
+
For instructions like `pick`, `place`, `dup`, `swap`, `pop`, _et cetera_, it is beneficial to have polynomials that evaluate to 1 if the instruction's argument is a specific value, and to 0 otherwise.
90
92
This allows indicating which registers are constraint, and in which way they are, depending on the argument.
91
93
This is the purpose of the _indicator polynomials_`ind_i`.
92
94
Evaluated on the binary decomposition of `i`, they show the behavior described above.
|`divine` + `n`| 9 | e.g., `_`| e.g., `_ b a`| Pushes `n` non-deterministic elements `a` to the stack. Interface for secret input. 1 ⩽ `n` ⩽ 5 |
28
-
|`dup` + `i`| 17 | e.g., `_ e d c b a`| e.g., `_ e d c b a d`| Duplicates the element `i` positions away from the top. 0 ⩽ `i` < 16 |
29
-
|`swap` + `i`| 25 | e.g., `_ e d c b a`| e.g., `_ e a c b d`| Swaps the `i`th stack element with the top of the stack. 0 ⩽ `i` < 16 |
28
+
|`pick` + `i`| 17 | e.g., `_ d x c b a`| e.g., `_ d c b a x`| Moves the element indicated by `i` to the top of the stack. 0 ⩽ `i` < 16 |
29
+
|`place` + `i`| 25 | e.g., `_ d c b a x`| e.g., `_ d x c b a`| Moves the top of the stack to the indicated position `i`. 0 ⩽ `i` < 16 |
30
+
|`dup` + `i`| 33 | e.g., `_ e d c b a`| e.g., `_ e d c b a d`| Duplicates the element `i` positions away from the top. 0 ⩽ `i` < 16 |
31
+
|`swap` + `i`| 41 | e.g., `_ e d c b a`| e.g., `_ e a c b d`| Swaps the `i`th stack element with the top of the stack. 0 ⩽ `i` < 16 |
30
32
31
33
Instruction `divine n` (together with [`merkle_step`](#many-in-one)) make Triton a virtual machine that can execute non-deterministic programs.
32
34
As programs go, this concept is somewhat unusual and benefits from additional explanation.
@@ -46,7 +48,7 @@ the divined values were supplied as and are read from secret input.
46
48
|`halt`| 0 |`_`|`_`|`ip`|`ip+1`|`_`|`_`| Solves the halting problem (if the instruction is reached). Indicates graceful shutdown of the VM. |
47
49
|`nop`| 8 |`_`|`_`|`ip`|`ip+1`|`_`|`_`| Do nothing |
48
50
|`skiz`| 2 |`_ a`|`_`|`ip`|`ip+s`|`_`|`_`| Skip next instruction if `a` is zero. `s` ∈ {1, 2, 3} depends on `a` and whether the next instruction takes an argument. |
49
-
|`call` + `d`|33|`_`|`_`|`ip`|`d`|`_`|`_ (ip+2, d)`| Push `(ip+2,d)` to the jump stack, and jump to absolute address `d`|
51
+
|`call` + `d`|49|`_`|`_`|`ip`|`d`|`_`|`_ (ip+2, d)`| Push `(ip+2,d)` to the jump stack, and jump to absolute address `d`|
50
52
|`return`| 16 |`_`|`_`|`ip`|`o`|`_ (o, d)`|`_`| Pop one pair off the jump stack and jump to that pair's return address (which is the first element). |
51
53
|`recurse`| 24 |`_`|`_`|`ip`|`d`|`_ (o, d)`|`_ (o, d)`| Peek at the top pair of the jump stack and jump to that pair's destination address (which is the second element). |
52
54
|`recurse_or_return`| 32 |`_ b a .....`|`_ b a .....`|`ip`|`d` or `o`|`_ (o, d)`|`_ (o, d)` or `_`| Like `recurse` if `st5 = a != b = st6`, like `return` if `a == b`. See also extended description below. |
@@ -64,7 +66,7 @@ The instruction is designed to facilitate loops using pointer equality as termin
64
66
65
67
| Instruction | Opcode | old op stack | new op stack | old RAM | new RAM | Description |
0 commit comments