JUMP
Move the instruction pointer (IP) to an arbitrary location.
| Opcode | Bytes | Cycles | Raw form | Jump example |
|---|---|---|---|---|
| $3C | 2 | 1 | ADD IP, {S_BYTE} | JUMP NEAR $12_3ABC |
| $90 | 3 | 1 | ADD IP, {S_PAIR} | JUMP FAR $12_3ABC |
| $B5 | 4 | 1 | MOVE IP, {U_TRIO} | JUMP FIXED $12_3ABC |
| $28 | 2 | 2 | MOVE IP, I:_ | JUMP I:4 |
Notes
-
Normally Chombit instructions are performed one by one in the order that they appear. In other words, after each operation, the instruction pointer (
IPregister) advances to the next instruction.JUMPallows other possibilities such as a loop or branch (when combined with IF). -
We consider
JUMPto be a "pseudo-instruction": The underlying implementation is actually a MOVE or ADD instruction involving theIPregister, but in Chombit source code, the jump target operand is more conveniently written as a label or memory address. The assembler calculates the actual jump offset (operand) by subtracting the jumping address from the target address, choosingNEARorFARorFIXEDto optimize the program size. This analysis is called branch-displacement optimization and involves multiple passes that converge to a solution. In other words,JUMPis really a concept introduced by the assembler, not a true machine instruction. -
Most CPU architectures include a "call" or "jump and link" instruction that allows a subroutine (function) to "return" to where we jumped from. Chombit accomplishes this using separate instructions PUSH RETURN IP and POP IP.
-
The
JUMP I:4form is used for calculated jumps such as Hybrix function pointers or virtual functions.