DSSSB TGT Computer Science – Operating System Organization | Kernels, System Calls, Process Models & Device Drivers

1. Introduction to Operating System Organization

An Operating System (OS) is system software that manages computer hardware and software resources and provides services to application programs.

Operating System Organization explains how the internal components of an OS are arranged and how they work together to manage processes, memory, devices and system services.

Simple example: When you open a music player, the OS allocates memory, schedules CPU time, accesses the audio device and manages the application. These activities are coordinated by OS components.

2. Factors in Operating System Design

Operating system design involves deciding how the OS should manage resources and provide services. Important considerations include:

  • Performance: The OS should use CPU, memory and devices efficiently.
  • Reliability: It should operate correctly and recover from errors where possible.
  • Security: It should protect data, processes and system resources from unauthorized access.
  • Resource management: CPU, memory, files and I/O devices must be allocated properly.
  • Scalability: The OS should support changing workloads and hardware capabilities.
  • Portability: The OS should be adaptable to different hardware platforms where designed to do so.
  • Usability: It should provide convenient ways for users and programs to interact with the system.
Exam point: OS design balances performance, reliability, security and efficient resource utilization.

3. Primary OS Functions

The operating system performs several major functions:

3.1 Process Management

A process is a program in execution. The OS creates, schedules, suspends and terminates processes. It also coordinates processes that need to share resources.

Example: Running a browser and a media player at the same time.

3.2 Memory Management

The OS keeps track of memory usage, allocates memory to processes and releases it when no longer needed.

Example: Allocating RAM to a newly opened application.

3.3 File Management

The OS manages files and directories. It supports operations such as creating, opening, reading, writing, renaming and deleting files.

3.4 Device and I/O Management

The OS coordinates input/output devices such as keyboards, printers, storage devices and monitors. Device drivers help the OS communicate with hardware.

3.5 Security and Protection

The OS controls access to system resources. Authentication checks identity, while authorization determines what an authenticated user or process is allowed to do.

3.6 Storage and Resource Management

The OS manages secondary storage and allocates available resources among competing processes.

3.7 User Interface and Networking

The OS may provide a command-line interface (CLI), graphical user interface (GUI), and networking facilities for communication between systems.

4. Implementation Consideration: Process Models

A process model describes how the operating system represents and manages executing programs.

4.1 Process

A process is an active instance of a program. A program stored on disk is passive; when it executes, it becomes a process.

4.2 Process Control Block (PCB)

The OS maintains information about each process in a data structure called the Process Control Block.

A PCB commonly contains:

  • Process ID (PID)
  • Process state
  • Program counter
  • CPU register information
  • Scheduling information
  • Memory-management information
  • I/O and file-related information
Remember: PCB stores the information required by the OS to manage and resume a process.

4.3 Process States

A common process-state model includes the following states:

StateMeaning
NewProcess is being created.
ReadyProcess is waiting for CPU allocation.
RunningProcess is currently executing on the CPU.
Waiting / BlockedProcess is waiting for an event or I/O operation.
TerminatedProcess has finished execution.

Typical flow:

New → Ready → Running → Terminated
                 ↓
              Waiting
                 ↓
               Ready

4.4 Context Switching

Context switching occurs when the CPU changes from executing one process to another. The OS saves the current process context and restores the context of the next process.

Example: The CPU stops executing Process A, saves its state, and starts executing Process B.

Exam point: Context switching enables multitasking but introduces overhead because saving and restoring process state takes time.

5. Kernels

The kernel is the central component of an operating system. It manages communication between software and hardware and performs essential system-level operations.

Major responsibilities of a kernel

  • Process and CPU management
  • Memory management
  • Device and I/O management
  • Handling system calls
  • Managing access to protected resources

Types of Kernel Architecture

TypeExplanation
Monolithic KernelMany OS services run in kernel space as part of a large kernel.
MicrokernelOnly essential services run in kernel space; other services run outside it.
Hybrid KernelCombines design ideas from monolithic and microkernel approaches.
Conceptual distinction: Kernel is the core of the OS. The operating system as a whole also includes other components and utilities.

User Mode and Kernel Mode

User ModeKernel Mode
Applications normally execute here.Core OS operations execute here.
Restricted access to hardware and protected resources.Privileged access to system resources.
Uses system calls to request OS services.Handles authorized system-service requests.

