0% found this document useful (0 votes)
4 views9 pages

Unit V Notes

The document outlines the basic structure of computer hardware and system software, detailing components such as input/output devices, CPU, memory, and the types of system software including operating systems and utility software. It also explains addressing methods in computer architecture, the instruction cycle, and different I/O organization methods like programmed I/O, interrupt-driven I/O, and direct memory access. Additionally, it covers the significance of interrupts and the relationship between hardware and software in executing programs efficiently.

Uploaded by

Hifa Islam
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views9 pages

Unit V Notes

The document outlines the basic structure of computer hardware and system software, detailing components such as input/output devices, CPU, memory, and the types of system software including operating systems and utility software. It also explains addressing methods in computer architecture, the instruction cycle, and different I/O organization methods like programmed I/O, interrupt-driven I/O, and direct memory access. Additionally, it covers the significance of interrupts and the relationship between hardware and software in executing programs efficiently.

Uploaded by

Hifa Islam
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Basic Structure of Computer Hardware and System Software: A computer system consists

of hardware and software, which work together to perform various tasks.

Hardware: The physical components of a computer that you can touch.

Software: Programs and instructions that tell the hardware what to do.

1. Computer Hardware: Computer hardware can be classified into the following main
components:

1.1. Input Devices: These devices allow the user to enter data into the computer.

e.g. Keyboard, Mouse, Scanner, Microphone, Webcam.

Function: Converts user input into a format the computer can process.
1.2. Output Devices: These devices display the results of computer processing.

e.g. Monitor, Printer, Speakers, Projector.

Function: Converts processed data into human-readable form.

1.3. Central Processing Unit (CPU): The CPU is the brain of the computer that performs
instructions of programs.

Components of CPU:

1. Arithmetic Logic Unit (ALU): Performs arithmetic (add, subtract, multiply, divide) and
logical operations (comparisons).

2. Control Unit (CU): Directs and coordinates all computer operations by controlling the
flow of data between CPU, memory, and peripherals.

3. Registers: Small, fast storage locations within the CPU used for temporary data and
instruction storage.

1.4. Memory: Memory stores data and instructions temporarily or permanently.

Primary Memory (RAM, ROM):

RAM (Random Access Memory): Volatile memory used for temporary storage while the
computer is running.

ROM (Read-Only Memory): Non-volatile memory that stores permanent instructions like
BIOS.

Secondary Memory (Hard Disk, SSD, Optical Discs): Non-volatile storage for long-term
data.

Cache Memory: Fast memory located inside or near the CPU to speed up access to
frequently used data.

Storage Devices: Hard Disk Drive (HDD), Solid State Drive (SSD), USB drives,
CDs/DVDs.
Function: Store large amounts of data permanently.

[Link] Devices: Network Interface Cards (NIC), Modems, Routers.

Function: Facilitate communication between computers over networks.

2. System Software: System software is a set of programs that manage hardware resources
and provide an environment for application software to run.

Types of System Software

2.1. Operating System (OS):


Examples: Windows, Linux, macOS, Android.

Functions:

• Manages hardware resources (CPU, memory, I/O devices).


• Provides a user interface (UI).
• Handles file management and system security.
• Controls execution of applications.
2.2. Utility Software: Provides maintenance and optimization functions.

Examples: Antivirus, Disk Defragmenter, Backup tools.

2.3. Device Drivers: Programs that allow the OS to communicate with hardware devices.

Example: Printer driver, Graphics driver.

Relationship Between Hardware and System Software: Hardware cannot operate without
software. System software acts as a bridge between hardware and application software.

Example: When you print a document, the OS uses the printer driver (system software) to
communicate with the printer (hardware).

Addressing Methods in Computer Architecture

Addressing methods (or addressing modes) define how the operand of an instruction is chosen
or accessed in a computer system. Operand: The data on which the instruction operates.
Addressing method determines where the operand is located (memory, register, or immediate
value).

Classification of Addressing Methods: Addressing methods can be broadly classified into 4


main types:

1. Immediate Addressing

2. Direct Addressing
3. Indirect Addressing

4. Register Addressing
5. Register Indirect Addressing

6. Indexed Addressing

7. Base-Register Addressing

8. Relative Addressing
Immediate Addressing:

The operand is directly specified in the instruction itself.

MOV A, #5` → Move the value 5 into register A.

Features: Fastest method (no memory access needed).

Operand is constant and cannot change during execution.

Use Case: Loading constants or initializing variables.

Direct Addressing: The instruction contains the address of the operand in memory.
Example: `MOV A, 2000` → Move the value stored at memory location 2000 to register A.
Features: Simple and easy to understand.

