0% found this document useful (0 votes)
9 views20 pages

Module 3 - Part 1

The document provides an overview of computer organization, focusing on basic computer instructions categorized into data transfer, arithmetic and logic, and control instructions. It details the instruction set of a basic computer, including memory reference, register reference, and input/output instructions, along with the roles of various registers and the instruction cycle. Additionally, it discusses the stack organization for memory management and arithmetic expression evaluation using postfix notation.

Uploaded by

manomitkundu1590
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)
9 views20 pages

Module 3 - Part 1

The document provides an overview of computer organization, focusing on basic computer instructions categorized into data transfer, arithmetic and logic, and control instructions. It details the instruction set of a basic computer, including memory reference, register reference, and input/output instructions, along with the roles of various registers and the instruction cycle. Additionally, it discusses the stack organization for memory management and arithmetic expression evaluation using postfix notation.

Uploaded by

manomitkundu1590
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

Computer Organization - Basic Computer

Instructions
Computer organization refers to the way in which the components of a computer system are
organized and interconnected to perform specific tasks. One of the most fundamental aspects of
computer organization is the set of basic computer instructions that the system can execute.

Basic Computer Instructions


Basic computer instructions are commands given to a computer to perform specific tasks. These
instructions are typically divided into three categories:

1. Data Transfer Instructions: Move data between memory and registers (e.g., Load,
Store).

1. Arithmetic and Logic Instructions: Perform math or logic operations (e.g., Add,
Subtract, AND, OR).

1. Control Instructions: Guide the flow of the program (e.g., Jump, Branch, Call).

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.

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.

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.

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 Set of a Basic Computer


The basic computer has 16-bit instruction register (IR) which can denote either memory reference
or register reference or input-output instruction.

Memory Reference Instructions

These instructions refer to memory address as an operand. The other operand is always
accumulator. Specifies 12-bit address, 3-bit opcode (other than 111) and 1-bit addressing mode
for direct and indirect addressing.

Register Reference Instructions

These instructions perform operations on registers rather than memory addresses. The IR(14 -
12) is 111 (differentiates it from memory reference) and IR(15) is 0 (differentiates it from
input/output instructions). The rest 12 bits specify register operation.

Input/Output Instructions

These instructions are for communication between computer and outside environment. The
IR(14 - 12) is 111 (differentiates it from memory reference) and IR(15) is 1 (differentiates it
from register reference instructions). The rest 12 bits specify I/O operation.

Essential Instructions in a Basic Computer


Program Counter (PC) is a key part of a computer, and its instructions are the basic tasks a
computer performs. These instructions are handled by the computer's CPU (Central Processing
Unit) and form the foundation for more complex operations. Some examples of basic PC
instructions include:

Symbol Description
AND AND memory word to AC
ADD Add memory word to AC
LDA Load memory word to AC
STA Store AC content in memory
BUN Branch Unconditionally
BSA Branch and Save Return Address
ISZ Increment and skip if 0
CLA Clear AC
Symbol Description
CLE Clear E(overflow bit)
CMA Complement AC
CME Complement E
CIR Circulate right AC and E
CIL Circulate left AC and E
INC Increment AC
HLT Halt computer
OUT Output character from AC
ION Interrupt On
IOF Interrupt Off

Note: In the given table,

1. AC (Accumulator): A register that temporarily stores data during arithmetic or logic


operations.

2. E (Carry/Overflow Bit): A single-bit register used for carry operations or overflow


detection in arithmetic calculations.

Example of Instruction Execution

 ADD Instruction:
Suppose the memory address 0001 contains the value 5, and the AC currently holds 10.
The ADD instruction fetches the value from memory, adds it to the AC, and stores the
result in the AC.

AC ← AC + M[0001]
Result: AC = 10 + 5 = 15

Instruction Cycle
A program residing in the memory unit of a computer consists of a sequence of instructions.
These instructions are executed by the processor by going through a cycle for each instruction.

In a basic computer, each instruction cycle consists of the following phases:

1. Fetch instruction from memory.


2. Decode the instruction.
3. Read the effective address from memory.
4. Execute the instruction.
Instruction Set Completeness
A set of instructions is said to be complete if the computer includes a sufficient number of
instructions in each of the following categories:

 Arithmetic, logical and shift instructions


 A set of instructions for moving information to and from memory and processor registers.
 Instructions which controls the program together with instructions that check status
conditions.
 Input and Output instructions

Arithmetic, logic and shift instructions provide computational capabilities for processing the type
of data the user may wish to employ.

A huge amount of binary information is stored in the memory unit, but all computations are done
in processor registers. Therefore, one must possess the capability of moving information between
these two units.

Program control instructions such as branch instructions are used change the sequence in which
the program is executed.