6. Methods of Requesting System Services

Application programs often need services that they cannot safely perform directly. They request these services from the OS through system calls.

A system call is a controlled interface between a user program and the operating system kernel.

How a system call works

  1. An application requests an OS service.
  2. The request is made through a system-call interface.
  3. Control transfers to the kernel through a controlled mechanism.
  4. The kernel performs the requested operation after checking the request.
  5. The result is returned to the application.
Application Program
       |
       | System Call
       v
System Call Interface
       |
       v
     Kernel
       |
       v
Hardware / OS Service
       |
       v
   Result Returned

Common Categories of System Calls

CategoryPurposeExample
Process controlCreate, execute or terminate processes.Process creation
File managementCreate, read, write and delete files.File read
Device managementRequest or release device resources.Device access
Information maintenanceObtain or update system information.Get process information
CommunicationExchange data between processes.Inter-process communication
ProtectionControl permissions and access.Permission checking
Important: A system call is not the same as an ordinary function call. A system call requests a service from the OS kernel.

7. Device Drivers

A device driver is software that allows the operating system to communicate with and control a particular hardware device or class of devices.

Different hardware devices may have different control commands and communication requirements. Drivers provide the software interface needed by the OS.

Examples

  • Printer driver – helps the OS communicate with a printer.
  • Graphics driver – supports communication with graphics hardware.
  • Audio driver – manages audio hardware interaction.
  • Network driver – enables communication with a network adapter.

How a device driver works

Application
    |
    v
Operating System
    |
    v
Device Driver
    |
    v
Hardware Device

Why are device drivers needed?

  • They translate OS requests into device-specific operations.
  • They help the OS control hardware.
  • They provide a consistent interface for device access.
  • They help manage device operations and errors.
Exam point: A device driver is software, not hardware. It acts as an interface between the operating system and a hardware device.

8. Quick Revision Table

TermRemember
KernelCore component of OS
PCBStores process information
Context switchingSwitching CPU execution between processes
System callRequest for an OS service
Device driverSoftware interface for hardware
User modeRestricted execution mode
Kernel modePrivileged execution mode
MicrokernelMinimal services in kernel space
Monolithic kernelMany services in kernel space

9. Interactive MCQ Test – 15 Questions

Select one answer for each question and click Submit Quiz to view your score and explanations.

10. Self-Assessment Checklist

  • Can I explain the factors involved in OS design?
  • Can I list the primary functions of an operating system?
  • Can I explain PCB and process states?
  • Can I define context switching?
  • Can I distinguish kernel mode and user mode?
  • Can I explain monolithic and microkernel architectures?
  • Can I describe how system calls work?
  • Can I explain the role of device drivers?
Next lesson: Day 2 – Lesson 3: Device Management — Service Management Approaches, Buffering, Device Drivers and Performance Tuning.

Study tip: First understand the kernel, system calls and device drivers. Then attempt the quiz without looking at the notes.

DSSSB TGT Computer Science – Computer Systems Architecture Complete Revision + 25 MCQ Mock Test


PART 1: COMPLETE REVISION NOTES

1. Computer Organization and Architecture

Computer Architecture describes the features visible to a programmer, such as instruction sets, addressing modes and data types.

Computer Organization describes how hardware components are connected and implemented.

ComponentFunction
CPUExecutes instructions
ALUArithmetic and logical operations
CUControls instruction execution
RegistersHigh-speed temporary storage
MemoryStores data and instructions
I/O DevicesCommunicate with external devices

Important CPU Registers

RegisterFunction
PCAddress of next instruction
IRCurrent instruction
MARMemory address
MDRData transferred to/from memory
ACCIntermediate arithmetic results
SPTop of stack

2. System Bus

A bus is a communication pathway connecting computer components.

BusFunction
Data BusTransfers data
Address BusCarries addresses
Control BusCarries control signals
Number of addressable locations = 2n

Example: A system has a 16-bit address bus.

216 = 65,536 distinct locations in a byte-addressable system.

PCI: Peripheral Component Interconnect is a standard for connecting peripheral devices to a computer system.

3. Computer Memory Organization

MemoryKey Property
SRAMFast; commonly used in cache
DRAMRequires refreshing; commonly used as main memory
ROMNon-volatile
PROMProgrammable once
EPROMErased using ultraviolet light
EEPROMElectrically erasable
FlashElectrically erasable in blocks

