0% found this document useful (0 votes)
3 views

CPU

The document provides an overview of the Central Processing Unit (CPU), detailing its components such as registers, the Arithmetic Logic Unit (ALU), and the Control Unit, which work together to perform arithmetic, logic, and control operations. It explains the microprocessor's evolution, the significance of 64-bit x86 architecture, and the role of various registers in instruction execution. Additionally, it describes the CPU's interaction with memory and the step-by-step process of executing an addition instruction, highlighting the fetch-decode-execute cycle.

Uploaded by

md.munwarasef
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

CPU

The document provides an overview of the Central Processing Unit (CPU), detailing its components such as registers, the Arithmetic Logic Unit (ALU), and the Control Unit, which work together to perform arithmetic, logic, and control operations. It explains the microprocessor's evolution, the significance of 64-bit x86 architecture, and the role of various registers in instruction execution. Additionally, it describes the CPU's interaction with memory and the step-by-step process of executing an addition instruction, highlighting the fetch-decode-execute cycle.

Uploaded by

md.munwarasef
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 22

CPU

CPU: The CPU, or Central Processing Unit, is the main part of a computer that does most of the work. It's
often called the "brain" of the computer.

Electronic circuitry: This means the arrangement of electronic parts (like transistors and circuits) inside the
CPU that allows it to perform tasks.

Performs basic arithmetic, logic, controlling, and input/output operations:

1. Arithmetic: It can do basic math operations, like adding and subtracting.


2. Logic: It can make decisions, like checking if one number is bigger than another.
3. Controlling: It manages and controls the flow of data in the computer.
4. Input/Output operations: It handles data coming into the computer (input) and going out of it (output),
like reading from the keyboard or showing something on the screen.

Specified by the instructions in the program: The CPU follows a set of instructions from the program
(software) to know what to do step by step.

In simple terms: The CPU is the part of the computer that does the main work by following instructions given
by the program. It performs calculations, makes decisions, and controls data flow in the computer.
Components of the CPU

1. Registers:
o Definition: Registers are small, fast storage areas within the CPU.
o Purpose: They temporarily hold data and instructions that the CPU is currently working on or will process next.
o Key Feature: Registers operate at very high speeds to keep up with the CPU's processing speed, making it quicker for the CPU
to access data than if it were stored in regular memory (like RAM).
2. Arithmetic Logic Unit (ALU):
o Definition: The ALU is the part of the CPU that handles all arithmetic (math) and logic (decision-making) operations.
o Functions:
 Arithmetic operations: These include basic math functions like addition and multiplication.
 Logic operations: These involve comparing values, such as checking if one number is equal to, greater than, or less
than another (AND, OR, etc.).
o How it works: The ALU takes numbers stored in registers, performs the needed calculations or comparisons, and then sends the
results back to registers.
3. Control Unit:
o Definition: The control unit is like the “manager” of the CPU.
o Purpose: It directs the operations of the CPU, telling other parts (like the ALU and registers) what to do, when to do it, and in
what order.
o Function: The control unit sends signals to other parts of the CPU, ensuring everything works in sync and that instructions are
followed in the correct order.

CPU Diagram Explanation

The diagram shows how these components fit together:

 Registers, ALU, and Control Unit are all inside the CPU.
 Memory (RAM): The CPU connects to RAM (Random Access Memory), which stores the program instructions and data that the CPU
will use. RAM is larger than registers but slower.
 Input/Output (I/O) Controllers: These connect the CPU to devices like a hard drive, mouse, keyboard, network modem, and other
external components.
o The I/O controllers act as a bridge, allowing the CPU to send and receive data to and from these devices.

In summary:

 Registers hold data temporarily.


 The ALU performs calculations and comparisons.
 The Control Unit directs operations within the CPU.
 The CPU communicates with memory (RAM) and external devices through I/O controllers.

This structure allows the CPU to process data, perform tasks, and interact with other parts of the computer.
Microprocessor

Back in the old days, a CPU (Central Processing Unit) was made up of many separate electronic chips
connected together. For example:

 Registers (temporary storage areas) might have been on one or more chips.
 The Arithmetic Logic Unit (ALU) might have been on a separate chip.

In other words, different parts of the CPU were on different chips, so they had to be connected to work together.

Then came the Microprocessor:

 A microprocessor is a CPU built on a single chip.


 This was a huge technological achievement because it made computers faster, smaller, and cheaper.

Nowadays, all CPUs are microprocessors, meaning they all fit on a single chip.
When we say "64-bit x86 CPUs with up to 18 cores," it refers to several key characteristics of the CPU:

1. 64-bit:
o The CPU can handle 64 bits (or binary digits) of data at once.---Q
o This means it can process larger chunks of data and access a larger memory space compared to
32-bit CPUs.
o A 64-bit CPU is capable of running both 32-bit and 64-bit software, while a 32-bit CPU can only
handle 32-bit software.
2. x86:
o This refers to the CPU architecture, a type of design and instruction set created by Intel.
o The "x86" architecture is widely used in personal computers and servers.
o Modern "x86" CPUs often use an extension called "x86-64," which allows them to be 64-bit
processors.
3. Up to 18 Cores:
o A core is like a mini-CPU within the main CPU. Each core can handle its own tasks
independently.
o Having 18 cores means the CPU can handle 18 different tasks simultaneously.
o This improves performance for multitasking and for applications that need a lot of processing
power, like video editing, 3D rendering, or running multiple programs at once.

In summary, a 64-bit x86 CPU with up to 18 cores is a powerful processor that can handle complex tasks, run
both 32-bit and 64-bit applications, and efficiently manage multiple tasks at the same time due to its multi-core
design.
This picture provides an overview of the Intel 8086 microprocessor and some of its key specifications:

1. Data Bus Size: 16 bits


o The data bus can transfer 16 bits of data at a time, meaning it can handle a 16-bit word in one
operation.
2. Address Bus Size: 20 bits
o The address bus can access 220 1,048,576 memory locations, giving the 8086 a maximum
addressing capability of 1 MB.
3. Control Bus Size: 21 bits
o The control bus has 21 lines used to manage and control signals, coordinating operations
between the processor and other components.

The pin diagram shows the layout of the 40-pin 8086 chip. Each pin has a specific function, like transferring
data or addressing memory. The 8086 has two operating modes, Max Mode and Min Mode, which dictate how
it interacts with other processors and components.
 Registers are small, high-speed memory slots built right into the CPU. They serve as temporary storage

locations for data or addresses that the CPU is actively using. Since they are on the CPU itself, accessing

data in registers is much faster than accessing data in RAM.

 Purpose: Registers hold data or memory addresses while instructions are being executed. For instance,

they may store intermediate results from calculations or the address of data in RAM.

 Number and Size: The quantity and bit capacity of registers differ across CPUs. The size of a register

(like 8-bit, 16-bit, etc.) defines the maximum number of bits it can hold. For example, a 16-bit register

can store data values up to 2^16 - 1. CPUs with larger registers can handle more data at once, making

them more powerful.

 Not in Main Memory: Registers are not part of the main memory (RAM). Instead, they are integrated

within the CPU, making them faster to access but limited in storage capacity.

In summary, registers are essential for quick data access and manipulation within the CPU, significantly

speeding up processing by minimizing the need to access slower memory types like RAM.
 Size: Registers come in different sizes (4 bits, 8 bits, 16 bits, etc.), which defines how much data they can
hold at once.

 ARM architecture: In ARM processors (like in iPhones), there are 31 general-purpose 64-bit registers (for
general tasks) and 32 special 128-bit registers for handling floating-point calculations.

In modern processors: Both the size and number of registers are increasing to handle more complex tasks
efficiently.

 Register types: Registers are generally divided into general-purpose (for various tasks) and special-purpose
(for specific functions) types.

 Assembly language programming: Understanding register architecture is essential for programming in


assembly language, where direct control of registers is needed.

 Addressing registers by name: Since there are limited registers, they are usually referenced by specific
names (like AX, EAX) in assembly language instead of memory addresses.

 Naming conventions: Register names vary by processor type and typically use uppercase letters and
combinations like A, AX, EAX to identify them.

 Scratch paper analogy: Registers act as temporary storage (scratch paper) for quick calculations and data
manipulation, holding data currently being processed.

 Function parameters and return values: Registers often store input values for functions and return results
after computations.

 Processor instructions: Most processor instructions involve moving data in and out of registers and
performing calculations directly on this data, as this is the foundation of program execution at a low level.
1. General Purpose Registers: These store data for the Arithmetic Logic Unit (ALU) to use in
calculations and can hold intermediate or final results from these operations.
2. Special Purpose Registers: These have specific functions, including:
o Instruction Address Register: Holds the memory location where the next instruction is located,
as managed by the operating system.
o Data Address Register: Holds the memory location where data is stored.
o Special Address Register: Holds memory addresses used for unique or special functions.
o Instruction Register: Contains the machine code (binary) of the current instruction being
executed.
o Status Register: Stores the current status or state of the CPU, such as whether it is busy or
ready.

