jsr

Jump to subroutine

Pushes the return address onto the stack and jumps to the specified address.

XNZVC –––––
  • Changes no flag

Forms

Operands

<ea>
An operand using one of the addressing modes listed for this form. The list determines whether it can be a register, memory or an immediate value. With opt p=68020, an allowed d(An,Xn) or d(PC,Xn) mode also permits the corresponding 68020 indexed and memory indirect forms. See 68020 addressing. More

For example, jsr 4(a0) calls the code at a0 + 4. Like lea, it computes the destination address without reading data there; a 68020 memory indirect operand reads a pointer while computing it.

move.l #10, d0
jsr add_two ; pushes return address, jumps to subroutine
move.l d0, d1 ; d1 = 12 (returned from subroutine)

* --- JSR through address register ---
lea add_two, a0
jsr (a0)
move.l d0, d2 ; d2 = 14
bra END

add_two:
    addq.l #2, d0
    rts

END: