0% found this document useful (0 votes)
6 views22 pages

Module 2 Foundation of Computing

The document outlines the foundational concepts of computing, including data storage units (bits, bytes, kilobytes, etc.), ASCII and Unicode character encoding, and CPU architecture. It explains the roles of the arithmetic/logic unit, control unit, and memory in a CPU, as well as the instruction formats for data movement and arithmetic operations. The content is aimed at providing a comprehensive understanding of how computers process and store information.

Uploaded by

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

Module 2 Foundation of Computing

The document outlines the foundational concepts of computing, including data storage units (bits, bytes, kilobytes, etc.), ASCII and Unicode character encoding, and CPU architecture. It explains the roles of the arithmetic/logic unit, control unit, and memory in a CPU, as well as the instruction formats for data movement and arithmetic operations. The content is aimed at providing a comprehensive understanding of how computers process and store information.

Uploaded by

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

GXEST203- FOUNDATIONS OF COMPUTING: FROM HARDWARE

ESSENTIALS TO WEB DESIGN

MODULE 2
Syllabus:
Binary representation of data and numbers, Integer Representation(refer classwork)
Data storage units - bits, bytes, kilobytes, etc., ASCII and Unicode
CPU Architecture and Instruction Set: Basic CPU architecture - ALU, registers, control unit
Instruction format and assembly language (basics only) Fetch- execute cycle and instruction
execution.

1. Data Storage units


Storage units are Standardized measurements used to quantify digital information
The most common units used to measure digital storage are:

Bits
Bits are the basic building blocks of not only data storage, but all computers. Computers work in
binary digits, combining 0's and 1's in countless patterns. These binary digits are known as bits,
and are the smallest possible unit for data storage.

Byte
A byte consists of 8 bits
It is the standard unit of storage used to measure file sizes and memory capacity in most systems.
(All memory storage is expressed in terms of bytes)
For example, one character of text typically takes up one byte.
Bits might be the foundation upon which data storage is built, bytes are the building blocks that
truly denote the usability of any one storage solution.

Kilobyte (KB)
1 KB = 1,024 bytes (in binary systems). In decimal (SI system), 1 KB is often considered 1,000
bytes. Kilobytes are used to measure small files such as text documents.

Megabyte (MB)
1 MB = 1,024 KB = 1,048,576 bytes (binary).
In the SI decimal system, 1 MB = 1,000,000 bytes.
Megabytes are used to measure the size of larger files like images, audio files, and software
applications.

Gigabyte (GB)
1 GB 1,024 MB = 1,073,741,824 bytes (binary).

---
Author: Athithya S.
Assistant Professor(CSE), Christ College of Engineering
Date: 26 March 2025
In the decimal = system, 1 GB = 1,000,000,000 bytes.
Gigabytes are commonly used to measure the storage capacity of devices like smartphones,
SSDs, and hard drives

2. AISCII

●​ To facilitate the exchange of textual information, such as Facebook posts or email,


between computer systems, it would be most helpful if everyone used the same code
mapping.
●​ Initially, the most widely used code set for representing characters internally in a
computer system was ASCII, an acronym for the American Standard Code for
Information Interchange.
●​ ASCII is an international standard for representing textual information that uses 8 bits per
character, so it is able to encode a total of 28= 256 different symbols.
●​ These are assigned the integer values 0 to 255. However, only the numbers 32 to 126
have been assigned to printable characters.
●​ The remainder either are unassigned or are used for representing non printing control
characters such as tab, form feed, and return.
●​ Figure 4.3 shows the ASCII conversion table for the numerical values 32–126.

---
Author: Athithya S.
Assistant Professor(CSE), Christ College of Engineering
Date: 26 March 2025
ASCII Representation of Given Characters

Character ASCII (Decimal)


a 97 1100001
z 122 1111010
A 65 1000001
Z 90 1011010
1 49 110001
9 57 111001
AISCII Representation of "aBc" in binary is 01100001 01000010 01100011
ASCII
Character (Decimal) Binary (8-bit)
a' 97 1100001
B' 66 1000010
c' 99 1100011

Using the ASCII code set given in Figure 4.3, show the internal binary representation for the
following character strings:
• a. AbC - 01000001 01100010 01000011
• b. Mike - 01001101 01101001 01101011 01100101
• c. $25.00 - 00100100 00110010 00110101 00101110 00110000 00110000
• d. (a + b) - 00101000 01100001 00100000 00101011 00100000 01100010 00101001

---
Author: Athithya S.
Assistant Professor(CSE), Christ College of Engineering
Date: 26 March 2025
3. UNICODE

●​ It uses, at a minimum, a 16-bit representation for characters rather than the 8-bit format
of ASCII.
●​ This means that it is able to represent at least 216 = 65,536 unique characters instead of
the 28 = 256 of ASCII.
●​ Unicode is a superset of ASCII. The decimal values 0–127 represent exactly the same
characters in both ASCII and Unicode.
●​ It might seem as though 256 characters should be more than enough to represent all the
textual symbols that we would ever need—for example, 26 uppercase letters, 26
lowercase letters, 10 digits, and a few dozen special symbols, such as =+ − { } ] [\: ” ? >
< . , ; % $ # @.
●​ Add that all together and it still totals only about 100 symbols, far less than the 256 that
can be represented in ASCII.
●​ Unicode has to symbols drawn from alphabets such as Russian, Arabic, Chinese, Hebrew,
Greek, Thai, Bengali, Sanskrit, Cherokee, Inuit, and Braille, as well as mathematical
symbols, linguistic marks such as the tilde, umlaut, and accent grave, and numerous
graphical symbols.
●​ ASCII does not have enough room to represent them all.
●​ Unicode, with its 16 bits and space for over 65,000 symbols, was initially considered
large enough to accommodate this enormous range of text. However, it turned out that
even 16 bits proved insufficient to handle the exploding range of textual information
being produced around the world, and Unicode now includes a 32-bit variant in which
each separate character is represented using 32 binary digits, allowing for the possibility
of 232 distinct textual symbols, or about 4 billion!
●​ Currently Unicode has assigned formal mappings to more than 128,000 characters drawn
from over 135 modern and historical alphabets.

4. CPU ARCHITECTURE

●​ CPU architecture refers to the fundamental design of a central processing unit (CPU),
which is responsible for executing instructions and performing basic operations in a
computer system.
●​ CPU architecture is sometimes called Instruction Set Architecture.
●​ The Architecture of CPU can vary depending on the type and design
●​ The computer unit is made up conceptually of three major components, the
arithmetic/logic unit (ALU), the control unit (CU), and memory.
●​ The ALU and CU together are known as the central processing unit (CPU).
●​ An input/output (I/O) interface is also included in the diagram.

---
Author: Athithya S.
Assistant Professor(CSE), Christ College of Engineering
Date: 26 March 2025
4.1 The Arithmetic/Logic Unit
●​ The arithmetic/logic unit (ALU) is the subsystem that performs such mathematical and
logical operations as addition, subtraction, and comparison for equality.
●​ The ALU is made up of three parts: the registers, the interconnections between
components, and the ALU circuitry. Together these components are called the data path.
●​ A register is a special high-speed storage cell that holds the operands of an arithmetic
operation and that, when the operation is complete, holds its result.
●​ Registers are quite similar to the random access memory cell
●​ ALU consists of two subsections, which are:
○​ Arithmetic Section: By arithmetic operations like addition, subtraction,
multiplication, and division, and all these operations and functions are performed
by ALU. Also, all the complex operations are done by making repetitive use of
the mentioned operations by ALU.
○​ Logic Section: By Logical operations, we mean operations or functions like
selecting, comparing, matching, and merging the data, and all these are performed
by ALU.

---
Author: Athithya S.
Assistant Professor(CSE), Christ College of Engineering
Date: 26 March 2025
4.2 Control Unit

●​ The control unit controls and interprets the execution of instructions.


●​ The most fundamental characteristic of the Von Neumann architecture is the stored
program—a sequence of machine language instructions stored as binary values in
memory.
●​ The task of the control unit is to
(1) fetch from memory the next instruction to be executed
(2) decode it—that is, determine what is to be done
(3)execute it by issuing the appropriate command to the ALU, memory, or I/O
controllers.

●​ These three steps are repeated over and over until we reach the last instruction in the
program, typically something called HALT, STOP, or QUIT.
●​ As the name suggests, a control unit controls the operations of all parts of the computer
but it does not carry out any data processing operations.
●​ It controls the functioning of the computer. Its main task is to maintain the flow of
information across the processor.

The control unit will also contain several 1-bit registers, sometimes known as flags, that are used
to allow the computer to keep track of special conditions such as arithmetic carry and overflow,
power failure, and internal computer error. Usually, several flags are grouped into one or more
status registers.

Main functions of the control unit are listed:


1. Controlling of data and transfer of data and instructions is done by the control unit among
other parts of the computer.
2. The control unit is responsible for managing all the units of the computer.
3. The main task of the control unit is to obtain the instructions or data that is input from the
memory unit, interpret them, and then direct the operation of the computer according to that.
4. The control unit is responsible for communication with Input and output devices for the
transfer of data or results from memory.
5. The control unit is not responsible for the processing of data or storing data.

4.3 Memory / Storage unit

●​ This unit can store instructions, data, and intermediate results.


●​ The memory unit is responsible for transferring information to other units of the
computer when needed.

---
Author: Athithya S.
Assistant Professor(CSE), Christ College of Engineering
Date: 26 March 2025
●​ It is also known as an internal storage unit or the main memory or the primary storage or
Random Access Memory (RAM) as all these are storage devices.
●​ There are two types of memory in the computer, which are primary memory and
secondary memory.

Main functions of memory units are listed below:


1. Data and instructions are stored in memory units which are required for processing.
2. It also stores the intermediate results of any calculation or task when they are in process.
3. The final results of processing are stored in the memory units before these results are released
to an output device for giving the output to the user.

4.4 Registers

●​ A register is a single, permanent storage location within the CPU used for a particular,
defined purpose. Registers are basic working components of the CPU.
●​ A register is used to hold a binary value temporarily for storage, for manipulation, and/or
for simple calculations.
●​ Each register is wired within the CPU to perform its specific role.

Registers also differ from memory in that they are not addressed as a memory location but
instead are manipulated directly by the control unit during the execution of instructions.
Registers may be as small as a single bit or as wide as several bytes, ranging usually from 1 to
128 bits.
Registers are used in many different ways in a computer. Depending on the particular use of a
register, a register may hold data being processed, an instruction being executed, a memory or
I/O address to be accessed, or even special binary codes used for some other purpose.

Different types of registers

1. Accumulator
●​ In the CPU, the equivalent to the calculator is known as an accumulator.
●​ Modern CPUs provide several accumulators; these are often known as general-purpose
registers.
●​ Groups of similar registers are also sometimes referred to collectively as a register file.
●​ General-purpose registers or accumulators are usually considered to be a part of the
arithmetic/logic unit In most computers, these registers are also used to transfer data
between different memory locations, and between I/O and memory

2. The Program Counter Register - holds the address of the current instruction being executed.

---
Author: Athithya S.
Assistant Professor(CSE), Christ College of Engineering
Date: 26 March 2025
3. The Instruction Register (IR) - IR the actual instruction being executed currently by the
computer.

4. The Memory Address Register (MAR) - holds the address of a memory location.

5. The Memory Data Register (MDR), sometimes known as the memory buffer register, will
hold a data value that is being stored to or retrieved from the memory location currently
addressed by the memory address register.

The control unit will also contain several 1-bit registers, sometimes known as flags, that are used
to allow the computer to keep track of special conditions such as arithmetic carry and overflow,
power failure, and internal computer error. Usually, several flags are grouped into one or more
status registers.

Most registers support four primary types of operations:


1. Registers can be loaded with values from other locations, in particular from other registers or
from memory locations.
2. Data from another location can be added to or subtracted from the value previously stored in a
register, leaving the sum or difference in the register.
3. Data in a register can be shifted or rotated right or left by one or more bits. This operation is
important in the implementation of multiplication and division.
4. The value of data in a register can be tested for certain conditions, such as zero, positive,
negative, or too large to fit in the register.

5. Instruction Format

5.1 Data movement Instruction(LOAD, STORE)

Data movement instructions move data between registers, memory, and I/O devices. They can be
used to
move bytes, words, or doublewords.

LOAD: Moves data from memory to registers.

There may be a load byte instruction, a load half-word (2 bytes), a load word (4 bytes), and a
load double word (8 bytes) within the same instruction set.

●​ General Form → LOAD destination_register, memory_address


●​ Example: MOV AX, [memory_address]

---
Author: Athithya S.
Assistant Professor(CSE), Christ College of Engineering
Date: 26 March 2025
STORE : Moves data from registers to memory.

The STORE (ST) instruction is used to move data from a register to a memory location. This is
the reverse operation of the LOAD instruction, which transfers data from memory to a register.

●​ General Form → STORE memory_address, source_register


●​ Example: → MOV [memory_address], AX

5.2 Arithmetic Instructions(ADD,SUB)

●​ Arithmetic instructions are essential operations performed by the Arithmetic Logic Unit
(ALU) of a processor to handle numeric calculations. These instructions manipulate data
in registers and memory, allowing the CPU to perform mathematical computations
efficiently.
●​ CPU also provides instructions for integer multiplication and division.
●​ Many instruction sets provide integer arithmetic for several different word sizes.
●​ Most current CPUs also provide floating point arithmetic capabilities, although some
CPUs offer floating point arithmetic as an extension to the basic architecture.
●​ Some architectures also offer instructions for other, more specialized operations, such as
square root, log, and trigonometry functions.

Arithmetic Instructions(ADD,SUB)

• ADD: Adds two values together


ADD destination, source

example:
MOV AX, 5 ​ ; Load 5 into AX
MOV BX, 3 ​ ; Load 3 into BX
ADD AX, BX ​ ; AX = AX + BX (AX = 5 + 3 = 8)

• ADC: Adds two values together, including the carry bit


ADC destination, source

example:
STC ​ ; Set carry flag (CF = 1)
ADC AL, BL

---
Author: Athithya S.
Assistant Professor(CSE), Christ College of Engineering
Date: 26 March 2025
• SUB: Subtracts one value from another
SUB destination, source

example:
MOV AX, 10 ​ ; Load 10 into AX
MOV BX, 4 ​ ; Load 4 into BX
SUB AX, BX ​ ; AX = AX - BX (AX = 10 - 4 = 6)

• SBC: Subtracts one value from another, including the carry bit

example:
STC ​ ; Set carry flag (CF = 1)
SBB AL, BL

5.3 Boolean Logic Instruction(AND,OR)


Boolean instructions are commands that perform logical operations on strings of characters.

AND: The AND instruction is used for supporting logical expressions by performing bitwise
AND operation. The bitwise AND operation returns 1, if the matching bits from both the
operands are 1, otherwise it returns 0.

Syntax: AND destination, source


Example
MOV AL, 0b1100 ; Load AL with binary 1100 (decimal 12)
MOV BL, 0b1010 ; Load BL with binary 1010 (decimal 10)
AND AL, BL ; AL = AL AND BL (1100 & 1010 = 1000 → AL = 8)

OR : The OR instruction is used for supporting logical expression by performing bitwise OR


operation. The bitwise OR operator returns 1, if the matching bits from either or both operands
are one. It returns 0, if both the bits are zero.

Syntax: OR destination, source

MOV AL, 0b1100 ; Load AL with binary 1100 (decimal 12)


MOV BL, 0b1010 ; Load BL with binary 1010 (decimal 10)
OR AL, BL ; AL = AL OR BL (1100 | 1010 = 1110 → AL = 14)

---
Author: Athithya S.
Assistant Professor(CSE), Christ College of Engineering
Date: 26 March 2025
5.4 Single Operand Instructions(INC,DEC)
These instructions operate on the value in a register, but some instruction sets provide similar
operations on memory values as well. The instruction set will contain instructions for
incrementing a value, for decrementing a value.

• NEG (Negate): Negates the value stored in the accumulator.


Syntax: NEG destination
MOV AL, 5 ; Load AL with 5
NEG AL ; AL = -AL (AL = -5)

• INC (Increment): Adds 1 to the value in the accumulator.


Syntax: INC destination
MOV CX, 10 ; Load 10 into CX
INC CX ; CX = CX + 1 (CX = 11)

• DEC (Decrement): Subtracts 1 from the value in the accumulator.


Syntax: DEC destination
MOV DX, 5 ; Load 5 into DX
DEC DX ; DX = DX - 1 (DX = 4)

• NOT (Logical NOT): Performs a bitwise NOT operation on the accumulator value.
Syntax: NOT destination
MOV AL, 0b00001111 ; Load AL with binary 00001111 (decimal 15)
NOT AL ; AL = ~AL (AL = 11110000 → decimal 240)

5.5 Shift and Rotate Instruction


Shift and rotate operations have been used to implement multiplication and division. Shift
instructions move the data bits left or right one or more bits.

Rotate instructions also shift the data bits left or right, but the bit that is shifted out of the end is
placed into the vacated space at the other end.

• Depending on the design of the particular instruction set, bits shifted out the end of the word
may be shifted into a different register or into the carry or overflow flag bit. The data word being
shifted might be logical or it might be numeric.

---
Author: Athithya S.
Assistant Professor(CSE), Christ College of Engineering
Date: 26 March 2025
Logical Shift Left (SHL)

●​ Fills the least significant bit (LSB) with 0.


●​ Equivalent to multiplying by 2.

Logical Shift Right (SHR)

●​ Fills the most significant bit (MSB) with 0.


●​ Equivalent to dividing by 2 (for unsigned numbers).

Arithmetic Shift (For Signed Numbers)

Arithmetic Shift Right (SAR)

●​ Preserves the sign bit (MSB) for signed numbers in two’s complement representation.
●​ Equivalent to dividing by 2, but keeps negative numbers correct.

---
Author: Athithya S.
Assistant Professor(CSE), Christ College of Engineering
Date: 26 March 2025
• Arithmetic shift instructions are commonly used to multiply or divide the original value by a
power of 2.
• Therefore, the instruction does not shift the leftmost bit, since that bit usually represents the
algebraic sign of the numeric value, obviously the sign of a number must be maintained.
• Right arithmetic shifts fill the space of moved bits with the sign bit rather than with zero.

Arithmetic Shift Left (SAL or SHL)


●​ shifts all bits to the left and fills the vacant least significant bits (LSB) with 0. It is
equivalent to multiplying by 2 for each shift.

• Rotate instructions take the bits as they exit and rotate them back into the other end of the
register.
Some instruction sets include the carry or overflow bit as part of the rotation.

---
Author: Athithya S.
Assistant Professor(CSE), Christ College of Engineering
Date: 26 March 2025
6. Instruction Word Format-Unary, Binary and Ternary

An instruction word consists of an opcode and one or more address fields.

●​ A simple 32-bit instruction format with one address field is shown in the figure.
●​ In this example, the 32 bits are divided into:​

○​ 8-bit opcode (specifies the operation).​

○​ 24-bit address field (specifies memory/register location).

Operand

The source and destination of data in an instruction are called operands.

●​ Load, Store, and Move Instructions require two operands.​

1.​ Example: Register-to-register move (shown in figure 2).


2.​ The instruction consists of an opcode and two address fields (registers).
3.​ Example: Moves data from Register 5 to Register 10.
4.​ The source and destination may be registers or memory locations.

●​ Arithmetic Instructions (such as ADD, SUB) typically require two to three operands.​

●​ Most instructions consist of one, two, or three address fields, leading to three
categories:​

1.​ Unary Instructions (One Operand)​

---
Author: Athithya S.
Assistant Professor(CSE), Christ College of Engineering
Date: 26 March 2025
2.​ Binary Instructions (Two Operands)​

3.​ Ternary Instructions (Three Operands)

1. Unary Instructions (One Operand)

●​ Operate on a single operand (usually a register).


●​ Example Instructions:​

○​ NOT → NOT destination eg. NOT R1​

○​ INC → INC destination eg. INC R2​

○​ DEC → DEC destination eg. DEC R3

2. Binary Instructions (Two Operands)

●​ Operate on two operands: source and destination.


●​ Example Instructions:​

○​ ADD → ADD destination, source​


ADD R1, R2
○​ SUB → SUB destination, source​
SUB R3, R4
○​ AND → AND destination, source​
AND R5, R6
○​ OR → OR destination, source​
OR R7, R8

3. Ternary Instructions (Three Operands)

●​ Operate on three operands (rare in some architectures).


●​ Example Instructions:​

○​ ADD → ADD destination, source1, source2​


ADD R1, R2, R3

---
Author: Athithya S.
Assistant Professor(CSE), Christ College of Engineering
Date: 26 March 2025
○​ SUB → SUB destination, source1, source2​
SUB R4, R5, R6
○​ MUL → MUL destination, source1, source2​
MUL R7, R8, R9

7. Assembly Language

7.1 The Limitations of Machine Language

One of the first steps toward a more user-friendly programming environment is selecting an
accessible programming language. Machine language, designed from a machine’s perspective
rather than a human’s, is complex and difficult to understand. Some specific challenges of
machine language include:

●​ Binary Representation: Machine language relies entirely on binary, lacking natural


language words, mathematical symbols, or convenient mnemonics for readability.​

●​ Numeric Memory Addresses: Instructions and data must be referenced by binary


addresses rather than human-readable names.​

●​ Difficulty in Modification: Inserting or deleting an instruction shifts all subsequent


memory addresses, requiring extensive updates.​

●​ It is difficult to create data. If a user wants to store a piece of data in memory, he or


she must compute the internal binary representation for that data item.

7.2 Assembly Language

Programmers working on early first-generation computers quickly realized the shortcomings of


machine language. They developed a new language, called assembly language, designed for
people as well as computers.

Assembly languages are called low-level programming languages, which means they are closely
related to the machine language and programs written in assembly language are called the source
program.

Languages like C++, Java, and Python, which are high-level programming languages. High-level
languages are more user oriented, they are not machine specific.

The processor does not “understand” assembly language instructions. The source program must
be translated into a corresponding machine language program, called the object program. This
translation is carried out by a piece of system software called an assembler.

---
Author: Athithya S.
Assistant Professor(CSE), Christ College of Engineering
Date: 26 March 2025
The assembler goes through the entire program, carrying out a translation of one instruction at a
time. Once the complete object program has been produced, its instructions can be loaded into
memory and executed by the processor.

Assembly languages created a more productive, user-oriented environment, and assemblers were
one of the first pieces of system software to be widely used.

7.3 Understanding Assembly Language

Assembly language instructions follow a structured format:

label: opcode(mnemonic) address field -- comment

●​ Labels provide symbolic names for instructions and memory locations.


●​ Mnemonics (e.g., LOAD, ADD, STORE) replace obscure binary codes.

---
Author: Athithya S.
Assistant Professor(CSE), Christ College of Engineering
Date: 26 March 2025
●​ Symbolic Addresses replace numeric memory addresses, improving readability and
maintainability.
●​ Comments, preceded by --, help explain code functionality.

7.4 Advantages of Assembly Language

Compared to machine language, assembly language offers three major benefits:

1.​ Symbolic Operation Codes: Instead of binary, mnemonics like LOAD and ADD make
instructions easier to understand.
2.​ Symbolic Memory Addresses: Labels such as LOOPSTART allow referencing memory
locations by name rather than number.
3.​ Pseudo-Operations: These provide useful features like data generation and code
structuring.

7.4.1 Advantage 1,2- Symbolic Labels: Enhancing Readability and Maintainability

Using symbolic labels instead of numeric addresses improves program clarity and
maintainability. For example:

LOOPSTART: LOAD X
JUMP LOOPSTART

Here, LOOPSTART represents the memory address of LOAD X. If instructions shift due to
modifications, the assembler automatically updates references, eliminating manual address
adjustments.

Example (Before Modification):

JUMP LOOP
... ← Point A
LOOP: LOAD X

New instruction is added to the program at point A. When the modified program is translated by
the assembler into machine language, all instructions following point A are placed in a memory
cell whose address is 1 higher than it was before .
The JUMP refers to the LOAD instruction only by the name LOOP, not by the address where it
is stored. Neither the JUMP nor the LOAD instruction needs to be changed.
.

---
Author: Athithya S.
Assistant Professor(CSE), Christ College of Engineering
Date: 26 March 2025
Example (After Modification - Added Instruction at Point A):

●​ The assembler automatically updates memory addresses.


●​ The JUMP LOOP instruction remains valid, as the assembler adjusts addresses internally.​

7.4.2 Advantage 3- Data Generation with Pseudo-Ops

Assembly language provides pseudo-op codes to help generate data in the correct binary format.

FIVE: .DATA +5

The assembler:

●​ Converts +5 into binary.


●​ Store it in memory.
●​ Assigns FIVE as its symbolic label.​

To load +5 into register R, we write:

LOAD FIVE

This is equivalent to LOAD 53 (if FIVE is stored at memory location 53). Using labels prevents
accidental errors, such as mistakenly loading data from memory address 5 instead of FIVE.

8. Fetch-Execute cycle instruction execution

The fetch-execute cycle is the fundamental operation of a computer, allowing it to process


instructions sequentially. This cycle consists of three primary stages: Fetch, Decode, and
Execute. The CPU continuously repeats this cycle to perform tasks.

---
Author: Athithya S.
Assistant Professor(CSE), Christ College of Engineering
Date: 26 March 2025
The Instruction Set & CPU Role

The instruction set is a predefined collection of tasks that the CPU is designed to execute. It
retrieves and processes instructions from the main memory to carry out operations efficiently.

Stages of the Fetch-Execute Cycle

1. Fetch Phase

The fetch phase involves retrieving the instruction from memory. Since the address of the current
instruction is stored in the program counter (PC), the first step is to transfer this address to the
memory address register (MAR):

(step 1) PC → MAR

This allows the computer to retrieve the instruction stored at that address. The instruction is then
moved from the memory data register (MDR) to the instruction register (IR):

(step 2) MDR → IR

At this point, the instruction register holds the instruction for the remainder of the cycle.

2. Decode Phase

During the decode phase, the CPU interprets the instruction in the instruction register to
determine the necessary operations. It extracts the address portion of the instruction and prepares
for execution:

(step 3) IR[address] → MAR

This step allows the CPU to access the required data from memory.

3. Execute Phase

The CPU performs the operation specified by the instruction. For a load instruction, data from
memory is transferred to the accumulator:

(step 4) MDR → A

After execution, the program counter is incremented to move to the next instruction:

(step 5) PC + 1 → PC

---
Author: Athithya S.
Assistant Professor(CSE), Christ College of Engineering
Date: 26 March 2025
Examples of Instructions

Load Instruction

PC → MAR

MDR → IR

IR[address] → MAR

MDR → A

PC + 1 → PC

Store Instruction

PC → MAR

MDR → IR

IR[address] → MAR

A → MDR

PC + 1 → PC

Add Instruction

PC → MAR

MDR → IR

IR[address] → MAR

A + MDR → A

PC + 1 → PC

---
Author: Athithya S.
Assistant Professor(CSE), Christ College of Engineering
Date: 26 March 2025
---
Author: Athithya S.
Assistant Professor(CSE), Christ College of Engineering
Date: 26 March 2025

You might also like