WITH
Enable a special behavior for the subsequent instruction.
| Opcode | Bytes | Cycles | Form | Example |
|---|---|---|---|---|
| $01 | 1 | 1 | WITH CARRY | WITH CARRY |
| $01 | 1 | 1 | WITH EUCLID | WITH EUCLID |
| Control flag | Output |
|---|---|
| with (WF) | This flag is always 1. |
Notes
-
Sets the with flag (WF) for the next instruction only. It will be automatically cleared afterwards.
-
For clarity, the assembly syntax uses
WITH CARRYorWITH EUCLIDaccording to the subsequent instruction, even though they share the same opcode. -
If the subsequent instruction is ADD, SUBTRACT, or COMPARE:
WITH CARRYincludes the carry flag (CF) in the calculation. See the instruction documentation for details. -
If the subsequent instruction is an DIVIDE:
WITH EUCLIDrequests Euclidean integer division instead of truncated division. See the instruction documentation for details. -
If the subsequent instruction is not one of the documented forms, the behavior is undefined apart from clearing the with flag (WF). Generally it has no effect; however, future versions may introduce additional behavior.
-
Unlike all other instructions,
WITHdoes not clear the skip flag (SF). This allows the pair of instructions to be skipped, for example:COMPARE I:0, 3
IF ZERO # DIVIDE ONLY IF I:0 EQUALS 3
WITH EUCLID
DIVIDE I:4, I:8