Input and Output instructions act as an interface between the computer and the user. Programs
and data must be transferred into memory, and the results of computations must be transferred
back to the user.

Input-Output Configuration
In computer architecture, input-output devices act as an interface between the machine and the
user.

Instructions and data stored in the memory must come from some input device. The results are
displayed to the user through some output device.

The input-output terminals send and receive information.

 The amount of information transferred will always have eight bits of an alphanumeric
code.
 The information generated through the keyboard is shifted into an input register ‘INPR’.
 The information for the printer is stored in the output register ‘OUTR’.
 Registers INPR and OUTR communicate with a communication interface serially and
with the AC in parallel.
 The transmitter interface receives information from the keyboard and transmits it to
INPR.
 The receiver interface receives information from OUTR and sends it to the printer
serially.

Design of a Basic Computer


A basic computer consists of the following hardware components.

1. A memory unit with 4096 words of 16 bits each


2. Registers: AC (Accumulator), DR (Data register), AR (Address register), IR (Instruction
register), PC (Program counter), TR (Temporary register), SC (Sequence Counter), INPR
(Input register), and OUTR (Output register).
3. Flip-Flops:
4. Decoders: a 3 x 8 operation decoder and 4 x 16 timing decoder
5. A 16-bit common bus
6. Control Logic Gates
7. The Logic and Adder circuits connected to the input of AC

Uses of Basic Computer Instructions


 Data manipulation: Basic computer instructions are used to handle data in the computer
system, including moving data between memory and the CPU.

 Control flow: Basic instructions guide the flow of a program by branching to different
parts based on conditions.

 Input/output operations: Instructions are used to transfer data between the computer
and external devices like keyboards, printers, or monitors.

 Program execution: They load programs into memory and control their execution by
moving data in and out of the program.

 System maintenance: These instructions handle tasks like memory allocation, interrupt
management, error detection and correction.

Issues of Basic Computer Instructions


 Complexity: Instructions can be hard to understand, especially for beginners, making
programming challenging.

 Limited functionality: Basic instructions can handle only simple tasks. Programmers
require to write extra code for complex operations.
 Compatibility: Instructions may vary across different computer systems This can require
programmers to write separate code for each system, which can be time-consuming and
inefficient.

 Security: Basic computer instructions can be vulnerable to security threats, such as


buffer overflows and code injection attacks.

 Maintenance: Basic computer instructions can be difficult to maintain, particularly as


systems become more complex and code becomes more extensive. This can require
significant resources, time and effort.

What are Computer Registers in Computer


Architecture?
Computer registers are high-speed memory storing units. It is an element of the computer
processor. It can carry any type of information including a bit sequence or single data.

A register should be 32 bits in length for a 32-bit instruction computer. Registers can be
numbered relies upon the processor design and language rules.

The instructions in a computer are saved in memory locations and implemented one after another
at a time. The function of the control unit is to fetch the instruction from the memory and
implement it. The control does the similar for all the instructions in the memory in sequential
order.

A counter is needed to maintain a path of the next instruction to be implemented and evaluate its
address. The figure shows the registers with their memories. The memory addresses are saved in
multiple registers. These requirements certainly state the use for registers in a computer.
The following table shows the registers and their functions.

Register Symbol Number of Bits Register Name Function


OUTR 8 Output register OIt holds output character.
INPR 8 Input register It holds input character.
PC 12 Program Counter It holds the address of the instruction.
AR 12 Address Register It holds an address for memory.
DR 16 Data Register It holds memory operand.
AC 16 Accumulator It’s a processor register.
IR 16 Instruction Register It holds an instruction code.
TR 16 Temporary Register It holds temporary data.

The description for each of the registers determined in the figure is as follows −

 The data register holds the operand read from the memory.
 The accumulator is a general-purpose register need for processing.
 The instruction register holds the read memory.
 The temporary data used while processing is stored in the temporary register.
 The address register holds the address of the instruction that is to be implemented next
from the memory.
 The Program Counter (PC) controls the sequence of instructions to be read. In case a
branch instruction is detected, the sequential execution does not arise. A branch execution
calls for a transfer to an instruction that is not in sequence with the instructions in the PC.
 The input register (INPR) and output register (OUTPR) are the registers used for the I/O
operations. The INPR receives an 8-bit character from the input device. It is similar to the
OUTPR.

Memory Stack Organization in Computer


Architecture
A stack is a storage device in which the information or item stored last is retrieved first. Basically,
a computer system follows a memory stack organization, and here we will look at how it works.

A portion of memory is assigned to a stack operation to implement the stack in the CPU. Here the
processor register is used as a Stack Pointer (SP). The above figure shows the portion of computer
memory divided into three segments: Program Instructions, Data, and Stack.

 Program Counter (PC): It is a register that points to the address of the next instruction
