Unit 1 Bca 303 Group C & Group H
Unit 1 Bca 303 Group C & Group H
Prepared By:
Dr Tejinder Kaur
Associate Professor
Basics of Computer Architecture
Computer architecture is about designing a computer system
to balance performance, efficiency, cost, and reliability. It
describes how a system is built from its components. This can
be a high-level overview or a detailed explanation, including the
instruction set architecture, micro architecture, logic design,
and implementation
• There are several types of registers available in the CPU for different
purposes let's discuss each one by one:
• Accumulator : This is the most frequently used register used to store data
taken from memory. It is indifferent numbers in different microprocessors.
• General Purpose Registers : These are numbered as R0, R1, R2....Rn-1, and
used to store temporary data during any ongoing operation. Its content can be
accessed by assembly programming. Modern CPU architectures tend to use
more GPR so that register-to-register addressing can be used more, which is
comparatively faster than other addressing modes .
continue
• Program Counter (PC) : Program Counter (PC) is used to keep the track of the
execution of the program. It contains the memory address of the next instruction to be
fetched. PC points to the address of the next instruction to be fetched from the main
memory when the previous instruction has been successfully completed. Program
Counter (PC) also functions to count the number of instructions. The incrementation of
PCs depends on the type of architecture being used. If we are using a 32-bit
architecture, the PC gets incremented by 4 every time to fetch the next instruction.
• Instruction Register (IR): The IR holds the instruction which is just about to be
executed. The instruction from the PC is fetched and stored in IR. As soon as the
instruction is placed in IR, the CPU starts executing the instruction, and the PC points
to the next instruction to be executed.
• Stack Pointer (SP): The stack PCs pointer points to the top of the stack, which is a
part of the memory used to store function calls and other operations.
• Flag Register: A flag register , also known as a status register or condition code
register, is a special type of register in a computer's central processing unit (CPU) used
to indicate the status of the CPU or the outcome of various operations such as Zero
Flag, Carry flag, Sign Flag, Overflow Flag, Parity Flag, Auxiliary Carry Flag, and
Interrupt Enable Flag.
continue
• Size of CPU Register
• The number and size of the register in the CPU depend on the
processor design and can have an important impact on its
performance and capabilities on the CPU. Now, let's discuss the
different sizes of the register available in the CPU:
• 8-bit registers: These can store 8 bits of data, which is the same as 1
byte. They are used for simple arithmetic and data manipulation.
• 16-bit registers: These hold 16 bits of data, or 2 bytes. These
registers are found in older processors or certain systems that need
16-bit operations.
• 32-bit registers: These can store 32 bits of data or 4 bytes. They are
common in many processors and can handle larger data sizes and
more complex calculations than 8-bit or 16-bit registers.
• 64-bit registers: These hold 64 bits of data, or 8 bytes. Modern
processors often use these, providing more computational power and
better memory-addressing capabilities.
General Register Organization
continue
or example:
MULT R1, R2, R3
This is an instruction of an arithmetic multiplication written in assembly language. It uses three address fi
this instruction is:
R1 <-- R2 * R3
This instruction also can be written using only two address fields as:
MULT R1, R2
In this instruction, the destination register is the same as one of the source registers. This means the oper
R1 <-- R1 * R2
continue
• When we are using multiple general-purpose
registers, instead of a single accumulator register, in
the CPU Organization then this type of organization is
known as General register-based CPU Organization.
In this type of organization, the computer uses two or
three address fields in their instruction format. Each
address field may specify a general register or a
memory word. If many CPU registers are available for
heavily used variables and intermediate results, we
can avoid memory references much of the time, thus
vastly increasing program execution speed, and
reducing program size.
continue
• Features of a General Register based CPU organization:
• Registers: In this organization, the CPU contains a set of registers, which are
small, high-speed memory locations used to store data that is being processed by
the CPU. The general-purpose registers can be used to store any type of data,
including integers, floating-point numbers, addresses, and control information.
• Operand access: The CPU accesses operands directly from the registers, rather
than having to load them from memory each time they are needed. This can
significantly improve performance, as register access is much faster than
memory access.
• Data processing: The CPU can perform arithmetic and logical operations
directly on the data stored in the registers. This eliminates the need to transfer
data between the registers and memory, which can further improve performance.
• Instruction format: The instruction format used in a General Register based
CPU typically includes fields for specifying the operands and operation to be
performed. The operands are identified by register numbers, rather than memory
addresses.
• Context switching: Context switching in a General Register based CPU involves
saving the contents of the registers to memory, and then restoring them when the
process resumes. This is necessary to allow multiple processes to share the CPU.
CONTINUE
• The advantages of General register-based CPU
organization -
• The efficiency of the CPU increases as large number of
registers are used in this organization.
• Less memory space is used to store the program since
the instructions are written in a compact way.
• The disadvantages of General register based CPU
organization -
• Care should be taken to avoid unnecessary usage of
registers. Thus, compilers need to be more intelligent in
this aspect.
• Since a large number of registers are used, thus extra
cost is required in this organization.
Computer instructions
• Basic Computer Instructions
• Basic computer instructions are commands given
to a computer to perform specific tasks. These
instructions are typically divided into three
categories:
• Data Transfer Instructions: Move data between
memory and registers (e.g., Load, Store).
• Arithmetic and Logic Instructions: Perform
math or logic operations (e.g., Add, Subtract, AND,
OR).
• Control Instructions: Guide the flow of the
program (e.g., Jump, Branch, Call).
continue
• Data Transfer Instructions
• These instructions deal with moving data from one
location to another within the computer. Think of it
as copying or transferring information between
various components like memory, registers, or
storage.
• Common Data Transfer Instructions:
• Load: Copies data from memory to a register
(temporary storage inside the CPU).
• Store: Transfers data from a register to memory.
• Move: Transfers data from one register to another.
continue
• Arithmetic and Logic Instructions
• These instructions are used to perform
mathematical and logical operations. They
enable computers to handle calculations and
make decisions based on certain conditions.
• Arithmetic Instructions:
• Add: Adds two numbers.
• Subtract: Subtracts one number from another.
• Multiply: Multiplies two numbers.
• Divide: Divides one number by another.
continue
• Logic Instructions:
• AND: Compares two bits and returns 1 if
both are 1; otherwise, returns 0.
• OR: Compares two bits and returns 1 if at
least one is 1.
• NOT: Inverts a bit (1 becomes 0, and 0
becomes 1).
• XOR (Exclusive OR): Returns 1 if the
bits are different, 0 if they are the same.
continue
• Control Instructions
• Control instructions determine the flow of execution in a
program. They guide the computer on which instruction to
execute next, allowing flexibility in decision-making and
repeated actions.
• Common Control Instructions:
• Jump (JMP): Directs the program to execute a specific
instruction elsewhere in the code.
• Conditional Branch: Jumps to another instruction only if a
specific condition is true. Example: Branch if zero (BZ) or
branch if not zero (BNZ).
• Call: Transfers control to a subroutine (a set of instructions
performing a specific task) and returns afterward.
• Return: Brings back control to the main program after a
subroutine is executed.
Instruction Cycles,
Each phase of Instruction Cycle can be
decomposed into a sequence of elementary
micro-operations. In the above examples,
there is one sequence each for the Fetch,
Indirect, Execute and Interrupt Cycles.
continue
• Fetch cycle: This cycle retrieves the instruction from memory and
loads it into the processor's instruction register. The fetch cycle is
essential for the processor to know what instruction it needs to
execute.
• Decode cycle: This cycle decodes the instruction to determine
what operation it represents and what operands it requires. The
decode cycle is important for the processor to understand what it
needs to do with the instruction and what data it needs to retrieve
or manipulate.
• Execute cycle: This cycle performs the actual operation specified
by the instruction, using the operands specified in the instruction or
in other registers. The execute cycle is where the processor
performs the actual computation or manipulation of data.
• Store cycle: This cycle stores the result of the operation in memory
or in a register. The store cycle is essential for the processor to
save the result of the computation or manipulation for future use.
Memory reference instruction,
Memory reference instructions (MRIs)
are a type of machine language instruction
that allows a program to access and
manipulate data stored in memory. These
instructions provide the memory address
where the data resides or where the data
should be stored. They are crucial for
operations like loading data into registers,
storing data from registers into memory,
and performing arithmetic and logical
continue
• Data Access:
• Memory reference instructions are crucial for fetching data
needed for computations or storing the results of calculations
back into memory.
• Program Control:
• They can also be used to control the flow of execution by
branching to different memory locations based on conditions.
• Key Components:
• Opcode: Specifies the operation to be performed (e.g., load,
store, add, branch).
• Address: Indicates the specific memory location the
instruction refers to.
• Addressing Mode: Determines how the address is calculated
(e.g., direct or indirect).
continue
• Common Examples:
• Load (LDA): Transfers data from a memory location to a register
(often the accumulator).
• Store (STA): Transfers data from a register to a memory location.
• Add (ADD): Adds the contents of a memory location to the
accumulator.
• Branch (BUN, BSA): Changes the program's flow by jumping to a
different memory address.
• Increment and Skip if Zero (ISZ): Increments a memory location
and skips the next instruction if the result is zero.
• Importance:
• Memory reference instructions are fundamental to the operation of
any computer system, enabling it to work with data stored in
memory.
• They are essential for executing complex programs and performing
various tasks.
Input / Output instructions.
Input/output (I/O) instructions in computer
architecture are used to transfer data
between the C Input / Output instructions
PU and peripheral devices like keyboards,
monitors, and storage devices. These
instructions facilitate communication
between the computer system and the
external world, enabling the system to
receive data from users and send data to
users or other systems.
continue
• I/O instructions allow the CPU to
communicate with peripheral devices, like
keyboards, printers, or hard drives.
• 🧩 Types of I/O Techniques
• Programmed I/O: CPU waits and checks the
device status until it’s ready.
• Interrupt-driven I/O: Device notifies CPU via
an interrupt when ready.
• Direct Memory Access (DMA): Device
transfers data directly to memory without CPU
intervention.