Memory Hierarchy:

Registers
    ↓
Cache Memory
    ↓
Main Memory (RAM)
    ↓
Secondary Storage
Cache Hit Ratio = Cache Hits / Total Accesses
Cache Miss Ratio = 1 − Hit Ratio

Example: 80 cache hits out of 100 accesses.

Hit Ratio = 80/100 = 80%

Miss Ratio = 20%

4. Advanced DRAM Organization

  • DRAM: Stores bits using capacitors and requires periodic refreshing.
  • SDRAM: Synchronous DRAM, operates in synchronization with a clock.
  • DDR SDRAM: Transfers data on both rising and falling clock edges.
  • Memory Banks: Divide memory into independently accessible sections.
  • Memory Interleaving: Organizes memory access across multiple banks to improve throughput.

5. Input/Output Organization

MethodWorking
Programmed I/OCPU repeatedly checks device status
Interrupt-driven I/ODevice interrupts CPU when attention is required
DMATransfers data between I/O and memory with reduced CPU involvement
I/O ChannelSpecialized processor/control mechanism for I/O operations
Exam Point: DMA stands for Direct Memory Access.

6. Computer Arithmetic

Unsigned 8-bit range:

0 to 28 − 1 = 0 to 255

Two's Complement 8-bit range:

−128 to +127

Example: Represent −12 in 8-bit two's complement.

Binary of 12:      00001100
Invert bits:       11110011
Add 1:             11110100

Answer:            11110100

IEEE 754 Floating-Point Representation

FormatSignExponentFraction
Single (32-bit)1 bit8 bits23 bits
Double (64-bit)1 bit11 bits52 bits

Exponent Bias:

  • Single precision = 127
  • Double precision = 1023
Actual Exponent = Stored Exponent − Bias

7. Instruction Sets

An instruction set is the collection of machine instructions supported by a processor.

ConceptMeaning
OpcodeSpecifies operation
OperandData or its location
Instruction FormatArrangement of instruction bits
Addressing ModeMethod of locating an operand
ISAInstruction Set Architecture

Addressing Modes

ModeKey Concept
ImmediateValue is inside instruction
DirectAddress is specified directly
IndirectAddress is obtained indirectly
RegisterOperand is in register
Register IndirectRegister contains memory address
IndexedBase address + index
RelativePC + displacement

Instruction Cycle

1. FETCH
     ↓
2. DECODE
     ↓
3. EXECUTE
     ↓
4. STORE / WRITE BACK

Instruction Pipelining

StageMeaning
IFInstruction Fetch
IDInstruction Decode
EXExecute
MEMMemory Access
WBWrite Back

Pipeline Hazards:

  1. Structural Hazard – Hardware resource conflict.
  2. Data Hazard – Dependency between instructions.
  3. Control Hazard – Branch or jump changes instruction flow.

PART 2: IMPORTANT FORMULA SHEET

TopicFormula
Addressable locations2n
Unsigned n-bit maximum2n − 1
Two's complement minimum−2n−1
Two's complement maximum2n−1 − 1
Cache hit ratioHits / Total Accesses
Cache miss ratio1 − Hit Ratio
Indexed addressBase + Index
Relative addressPC + Displacement
Actual exponentStored Exponent − Bias

PART 3: MOCK TEST – 25 MCQs

Instructions:
  • Total Questions: 25
  • Total Marks: 25
  • Each question carries 1 mark.
  • Select one correct answer.
  • Click Submit Test to see your score and explanations.
Attempted: 0/25
Your Result

PART 4: NUMERICAL PRACTICE

Try solving these five questions yourself. Click the button to reveal the answer and explanation.

1. A computer has a 12-bit address bus. How many locations can it address?
Answer: 4096 locations

212 = 4096.

2. Find the unsigned maximum value of a 10-bit number.
Answer: 1023

210 − 1 = 1023.

3. Calculate the cache miss ratio if the hit ratio is 95%.
Answer: 5%

Miss Ratio = 100% − 95% = 5%.

4. Find the effective address if base = 1500 and index = 75.
Answer: 1575

EA = Base + Index = 1500 + 75 = 1575.