that is going to be executed in the program.

 Address Register (AR): This register points at the collection of data and is used during
the execute phase to read an operand.

 Stack Pointer (SP): It points at the top of the stack and is used to push or pop the data
items in or from the stack.

As we can see in the figure, these three registers are connected to a common address bus and
either one of them can provide an address for memory.
Stack Pointer is first going to point at the address 3001, and then the stack will grow with the
decreasing addresses. It means that the first item is going to be stored at address 3001, the second
item at address 3000, and the items can keep getting stored in the stack until it reaches the last
address 2000 where the last item will be held.

Here the data which is getting inserted into the Stack is obtained from the Data Register and the
data retrieved from the Stack is also read by the Data Register.

Now, let's see the working of PUSH and POP operations in Memory Stack Organization.

PUSH
This operation is used to insert a new data item into the top of the Stack. The new item can be
inserted as follows:-

SP ←SP-1

M[SP]← DR

In the first step, the Stack Pointer is decremented to point at the address where the data item will
be stored.
Then, by using the memory write operation, the data item from Data Register gets inserted into the
top of the stack ( at the address where the Stack Pointer is pointing).

POP
This operation is used to delete a data item from the top of the Stack. Data item can be deleted as
follows:-

DR←M[SP]

SP←SP+1

In the first step, the top data item is read from the Stack into the Data Register. The Stack Pointer
is then incremented to point at the next data item in the stack. Push or Pop operations can be
performed with the help of the following microoperations:

 Access to memory with the help of Stack Pointer (SP), and

 Updating the stack.

It totally depends upon the organization of the stack whether the Stack Pointer (SP) is updated by
incrementing or decrementing the address values.

In this case, the Stack Pointer grows by decreasing the memory address. The Stack may be made
in a way that the Stack Pointer grows by increasing the memory also.

Since the address is always available and automatically updated in the Stack Pointer, the CPU can
refer to the Memory Stack without having to specify an address.

Arithmetic Expression Evaluation


The stack organization is very effective in evaluating arithmetic expressions. Expressions are
usually represented in what is known as Infix notation, in which each operator is written
between two operands (i.e., A + B). With this notation, we must distinguish between ( A + B )*C
and A + ( B * C ) by using either parentheses or some operator-precedence convention. Thus, the
order of operators and operands in an arithmetic expression does not uniquely determine the
order in which the operations are to be performed.

1. Polish notation (prefix notation) -


It refers to the notation in which the operator is placed before its two operands. Here no
parentheses are required, i.e.,

+AB
2. Reverse Polish notation(postfix notation) -
It refers to the analogous notation in which the operator is placed after its two operands. Again,
no parentheses is required in Reverse Polish notation, i.e.,

AB+

Stack-organized computers are better suited for post-fix notation than the traditional infix
notation. Thus, the infix notation must be converted to the postfix notation. The conversion from
infix notation to postfix notation must take into consideration the operational hierarchy.

There are 3 levels of precedence for 5 binary operators as given below:

Highest: Exponentiation (^)


Next highest: Multiplication (*) and division (/)
Lowest: Addition (+) and Subtraction (-)

For example -

Infix notation: (A-B)*[C/(D+E)+F]


Post-fix notation: AB- CDE +/F +*

Here, we first perform the arithmetic inside the parentheses (A-B) and (D+E). The division of
C/(D+E) must be done prior to the addition with F. After that multiply the two terms inside the
parentheses and bracket.

Now we need to calculate the value of these arithmetic operations by using a stack.

The procedure for getting the result is:

1. Convert the expression in Reverse Polish notation( post-fix notation).


2. Push the operands into the stack in the order they appear.
3. When any operator encounters then pop two topmost operands for executing the
operation.
4. After execution push the result obtained into the stack.
5. After the complete execution of expression, the final result remains on the top of the
stack.

For example -

Infix notation: (2+4) * (4+6)


Post-fix notation: 2 4 + 4 6 + *
Result: 60

The stack operations for this expression evaluation is shown below:


Addressing Modes
Addressing modes are techniques used by the CPU to identify the location of the operand(s)
needed for executing an instruction. They provide rules for interpreting the address field in an
instruction, helping the CPU fetch operands correctly.

 Opcode – Tells the CPU what operation to perform (e.g., ADD, MOV).

 Operands – The data or addresses on which the operation is performed.

Addressing Modes Types


Implicit (Implied) Addressing

The instruction does not mention the operand directly. The CPU knows what to use from the
instruction itself, usually a special register like the accumulator or the stack.
It is used for special instructions or control commands like CLA, PUSH, and RET, where the
operand is automatically known from the instruction itself

