Basic Computer Organization and Design: Instruction Codes, Computer Registers, Computer
Instructions, Timing and Control, Instruction Cycle, Memory-Reference Instructions, Input-
Output and Interrupt, Complete Computer Description, Design of Basic Computer, Design of
Accumulator Logic.
A computer is an electronic device that accepts data as input, processes it according to a set of
instructions (called a program), stores the data if required, and produces meaningful
information as output.
A program is a set of instructions written in a programming language that tells the computer what
task to perform.
A program guides the computer step by step to solve a problem or complete a specific task.
Example
Program to add two numbers:
1. Read first number.
2. Read second number.
3. Add both numbers.
4. Display the result.
Computer Architecture refers to the design and structure of a computer system as seen by the
programmer. It describes what the computer does and how the programmer interacts with it.
It includes:
Instruction Set (instructions the CPU understands)
Data formats
Addressing modes
Registers visible to the programmer
Input/Output methods
Computer Organization refers to how the hardware components are connected and work
together to implement the computer architecture.
It explains how the computer does the work internally.
It includes:
Control Unit
Arithmetic Logic Unit (ALU)
Registers
Memory organization
Buses
Timing and control signals
Example
When an ADD instruction is executed:
Data is fetched from registers.
The ALU performs the addition.
The result is stored back into a register.
These internal operations belong to computer organization.
Functional Unit
A computer in its simplest form comprises five functional units namely input unit, output unit
memory unit, arithmetic & logic unit and control unit.
1. Input Unit: Computer accepts encoded information through input unit. The standard input
device is a keyboard. Whenever a key is pressed, keyboard controller sends the code to
CPU/Memory.
Examples include Mouse, Joystick, Tracker ball, Light pen, Digitizer, Scanner etc.
2. Memory Unit: Memory unit stores the program instructions (Code), data and results of
computations etc. Memory unit is classified as:
Primary /Main Memory
Secondary /Auxiliary Memory
Primary memory is a semiconductor memory that provides access at high speed. Run time program
instructions and operands are stored in the main memory. Main memory is classified again as
ROM and RAM.
Secondary memories are non volatile in nature.
3. Arithmetic and logic unit: ALU consist of necessary logic circuits like adder, comparator etc.,
to perform operations of addition, multiplication, comparison of two numbers etc.
4. Output Unit: Computer after computation returns the computed results, error messages, etc. via
output plotters etc.
5. Control Unit: Control unit co-ordinates activities of all units by issuing control signals. Control
signals issued by control unit govern the data transfers and then appropriate operations take
place. Control unit interprets or decides the operation/action to be performed.
Instruction Code
An Instruction Code is a group of binary bits (0s and 1s) that tells the computer what operation
to perform and on which data (operand).
It is the machine language instruction understood directly by the CPU.
It specifies:
The operation to be performed (Opcode)
The operand or data to be used
The sequence in which the operation is executed
Example
ADD R1, R2 → Adds the contents of registers R1 and R2.
LDA 500 → Loads data from memory location 500 into the accumulator.
Instruction Format
Definition
An Instruction Format is the layout or arrangement of different fields in an instruction. It
defines how the instruction is organized in memory so that the CPU can understand and execute
it.
Basic Instruction Format
OPCODE MODE ADDRESS
1. Opcode (Operation Code)
Specifies what operation the CPU should perform.
It is represented by a binary code.
Examples:
ADD
SUB
LOAD
STORE
JUMP
2. Mode Field (Addressing Mode)
Specifies how the CPU should locate the operand or calculate the effective address.
Examples of addressing modes:
Direct
Indirect
a) Direct Addressing Mode (Direct Address Mode)
Direct Addressing Mode is an addressing mode in which the address field of the instruction
contains the actual memory address of the operand.
The CPU directly accesses that memory location to fetch the data.
Formula
Effective Address (EA) = Address field
Example
Suppose:
Instruction: LOAD 500
Memory [500] = 25
Working:
CPU reads the instruction LOAD 500.
The address field is 500.
CPU directly accesses Memory location 500.
The value 25 is loaded into the Accumulator (AC).
Result:
AC = 25
b) Indirect Addressing Mode
In Indirect Addressing Mode, the address field does not contain the actual operand address.
Instead, it contains the address of another memory location, which stores the effective address
of the operand.
The CPU first finds the effective address and then accesses the operand.
Formula
Effective Address (EA) = Memory(Address field)
Example
Suppose:
Instruction: LOAD 500
Memory[500] = 800
Memory[800] = 25
Working:
CPU reads the instruction LOAD 500.
It goes to Memory[500].
Memory[500] contains 800, which is the effective address.
CPU then accesses Memory[800].
The value 25 is loaded into the Accumulator.
Result:
AC = 25
3. Address Field
Specifies the memory address or register where the operand is located.
The CPU uses this field to fetch the required data.
Computer Instructions
Computer instructions are commands that tell a computer how to perform specific tasks. These
instructions are typically divided into three categories:
Data Transfer Instructions
Arithmetic and Logic Instructions
Control Instructions
a) Data Transfer Instructions
Data transfer instructions are used to move data from one location to another within a computer
system. This includes transferring information between memory, CPU registers, and other
storage locations.
Common Data Transfer Instructions
Load: Copies data from memory into a CPU register for processing.
Store: Transfers data from a CPU register back to memory.
Move: Transfers data from one register to another within the CPU.
b) 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: Performs a bitwise operation on binary operands. The result is 1 only if all
corresponding bits are 1, otherwise, the result is 0.
OR: Performs a bitwise operation on binary operands. The result is 1 if at least one of the
corresponding bits is 1, otherwise, the result is 0.
NOT: A unary bitwise operation that inverts each bit of the operand (1 becomes 0 and 0
becomes 1).
XOR (Exclusive OR): Performs a bitwise operation that returns 1 if the corresponding bits are
different and 0 if they are the same. For multiple operands, it returns 1 when the number of 1s
is odd and 0 when even.
Uses of Computer Instructions
Data Manipulation: Basic computer instructions are used to move and process data within the
computer system, including transferring data between memory and the CPU and performing
arithmetic and logical operations.
Control Flow: These instructions control the sequence of program execution by enabling
conditional branching, looping, and function calls.
Input and Output Operations: Basic instructions allow data to be transferred between the
computer system and external devices such as keyboards, displays, printers, and storage
devices.
Program Execution: They support program execution by fetching, decoding, and executing
instructions and managing the movement of data required by programs.
Operating System Support: Basic computer instructions provide low-level functionality that
the operating system uses to implement tasks such as process control, interrupt handling, and
resource management.
Issues of Computer Instructions
Complexity: Basic computer instructions can be difficult to understand, especially for
beginners, which makes programming more challenging.
Limited Functionality: These instructions support only simple operations. Complex tasks
often require writing additional instructions, increasing program length and effort.
Compatibility: Instruction sets may vary across different computer systems. This variation can
require programmers to write system-specific code, which is time-consuming and inefficient.
Security: Basic computer instructions can be vulnerable to security issues such as buffer
overflows and code injection attacks.
Maintenance: Programs written using basic instructions can be difficult to maintain as systems
grow more complex and codebases become larger, requiring significant time and resources.
Timing and Control
The timing for all registers in the basic computer is controlled by a master clock generator.
The clock pulses are applied to all flip-flops and registers in the system, including the flip-flops
and registers in the control unit.
The clock pulses do not change the state of a register unless the register is enabled by a control
signal.
The clock signals are generated in the control unit and provide control inputs for the multiplexers
in the common bus, control inputs in processor registers, and micro operations for the
accumulator.
The outputs of the counter are decoded into 16 timing signals T0 through T15.
Instruction Cycle
The CPU performs a sequence of microoperations for each instruction. This sequence of
microoperations is called the Instruction Cycle.
Each instruction cycle consists of the following phases
1. Fetch an instruction from memory
2. Decode the instruction.
3. Read the effective address from memory if the instruction has an indirect address.
4. Execute the instruction.
Memory Reference Instructions
Registers Involved In Each Instruction Cycle:
Memory address registers(MAR) : It is connected to System Bus address lines. It specifies the
address of a read or write operation in memory.
Memory Buffer Register(MBR) : It is connected to the data lines of the system bus. : It is
connected to the system bus Data Lines. It holds the memory value to be stored, or the last
value read from the memory.
Program Counter(PC) : Holds the address of the next instruction to be fetched.
Instruction Register(IR) : Holds the last instruction fetched.
Fetch cycle
The address of the next instruction to execute is in the Program Counter(PC) at the beginning
of the fetch cycle.
Step 1: The address in the program counter is transferred to the Memory Address
Register(MAR), as this is the only register that is connected to the system bus address lines.
Step 2: The address in MAR is put on the address bus, now a Read order is provided by the
control unit on the control bus, and the result appears on the data bus and is then copied into
the memory buffer register. Program counter is incremented by one, to get ready for the next
instruction. These two acts can be carried out concurrently to save time.
Step 3: The content of the MBR is moved to the instruction register(IR).
Instruction fetch cycle consist of four micro operation:
T1: MAR ←PC
T2: MBR←memory
PC← PC + stepsize or length of instruction
T3: IR←MBR
Decode instruction cycle
The next move is to fetch source operands once an instruction is fetched. Indirect addressing
(it can be obtained by any addressing mode, here it is done by indirect addressing) is obtained
by Source Operand. You don't need to fetch register-based operands. If the opcode is
executed, it will require a similar process to store the result in main memory. Micro
operations take place:
T1: MAR←IR(address)
T2: MBR←Memory
T3: IR(address) ← (MBR(Address))
Step 1: The instruction address field is passed to the MAR. This is used to fetch the operand
's address.
Step 2: The address field of the IR is updated from the MBR.
Step 3: The IR is now in the state. Now IR is ready for the execute cycle.
Execute instruction Cycle
The initial three cycles (Fetch, Indirect, and Interrupt) are predictable and quick. Each requires
simple , small, and fixed micro-operation sequences. The same micro-operation is repeated
every time around in each event. Execute instruction cycle is different from them. Like, there
is N different series of micro-operations that can occur for a computer with different N
opcodes.
Example
ADD R , X
T1: MAR← (IR(address))
T2: MBR←Memory
T3: R← (R) + (MBR)
Step 1: The address portion of IR is loaded into the MAR.
Step 2: The address field of the IR is updated from the MBR, so the reference memory
location is read.
Step 3: Now, the contents of R and MBR are added by the ALU.
1. Input Device : An input device is a hardware or peripheral device used to enter data, instructions,
and commands into the computer system. It sends data to the CPU through the Input Register
(INPR) for processing.
Examples: Keyboard, Mouse, Scanner, Microphone
When a user types the letter A on the keyboard, the keyboard sends the ASCII code of A to the
Input Register (INPR). The CPU then reads this data and processes it.
2. Output Device: An output device is a hardware or peripheral device that receives the processed
data from the computer and presents it to the user in a meaningful form such as text, images, or
sound.
Examples: Monitor, Printer, Speaker, Projector
When the CPU processes the instruction to display the letter A, it first stores the data in the Output
Register (OUTR). The monitor then displays the character A on the screen.
3. Input Register (INPR): The Input Register (INPR) is an 8-bit register used to receive and
temporarily store data coming from an input device before it is transferred to the CPU for
processing.
Receives data from an input device.
Temporarily stores the input data.
Transfers the data to the CPU.
Example: Suppose the user presses the key A.
ASCII code of A = 65
Binary = 01000001
This binary value is stored in the Input Register (INPR) until the CPU reads it.
4. Output Register (OUTR): The Output Register (OUTR) is an 8-bit register used to
temporarily store data before sending it to an output device.
Functions
Receives processed data from the CPU.
Temporarily stores the data.
Sends the data to the output device.
Example: Suppose the CPU wants to display the letter B.
ASCII code of B = 66
Binary = 01000010
The CPU stores this value in OUTR, and then the monitor displays the letter B.
5. Input Flag (FGI): The Input Flag (FGI) is a 1-bit control flag that indicates whether new input
data is available in the Input Register (INPR).
If FGI = 1
o Indicates that new input data is available.
o The CPU can read the data from INPR.
If FGI = 0
o Indicates that no new input data is available.
o The CPU waits until new data arrives.
Example
1. The user presses the key C.
2. The keyboard stores the ASCII code of C in INPR.
3. FGI becomes 1, indicating that input data is ready.
4. The CPU reads the data from INPR.
5. After reading the data, FGI becomes 0.
6. Output Flag (FGO): The Output Flag (FGO) is a 1-bit control flag that indicates whether the
output device is ready to receive new data.
If FGO = 1
o The output device is ready.
o The CPU can send data to OUTR.
If FGO = 0
o The output device is busy.
o The CPU must wait before sending new data.
Example
1. The printer is ready.
2. FGO = 1.
3. The CPU sends data to OUTR.
4. While the printer is printing, FGO = 0.
5. After printing is complete, FGO = 1 again.
7. Interrupt: An interrupt is a signal generated by an input or output device that temporarily stops
the execution of the current program and requests the CPU to execute a special program called
the Interrupt Service Routine (ISR). After servicing the interrupt, the CPU resumes execution
of the interrupted program.
Why is Interrupt Needed?
The CPU is much faster than I/O devices.
Instead of continuously checking whether an I/O device is ready, the CPU performs other tasks.
When the device becomes ready, it sends an interrupt signal to the CPU.
Example
Suppose the CPU is executing a program and the user presses a key on the keyboard.
1. The keyboard stores the data in INPR.
2. It generates an interrupt signal.
3. The CPU temporarily stops the current program.
4. The CPU reads the keyboard input.
5. After servicing the interrupt, the CPU continues executing the previous program.
The Interrupt Enable (IEN) is a 1-bit flip-flop used to control whether interrupts are enabled or
disabled in the Basic Computer.
If IEN = 1 (Interrupt Enabled)
Interrupts are enabled.
If FGI = 1 or FGO = 1, an interrupt request is generated.
The CPU services the interrupt.
If IEN = 0 (Interrupt Disabled)
Interrupts are disabled.
The CPU ignores interrupt requests even if FGI = 1 or FGO = 1.
The CPU continues executing the current program.
Example: Suppose the keyboard has input ready (FGI = 1).
If IEN = 1, the CPU responds to the interrupt and reads the data.
If IEN = 0, the CPU ignores the interrupt and continues executing the current program.
Complete Computer Description
• The Basic Computer executes instructions stored in memory.
• It consists of CPU, Memory, Input-Output devices, and Control Unit.
• Every instruction is executed through Fetch, Decode, Execute, and Interrupt cycles.
Fetch Cycle
• Fetches the next instruction from memory.
• T₀: AR ← PC
• T₁: IR ← M[AR], PC ← PC + 1
• T₂: Decode opcode and load address.
AR ← IR(0–11)
Decode Cycle
• Identifies the type of instruction.
• D₇ = 0 → Memory Reference Instruction.
• D₇ = 1, I = 0 → Register Reference Instruction.
• D₇ = 1, I = 1 → Input-Output Instruction.
Memory Reference Instructions
• Executed when D₇ = 0.
• I = 0 → Direct Addressing.
• I = 1 → Indirect Addressing (AR ← M[AR]).
• Instructions: AND, ADD, LDA, STA, BUN, BSA, ISZ.
• After execution: SC ← 0.
Register Reference Instructions
• Executed when D₇ = 1 and I = 0.
• Operate directly on CPU registers.
• Instructions: CLA, CLE, CMA, CME, CIR, CIL, INC, SPA, SNA, SZA, SZE, HLT.
• After execution: SC ← 0.
Input-Output Instructions
• Executed when D₇ = 1 and I = 1.
• Used for communication with I/O devices.
• Instructions: INP, OUT, SKI, SKO, ION, IOF.
• After execution: SC ← 0.
Interrupt Cycle
• Executed when IEN = 1 and FGI = 1 or FGO = 1.
• T₀: AR ← 0, TR ← PC
• T₁: M[AR] ← TR, PC ← 0
• T₂: PC ← PC + 1, IEN ← 0, R ← 0, SC ← 0
• CPU executes the Interrupt Service Routine (ISR) and then returns to the main program.
Sequence Counter (SC)
• Generates timing signals T₀, T₁, T₂, T₃...
• Controls the sequence of microoperations.
• After each instruction, SC ← 0.
The cycle repeats until all program instructions are executed.
Design of Basic Computer
The Basic Architecture of a Computer shows how different components of a computer work
together to process data. It mainly consists of Input Devices, CPU (Control Unit and ALU),
Memory, and Output Devices.
Input Devices: Input devices are used to enter data and instructions into the computer. They send
the input data to the CPU for processing through memory. Common input devices are
Keyboard, Mouse, Scanner, and Joystick.
Central Processing Unit (CPU)
The CPU (Central Processing Unit) is called the brain of the computer because it controls and
performs all operations. It consists of two main parts:
Control Unit (CU) – Controls all the operations of the computer and coordinates the activities of
all components.
Arithmetic Logic Unit (ALU) – Performs arithmetic operations such as addition and subtraction,
and logical operations such as AND, OR, and NOT.
Memory: Memory is used to store data, instructions, and processing results. It stores the input data
before processing and the processed information before sending it to the output devices. The
CPU continuously exchanges data with memory during execution.
Output Devices: Output devices display the processed information to the user. They receive the
results from the CPU through memory. Common output devices are Monitor, Printer,
Speaker, and Headphones.
Working of the Computer
The user enters data using an input device. The data is stored in memory and sent to the CPU. The
Control Unit controls the execution of instructions, while the ALU performs arithmetic and
logical operations. The processed information is stored in memory and then sent to the output
device, where the final result is displayed to the user.
Design of Accumulator Logic