5. In IEEE 754 single precision, find the actual exponent if the stored exponent is 135.
Answer: 8

Actual Exponent = 135 − 127 = 8.

PART 5: SELF-ASSESSMENT

Tick the topics you can explain without looking at your notes.

Completed: 0/10

LESSON COMPLETED

Day 1 – Computer Systems Architecture Revision Completed!

You have revised:

  • Computer Organization and Architecture
  • System Buses and PCI
  • Internal Memory and Cache
  • Advanced DRAM Organization
  • Input/Output Organization
  • Computer Arithmetic
  • Instruction Sets and Pipelining

Next Lesson: Day 2 – Operating System Overview.

DSSSB TGT Computer Science: Computer Systems Architecture – Complete Revision + 25 MCQ Mock Test

 

Part 1: Complete Revision Notes

1. Computer Organization and Architecture

Computer Architecture describes the features visible to a programmer, such as instruction sets, addressing modes and data types.

Computer Organization describes how hardware components are connected and implemented.

Component

Function

CPU

Executes instructions

ALU

Arithmetic and logical operations

CU

Controls instruction execution

Registers

High-speed temporary storage

Memory

Stores data and instructions

I/O devices

Communicate with external devices

Important registers

Register

Function

PC

Address of next instruction

IR

Current instruction

MAR

Memory address

MDR

Data transferred to/from memory

ACC

Intermediate arithmetic results

SP

Top of stack

2. System Bus

A bus is a communication pathway connecting computer components.

Bus

Function

Data Bus

Transfers data

Address Bus

Carries addresses

Control Bus

Carries control signals

Numerical example:

A system has a 16-bit address bus.

\[ 2^{16}=65,536 \]

Therefore, it can address 65,536 distinct byte locations in a byte-addressable system.

PCI: Peripheral Component Interconnect is a standard for connecting peripheral devices to a computer system.

3. Computer Memory Organization

Memory

Key property

SRAM

Fast; commonly used in cache

DRAM

Requires refreshing; commonly used as main memory

ROM

Non-volatile

PROM

Programmable once

EPROM

Erased using ultraviolet light

EEPROM

Electrically erasable

Flash

Electrically erasable in blocks

Memory hierarchy:

Registers → Cache → Main Memory → Secondary Storage.

As we move down the hierarchy, capacity generally increases and access speed generally decreases.

Cache formulas:

\[ Hit\ Ratio=\frac{Cache\ Hits}{Total\ Accesses} \]
\[ Miss\ Ratio=1-Hit\ Ratio \]

Example: 80 cache hits out of 100 accesses.

\[ Hit\ Ratio=80/100=0.8=80\% \]
\[ Miss\ Ratio=20\% \]

4. Advanced DRAM Organization

  • DRAM: Stores bits using capacitors and requires periodic refreshing.

  • SDRAM: Synchronous DRAM, operates in synchronization with a clock.

  • DDR SDRAM: Transfers data on both rising and falling clock edges.

  • Memory banks: Divide memory into independently accessible sections.

  • Memory interleaving: Organizes memory access across multiple banks to improve throughput.

5. Input/Output Organization

Method

Working

Programmed I/O

CPU repeatedly checks device status

Interrupt-driven I/O

Device interrupts CPU when attention is required

DMA

Transfers data between I/O and memory with reduced CPU involvement

I/O Channel

Specialized processor/control mechanism for I/O operations

Remember: DMA stands for Direct Memory Access.

6. Computer Arithmetic

Unsigned 8-bit range:

\[ 0 \text{ to } 2^8-1=255 \]

Two's complement 8-bit range:

\[ -128 \text{ to } +127 \]

Example: Represent -12 in 8-bit two's complement

  1. Binary of 12 = 00001100

  2. Invert bits = 11110011

  3. Add 1 = 11110100

Therefore:

\[ -12=11110100 \]

IEEE 754 floating-point representation

Format

Sign

Exponent

Fraction

Single precision (32-bit)

1 bit

8 bits

23 bits

Double precision (64-bit)

1 bit

11 bits

52 bits

Exponent bias:

  • Single precision = 127

  • Double precision = 1023

\[ Actual\ Exponent=Stored\ Exponent-Bias \]

7. Instruction Sets

An instruction set is the collection of machine instructions supported by a processor.

Concept

Meaning

Opcode

Specifies operation

