DDCO Assignment 2 by harsh
DDCO Assignment 2 by harsh
computer
1. Input: Data is entered into the computer via input devices (keyboard,
mouse, etc.).
2. Process: The central processing unit (CPU) processes the input data based
on instructions from software.
3. Output: The processed data is then presented to the user through output
devices (monitor, printer, etc.).
Q-2 ) What is performance measurement? Explain the basic performance
equation.
Performance Measurement
The terms Big Endian and Little Endian refer to how multi-byte data (e.g.,
integers) is stored in memory. Computers can represent numbers in multiple
bytes, and the ordering of these bytes determines the system's endianness.
Q-4) Explain basic instruction types with examples.
● Examples:
○ MOV (Move data between registers or memory).
○ LOAD (Load data from memory to a register).
○ STORE (Store data from a register to memory).
● Example for C ← A + B:
○ LOAD R1, A (Load value of A into register R1).
○ LOAD R2, B (Load value of B into register R2).
2. Arithmetic Instructions
● Examples:
○ ADD (Add two operands).
○ SUB (Subtract one operand from another).
○ MUL (Multiply two operands).
● Example for C ← A + B:
○ ADD R3, R1, R2 (Add values in R1 and R2, store the result in R3).
3. Logical Instructions
These instructions perform logical operations like AND, OR, XOR, and NOT.
● Examples:
○ AND (Logical AND).
○ OR (Logical OR).
○ NOT (Logical NOT).
● Usage in a Context: Logical instructions could be used to validate or
set flags before performing C ← A + B.
● Examples:
○ JMP (Jump to a specific instruction).
○ BEQ (Branch if equal).
○ CALL (Call a subroutine).
● Example for C ← A + B:
○ If a branch condition is required:
■ BEQ LABEL (Branch to LABEL if a condition is met).
5. Input/Output Instructions
These instructions are used to transfer data between the processor and I/O
devices.
● Examples:
○ IN (Input data from an I/O device).
○ OUT (Output data to an I/O device).
● Usage in Context: The result C can be stored in memory or sent to an
output device.
Q-5) Explain instruction execution straight-line sequencing and
Branching sequencing.
Instruction Execution
1. Fetch:
○ The Program Counter (PC) holds the memory address of the
next instruction to be executed.
○ The CPU fetches the instruction from the memory location
specified by the PC.
○ The fetched instruction is stored in the Instruction Register
(IR).
2. Decode:
○ The instruction in the IR is decoded to determine what
operation needs to be performed.
○ The Control Unit (CU) decodes the opcode (operation code) to
identify the type of instruction (e.g., arithmetic, logical, data
transfer).
○ The operands (if any) are extracted from the instruction.
3. Execute:
○ The CPU performs the operation specified by the decoded
instruction (e.g., arithmetic operation, data transfer).
○ If the instruction requires the use of registers or memory, the
CPU accesses those resources.
○ Once the execution is complete, the result is either stored in a
register or written back to memory.
4. Update PC:
○ The Program Counter (PC) is updated to point to the next
instruction to be fetched.
○ This may be incremented by the length of the current
instruction (often 1 word or byte).
This cycle continues for each instruction in the program, repeating as long
as there are instructions to execute.
Straight-Line Sequencing
Addressing Mode
Addressing mode refers to the way in which the operand (data) for an
instruction is specified. It determines how the address of the operand is
calculated and accessed. Addressing modes allow flexibility in programming by
enabling different ways to reference data.
● Formula:
Effective Address = Base Address + (Index Register)
● Example: Suppose we have an array stored in memory and we want to
access its elements using an index:
Q-8) What is DMA? Explain the use of a DMA controller in a computer
system, with a neat diagram.
The DMA controller is a hardware component that manages the direct data
transfer between peripherals and memory. It acts as an intermediary between
the system’s memory and I/O devices, taking over control of the data bus to
transfer data without requiring CPU involvement. The DMA controller uses
system buses (address bus, data bus, and control bus) to facilitate this transfer.
Interrupts
Example of Interrupts
Consider the scenario where you are typing on a keyboard and running a
program that’s calculating something. The keyboard can generate interrupts to
signal that a key has been pressed. The CPU will stop its current work, read the
keypress (interrupt handling), and then continue the calculation.
Sequence of Events:
A Mapping function is used to decide where data should be stored in the cache
memory. Cache memory is much faster than main memory, but it is smaller in
size, so only a portion of the data from main memory is stored in the cache. The
mapping function determines how the data from the main memory is
transferred to the cache and how it is retrieved.
When a CPU accesses data, the mapping function decides the location of the
data in the cache based on the address of the data in the main memory. The
objective of the mapping function is to efficiently utilize cache space and
improve data access speed.
1. Direct Mapping
In Direct Mapping, each block of main memory is mapped to exactly one cache
line. The mapping function uses the memory address to determine which cache
line a specific memory block will go into.
2. Associative Mapping
In Associative Mapping, any block of memory can be placed in any cache line.
There is no fixed mapping between memory blocks and cache lines. When a
memory block is accessed, the cache is searched to check if it is already loaded
in any cache line.
How it Works:
3. Set-Associative Mapping
How it Works:
Assumptions: