Coal Lab Exeersice-1

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Lab Exersices

1. Processors's Structure
Identify the different components of a CPU and their functions. Draw a block
diagram of a CPU and label each component?
CPU consist of 3 parts
Arithmetic Logic Unit (ALU) , Control Unit (CU) and Storage unit.
The CPU is like the heart/brain of the computer. The user does not get the desired output, without the
necessary option taken by the CPU. The Central processing unit (CPU) is responsible for the processing
of all the instructions which are given by the user to the computer system .
Control Unit
When the control unit receives an instruction set or information, it converts the instruction set to
control signals then; these signals are sent to the central processor for further processing. The control
unit understands which operation to execute, accurately, and in which order.
Arithmetic Logic Unit
The arithmetic and logical unit is the combinational digital electronic circuit that can perform arithmetic
operations on integer binary numbers.It presents the arithmetic and logical operation. The outputs of
ALU will change asynchronously in response to the input. The basic arithmetic and bitwise logic
functions are supported by ALU.
Storage Unit
It is used to store data as well address of current execution via registers and L1 cache.

2.Buses and Control unit


Explain the role of data , address , and control buses in data transfer. Describe
how the control unit manages the flow of instructions.
Data Bus
The data bus is a set of electrical lines or wires that are used to transfer actual data between different
components of a computer system. This data can include instructions, program data, or any other
information that needs to be moved between components.

Address Bus
The address bus is another set of electrical lines or wires that is used to specify the memory location or
the I/O (Input/Output) device to which data needs to be transferred or retrieved. In other words, it is
used to indicate the location of data.

Control Bus
The control bus is a set of lines used for control signals that manage the operation of various
components within the computer system. These control signals include read, write, memory enable, I/O
request, and various other control commands.

Control signals are essential for coordinating the timing and sequence of actions within the system, such
as when to read or write data, when to execute certain operations, and when to signal external devices
for input or output.
The control unit oversees instruction flow within the CPU. It fetches instructions from memory using the
program counter, decodes them to determine the operation and operands, and generates control
signals for execution. It manages the execution of instructions, coordinates data transfers using the
buses, and ensures instructions are executed in the correct sequence, thus facilitating efficient data
processing in the computer.

3.Program Execution Cycle


Simulate the fetch decode execute cycle for simple instruction use flow chart .
Instruction Fetch: It retrieves instructions from memory using the program counter (PC), which holds
the address of the next instruction. The fetched instruction is stored in an instruction register.

Instruction Decode: The control unit decodes the instruction to understand the operation and operands
involved. It generates control signals to execute the instruction.

Execution: It coordinates the execution of the instruction by controlling the Arithmetic Logic Unit (ALU)
and other relevant components in the CPU. It ensures that operations occur in the right sequence.

Memory Access: If the instruction involves data transfer to or from memory, the control unit uses the
address bus to specify the memory location and the data bus for data transfer.

Write-back: After execution, the control unit updates registers or memory as needed.

By consistently repeating these steps, the control unit manages the orderly execution of instructions,
ensuring that tasks are performed according to the program's instructions.
4.Introduction to assembly language
Write a simple assembly language code for adding 2 numbers and compare to its
high level languages equivalent code.
Assembly code

dosseg
.model small
.stack 100h
.data
.code
main proc
mov bl,2
mov dl,3
add dl,bl
add dl,48 ;ascii adjustment
mov ah,2
int 21h
mov ah,4ch
int 21h
main endp
end main

C++ Code
#include<iostream>
using namespace std;
void main()
{
cout<<2+3;
}
Both display 5 in result but C++ (high level language) code is easy to write and implement as compared
to assembly code

5.How processor read and interpret instructions


Analyze the memory organization of a computer system. Demonstrate the use of
different adressing modes in assembly language
The memory organization of a computer system typically consists of four main segments:
Code Segment: This is where the program's instructions are stored.
Data Segment: It holds data, including variables and constants used by the program.
Stack Segment: Used for managing function calls, local variables, and program execution flow.
Heap Segment: Used for dynamic memory allocation.

Addressing modes:

Immediate Mode: Values are directly specified in the instruction, e.g., MOV AX, 42 loads the value 42
into register AX.
Register Mode: Operands are stored in registers, offering fast access, e.g., ADD AX, BX adds the values in
registers AX and BX.
Direct Mode: Memory locations are directly accessed using addresses, e.g., MOV AL, [0x1234] loads the
value at memory address 0x1234 into register AL.

6.Components of CPU
Experiment with the arithmetic and logic operations of ALU .Investigate the role
of the control unit in managing CPU organization.
In an ALU (Arithmetic Logic Unit), arithmetic operations include addition, subtraction, multiplication, and
division, while logic operations involve bitwise operations like AND, OR, and NOT. The ALU performs
these operations based on control signals from the control unit.
The control unit manages CPU organization by coordinating instruction fetching, decoding, execution,
and memory access. It generates control signals that direct data flow within the CPU, ensuring
instructions are executed in the correct order and coordinating interactions with memory and
peripherals. It's a key component for efficient CPU operation.

7.CPU registers and Memory Segments


Write assembly language code to manipulate data using CPU registers.Acess and
modify data stored in different memory segment
Code present in exersice 4 is an example of code manipulation

You might also like