These registers help manage data flow, control processes, and track the CPU's operational state.
Program Counter (PC): This register keeps track of the address in memory where the next instruction is
stored. After each instruction, it moves to the next memory address, guiding the CPU on what to execute next.

1. Memory Address Register (MAR): The MAR holds the memory address for either:
o The current instruction being fetched, or
o The location where data should be transferred (read from or written to memory).
2. Memory Data Register (MDR): This register temporarily stores data:
o That was fetched from the memory address in the MAR, or
o That is about to be transferred to a specific memory address.
3. Instruction Register (IR): The Instruction Register (IR) is where the CPU places an instruction after fetching
it from memory. Once the instruction is in the IR, the CPU decodes it to understand what action to perform (like
addition, data movement, etc.). After decoding, the CPU executes the instruction, carrying out the action
specified. Essentially, the IR temporarily holds the instruction while the CPU figures out and performs the
necessary operation.
4. Accumulator (ACC): The ACC is a special register that the ALU (Arithmetic Logic Unit) uses to hold
data while performing calculations. It temporarily stores results, making it easier for the CPU to process
continuous operations.

Each of these registers has a specific role in the CPU's process of fetching, decoding, and executing instructions.
This diagram depicts the architecture of a basic Central Processing Unit (CPU) and its interaction with memory. Here's a breakdown:

CPU Components:

 General Registers (R0-R3): These are temporary storage locations used to hold data during program execution.
 ALU (Arithmetic Logic Unit): Performs arithmetic and logical operations on data from registers.
 Input Register 1 & 2: Registers used to temporarily hold data being fetched from memory.
 Output Register: Holds results from the ALU before being sent to memory.
 Program Counter: Keeps track of the address of the next instruction to be executed.
 Instruction Register: Holds the current instruction being processed.
 Instruction Decoder: Decodes the current instruction and generates control signals for other components.
 Control Unit: Generates control signals to coordinate all CPU operations.

Memory Components:

 Memory: Stores program instructions and data.


 Address Bus: Carries the memory address to be accessed.
 Data Bus: Carries data between the CPU and memory.
 Control Bus: Carries control signals for read/write operations to memory.

How the CPU and Memory Work Together:

1. Fetch: The Program Counter holds the address of the next instruction in memory. The CPU sends this address on the Address Bus to
memory.
2. Decode: The instruction is fetched from memory and placed in the Instruction Register. The Instruction Decoder interprets the
instruction and generates control signals.
3. Execute: The CPU executes the instruction. This may involve using the ALU, loading/storing data from registers, or accessing data in
memory.
4. Store: Results of operations are stored in registers or back to memory.

This cycle repeats continuously, executing the program instructions one after another. The control signals generated by the CPU
determine the overall operation and flow of data through the system.
Let's imagine we want the CPU to add two numbers stored in memory at specific addresses: 1001 and 1002.
The addition instruction is at memory address 1000.

Step-by-Step Process:

1. Program Counter (PC) Setup:


o Purpose: The Program Counter (PC) holds the address of the next instruction to fetch.
o Action: The PC starts at address 1000, where our addition instruction is stored.
o Example: The PC points to address 1000 so that the CPU knows it needs to fetch the instruction located
there.

2. Fetch Instruction into Instruction Register (IR):


o Purpose: The Instruction Register (IR) temporarily holds the instruction fetched from memory.
o Action: The CPU fetches the instruction at address 1000 (as pointed to by the PC) and loads it into the
IR.
o Example: The IR now holds the addition instruction. Meanwhile, the PC increments to point to the next
instruction (e.g., 1001) in case there’s more to execute afterward.

3. Decode Instruction using Instruction Decoder:


o Purpose: The Instruction Decoder interprets the contents of the IR, breaking down the instruction so
the CPU can understand it.
o Action: The Decoder analyzes the addition instruction, identifying that it needs to add values from
addresses 1001 and 1002.
o Example: The Decoder recognizes that this is an "ADD" command and prepares to retrieve the numbers
at addresses 1001 and 1002.

4. Control Unit Coordination:


