Skip to content

Commit

Permalink
Documentation fixes (#1506)
Browse files Browse the repository at this point in the history
* fix(docs): Fix number of locals and typos

* fix(docs): Consistently use `advstack` for the advice stack
  • Loading branch information
PhilippGackstatter authored Sep 23, 2024
1 parent 080597b commit 097f76d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions docs/src/user_docs/assembly/flow_control.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
8 changes: 4 additions & 4 deletions docs/src/user_docs/assembly/io_operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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* <br> - *(n cycles)* | [ ... ] | [a, ... ] | $a \leftarrow stack.pop()$ <br> Pops $n$ values from the advice stack and pushes them onto the operand stack. Valid for $n \in \{1, ..., 16\}$. <br> Fails if the advice stack has fewer than $n$ values. |
| adv_loadw <br> - *(1 cycle)* | [0, 0, 0, 0, ... ] | [A, ... ] | $A \leftarrow stack.pop(4)$ <br> Pop the next word (4 elements) from the advice stack and overwrites the first word of the operand stack (4 elements) with them. <br> Fails if the advice stack has fewer than $4$ values. |
| adv_push.*n* <br> - *(n cycles)* | [ ... ] | [a, ... ] | $a \leftarrow advstack.pop()$ <br> Pops $n$ values from the advice stack and pushes them onto the operand stack. Valid for $n \in \{1, ..., 16\}$. <br> Fails if the advice stack has fewer than $n$ values. |
| adv_loadw <br> - *(1 cycle)* | [0, 0, 0, 0, ... ] | [A, ... ] | $A \leftarrow advstack.pop(4)$ <br> Pop the next word (4 elements) from the advice stack and overwrites the first word of the operand stack (4 elements) with them. <br> Fails if the advice stack has fewer than $4$ values. |
| adv_pipe <br> - *(1 cycle)* | [C, B, A, a, ... ] | [E, D, A, a', ... ] | $[D, E] \leftarrow [adv\_stack.pop(4), adv\_stack.pop(4)]$ <br> $a' \leftarrow a + 2$ <br> 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$.<br> 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.
Expand Down Expand Up @@ -74,7 +74,7 @@ Memory is guaranteed to be initialized to zeros. Thus, when reading from memory
| mem_storew <br> - *(1 cycle)* <br> mem_storew.*a* <br> - *(2-3 cycles)* | [a, A, ... ] | [A, ... ] | $A \rightarrow mem[a]$ <br> 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. <br> Fails if $a \ge 2^{32}$ |
| mem_stream <br> - *(1 cycle)* | [C, B, A, a, ... ] | [E, D, A, a', ... ] | $[E, D] \leftarrow [mem[a], mem[a+1]]$ <br> $a' \leftarrow a + 2$ <br> 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 |
| ------------------------------------ | ------------------ | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -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.

0 comments on commit 097f76d

Please sign in to comment.