Operand

Data or its location

Instruction format

Arrangement of instruction bits

Addressing mode

Method of locating an operand

ISA

Instruction Set Architecture

Addressing modes:

Mode

Key concept

Immediate

Value is inside instruction

Direct

Address is specified directly

Indirect

Address is obtained indirectly

Register

Operand is in register

Register Indirect

Register contains memory address

Indexed

Base address + index

Relative

PC + displacement

Instruction cycle: Fetch → Decode → Execute → Store/Write Back (where required).

Instruction pipeline stages:

  • IF – Instruction Fetch

  • ID – Instruction Decode

  • EX – Execute

  • MEM – Memory Access

  • WB – Write Back

Pipeline hazards:

  1. Structural hazard – resource conflict.

  2. Data hazard – dependency between instructions.

  3. Control hazard – branch or jump changes instruction flow.

Part 2: Important Formula Sheet

Topic

Formula

Addressable locations

\(2^n\)

Unsigned n-bit maximum

\(2^n-1\)

Two's complement minimum

\(-2^{n-1}\)

Two's complement maximum

\(2^{n-1}-1\)

Cache hit ratio

Hits / Total accesses

Cache miss ratio

1 − Hit ratio

Effective address (indexed)

Base + Index

Effective address (relative)

PC + Displacement

Actual exponent

Stored exponent − Bias


DSSSB TGT Computer Science

Day 1 – Lesson 7: Computer Systems Architecture

Complete Revision + Mock Test

Revise Computer Organization, Memory, DRAM, Input/Output, Computer Arithmetic and Instruction Sets.

Mock Test: 25 Questions | 25 Marks

PART 1: COMPLETE REVISION NOTES

1. Computer Organization and Architecture

Computer Architecture describes the features visible to a programmer, such as instruction sets, addressing modes and data types.

Computer Organization describes how hardware components are connected and implemented.

ComponentFunction
CPUExecutes instructions
ALUArithmetic and logical operations
CUControls instruction execution
RegistersHigh-speed temporary storage
MemoryStores data and instructions
I/O DevicesCommunicate with external devices

Important CPU Registers

RegisterFunction
PCAddress of next instruction
IRCurrent instruction
MARMemory address
MDRData transferred to/from memory
ACCIntermediate arithmetic results
SPTop of stack

2. System Bus

A bus is a communication pathway connecting computer components.

BusFunction
Data BusTransfers data
Address BusCarries addresses
Control BusCarries control signals
Number of addressable locations = 2n

Example: A system has a 16-bit address bus.

216 = 65,536 distinct locations in a byte-addressable system.

PCI: Peripheral Component Interconnect is a standard for connecting peripheral devices to a computer system.

3. Computer Memory Organization

MemoryKey Property
SRAMFast; commonly used in cache
DRAMRequires refreshing; commonly used as main memory
ROMNon-volatile
PROMProgrammable once
EPROMErased using ultraviolet light
EEPROMElectrically erasable
FlashElectrically erasable in blocks

Memory Hierarchy:

Registers
    ↓
Cache Memory
    ↓
Main Memory (RAM)
    ↓
Secondary Storage
Cache Hit Ratio = Cache Hits / Total Accesses
Cache Miss Ratio = 1 − Hit Ratio

Example: 80 cache hits out of 100 accesses.

Hit Ratio = 80/100 = 80%

Miss Ratio = 20%

4. Advanced DRAM Organization

  • DRAM: Stores bits using capacitors and requires periodic refreshing.
  • SDRAM: Synchronous DRAM, operates in synchronization with a clock.
  • DDR SDRAM: Transfers data on both rising and falling clock edges.
  • Memory Banks: Divide memory into independently accessible sections.
  • Memory Interleaving: Organizes memory access across multiple banks to improve throughput.

5. Input/Output Organization

MethodWorking
Programmed I/OCPU repeatedly checks device status
Interrupt-driven I/ODevice interrupts CPU when attention is required
DMATransfers data between I/O and memory with reduced CPU involvement
I/O ChannelSpecialized processor/control mechanism for I/O operations
Exam Point: DMA stands for Direct Memory Access.

6. Computer Arithmetic

Unsigned 8-bit range:

0 to 28 − 1 = 0 to 255

Two's Complement 8-bit range:

−128 to +127

