Skip to main content

JUMP

Move the instruction pointer (IP) to an arbitrary location.

OpcodeBytesCyclesRaw formJump example
$3C21ADD IP, {S_BYTE}JUMP NEAR $12_3ABC
$9031ADD IP, {S_PAIR}JUMP FAR $12_3ABC
$B541MOVE IP, {U_TRIO}JUMP FIXED $12_3ABC
$2822MOVE 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 (IP register) advances to the next instruction. JUMP allows other possibilities such as a loop or branch (when combined with IF).

  • We consider JUMP to be a "pseudo-instruction": The underlying implementation is actually a MOVE or ADD instruction involving the IP register, 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, choosing NEAR or FAR or FIXED to optimize the program size. This analysis is called branch-displacement optimization and involves multiple passes that converge to a solution. In other words, JUMP is 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:4 form is used for calculated jumps such as Hybrix function pointers or virtual functions.