o Purpose: The Control Unit oversees all CPU operations, ensuring everything runs in sync.
o Action: The Control Unit directs the data flow between CPU components, making sure the values from
addresses 1001 and 1002 are ready for the ALU.
o Example: The Control Unit signals to load values from memory into the ALU Input Registers (special registers in
the CPU that temporarily hold data (operands) for the Arithmetic & Logic Unit (ALU) to process).
5. Load Operands into ALU Input Registers:
o Purpose: ALU Input Registers 1 & 2 hold the two numbers for the ALU to process.
o Action: The CPU loads the numbers from addresses 1001 and 1002 into these registers.
o Example: If the numbers stored are 5 (at 1001) and 3 (at 1002), they are placed into Input Registers 1
and 2, respectively.

6. Arithmetic & Logic Unit (ALU) Operation:


o Purpose: The ALU performs arithmetic and logical operations, such as addition.
o Action: The ALU takes the values in its input registers and adds them together.
o Example: The ALU adds 5 + 3 to get 8.

7. Store Result in ALU Output Register:


o Purpose: The ALU Output Register holds the result of the ALU operation.
o Action: The result (8) is temporarily stored here before it’s sent to its final destination.
o Example: The number 8 is placed in the ALU Output Register.

8. Final Storage or Output of Result:


o Purpose: After calculation, the result may be stored in a CPU register, main memory, or sent to an I/O
device.
o Action: The Control Unit directs the result to its final location.
o Example: If we want to store 8 in memory at address 1003, the result moves from the ALU Output
Register to address 1003.

This sequence allows the CPU to complete instructions, one at a time, using registers and control units to
manage data and operations efficiently. The CPU continuously fetches, decodes, executes, and stores results,
moving seamlessly from one instruction to the next.

---------------------------------------------------------------------------------------------------------------------------------------
1. General Registers (R0, R1, R2, R3):
o These are small, fast storage locations in the CPU.
o Programmers use these registers to store temporary data while the program runs, which helps the
CPU process faster.
o Each register is 16 bits in size, meaning it can store numbers up to 16 bits long, matching the
memory size in TOY1.
2. Buses (Communication Paths):
o Buses are like highways in the CPU for transferring data and instructions within the CPU and
between the CPU and memory.
o There are three main buses:
 Address Bus: Carries memory addresses from the CPU to memory, telling it where to
read or write data. This bus is one-way (CPU to memory).
 Data Bus: Transfers actual data between the CPU and memory. It’s bi-directional,
meaning it can go both ways (CPU to memory or memory to CPU).
 Control Bus: Sends commands to memory, like whether the CPU wants to read data or
write data.
3. TOY1 Bus Sizes:
o Address Bus: 10 bits wide, so it can handle addresses up to 10 bits long.
o Data Bus: 16 bits wide, matching the size of each memory location.
o Control Bus: 1 bit wide, to signal a read or write operation.
4. Extra Registers (MAR and MDR):
o Memory Address Register (MAR): Temporarily holds the address of the data to be accessed.
o Memory Data Register (MDR): Temporarily holds the data itself, either being written to or
read from memory.

These components work together to efficiently move data and instructions across the CPU and memory, making
program execution faster and smoother.
This image illustrates the registers in the Intel Core i7 processor, released in 2009. The table shows the 64-bit
registers, along with the 32-bit registers that make up the lower half of the 64-bit registers, the 16-bit registers
that form the lower half of the 32-bit registers, and the 8-bit registers that form the lower half of the 16-bit
registers.
Key registers in the processor include:

 rax: Stores the return value from functions.


 rbx: Holds function arguments.
 rcx: Used as a loop counter.
 rdx: Holds the destination address for memory operations.
 rdi: Stores the first argument to a function.
 rsi: Stores the second argument to a function.
 rbp: Contains the address of the current stack frame.
 rsp: Points to the top of the stack.
 r8 - r15: General-purpose registers available for data storage in programs.

The table also shows naming conventions for each register. The "r" prefix indicates a general-purpose register,
while suffixes represent register sizes: "d" for 32-bit, "w" for 16-bit, and "b" for 8-bit. For example, rax is a
64-bit register, eax refers to its lower 32 bits, ax to its lower 16 bits, and al to its lower 8 bits.This visual
overview of Intel Core i7 registers and naming conventions aids programmers in understanding the processor’s
memory architecture and effectively using these registers in their programs.

Another diagram of the Intel 8086 microprocessor's registers. The diagram shows the different types of
registers: general purpose, pointer and index, segment, and flags. Each register has a specific purpose. For
example, the accumulator is used for arithmetic operations, the stack pointer keeps track of the stack, and the
flags are used to store the results of conditional operations.
Summarry of Registers