Access time depends on memory speed.

Use Case: Accessing global variables or specific memory locations.

Indirect Addressing: The instruction specifies a memory location or register that contains the
effective address of the operand.

Example: `MOV A, (R1)` → Move the value from the memory location whose address is in
register R1 to register A.

Features: More flexible; allows dynamic data access.

Slower than direct addressing (requires extra memory access).

Use Case: Accessing arrays, linked lists, or pointers.

Register Addressing: Operand is stored in a register.

Example: `ADD A, B` → Add the contents of register B to register A.


Features: Very fast (register access is faster than memory).

Limited by the number of registers.

Use Case: Temporary data storage and fast computations.

Register Indirect Addressing: The instruction specifies a register that contains the address of
the operand in memory.
Example: `MOV A, (R2)` → Move the value from memory location pointed by R2 to register
A.

Features: Combines flexibility of memory with speed of registers.

Use Case: Accessing dynamic data structures.

Indexed Addressing: The effective address of the operand is computed by adding a constant
(offset) to the contents of a register (index register).

Example: `MOV A, 2000(R1)` → Address = 2000 + content of R1.

Features: Efficient for accessing array elements.

* Useful in loops.
Use Case: Iterating through arrays or tables.

Base-Register Addressing: The effective address = content of a base register + constant


displacement.
Example: `MOV A, 1000(BR)` → Address = 1000 + content of Base Register.

Features: Supports relocation of programs in memory.

Use Case: Memory management and modular programming.

Relative Addressing: Operand address = program counter (PC) + offset.

Example: `JMP +10` → Jump 10 instructions ahead of the current PC.

Features: Useful for branching within a program. Allows position-independent code.

Use Case: Loops, conditional statements, and jumps.


Comparison of Addressing Methods:

Addressing Method Operand Location Speed Use Case


Immediate Instruction itself Fast Constants,
initialization
Direct Memory Medium Global variables
Indirect Memory via pointer Slower Dynamic data,
pointers
Register CPU Register Fastest Temporary data
Register Indirect Memory via register Medium Dynamic data,
arrays
Indexed Base + offset Medium Arrays, tables
Base-Register Base + displacement Medium Relocatable
programs
Relative PC + offset Medium Branching, loops
Machine Program Sequencing: Machine program sequencing refers to the order in which
instructions are executed by the CPU. It is fundamental to understanding how computers
execute programs. Modern computers do not always execute instructions strictly sequentially
due to features like branching and pipelining.
Instruction Cycle: Execution of a program involves repeating the instruction cycle:

1. Fetch: Retrieve the instruction from memory.

2. Decode: Interpret the instruction to determine the operation and operands.

3. Execute: Perform the operation using ALU, registers, or memory.

4. Store: Write the result back to memory or registers.

The instruction cycle is repeated for every instruction in the program.

The Instruction Cycle is the basic operational process of a computer’s CPU, referring to the
sequence of steps it follows to fetch, decode, and execute each machine-level instruction. This
cycle happens millions or even billions of times per second, ensuring proper execution and
smooth system operation.

Key Registers Used in the Instruction Cycle:

Several registers inside the CPU are actively involved in carrying out the instruction cycle:

Program Counter (PC): Holds the address of the next instruction to be executed. Automatically
increments after fetching an instruction.

Instruction Register (IR): Holds the instruction currently being executed.

Memory Address Register (MAR) (optional): Holds the address of the memory location being
accessed.

Memory Data Register (MDR) (optional): Holds the data read from or written to memory.

Fetch Cycle: The Fetch Cycle is the first step in the instruction cycle. Here, the CPU retrieves
the instruction from memory using the Program Counter (PC).

Steps in Fetch Cycle:

The address in PC is transferred to MAR.


Control Unit sends a read signal to memory.

The instruction at that memory address is placed into MDR.

MDR contents are transferred to IR.

PC is incremented to point to the next instruction.

Example:
Instruction: LOAD 500
PC = 100
IR ← Memory[100]
PC ← PC + 1
After this cycle, IR contains the instruction LOAD 500. PC now points to the next instruction.
Decode Cycle: In the Decode Cycle, the Control Unit interprets the fetched instruction stored
in the IR.

Steps in Decode Cycle:


Control Unit checks the opcode part of the instruction.

Determines what operation to perform.

Identifies the operand(s) or registers involved.

Example:

IR = LOAD 500

Control Unit:

Opcode = LOAD
Operand = 500

Here, LOAD indicates the operation. 500 is the address of the data to be loaded.

Execute Cycle: Finally, the Execute Cycle performs the actual operation determined during
the decode stage.

