Skip to content
The Computer Science
TheCScience
  • Engineering Subjects
    • Human Values
    • Computer System Architecture
    • Digital Communication
    • Internet of Things
  • NCERT Solutions
    • Class 12
    • Class 11
  • HackerRank solutions
    • HackerRank Algorithms Problems Solutions
    • HackerRank C solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
The Computer Science
TheCScience

Subroutine In Computer Architecture

YASH PAL, March 1, 2026March 1, 2026

Subroutine in Computer Architecture – In a computer program, the same piece of code might be written again in many different parts. The common code is written only once. A set of common instructions that can be used in a program many times is called a subroutine.

Each time a subroutine is used in the main program, a branch is made to the beginning of the subroutine. The branch can be made from any part of the main program. It is necessary to store the return address somewhere in the computer for the subroutine to know where to return. In the basic computer, the link between the main program and a subroutine is the BSA instruction (branch and save return address).

The first memory location of each subroutine serves as a link between the main program and the subroutine. The procedure for branching to a subroutine and returning to the main program is referred to as a subroutine linkage. The BSA instruction performs the call, and the BUN instruction performs the return.

Let’s take an example program to demonstrate the use of subroutines.

Location
ORG 100/Main program
100LDA X/Load X
101BSA SH4/Branch to subroutine
102STA X/Store shifted number
103LDA Y/Load Y
104BSA SHA/Branch to subroutine again
105STA Y/Store shifted number
106HLT
107X,HEX 1234
108Y,HEX 4321
/Subroutine to shift left 4 times
109SH4,HEX 0/Store return address here
10ACIL/Circulate left once
10BCIL
10CCIL
10DCIL/Circulate left fourth time
10EAND MSK/Set AC (13-16) to zero
10FBUN SH4 1/Return to main program
110MSK,HEX FFF0/Mask operand
END

When a subroutine is called, the main program must transfer the data it wishes the subroutine to work with. It is necessary for the subroutine to have access to data from the calling program and to return results to that program. The accumulator can be used for a single input parameter and a single output parameter.

In computers with multiple processor registers, more parameters can be transferred this way. Another way to transfer data to a subroutine is through the memory. Data are often placed in memory locations following the call. They can also be placed in a block of storage. The first address of the block is then placed in the memory location following the call. In any case, the return address always gives the link information for transferring data between the main program and the subroutine.

Computer System Architecture engineering subjects Computer System Architecture

Post navigation

Previous post
Next post

Computer Architecture fundamentals
Basic structure of a computer
Functional Units of Computer
Development of Computers
Von Neuman and Harvard machine Architecture
Flynn Classification
Computer Structure Architecture
Interfacing Logic Devices
Levels of Design abstraction
Performance Metrics

Register Transfer Language
Memory Transfer
Arithmetic Micro-operations
Arithmetic Complements
Logic Micro-operations
Shift Micro-operations
Bus Architecture
Data Transfer
Central Processing Unit
CPU Bus Architecture

Computer Register and Types
Common Bus System
Instruction Format
Instruction Types
Instruction Cycle
Addressing Modes
Design of a basic computer

Basic function of a Computer
General register organization
Stack organization
Infix to Reverse Polish Notation Conversion
Instruction Types and their classifications
Data transfer and manipulation
Program control
RISC characteristics
CISC characteristics

Pipeline
Types of Pipeline
Arithmetic Pipeline
Instruction Pipeline
Hazards
Vector Processing

Data Representation
Addition and Subtraction
Adder Circuits
Shift and Add Multiplication Method
Booth's Algorithm
Restoring Division Algorithm
Non-Restoring Division Algorithm
Array Multiplier

Memory Classification
Memory Characteristics
Memory Organization
Memory Types
Associative Memory
Cache Memory
Virtual Memory

Input Output Interface
Modes of Data Transfer
Priority Interrupt
Direct Memory Access
Input-Output Processor
Serial Communication

TheCScience

We at TheCScience.com are working towards the goal to give free education to every person by publishing in dept article about Secondary, Senior-Secondary, and Graduation level subjects.

Pages

About US

Contact US

Privacy Policy

DMCA

Our Tools

Hosting - get 20% off

Engineering Subjects

Internet of Things

Human Values

Digital Communication

Computer System Architecture

Programming Tutorials

Data Structure and Algorithm

C

Java

NCERT

Class 12th

©2026 TheCScience | WordPress Theme by SuperbThemes