Understanding CPU Registers

In a CPU, registers are small storage units that temporarily hold data, instructions, or addresses. They help the
CPU work faster by keeping essential information close by, so it doesn’t have to repeatedly access slower
memory. Here’s an overview of the main types of registers and what they do:

1. General-Purpose Registers
o Purpose: These are flexible registers used to store temporary data, results from calculations, or values
needed during program execution.
o Examples: Common names for these registers are R0, R1, AX, EAX, or RAX depending on the processor
type. For example, RAX can store a return value from a function.

2. Special-Purpose Registers
o Purpose: These registers are used for specific control and memory-related tasks within the CPU. They
ensure the CPU knows where to find data and instructions and manage the flow of information.
o Examples of Special-Purpose Registers:
 Program Counter (PC): Holds the address of the next instruction the CPU needs to fetch and
execute.
 Instruction Register (IR): Stores the current instruction being processed by the CPU.
 Memory Address Register (MAR): Contains the memory address of data the CPU needs to
access.
 Memory Data Register (MDR): Temporarily holds data either fetched from memory or waiting
to be written to memory.
 Status Register (Flags Register): Holds flags or status indicators, like whether a calculation
resulted in zero, if there was a carry-over, or if an error occurred.

3. Accumulator Register (ACC)


o Purpose: This register is specifically used by the Arithmetic Logic Unit (ALU) to store data being
processed and the results of arithmetic or logic operations.
o Example: When performing a calculation like adding two numbers, the CPU might store one number in
the ACC, perform the addition, and then keep the result in the ACC until it’s moved to a different part of
memory or another register.

4. Floating-Point Registers
o Purpose: These registers handle decimal (floating-point) numbers, which are used in complex
calculations requiring high precision.
o Example: In scientific calculations involving decimals, floating-point registers store numbers like
3.14159.

5. Index and Base Registers


o Purpose: These are used for memory addressing, especially when working with arrays or loops. They
help the CPU keep track of positions within a block of memory.
o Example: When processing a list of items in memory, an index register might store the location of the
current item, making it easier to move to the next one.

Each type of register plays a specific role to help the CPU quickly access and process information. General-
purpose registers handle varied tasks, while special-purpose registers keep track of instructions and memory
locations. Together, they enable efficient and organized processing within the CPU.
This image illustrates the core structure of an Arithmetic Logic Unit (ALU) and how it functions within a
Pentium processor.

ALU Structure

 Components: The ALU includes an adder, a shift register, carry/rotate logic, and a control unit.
 Function: It performs basic arithmetic (like addition and subtraction) and logical operations (like shifting and
rotating) on binary data.
 Inputs: The ALU takes two operands (A and B), a carry-in bit (Cin), and control signals to direct the operation.
 Outputs: It generates the operation result and a carry-out bit (Cout) for certain operations.

Pentium Processor Architecture

 Multiple ALUs: The Pentium processor has several ALUs for fast, efficient processing.
 Dedicated ALUs: Separate ALUs handle integer calculations, floating-point calculations, and operations like
multiplication and division.
 Cache and Pipelines: The processor uses caches (for code and data) to speed up data access, and pipelines to
handle multiple tasks simultaneously.
 Bus Interface: A 64-bit bus interface connects the ALU with other processor components for data transfer.

Summary

This image offers a simplified view of a basic ALU, showing its main components and their roles in performing
arithmetic and logical operations. In the Pentium processor, multiple ALUs work together to boost processing
power, aided by caching, pipelining, and an efficient bus interface.
Function: The Control Unit (CU) is a crucial part of the CPU that directs how the computer operates.

Role: It manages the flow of instructions, ensuring that different components (like memory and the Arithmetic Logic
Unit) work together at the right time.

Operation:

Instruction Handling: The CU fetches instructions from memory and decodes them to determine the next steps.

Coordination: It activates the necessary parts of the CPU and other devices to perform tasks in the correct order.

In summary, the CU acts like a manager, ensuring all parts of the computer work together smoothly to follow
instructions.
The image shows the different stages of the CPU's instruction cycle, which is the basic process that CPUs use to execute
instructions. The cycle has four main stages:

Fetch: The CPU fetches the next instruction from memory.

Decode: The CPU decodes the instruction, which means it figures out what the instruction means.

Execute: The CPU executes the instruction, which means it performs the actions specified by the instruction.

Store: The CPU stores the results of the execution, either in a temporary storage location (a register) or in memory.

