bsr
Branch to subroutine
Pushes the return address onto the stack and branches to the specified address.
Sizes .b .s .w .l
Used in
- bsr, rts, link and unlkM68K assembly
- A subroutine with its arguments in registersM68K assembly
- Stack arguments and a stack frameM68K assembly
- Recursion: factorial and FibonacciM68K assembly
- Convert a number to a string in any baseM68K assembly
- Drawing shapes on the screenM68K assembly
- The snake gameM68K assembly
- Flappy ASMM68K assembly
- Play a WAV and a MIDI fileM68K assembly
- ChiptuneM68K assembly
XNZVC –––––
- Leaves every flag unchanged
Forms
bsr
Operands
label- A branch target, written as a label or address. The assembler calculates the relative displacement. More
The size sets the branch’s reach: about 128 bytes in either direction for .s (or .b), and 32 KB for .w. With no size, the assembler chooses .s for a known target when the short encoding can reach it. On the 68020, it chooses .l for a known target beyond .w reach. All other cases use .w, including forward references. On the 68020, .l reaches anywhere in memory. See long branches. On the 68000 and 68010, .l is treated as .w, as in EASy68K.
move.l #10, d0
bsr add_two
move.l d0, d1 ; d1 = 12
bra END
add_two:
addq.l #2, d0
rts
END: