Section 05 Part 06 – The BSR Instruction

 

 “Some parents say it is toy guns that make boys warlike. But give a boy a rubber duck and he will seize its neck like the butt of a pistol and shout 'Bang!” ~George Will

 

 

 

Introduction

 

BSR – Branch to SubRoutine

 

The destination operand is added to the PC, the return address is moved into the stack, the 68k will continue reading at the new offset held in PC.

 

 

 

Examples

 

This is similar to JSR with a few minor differences (In fact, the same differences between BRA and JMP).  Here’s a small list as a quick example:

 

          bsr.s     Subroutine

          jmp       Continue

 

Subroutine:

          rts

 

Continue:

          ...etc

 

Now obviously:

 

 

That part you should know from reading Section 05 Part 05 (JSR and RTS).

 

Once again, the main difference between BSR and JSR, is memory and processing time.  The BSR instruction is similar to BRA in that you have two different sizes .s for short, and .w for word.

 

For “bsr.s”, the add value is only a byte big, and it is a signed value.  This means the maximum number of bytes it can branch forwards by is 7E, and the maximum it can branch backwards by is 80.  So obviously “bsr.s” cannot reach certain places where the JSR instruction can.

 

For “bsr.w”, the add value here is a word big and is also signed.  This now means the maximum number of bytes it can branch forwards by is 7FFE, and the maximum it can branch backwards by is 8000.

 

As you can see, the range is larger than “bsr.s”, but still smaller than the JSR instruction.

 

 

 

Usage

 

Just like BRA and JMP, with BSR and JSR you’ll be looking to use the quickest and smallest instructions you possibly can, below is a table to help narrow out the relationship between the two branch sizes and the jump:

 

Instruction

Memory/Size

Range

 

 

 

bsr.s

61 ??

7E bytes forwards or backwards

bsr.w

61 00 ?? ??

7FFE bytes forwards or backwards

jsr

4E B9 00 ?? ?? ??

000000 – FFFFFF (Unlimited)

 

Your priority of course is:

 

bsr.s -> bsr.w -> jsr

 

 

 

Previous Part

Main Page

Next Part