The image shows these four stages with different colors and arrows showing the flow of the cycle. The arrows indicate
the different steps of the CPU's processing:

Fetch instruction from memory

Decode the instruction

Execute the instruction in the ALU

Store the result in memory.

This cycle repeats continuously, allowing the CPU to execute programs and perform tasks.

For example, imagine a simple program that adds two numbers:

Fetch: The CPU retrieves the instruction from memory, which might look something like "ADD 10, 5".

Decode: The CPU interprets this instruction as meaning "add the number 10 to the number 5".

Execute: The CPU performs the addition operation, calculating the sum of 10 and 5, which is 15.

Store: The CPU stores the result (15) in a temporary location or in memory, where it can be used later by the program.

The CPU then repeats this cycle for every instruction in the program, processing each one step by step. This is how the
CPU carries out the instructions of a program, enabling it to perform tasks such as calculations, data manipulation, and
output.
The Fetch-Decode-Execute-Store cycle is a fundamental process in computer architecture that explains how a CPU
executes instructions. Here's a breakdown of each step:

Fetch: The CPU retrieves the next instruction from main memory and places it in the Instruction Register. This is like
picking up a recipe from the cookbook.

Decode: The Control Unit, a part of the CPU, analyzes the instruction to understand its purpose and the data it needs to
work with. This is like reading the recipe and identifying the ingredients and cooking steps.

Execute: The CPU performs the operations specified by the instruction, using the data from the registers. This is like
following the recipe and preparing the dish.

Store: The result of the executed instruction is stored back into a register or memory location. This is like putting the
finished dish on the table.

This cycle repeats continuously, allowing the CPU to process a stream of instructions and perform tasks.
How the CPU runs a program to add two numbers, using a simple example. We'll say we want to add the
numbers 5 and 3.
Example Program
Let's say our program has the following instructions in memory:

1. Load the number 5 into register A.


2. Load the number 3 into register B.
3. Add the contents of register A and register B, and store the result in register C.

Step-by-Step Process

1. Program Counter (PC)


• What it is: The Program Counter starts at the address of the first instruction.
• Example: Let's say the first instruction is at address 1000. So, PC = 1000.
2. Fetch the Instruction
• What happens: The CPU reads the instruction at address 1000 (which is "Load 5 into register A").
• Example: The CPU fetches the instruction "Load 5 into A".
3. Move Instruction to Instruction Register
• What it is: The fetched instruction is moved to the Instruction Register (IR).
• Example: IR now holds "Load 5 into A".
4. Increment the Program Counter
• What happens: The PC is updated to point to the next instruction.
• Example: PC now points to address 1001.
5. Decode the Instruction
• What it is: The Control Unit decodes the instruction in the IR.
• Example: It understands that it needs to load the number 5 into register A.
6. Read Data from RAM (if needed)
• What happens: The CPU retrieves the number 5 from memory.
• Example: The number 5 is stored in memory at address 2000, so the CPU fetches it.
7. Perform Operation in the ALU
• What it is: Since this instruction just loads a value, we skip this step for now. We will use it in the next
instruction.
8. Store Result to a Register
• What happens: The CPU stores the number 5 in register A.
• Example: Register A now contains 5.
9. Repeat for Next Instruction
• What it is: The CPU goes back to the beginning of the process with the next instruction.
• Example: Now, the PC points to address 1001, which contains "Load 3 into B".

Next Instructions
Following the same process:

1. Fetch the instruction at address 1001 ("Load 3 into B").


2. Move it to the Instruction Register.
3. Increment the Program Counter to point to address 1002.
4. Decode the instruction to understand it needs to load 3 into register B.
5. Read the number 3 from memory (let's say it's at address 2001).
6. Store the number 3 in register B.

Adding the Numbers


Now, the CPU processes the instruction at address 1002, which is "Add A and B, store in C".
1. Fetch the instruction at address 1002 ("Add A and B").
2. Move it to the Instruction Register.
3. Increment the Program Counter to point to the next instruction (1003).
4. Decode the instruction to understand it needs to add the values in registers A and B.
5. Perform the addition in the ALU: 5 (from A) + 3 (from B) = 8.
6. Store the result in register C.

Final Step
• The CPU will continue this process for any remaining instructions in the program, but for this example, we
have successfully added 5 and 3, and the result (8) is now stored in register C.

Summary
In summary, the CPU runs the program by fetching, decoding, and executing each instruction in a loop. In this
case, it added two numbers (5 and 3) and stored the result (8) in a register.

You might also like