Use Zig’s `+%` when integer addition should return the modulo-width result on overflow. Unlike `+`, it makes wrapping explicit. section 6.5.4 section 2.1.3
Choose the overflow behavior deliberately:
- Ordinary `+` treats overflow as illegal behavior and can panic in debug or safe mode. section 6.5.4 section 2.1.3
- `@addWithOverflow` and `@subWithOverflow` return the wrapped result and a `u1` flag indicating whether overflow occurred. section 6.5.4
Table 6.3 More register instructions
| Mnemonic | Description |
|
Add a constant to a register, wrapping on overflow. |
|
Set register |
|
Set register |
|
Set register |
|
Set register |
|
Set register |
|
Set register |
The CHIP-8 register-instruction table shows 7XKK adding a constant with wraparound, alongside instructions that expose overflow. section 6.5.4
