Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/fuel-vm/instruction-set.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
- [`JNZF`: Jump if not zero relative forwards](#jnzf-jump-if-not-zero-relative-forwards)
- [`JNEB`: Jump if not equal relative backwards](#jneb-jump-if-not-equal-relative-backwards)
- [`JNEF`: Jump if not equal relative forwards](#jnef-jump-if-not-equal-relative-forwards)
- [`JAL`: Jump and link](#jal-jump-and-link)
- [`RET`: Return from context](#ret-return-from-context)
- [Memory Instructions](#memory-instructions)
- [`ALOC`: Allocate memory](#aloc-allocate-memory)
Expand Down Expand Up @@ -1299,6 +1300,21 @@ Panic if:

- `$pc + ($rC + imm + 1) * 4 > VM_MAX_RAM - 1`

### `JAL`: Jump and link

| | |
|-------------|-----------------------------------------------------------------------------------------------|
| Description | Set `$rA` to address of the next instruction. Jump to instruction at address `$rB + imm * 4`. |
| Operation | `if $rA is not $zero { $rA = $pc + 4 }` <br> `$pc = $rB + imm * 4` |
| Syntax | `jal $rA $rB imm` |
| Encoding | `0x00 rA rB i i` |
| Notes | If `$rA` is `$zero`, the return address discarded. |

Panic if:

- `$rA` is a reserved register other than `$zero`
- `$rB + imm * 4 >= VM_MAX_RAM`

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we panic if $rB == $pc && imm == 0 to avoid jumping into the exact same spot?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely not. It's not like you couldn't otherwise make an infinite loop if you want, and then you'll just run out of gas anyway.

### `RET`: Return from context

| | |
Expand Down
Loading