Immediate Addressing

The operand is the part of the instruction itself. It is used when the value is known while writing
the program.

Example: MOV R1, #5 moves the value 5 into register R1, where #5 is the immediate value.

Direct Addressing

The instruction contains the memory address of the operand. The CPU accesses the data directly
from that address.

Example: LOAD R1, 1000 loads data from memory address 1000 into register R1.
Indirect Addressing

The instruction contains the address of a register or memory location that holds the actual
address of the operand. The CPU first fetches this address, then accesses the operand.

Example: LOAD R1, (R2) loads data from the memory location whose address is in register R2.

Register Addressing

The operand is located in a CPU register specified by the instruction.

Step:

 The instruction specifies a register (R).

 The CPU takes operand directly from register R.


Example: MOV A, B operates between registers A and B.

Register Indirect Addressing

The register specified in the instruction contains the memory address of the operand.

Step:

 The instruction specifies a register.

 This register holds the address (A).

 The CPU fetches the operand from memory location A.

Example: MOV A, [R1] uses content of R1 as memory address.

Displacement Addressing (Indexed, Base-Register, Relative)

The operand’s effective address is calculated by adding a constant value (displacement) to the
contents of one or more registers.
Step:

 The instruction provides a base register (R) and an address part (A).

 CPU adds the value of R and A to get the effective operand address.

 Operand is fetched from the calculated address in memory.

Example: Used for arrays, accessing an element at a position relative to a base.

Stack Addressing

The operand is implicitly taken from the top of the stack, without being mentioned in the
instruction.
Step:

 Operation is performed using the value at the stack’s top (implied by instruction).

 No need for explicit operand field; CPU refers to stack pointer register by default.

Example: POP and PUSH operations.

RISC vs CISC Architecture


RISC and CISC are two different ways of designing computer processors.

 RISC uses a small set of simple, fixed-size instructions designed to execute in a single
clock cycle.

 CISC includes a larger set of instructions, many of which are complex and can perform
multiple operations (e.g., memory access and computation) in a single instruction.

 CISC instructions often require multiple clock cycles.

Reduced Instruction Set Architecture (RISC)


RISC simplifies processor design by using a small, uniform set of instructions. Each instruction
performs a basic operation (e.g., load, compute, store) and is designed to execute in a single
clock cycle, enabling efficient pipelining and simpler hardware.

Characteristics of RISC

 Simpler instruction, hence simple instruction decoding.

 Instruction comes in the form of one word.

 An instruction takes a single clock cycle to get executed.

 More general-purpose registers for register-to-register operations.

 Simple Addressing Modes.

 Optimized for pipelining due to uniform instruction size and simplicity.

Complex Instruction Set Architecture (CISC)


CISC reduces the number of instructions a program needs by using a large set of complex,
variable-length instructions. A single instruction can perform multiple operations (e.g., load,
compute, and store), which may take multiple clock cycles.

Characteristics of CISC

 Complex instruction, hence complex instruction decoding.

 Instructions are larger than one-word size.

 Instruction may take more than a single clock cycle to get executed.

 Less number of general-purpose registers as operations get performed in memory itself.

 Complex Addressing Modes.

CPU Performance of RISC and CISC


Both approaches try to increase the CPU performance

CPU Time

 RISC: Reduce the cycles per instruction at the cost of the number of instructions per
program.

 CISC: The CISC approach attempts to minimize the number of instructions per program
but at the cost of an increase in the number of cycles per instruction.

Earlier when programming was done using assembly language, a need was felt to make instruction
do more tasks because programming in assembly was tedious and error-prone due to which CISC
architecture evolved but with the uprise of high-level language dependency on assembly reduced
RISC architecture prevailed.

Example:

Suppose we have to add two 8-bit numbers:

 CISC approach: There will be a single command or instruction for this like ADD which
will perform the task.

 RISC approach: Here programmer will write the first load command to load data in
registers then it will use a suitable operator and then it will store the result in the desired
location.
So, add operation is divided into parts i.e. load, operate, store due to which RISC programs are
longer and require more memory to get stored but require fewer transistors due to less complex
command.

Comparison Table
RISC and CISC are two processor designs, here is a comparison table between them:

RISC CISC
Small and simple instruction set Large and complex instruction set
Fixed-length instructions Variable-length instructions
Usually 1 cycle per instruction Multiple cycles per instruction
More general-purpose registers Fewer registers
Simple and limited addressing modes Complex and many addressing modes
Larger code size (more instructions) Smaller code size (fewer instructions)
Simple hardware, easier pipelining Complex hardware, harder pipelining
Examples: ARM, RISC-V, MIPS Examples: x86, Intel 80386

You might also like