Arithmetic Opcodes
This section documents the arithmetic instructions available in CandleVM.
For operand encodings, see the executable format reference.
Arithmetic
| Opcode byte | Opcode | Operand bytes | Behavior |
|---|---|---|---|
| 18 | Add | destination: register, left: register, right: register | Adds numeric values as f64; finite integral results from 0 through 255 are stored as Byte, otherwise as Number. |
| 19 | Sub | destination: register, left: register, right: register | Subtracts numeric values with the same result narrowing as Add. |
| 20 | Mul | destination: register, left: register, right: register | Multiplies numeric values with the same result narrowing as Add. |
| 21 | Div | destination: register, left: register, right: register | Divides numeric values. A zero divisor (including negative zero) raises DivisionByZero; otherwise result narrowing is the same as Add. |
| 22 | Mod | destination: register, left: register, right: register | Computes floating-point remainder. A zero divisor raises DivisionByZero; result narrowing is the same as Add. |
| 23 | Inc | value: register | Adds numeric 1 to the register in place using the normal narrowing rule. |
| 24 | Dec | value: register | Subtracts numeric 1 from the register in place using the normal narrowing rule. |
Numeric operands may be Byte or Number; other value types raise ValueTypeMismatch. In CandleVM, a result that is integral and within 0..255 automatically becomes Byte; other results remain Number.