Open In App

Computer Organization - Basic Computer Instructions

Last Updated : 31 Jan, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

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. memory reference instruction

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. register reference instruction

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. i/o instruction

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:

SymbolHexadecimal CodeDescription
AND0xxx, 8xxxAND memory word to AC
ADD1xxx, 9xxxAdd memory word to AC
LDA2xxx, AxxxLoad memory word to AC
STA3xxx, BxxxStore AC content in memory
BUN4xxx, CxxxBranch Unconditionally
BSA5xxx, DxxxBranch and Save Return Address
ISZ 6xxx, ExxxIncrement and skip if 0
CLA7800Clear AC
CLE7400Clear E(overflow bit)
CMA7200Complement AC
CME7100Complement E
CIR7080Circulate right AC and E
CIL7040Circulate left AC and E
INC7020Increment AC
SPA7010Skip next instruction if AC > 0
SNA7008Skip next instruction if AC < 0
SZA7004Skip next instruction if AC = 0
SZE7002Skip next instruction if E = 0
HLT7001Halt computer
INPF800Input character to AC
OUTF400Output character from AC
SKIF200Skip on input flag
SKOF100Skip on output flag
IONF080Interrupt On
IOFF040Interrupt 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

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.

Next Article

Similar Reads