Steps in Execute Cycle:

Depending on the opcode, the CPU perform operations.

Perform arithmetic or logical operations via the ALU.

Transfer data between memory and registers.

Change the sequence of execution (e.g., jump instructions).

Example:
LOAD 500

Accumulator ← Memory[500]

After execution, the cycle can begin again with the next instruction.
Interrupts: Interrupts are signals that temporarily pause the normal program sequence.

CPU executes a special routine called an Interrupt Service Routine (ISR).

Types of interrupts:

1. Hardware Interrupt: Generated by hardware devices (keyboard, timer).


2. Software Interrupt: Generated by software instructions.

```

Current instruction → Interrupt → Execute ISR → Resume original instruction

```

Looping: Instructions may be repeated multiple times using conditional branches. Enables
iteration without rewriting instructions multiple times.

Example:

```

LOOP_START:

Instruction
DEC Counter

JNZ LOOP_START

```

JNZ = Jump if Not Zero; loops until counter becomes zero.

Program Counter (PC): The PC register holds the address of the next instruction to execute.
Normally increments sequentially. Modified by branching, subroutine calls, and interrupts to
change program sequence.

Machine program sequencing controls the order of instruction execution. Default execution is
sequential but can be altered by:

* Branching (conditional/unconditional)

* Subroutine calls and returns

* Interrupt handling

* Loops

* Program Counter (PC): is central to maintaining the next instruction address.

Proper sequencing ensures correct program execution and enables features like decision-
making, iteration, and multitasking.
Input-Output (I/O) Organization and Accessing I/O Devices: Input-output organization deals
with how the CPU communicates with peripheral devices such as keyboards, printers, disks,
and monitors. I/O devices allow the computer to interact with the external world. I/O operations
must be efficient to avoid CPU idle time.
2. Methods of Accessing I/O Devices: There are three primary ways the CPU can access I/O
devices:

2.1 Programmed I/O (Polling): The CPU actively waits and checks whether the I/O device is
ready. CPU repeatedly polls a status register in the device.

Steps:
1. CPU issues a read/write command to I/O device.

2. CPU continuously checks the status flag of the device.

3. When ready, data is transferred between CPU and device.

Advantages: Simple to implement.

Disadvantages: CPU wastes time waiting (inefficient).

2.2 Interrupt-Driven I/O: I/O devices send an interrupt signal to the CPU when they are ready.
CPU can continue other tasks until interrupted.

Steps:

1. CPU initiates I/O operation and continues other tasks.

2. When I/O device is ready, it sends an interrupt.


3. CPU stops current execution and services the device.
Advantages: Efficient CPU usage; avoids busy waiting.

Disadvantages: Slight overhead in context switching.

2.3 Direct Memory Access (DMA): DMA allows data transfer directly between memory and
I/O devices without continuous CPU involvement. CPU initiates the transfer and is free to
perform other tasks.

Steps:

1. CPU programs the DMA controller with source, destination, and transfer size.

2. DMA controller transfers data between memory and I/O device.

3. DMA controller interrupts CPU after transfer completion.

Advantages:

* Speeds up data transfer for large blocks.


* Reduces CPU load.
Example: Disk-to-memory transfer using DMA is faster than programmed I/O.

3. I/O Organization: I/O organization defines how CPU, memory, and I/O devices
communicate.

3.1 Isolated I/O (Port-Mapped I/O): I/O devices have separate address space from memory.
Special CPU instructions are used to access I/O ports (e.g., `IN`, `OUT`).

3.2 Memory-Mapped I/O: I/O devices are assigned memory addresses in the main address
space. Same instructions as memory read/write are used.

Advantage: Simplifies CPU instruction set.

4. Interrupts: Interrupts are signals sent by hardware or software to gain CPU attention.

4.1 Types of Interrupts:

1. Hardware Interrupt: Generated by I/O devices (e.g., keyboard, timer).

2. Software Interrupt (Trap): Generated by instructions (e.g., system calls, divide by


zero).

4.2 Interrupt Handling:


Steps:

1. CPU completes the current instruction.

2. CPU saves the current program counter (PC) and status.

3. CPU jumps to Interrupt Service Routine (ISR).

4. ISR executes and returns control to the original program.

Advantages of Interrupts:

* Efficient CPU utilization.


* Allows asynchronous I/O operations.

Comparison of I/O Methods:

I/O Method CPU Involvement Speed Suitable For


Programmed I/O High (busy waiting) Slow Small data transfer
Interrupt-Driven I/O Moderate Medium Moderate size data
Direct Memory Low Fast Large block data
Access transfer

You might also like