Example: Represent −12 in 8-bit two's complement.

Binary of 12:      00001100
Invert bits:       11110011
Add 1:             11110100

Answer:            11110100

IEEE 754 Floating-Point Representation

FormatSignExponentFraction
Single (32-bit)1 bit8 bits23 bits
Double (64-bit)1 bit11 bits52 bits

Exponent Bias:

  • Single precision = 127
  • Double precision = 1023
Actual Exponent = Stored Exponent − Bias

7. Instruction Sets

An instruction set is the collection of machine instructions supported by a processor.

ConceptMeaning
OpcodeSpecifies operation
OperandData or its location
Instruction FormatArrangement of instruction bits
Addressing ModeMethod of locating an operand
ISAInstruction Set Architecture

Addressing Modes

ModeKey Concept
ImmediateValue is inside instruction
DirectAddress is specified directly
IndirectAddress is obtained indirectly
RegisterOperand is in register
Register IndirectRegister contains memory address
IndexedBase address + index
RelativePC + displacement

Instruction Cycle

1. FETCH
     ↓
2. DECODE
     ↓
3. EXECUTE
     ↓
4. STORE / WRITE BACK

Instruction Pipelining

StageMeaning
IFInstruction Fetch
IDInstruction Decode
EXExecute
MEMMemory Access
WBWrite Back

Pipeline Hazards:

  1. Structural Hazard – Hardware resource conflict.
  2. Data Hazard – Dependency between instructions.
  3. Control Hazard – Branch or jump changes instruction flow.

PART 2: IMPORTANT FORMULA SHEET

TopicFormula
Addressable locations2n
Unsigned n-bit maximum2n − 1
Two's complement minimum−2n−1
Two's complement maximum2n−1 − 1
Cache hit ratioHits / Total Accesses
Cache miss ratio1 − Hit Ratio
Indexed addressBase + Index
Relative addressPC + Displacement
Actual exponentStored Exponent − Bias

PART 3: MOCK TEST – 25 MCQs

Instructions:
  • Total Questions: 25
  • Total Marks: 25
  • Each question carries 1 mark.
  • Select one correct answer.
  • Click Submit Test to see your score and explanations.
Attempted: 0/25
Your Result

PART 4: NUMERICAL PRACTICE

Try solving these five questions yourself. Click the button to reveal the answer and explanation.

1. A computer has a 12-bit address bus. How many locations can it address?
Answer: 4096 locations

212 = 4096.

2. Find the unsigned maximum value of a 10-bit number.
Answer: 1023

210 − 1 = 1023.

3. Calculate the cache miss ratio if the hit ratio is 95%.
Answer: 5%

Miss Ratio = 100% − 95% = 5%.

4. Find the effective address if base = 1500 and index = 75.
Answer: 1575

EA = Base + Index = 1500 + 75 = 1575.

5. In IEEE 754 single precision, find the actual exponent if the stored exponent is 135.
Answer: 8

Actual Exponent = 135 − 127 = 8.

PART 5: SELF-ASSESSMENT

Tick the topics you can explain without looking at your notes.

Completed: 0/10

LESSON COMPLETED

Day 1 – Computer Systems Architecture Revision Completed!

You have revised:

  • Computer Organization and Architecture
  • System Buses and PCI
  • Internal Memory and Cache
  • Advanced DRAM Organization
  • Input/Output Organization
  • Computer Arithmetic
  • Instruction Sets and Pipelining

Next Lesson: Day 2 – Operating System Overview.

DSSSB TGT Computer Science: Instruction Sets – Machine Instructions, Addressing Modes, Register Organization & Instruction Cycle | Notes + MCQ Quiz

 

1. What is an Instruction Set?

An Instruction Set is the complete collection of machine-level instructions that a CPU can understand and execute.

It acts as an interface between software and hardware.

For example:

ADD R1, R2
SUB R3, R4
LOAD R1, 1000
STORE R1, 2000

These instructions tell the CPU what operation to perform and which data to use.

ISA (Instruction Set Architecture): The specification of instructions, registers, data types, addressing modes and other programmer-visible features of a processor.

Functions of an Instruction Set

  1. Performs arithmetic operations.

  2. Performs logical operations.

  3. Transfers data between registers and memory.

  4. Controls program execution.

  5. Supports input/output operations.

