Central Processing Unit
Instruction Formats

Data Transfer and Manipulation

Introduction

Computers provide an extensive set of instructions to give the user the flexibility to perform various computational tasks. While the instruction sets of different computers vary mainly in how operands are determined from the address and mode fields, the actual operations are largely similar across different machines. Differences typically arise in the binary code assignments for the operation code field and the symbolic names given to instructions in assembly language. However, most computers include a set of basic operations in their instruction repertoire. This documentation covers the basic set of operations found in a typical computer, focusing on data transfer and manipulation instructions.

Classification of Instructions

Most computer instructions can be categorized into three groups:

  1. Data transfer instructions
  2. Data manipulation instructions
  3. Program control instructions
  • Data transfer instructions move data from one location to another without changing the data's content.
  • Data manipulation instructions perform arithmetic, logic, and shift operations on data.
  • Program control instructions enable decision-making and change the program's execution path.

The instruction set of a particular computer determines the available register transfer operations and control decisions for the user.

Data Transfer Instructions

Data transfer instructions move data within the computer without altering its content. Common transfers include:

  • Between memory and processor registers
  • Between processor registers and input/output devices
  • Between processor registers themselves

Typical Data Transfer Instructions

NameMnemonic
LoadLD
StoreST
MoveMOV
ExchangeXCH
InputIN
OutputOUT
PushPUSH
PopPOP

Different computers may use various mnemonics for these instructions.

Load Instruction with Various Addressing Modes

ModeAssembly ConventionRegister Transfer
Direct addressLD ADRAC ← M[ADR]
Indirect addressLD @ADRAC ← M[M[ADR]]
Relative addressLD $ADRAC ← M[PC + ADR]
Immediate operandLD #NBRAC ← NBR
Index addressingLD ADR(X)AC ← M[ADR + XR]
RegisterLD R1AC ← R1
Register indirectLD (R1)AC ← M[R1]
AutoincrementLD (R1)+AC ← M[R1], R1 ← R1 + 1

In the above table:

  • ADR stands for an address.
  • NBR is a number or operand.
  • X is an index register.
  • R1 is a processor register.
  • AC is the accumulator register.

Data Manipulation Instructions

Data manipulation instructions perform operations on data, providing computational capabilities. They can be categorized into three types:

  1. Arithmetic instructions
  2. Logical and bit manipulation instructions
  3. Shift instructions

Arithmetic Instructions

Typical arithmetic instructions include:

NameMnemonic
IncrementINC
DecrementDEC
AddADD
SubtractSUB
MultiplyMUL
DivideDIV
Add with carryADDC
Subtract with borrowSUBB
Negate (2's complement)NEG

Computers may have multiple add instructions for different data types, such as:

  • ADDI: Add two binary integers
  • ADDF: Add two floating-point numbers
  • ADDD: Add two decimal numbers in BCD

Logical and Bit Manipulation Instructions

Logical instructions operate on binary data at the bit level. Typical instructions include:

NameMnemonic
ClearCLR
ComplementCOM
ANDAND
OROR
Exclusive-ORXOR
Clear carryCLRC
Set carrySETC
Complement carryCOMC
Enable interruptEI
Disable interruptDI
  • AND: Used to clear specific bits by masking.
  • OR: Used to set specific bits.
  • XOR: Used to complement specific bits.

Shift Instructions

Shift instructions move bits within a word, with variations in how bits are shifted in. Types of shift instructions include:

NameMnemonic
Logical shift rightSHR
Logical shift leftSHL
Arithmetic shift rightSHRA
Arithmetic shift leftSHLA
Rotate rightROR
Rotate leftROL
Rotate right through carryRORC
Rotate left through carryROLC

Shifts can be logical (inserting 0s), arithmetic (preserving the sign bit), or rotate (circular shifts). Some computers use a multiple-field format for shift instructions, allowing specification of the type, direction, and number of shifts.

Shift Instruction Format

A possible format for a shift instruction includes five fields:

  • OP: Operation code field
  • REG: Register address specifying the operand location
  • TYPE: 2-bit field specifying the type of shift
  • RL: 1-bit field specifying right or left shift
  • COUNT: Field specifying the number of shifts

By using such a format, one instruction can specify the type, direction, and number of shifts.