BSA: Branch and Save Return Address

Understanding Memory Reference Instructions

📋 Overview

The BSA (Branch and Save Return Address) instruction is a fundamental operation in computer architecture used for subroutine calling. It enables branching to a subroutine while preserving the return address for later continuation.

M[AR] ← PC, PC ← AR + 1

This instruction, expressed in register transfer notation, demonstrates how the return address is saved before jumping to the subroutine.

🎯 Instruction Tabs

Execution Process

1
The current value of the Program Counter (PC) is stored at the memory address specified by the Address Register (AR)
2
The effective address plus one (AR + 1) is transferred to PC
3
Program execution continues at the new PC address (subroutine entry point)
4
The return address is stored at the first location of the subroutine
⚠️ Important Note:

BSA cannot be executed in one clock cycle due to bus system limitations. It requires a sequence of two microoperations with appropriate timing signals.

Numerical Example: BSA at Address 20

Consider the instruction BSA 135 located at address 20:

BSA Execution
Address 20
BSA 135
Address 21
Next Instruction
Address 135
21 (saved)
Address 136
Subroutine Start
1
Fetch BSA instruction from address 20
2
M[135] ← 21 (save return address)
3
PC ← 136 (branch to subroutine)
4
Execute subroutine starting at 136
5
BUN indirect at 135 returns to address 21
💡 Key Insight:

The return address (21) is stored at the subroutine entry point (135), and the PC is set to 136 (AR + 1) to begin execution of the subroutine body.

Timing Sequence

The BSA instruction requires two microoperations:

D₅T₄: M[AR] ← PC, AR ← AR + 1
D₅T₅: PC ← AR, SC ← 0
⏱️ Timing Breakdown:
  • T₄: Initiates memory write, places PC content onto bus, enables INR input of AR
  • T₅: Completes memory write, transfers AR to PC by next clock transition

Memory Reference Instructions Flowchart

Control sequence for memory reference instructions including BSA:

Memory Instruction Flow
🔄 Subroutine Return:

The BUN instruction at the end of the subroutine performs an indirect jump: PC ← M[AR], which retrieves the saved return address and continues execution at the original calling point.

🎮 Interactive Demo

Simulate BSA instruction execution:

PC (Program Counter)
20
AR (Address Register)
135
Memory[135]
—
SC (Sequence Counter)
0
Step: Initial state - Ready to execute BSA 135

🔍 Other Memory Reference Instructions

AND
AC ← AC ∧ DR
ADD
AC ← AC + DR
LDA
AC ← DR
STA
M[AR] ← AC
BUN
PC ← AR
ISZ
M[AR] ← M[AR] + 1
if (M[AR] = 0)
then PC ← PC + 1
Start Register Reference Instruction