2. Characteristics of Machine Instructions

A machine instruction generally contains:

Component

Meaning

Opcode

Specifies the operation

Operand

Specifies the data or its location

Address field

Identifies a memory address or register

Addressing mode

Specifies how to locate the operand

Example:

ADD R1, R2
  • ADD = Opcode

  • R1, R2 = Operands

  • Operation = Add the contents of the registers.

Instruction length

Instruction length refers to the number of bits occupied by an instruction.

Examples:

  • 8-bit instruction

  • 16-bit instruction

  • 32-bit instruction

  • 64-bit instruction

Instruction formats may be fixed-length or variable-length, depending on the architecture.

3. Types of Operands

An operand is the data on which an instruction operates.

Common types include:

Operand type

Example

Address

Memory location 1000

Integer

25, -10

Floating-point

3.14, 5.75

Character

'A', 'B'

Logical/Boolean

TRUE, FALSE

Example:

ADD R1, R2

Here, the contents of R1 and R2 are the operands.

4. Types of Operations

Machine instructions can be classified according to the operations they perform.

Operation

Purpose

Example

Data transfer

Move data

MOV R1, R2

Arithmetic

Mathematical calculation

ADD R1, R2

Logical

Boolean operations

AND R1, R2

Shift

Shift bits

SHL R1

Control transfer

Change execution sequence

JMP LABEL

Input/Output

Communicate with devices

IN, OUT

Important exam point: Opcode identifies the operation that the CPU must perform.

5. Addressing Modes

Addressing modes specify how the CPU finds the operand required by an instruction.

This is an important examination topic.

A. Immediate Addressing

The operand is directly included in the instruction.

MOV R1, #25

Meaning: Put the value 25 into R1.

  • Operand value = 25

  • No separate memory lookup is needed to obtain the operand.

B. Direct Addressing

The instruction contains the memory address of the operand.

LOAD R1, 1000

Meaning: Load the data stored at memory address 1000 into R1.

If:

\[ M[1000] = 50 \]

Then:

\[ R1 = 50 \]

C. Indirect Addressing

The instruction refers to a memory location that contains the effective address of the operand.

Suppose:

\[ M[1000] = 2000 \]
\[ M[2000] = 75 \]

If the instruction uses indirect addressing through address 1000:

  • First, read address 1000.

  • It contains 2000.

  • Then read the operand from address 2000.

Therefore:

\[ Operand = 75 \]

D. Register Addressing

The operand is stored in a CPU register.

ADD R1, R2

The CPU uses the values already stored in R1 and R2.

E. Register Indirect Addressing

A register contains the memory address of the operand.

Suppose:

\[ R1 = 3000 \]
\[ M[3000] = 90 \]

The operand is 90.

F. Indexed Addressing

The effective address is calculated by adding an index value to a base address.

\[ EA = Base\ Address + Index\ Register \]

Example:

  • Base address = 1000

  • Index register = 20

\[ EA = 1000 + 20 = 1020 \]

G. Relative Addressing

The effective address is calculated using the program counter and a displacement.

\[ EA = PC + Displacement \]

Example:

  • PC = 500

  • Displacement = 20

\[ EA = 500 + 20 = 520 \]

This is commonly useful in branch instructions. The exact PC convention can vary by processor architecture.

Addressing Modes – Quick Revision

Mode

Operand location

Immediate

Inside instruction

Direct

Specified memory address

Indirect

Address stored in memory

Register

CPU register

Register Indirect

Memory address stored in register

Indexed

Base address + index

Relative

PC + displacement

6. Instruction Formats

An instruction format describes how the bits of a machine instruction are arranged.

A basic instruction can contain:

Example: General instruction format

Opcode

Operand 1

Operand 2

Illustrative format only; actual field sizes depend on the processor architecture.

Instruction formats based on address fields

Format

Description

Example

Three-address

Three address fields

ADD A, B, C

Two-address

Two address fields

ADD A, B

One-address

One explicit address

ADD A

Zero-address

No explicit address

ADD

Examples:

Three-address instruction

ADD R1, R2, R3

Meaning:

\[ R1 = R2 + R3 \]

Two-address instruction

ADD R1, R2

Meaning:

\[ R1 = R1 + R2 \]

One-address instruction

ADD X

In an accumulator-based architecture:

