0% found this document useful (0 votes)
2 views18 pages

Presentation 2

Uploaded by

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

Presentation 2

Uploaded by

Poorvi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

A Deep Dive into

Computer Instruction Sets


This presentation explores the fundamental building blocks
of computer programs: instructions. We will delve into
instruction formats, types, and sequencing, laying the
groundwork for understanding how computers execute code.
Instruction Sequencing: The Language of
Machines
Defining Actions Order Matters

Instructions tell the computer what actions to Instructions are executed in a specific order,
perform, like moving data, performing arithmetic dictated by the program's logic, ensuring the
operations, or making decisions. computer performs the desired sequence of steps.
Essential Instruction
Types: The Building Blocks

1 Data Transfer 2 Arithmetic & Logic

Moving data between Performing


memory, registers, calculations and
and I/O devices. logical operations on
data.

3 Control Flow

Altering the order of instruction execution, enabling


decision-making.
Register Transfer Notation:
A Concise Representation
Concise Abstraction

RTN provides a succinct It focuses on the logical


way to describe the flow of data rather than
movement and the low-level details of
manipulation of data hardware
within a computer's implementation.
registers.
Clarity

RTN makes it easier to understand and analyze the


behavior of instructions.
Assembly Language:
Bridging the Gap

Low-Level Human-Readable

Assembly language directly Unlike machine code,


maps to machine assembly language uses
instructions, providing fine- mnemonic symbols that are
grained control over easier for programmers to
hardware operations. understand.
Assembly Language
Notation
Assembly language employs mnemonics to represent
machine instructions, making them more readable for
humans.
These mnemonics correspond directly to the binary opcodes
and operand values used by the processor.
Basic Instruction Types
Instructions are the fundamental building blocks of computer
programs. They specify the actions that the computer should
perform, like moving data, performing arithmetic operations,
or making decisions.
Instruction Types

One-Address Instructions Two-Address Instructions Three-Address Instructions

A single operand is specified, typically Two operands are specified, often Three operands are specified, enabling
residing in a register. This simplifies residing in registers or memory operations involving multiple data
instruction format but might require locations. This allows more complex sources. This enhances flexibility and
multiple instructions for complex operations in a single instruction, reduces the number of temporary
operations. improving efficiency. storage locations needed.
ADD R1, #5 ; Add 5 to register R1 ADD R1, R2 ; Add the contents of ADD R3, R1, R2 ; Add the contents
R2 to R1, storing the result in R1 of R1 and R2, storing the result in
R3
Instruction Types: Loading, Storing, Arithmetic,
and Movement

Loading Instructions Storing Instructions Arithmetic Movement


Instructions Instructions
These instructions Storing instructions
move data from move data from These instructions These instructions copy
memory into registers, registers back into perform mathematical data between registers
where it can be memory, making it operations like addition, or between memory
processed by the CPU. persistent. subtraction, locations.
multiplication, and
division.
Instruction Types: Loading, Storing, Arithmetic,
and Movement
Load instructions move data from memory into
registers. Store instructions move data from registers
into memory. These instructions are fundamental for
accessing and manipulating data within the
computer's memory.
Arithmetic instructions perform calculations like
addition, subtraction, multiplication, and division on
data stored in registers. These instructions are used
to perform computations and manipulate numeric
data.
Move instructions copy data from one register to
another. They are used to transfer data between
different registers or to move data to a specific
register before performing an operation.
Straight Line Sequencing: The Simple Case
Instructions are executed in a sequential order,
one after the other.

This execution model resembles a linear path,


with no deviations or jumps.

Example: A program adding two numbers and


storing the result will execute the load, add, and
store instructions in order.
Instruction Execution: From
Code to Action

1 Fetch

The CPU retrieves the instruction from memory.

2 Decode

The CPU interprets the instruction's meaning.

3 Execute

The CPU performs the operation specified by the instruction.

4 Store

The CPU stores the result of the operation, if applicable.


Adding a List of n Numbers

• The addresses of the memory locations containing the


n numbers are symbolically given as NUM1, NUM2, ...,
NUMn .

• Separate Add instruction is used to add each number


to the contents of register R0 •

• After all the numbers have been added, the result is


placed in memory location SUM
Branching: Making Decisions
Conditional Jumps

Branching allows programs to make decisions based on condit

Flexibility

The flow of execution can be altered dynamically,


enabling complex program logic.

Looping

Branching instructions can create loops, repeating


blocks of code until a condition is met.
Branching: Making Decisions
Branch Target

The "branch target" is the specific instruction address or memory location that the program jumps to
when a conditional jump is taken. This target instruction will be executed next instead of the subsequent
sequential instruction.
Precisely defining the branch target is crucial for the correct execution of branched code.

Branching, using conditional jumps and branch targets, allows for loops (repeating code blocks until a
condition is met), significantly impacting program efficiency and dynamism.
Condition Code Flags: Capturing Results

1 2
Zero Negative

Indicates if the result of the previous operation was zero. Indicates if the result of the previous operation was negative.

3 4
Carry Overflow

Indicates if a carry occurred during the previous operation (often Indicates if the result of the previous operation exceeded the
relevant for unsigned arithmetic). maximum value representable by the register (often relevant for
signed arithmetic).
Conclusion

Instruction Sets Branching and Decisions Instruction Execution

Understanding the language of Dynamic control flow From code to action


machines

You might also like