From 097f76db0e8d6ff13a6ec43c4adf131e3ab255a0 Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Mon, 23 Sep 2024 18:42:52 +0200 Subject: [PATCH] Documentation fixes (#1506) * fix(docs): Fix number of locals and typos * fix(docs): Consistently use `advstack` for the advice stack --- docs/src/user_docs/assembly/flow_control.md | 6 +++--- docs/src/user_docs/assembly/io_operations.md | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/src/user_docs/assembly/flow_control.md b/docs/src/user_docs/assembly/flow_control.md index 0b23a268f8..0075f1d334 100644 --- a/docs/src/user_docs/assembly/flow_control.md +++ b/docs/src/user_docs/assembly/flow_control.md @@ -82,9 +82,9 @@ where `instructions` can be a sequence of any instructions, including nested con 1. Pops the top item from the stack. 2. If the value of the item is $1$, `instructions` in the loop body are executed. - a. After the body is executed, the stack is popped again, and if the popped value is $1$, the body is executed again. - b. If the popped value is $0$, the loop is exited. - c. If the popped value is not binary, the execution fails. + 1. After the body is executed, the stack is popped again, and if the popped value is $1$, the body is executed again. + 2. If the popped value is $0$, the loop is exited. + 3. If the popped value is not binary, the execution fails. 3. If the value of the item is $0$, execution of loop body is skipped. 4. If the value is not binary, the execution fails. diff --git a/docs/src/user_docs/assembly/io_operations.md b/docs/src/user_docs/assembly/io_operations.md index 697d6ffc94..fc8c08608c 100644 --- a/docs/src/user_docs/assembly/io_operations.md +++ b/docs/src/user_docs/assembly/io_operations.md @@ -37,8 +37,8 @@ As mentioned above, nondeterministic inputs are provided to the VM via the advic | Instruction | Stack_input | Stack_output | Notes | | -------------------------------- | ------------------ | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| adv_push.*n*
- *(n cycles)* | [ ... ] | [a, ... ] | $a \leftarrow stack.pop()$
Pops $n$ values from the advice stack and pushes them onto the operand stack. Valid for $n \in \{1, ..., 16\}$.
Fails if the advice stack has fewer than $n$ values. | -| adv_loadw
- *(1 cycle)* | [0, 0, 0, 0, ... ] | [A, ... ] | $A \leftarrow stack.pop(4)$
Pop the next word (4 elements) from the advice stack and overwrites the first word of the operand stack (4 elements) with them.
Fails if the advice stack has fewer than $4$ values. | +| adv_push.*n*
- *(n cycles)* | [ ... ] | [a, ... ] | $a \leftarrow advstack.pop()$
Pops $n$ values from the advice stack and pushes them onto the operand stack. Valid for $n \in \{1, ..., 16\}$.
Fails if the advice stack has fewer than $n$ values. | +| adv_loadw
- *(1 cycle)* | [0, 0, 0, 0, ... ] | [A, ... ] | $A \leftarrow advstack.pop(4)$
Pop the next word (4 elements) from the advice stack and overwrites the first word of the operand stack (4 elements) with them.
Fails if the advice stack has fewer than $4$ values. | | adv_pipe
- *(1 cycle)* | [C, B, A, a, ... ] | [E, D, A, a', ... ] | $[D, E] \leftarrow [adv\_stack.pop(4), adv\_stack.pop(4)]$
$a' \leftarrow a + 2$
Pops the next two words from the advice stack, overwrites the top of the operand stack with them and also writes these words into memory at address $a$ and $a + 1$.
Fails if the advice stack has fewer than $8$ values. | > **Note**: The opcodes above always push data onto the operand stack so that the first element is placed deepest in the stack. For example, if the data on the stack is `a,b,c,d` and you use the opcode `adv_push.4`, the data will be `d,c,b,a` on your stack. This is also the behavior of the other opcodes. @@ -74,7 +74,7 @@ Memory is guaranteed to be initialized to zeros. Thus, when reading from memory | mem_storew
- *(1 cycle)*
mem_storew.*a*
- *(2-3 cycles)* | [a, A, ... ] | [A, ... ] | $A \rightarrow mem[a]$
Stores the top four elements of the stack in memory at address $a$. If $a$ is provided via the stack, it is removed from the stack first.
Fails if $a \ge 2^{32}$ | | mem_stream
- *(1 cycle)* | [C, B, A, a, ... ] | [E, D, A, a', ... ] | $[E, D] \leftarrow [mem[a], mem[a+1]]$
$a' \leftarrow a + 2$
Read two sequential words from memory starting at address $a$ and overwrites the first two words in the operand stack. | -The second way to access memory is via procedure locals using the instructions listed below. These instructions are available only in procedure context. The number of locals available to a given procedure must be specified at [procedure declaration](./code_organization.md#procedures) time, and trying to access more locals than was declared will result in a compile-time error. The number of locals per procedure is not limited, but the total number of locals available to all procedures at runtime must be smaller than $2^{32}$. +The second way to access memory is via procedure locals using the instructions listed below. These instructions are available only in procedure context. The number of locals available to a given procedure must be specified at [procedure declaration](./code_organization.md#procedures) time, and trying to access more locals than was declared will result in a compile-time error. A procedure can have at most $2^{16}$ locals, and the total number of locals available to all procedures at runtime is limited to $2^{30}$. | Instruction | Stack_input | Stack_output | Notes | | ------------------------------------ | ------------------ | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -85,4 +85,4 @@ The second way to access memory is via procedure locals using the instructions l Unlike regular memory, procedure locals are not guaranteed to be initialized to zeros. Thus, when working with locals, one must assume that before a local memory address has been written to, it contains "garbage". -Internally in the VM, procedure locals are stored at memory offset stating at $2^{30}$. Thus, every procedure local has an absolute address in regular memory. The `locaddr.i` instruction is provided specifically to map an index of a procedure's local to an absolute address so that it can be passed to downstream procedures, when needed. +Internally in the VM, procedure locals are stored at memory offset starting at $2^{30}$. Thus, every procedure local has an absolute address in regular memory. The `locaddr.i` instruction is provided specifically to map an index of a procedure's local to an absolute address so that it can be passed to downstream procedures, when needed.