Skip to content

Commit

Permalink
Clarify meaning of the bitmask of push and pop opcodes (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dentosal authored Feb 12, 2024
1 parent 6cd7270 commit 1eafbe2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/fuel-vm/instruction-set.md
Original file line number Diff line number Diff line change
Expand Up @@ -1493,6 +1493,8 @@ Panic if:
| Encoding | `0x00 i i i i` |
| Notes | The immediate value is used as a bitmask for selecting the registers. |

The nth bit of the bitmask corresponds to nth entry of the register range. In other words, the most significant (i.e. leftmost) bit of the bitmask corresponds to the highest register index. So for instance bitmask `011000000000000000000000` pushes the register 61 followed by register 62.

Panic if:

- `$sp + popcnt(imm)*8` overflows
Expand All @@ -1508,6 +1510,8 @@ Panic if:
| Encoding | `0x00 i i i i` |
| Notes | The immediate value is used as a bitmask for selecting the registers. |

The nth bit of the bitmask corresponds to nth entry of the register range. In other words, the most significant (i.e. leftmost) bit of the bitmask corresponds to the highest register index. So for instance bitmask `011000000000000000000000` pushes the register 37 followed by register 38.

Panic if:

- `$sp + popcnt(imm)*8` overflows
Expand All @@ -1523,6 +1527,10 @@ Panic if:
| Encoding | `0x00 i i i i` |
| Notes | The immediate value is used as a bitmask for selecting the registers. |

The nth bit of the bitmask corresponds to nth entry of the register range. In other words, the most significant (i.e. leftmost) bit of the bitmask corresponds to the highest register index. So for instance bitmask `011000000000000000000000` pops the register 62 followed by register 61.

Note that the order is reverse from `PSHH`, so that `PSHH a; POPH a` returns to the original state.

Panic if:

- `$sp - popcnt(imm)*8` overflows
Expand All @@ -1538,6 +1546,10 @@ Panic if:
| Encoding | `0x00 i i i i` |
| Notes | The immediate value is used as a bitmask for selecting the registers. |

The nth bit of the bitmask corresponds to nth entry of the register range. In other words, the most significant (i.e. leftmost) bit of the bitmask corresponds to the highest register index. So for instance bitmask `011000000000000000000000` pops the register 38 followed by register 37.

Note that the order is reverse from `PSHL`, so that `PSHL a; POPL a` returns to the original state.

Panic if:

- `$sp - popcnt(imm)*8` overflows
Expand Down

1 comment on commit 1eafbe2

@Hunch0sznn
Copy link

Choose a reason for hiding this comment

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

This is good

Please sign in to comment.