\[ AC = AC + M[X] \]

Zero-address instruction

ADD

In a stack-based architecture, the CPU takes the top two stack values, adds them and pushes the result back.

7. Register Organization

Registers are small, high-speed storage locations inside the CPU.

They temporarily hold data, addresses and instructions.

Important CPU Registers

Register

Full form / Function

PC

Program Counter – address of the next instruction

IR

Instruction Register – holds the current instruction

MAR

Memory Address Register – holds the memory address

MDR

Memory Data Register – holds data transferred to/from memory

ACC

Accumulator – stores intermediate arithmetic results

General-purpose registers

Store data and intermediate results

SP

Stack Pointer – points to the top of the stack

Remember these exam facts:

  • PC → Next instruction address.

  • IR → Current instruction.

  • MAR → Memory address.

  • MDR → Memory data.

  • SP → Stack top.

8. Instruction Cycle

The instruction cycle is the sequence of steps the CPU follows to process an instruction.

Instruction Cycle

1. Fetch

Get instruction from memory

2. Decode

Understand the instruction

3. Execute

Perform the required operation

4. Store / Write Back

Save the result when required

The CPU repeats the cycle for subsequent instructions. Memory access and write-back steps depend on the instruction.

Step 1: Fetch

The CPU fetches the instruction from memory.

A simplified sequence:

  1. PC contains the address of the next instruction.

  2. That address is transferred to MAR.

  3. The instruction is read from memory through MDR.

  4. The instruction is loaded into IR.

  5. PC is updated to the next instruction address.

Step 2: Decode

The Control Unit interprets the instruction and identifies the operation, operands and addressing mode.

Step 3: Execute

The CPU performs the operation using the ALU or another appropriate unit.

Step 4: Store / Write Back

The result is stored in a register or memory if required.

9. Instruction Pipelining

Instruction pipelining is a technique in which multiple instructions are processed in overlapping stages.

Without pipelining, the CPU may finish all stages of one instruction before starting the next.

With pipelining, different instructions can occupy different stages simultaneously.

Example: Five-stage pipeline

  • IF – Instruction Fetch

  • ID – Instruction Decode

  • EX – Execute

  • MEM – Memory Access

  • WB – Write Back

Illustrative pipeline timing

Each row represents one instruction; each column represents one clock cycle.

Instruction

1

2

3

4

5

6

7

I1

IF

ID

EX

MEM

WB

I2

IF

ID

EX

MEM

WB

I3

IF

ID

EX

MEM

WB

Illustrative schedule with no pipeline stalls.

Advantages of Pipelining

  1. Increases instruction throughput.

  2. Improves CPU performance.

  3. Makes better use of CPU processing stages.

Pipeline Hazards

A pipeline hazard is a condition that prevents the next instruction from executing in its intended clock cycle.

Hazard

Meaning

Structural hazard

Hardware resource conflict

Data hazard

Instruction depends on an earlier instruction's result

Control hazard

Branch or jump changes the instruction flow

Exam point: Pipelining improves instruction throughput, but it does not necessarily reduce the execution latency of an individual instruction.

10. Numerical Practice

Question 1: Indexed addressing

Given:

  • Base address = 2500

  • Index register = 40

Find the effective address.

\[ EA = Base + Index \]
\[ EA = 2500 + 40 = \boxed{2540} \]

Question 2: Relative addressing

Given:

  • PC = 1200

  • Displacement = 60

\[ EA = PC + Displacement \]
\[ EA = 1200 + 60 = \boxed{1260} \]

Question 3: Three-address instruction

Given:

\[ R1 = R2 + R3 \]

If R2 = 15 and R3 = 25:

\[ R1 = 15 + 25 = \boxed{40} \]

11. Important Exam Revision

Question

Answer

What identifies an operation?

Opcode

Which register stores the current instruction?

IR

Which register stores the next instruction address?

PC

Which register stores the memory address?

MAR

Which register holds memory data?

MDR

Which addressing mode stores data in the instruction?

Immediate

Which addressing mode uses PC + displacement?

Relative

Which unit decodes instructions?

Control Unit

Which unit performs arithmetic operations?

ALU

What improves instruction throughput?

Pipelining

Instruction Sets – MCQ Practice Test

15 Questions | 15 Marks | Select one correct answer for each question.