Instruction Codes

Understanding Computer Operations & Binary Instructions

Introduction to Instruction Codes

A computer instruction is a binary code that specifies a sequence of micro-operations for the computer to perform.

BINARY
What is an Instruction Code?

Instructions are fundamental to how computers process information, dictating the specific operations the machine should execute. Each instruction tells the computer exactly what to do and how to do it.

Example 16-bit Instruction
0010 1100 1010 0001
↑ Opcode ↑ ↑ Address ↑

Key Concepts

1
Binary Foundation

All computer instructions are represented in binary format (0s and 1s) that the processor can understand and execute.

2
Micro-operations

Each instruction triggers a sequence of micro-operations - the smallest executable operations within the processor.

3
Control Unit

The control unit interprets instruction codes and generates appropriate control signals to execute operations.

Components of Instruction Codes

Operation Code (Opcode)

OPCODE
The Heart of Every Instruction

The opcode is a group of bits that defines the specific operation to be performed. Common operations include add, subtract, shift, and complement.

Opcode Examples

000
AND Operation
001
ADD Operation
010
LDA (Load Accumulator)

Addressing Components

ADDR
Operands and Addresses

Instructions must specify where operands (data) are located and where results should be stored. This involves processor registers or memory addresses.

Interactive Address Calculator

Enter a 12-bit address (0-4095) to see its binary representation:

Instruction Formats

Memory-Reference Instructions

16-bit Memory-Reference Format

15
14
13
12
|
11
10
9
8
...
1
0
I
Opcode (3 bits)
Address (12 bits)

I bit (bit 15): Addressing mode (0 = Direct, 1 = Indirect)

Opcode: 000 through 110 for memory operations

Address: 12-bit address (0-4095)

Register-Reference Instructions

16-bit Register-Reference Format

15
14
13
12
|
11
10
9
8
...
1
0
0
111
Register Operation (12 bits)

Input-Output Instructions

16-bit I/O Format

15
14
13
12
|
11
10
9
8
...
1
0
1
111
I/O Operation (12 bits)

Instruction Format Identifier

Enter a 16-bit binary instruction to identify its format:

Basic Computer Instruction Set

Memory-Reference Instructions

AND
Logical AND

Performs logical AND between memory word and Accumulator (AC)

ADD
Addition

Adds memory word to AC with carry to E flip-flop

LDA
Load Accumulator

Loads memory word into the Accumulator

STA
Store Accumulator

Stores AC content into memory location

BUN
Branch Unconditionally

Transfers program control to new address

BSA
Branch and Save

Branches to subroutine and saves return address

Register-Reference Instructions

CLA
Clear AC

Sets Accumulator to zero

CLE
Clear E

Sets E flip-flop to zero

CMA
Complement AC

Complements all bits in AC

INC
Increment AC

Increments AC by one

Input-Output Instructions

INP
Input Character

Inputs character from terminal into AC

OUT
Output Character

Outputs character from AC to printer

SKI
Skip if Input Flag

Skips next instruction if input flag is on

ION
Interrupt On

Turns interrupt facility on

Interactive Demonstration

Instruction Execution Simulator

Select an instruction and see how it executes step by step:

Before Execution

AC: 0000000000000000
Memory[100]: 0000000000001010

After Execution

AC: 0000000000001010
Memory[100]: 0000000000001010

Binary to Hex Converter

Convert instruction codes between binary and hexadecimal:

Knowledge Quiz

What is the primary purpose of an instruction code's opcode?
A) To specify the memory address of operands
B) To define the specific operation to be performed
C) To indicate the addressing mode only
D) To store the result of the operation

Key Takeaways

1
Binary Foundation

All instructions are binary codes that specify micro-operations

2
Three Formats

Memory-reference, Register-reference, and I/O instructions

3
Addressing Modes

Direct (I=0) and Indirect (I=1) addressing modes