Instruction Sets, Addressing Modes, and Processor Structure
Machine Instruction Principles and Instruction Set Architecture
Definition and Operational Role of Machine Instructions:
- The operational behavior of a processor is fundamentally determined by the instructions it executes, referred to as machine instructions or computer instructions.
- The complete collection of distinct instructions that a processor can execute is defined as the processor's instruction set.
- Each instruction must encapsulate all information required by the processor for execution, dictating operations, data sources, destinations, and subsequent sequencing.
Constituent Elements of a Machine Instruction:
- Operation Code (Opcode): Specifies the operation to be performed using a binary code known as the opcode.
- Source Operand Reference: The operation may involve one or more source operands, which serve as inputs for the operation.
- Result Operand Reference: The operation may produce a result that needs to be stored in a designated destination.
- Next Instruction Reference: Informs the processor where to fetch the next instruction after the execution of the current instruction is complete (typically sequential unless a branch or jump occurs).
Operand Storage Locations:
- Source and result operands can reside in four primary areas:
- Processor Register: The processor contains one or more internal registers. If multiple registers exist, each is assigned a unique name or numerical identifier, and the instruction explicitly references the desired register (e.g., , which adds the contents of and and stores the sum in ).
- Main or Virtual Memory: The instruction supplies the memory address of the operand (e.g., , which fetches data from memory address into ).
- I/O Device: The instruction specifies the I/O module and device. When memory-mapped I/O is employed, the device port is referenced simply as another main or virtual memory address (e.g., ).
- Immediate Value: The operand value is stored directly in an immediate field within the instruction itself, requiring no memory or register reference (e.g., , which adds the literal value to and stores the result in ).
Instruction Representation and Fields:
- Within the computer, each instruction is represented physically as a sequence of bits.
- The instruction is partitioned into structured bit fields corresponding to its constituent elements (Opcode, Operand References, Addressing Modes).
- Opcodes are represented in assembly language and technical literature using human-readable abbreviations called mnemonics:
: Add numeric values: Subtract numeric values: Multiply numeric values: Divide numeric values: Load data from memory into processor registers: Store data from processor registers into memory

- Instruction Addressing Architectures (Three, Two, and One Address):
- To compute the expression , architectures utilize different instruction formats depending on the number of address references allowed per instruction:
- Three-Address Instructions:
- Format specifies two source operand addresses and one destination address ().
- Program sequence:
ComputesComputes temporary variableComputesComputes
- Characteristics: Results in short programs with fewer instructions, but requires longer instruction bit lengths to encode three distinct address fields.
- Two-Address Instructions:
- One address field doubles as both an operand source and the destination for the result ().
- Program sequence:
CopiesComputesCopies temporary variableComputesComputesComputes
- Characteristics: Balances instruction length and program length; requires explicit move instructions to avoid overwriting needed operands.
- One-Address Instructions:
- Relies on an implicit processor register, the Accumulator (), as a source and destination for all computations ().
- Program sequence:
LoadsComputesComputesStoresLoadsComputesComputesStores
- Characteristics: Very short instruction word lengths, but requires a higher total instruction count and frequent memory access cycles.
Operands and Hardware Data Types
General Types of Operands:
- Addresses: Unsigned integers that reference specific memory locations or offset values (e.g.,
fetches content from memory address ). - Numbers: All digital machines process numerical data across three standard formats:
- Binary Integer (signed fixed-point or unsigned).
- Binary Floating Point (scientific notation: sign, exponent, and significand/mantissa).
- Decimal (base- representations).
- Packed Decimal:
- Each decimal digit ( to ) is encoded using a binary nibble.
- Two decimal digits are packed into each byte (representing values from to per byte).
- Multiple consecutive bytes are concatenated to represent arbitrarily large decimal numbers without rounding errors, widely used in financial computation.
- Characters:
- Textual strings composed of alphabetic characters, numerals, and punctuation symbols encoded as binary values.
- Common standards: ASCII ( or code) and Unicode.
- Example: Character
'A'corresponds to decimal code , encoded as binary byte . - Logical Data:
- Treats an unit (word, byte) as an array of individual bits, where each bit represents a Boolean truth value (, ).
- Operates on individual bits directly via Boolean logic gates rather than treating the unit as a collective numeric quantity.
- Addresses: Unsigned integers that reference specific memory locations or offset values (e.g.,
Comprehensive Classification of Data Types:
- General: Byte, word (), doubleword (), quadword (), and double quadword () locations with arbitrary binary contents.
- Integer: Signed binary value contained within a byte, word, or doubleword using two's complement representation.
- Ordinal: Unsigned binary integer contained within a byte, word, or doubleword.
- Unpacked Binary Coded Decimal (BCD): Representation of a single BCD digit in the range through , stored with one digit per byte.
- Packed BCD: Byte representation packing two BCD digits into one byte, spanning values from to .
- Near Pointer: A , , or effective address representing an offset within a segment; used for all pointers in nonsegmented memory architectures and references within a segment in segmented models.
- Far Pointer: A logical address comprising a segment selector combined with a , , or offset; required when accessing memory across segmented boundaries where the target segment identity must be explicitly stated.
- Bit Field: A contiguous sequence of bits where the position of each bit is evaluated independently; can originate at any bit position in any byte and span up to .
- Bit String: A contiguous bit sequence spanning anywhere from to .
- Byte String: A contiguous sequence of bytes, words, or doublewords spanning from to .
- Packed SIMD (Single Instruction, Multiple Data): Dedicated packed data configurations structured in and chunks containing multiple parallel sub-elements.

- Numeric Data Format Structural Bit Layouts:
- Byte Unsigned Integer: Bits .
- Word Unsigned Integer: Bits .
- Doubleword Unsigned Integer: Bits .
- Quadword Unsigned Integer: Bits .
- Byte Signed Integer (Two's Complement): Bit is sign bit; bits represent value magnitude.
- Word Signed Integer (Two's Complement): Bit is sign bit; bits represent value magnitude.
- Doubleword Signed Integer (Two's Complement): Bit is sign bit; bits represent value magnitude.
- Quadword Signed Integer (Two's Complement): Bit is sign bit; bits represent value magnitude.
- Half Precision Floating Point: layout; Bit is sign bit; bits encode the exponent; bits represent the significand.
- Single Precision Floating Point: layout; Bit is sign bit; bits encode the exponent; bits represent the significand.
- Double Precision Floating Point: layout; Bit is sign bit; bits encode the exponent; bits represent the significand.
- Double Extended Precision Floating Point: layout; Bit is sign bit; bits encode the exponent; bit is an explicit integer bit; bits represent the fractional significand.
Types of Operations in Instruction Sets
High-Level Functional Categories of Machine Instructions:
- Data Processing: Computational instructions executing arithmetic and logical evaluations on data words inside the Arithmetic Logic Unit (ALU).
- Data Storage: Memory instructions responsible for moving data between processor registers and memory locations.
- Data Movement: I/O instructions moving data between processor/memory registers and external peripheral interfaces.
- Control: Test and branch instructions examining computational conditions and directing programmatic control flow.
Data Transfer Operations:
- The most fundamental and frequently executed type of machine instruction.
- Must unambiguously specify three parameters:
- The exact location of the source operand and destination operand (memory address, processor register, stack top).
- The length (number of bits/bytes) of data to be transferred.
- The addressing mode for each operand.
- Standard operations:
: Transfer a word or block from source to destination.: Transfer a word from processor register to memory.: Transfer a word from memory to processor register.: Swap the contents of source and destination.: Transfer a word of binary to destination.: Transfer a word of binary to destination.: Transfer a word from source to top of the system stack.: Transfer a word from top of the system stack to destination.- IBM EAS/390 Data Transfer Example Implementations:
(Load): ; transfer from memory to general register.(Load Halfword): ; transfer from memory to register.(Load): ; transfer from register to register.(Load Short): ; transfer from floating-point register to floating-point register.(Load Short): ; transfer from memory to floating-point register.(Load Long): ; transfer from floating-point register to floating-point register.(Load Long): ; transfer from memory to floating-point register.(Store): ; transfer from register to memory.(Store Halfword): ; transfer from register to memory.(Store Character): ; transfer from register to memory.(Store Short): ; transfer from floating-point register to memory.(Store Long): ; transfer from floating-point register to memory.
Arithmetic Operations:
- Core arithmetic primitives provided for signed fixed-point integers, binary floating-point numbers, and packed decimal numbers:
: Compute sum of two operands ().: Compute difference of two operands ().: Compute product of two operands ().: Compute quotient of two operands ().- Single-operand arithmetic instructions:
: Replace operand by its absolute magnitude ().: Change the mathematical sign of the operand via two's complement negation ().: Add to the operand ().: Subtract from the operand ().
Logical Operations:
- Treat words as strings of individual binary bits to execute Boolean evaluations:
(): Output is if and only if both input bits are .(): Output is if at least one input bit is .(): Complement/reverses each bit (, ).(): Output is if inputs differ; if inputs are identical.
Standard Boolean Truth Table Verification:
- When : , , , , .
When : , , , , .
When : , , , , .
When : , , , , .
- Specialized logical instructions:
: Test a specified bit or condition without modifying data; updates hardware processor flags.: Performs an arithmetic subtraction or logical comparison to set processor condition codes without saving the subtraction result.: Class of instructions modifying hardware controls for memory protection, interrupt management, and timer operations.
Shift and Rotate Operations:
- Bitwise manipulation instructions altering the position of bits within an operand word.

Shift Operations:
- Bits shift linearly in the specified direction; vacated positions are filled with constant binary values (usually zero), and bits dropping off the end are discarded.
- Logical Right Shift: Bits move right; is inserted at the most significant bit (MSB); dropped least significant bits (LSB) are discarded.
- Logical Left Shift: Bits move left; is inserted at the LSB; dropped MSB bits are discarded.
- Arithmetic Right Shift: Preserves signed numbers; bits shift right, but the sign bit (MSB) is replicated into vacated positions to preserve arithmetic sign.
- Arithmetic Left Shift: Bits move left, filling LSB with (identical to logical left shift, though overflow is signaled if sign bit changes).
Rotate Operations:
- Wraparound operations preserving all bits; bits displaced out of one end are circulated back into the vacated position at the opposite end.
- Right Rotate: Bits shifted right; displaced LSB wraps around to enter the MSB.
- Left Rotate: Bits shifted left; displaced MSB wraps around to enter the LSB.
Worked Reference Examples ( Displacements on Input Byte ):
Input Byte:
Logical Right Shift (): Result =
Logical Left Shift (): Result =
Arithmetic Right Shift (): Result = (sign bit replicated)
Arithmetic Left Shift (): Result =
Right Rotate (): Result =
Left Rotate (): Result =
Conversion Operations:
Transform data representation or numeric base format:
Converting binary to decimal, or packed BCD to binary representation.
: Translates a buffer of byte values in memory according to an indexed conversion table of correspondences.: Converts the internal representation of a word (e.g., packed decimal to signed binary integer).Input/Output Operations:
Architectural mechanisms implemented for peripheral interfacing:
- Isolated programmed I/O (separate address space and control lines for I/O ports).
- Memory-mapped programmed I/O (I/O registers occupy standard memory address space).
- Direct Memory Access (DMA) (hardware controller moves data directly between memory and device without constant processor intervention).
- Dedicated I/O Processor (channel architecture executing autonomous I/O programs).
Primitive operations:
: Transfer data from specified I/O port/device into register or memory.: Transfer data from register or memory to specified I/O port/device.: Dispatch control parameters to I/O processor to initiate asynchronous I/O transaction.: Poll and transfer status flags from the I/O interface to verify availability or transfer completion.System Control Operations:
Restricted instructions executable only when the processor operates in a privileged supervisory state or executes code located inside protected kernel memory.
Operating system functions executing via system control:
Reading or altering hardware control registers.
Reading or modifying storage protection keys.
Accessing and swapping Process Control Blocks (PCBs) in a multiprogramming operating system.
Transfer of Control Operations:
Fundamental necessity for program flow:
- Permits executing instruction sequences multiple times (iterative loops).
- Facilitates runtime conditional decision-making.
- Enables modular software construction by decomposing tasks into modular subroutines.
Primary control transfer types:
: Changes execution sequence to a specified memory address; can be unconditional or conditional upon testing processor condition codes.: Conditionally increments the Program Counter () to bypass the immediately following instruction without requiring an explicit destination address.: Saves current program execution state and return address (to stack or link register) before jumping to a target procedure address.: Restores the stored return address and processor state from the stack or link register back to the Program Counter, resuming parent execution.: Fetches an instruction from a remote memory address and executes it without modifying the Program Counter.: Terminates program instruction execution.: Suspends instruction execution, continually testing for an external condition/interrupt until satisfied.: Executes no state modification; processor simply advances the Program Counter to the next instruction.
Addressing Modes and Mechanics
- Purpose and Need for Addressing Modes:
- In typical instruction word formats, the number of bits allocated to address fields is strictly limited.
- Addressing modes allow programs to access very large physical and virtual memory spaces using compact bit allocations in instruction fields, providing reference versatility.

Comprehensive Breakdown of Basic Addressing Modes:
Immediate Addressing:
Algorithm:
Mechanics: The operand value is contained explicitly within the instruction address field itself; no address calculation is performed.
Example:
directly adds integer constant to register .Advantage: Zero memory references; fetches instantly with the instruction.
Disadvantage: Limited operand magnitude restricted to the bit width of field .
Direct Addressing:
Algorithm:
Mechanics: The address field directly specifies the physical/virtual memory address of the target operand.
Example:
directs the CPU to access memory cell (holding data value ) and add it to register .

Advantage: Simple architecture; requires only one memory reference to obtain the operand.
Disadvantage: Limited address space restricted directly to the address range expressible within field .
- Indirect Addressing:
Algorithm:
Mechanics: Address field contains the memory address of a pointer location, which in turn contains the true effective address of the operand.
Example:
or, where register contains address , which references memory cell holding pointer , resolving the actual data location.

Advantage: Huge address space ( where is word length).
Disadvantage: Multiple memory references required to access a single operand, significantly degrading execution speed.
- Register Addressing:
Algorithm:
Mechanics: The operand is held inside a processor register specified by register identifier field .
Example:
adds operand in register directly to register .

Advantage: No memory reference required; highest possible operand access speed.
Disadvantage: Severely limited address space restricted solely to the small set of internal CPU registers.
- Register Indirect Addressing:
Algorithm:
Mechanics: The instruction refers to register , which contains the effective memory address of the operand.
Example:
, where register holds address value , directing the CPU to fetch data value from memory address and store it into register .

Advantage: Enormous address space accessible with very small instruction field allocations; one less memory access cycle than full indirect addressing.
Disadvantage: Requires one memory reference cycle compared to pure register addressing.
- Displacement Addressing:
Algorithm:
Mechanics: Combines direct addressing and register indirect addressing; the effective address is computed by summing constant address offset with the contents of register .

- Mathematical Examples:
- If a base register holds value and displacement , the effective address is .
- If base register holds content and displacement is , the effective address is .

Advantage: High architectural flexibility (supports base-register addressing, index addressing, and program-counter relative addressing).
Disadvantage: Increased instruction calculation complexity and hardware overhead.
- Stack Addressing:
Algorithm:
Mechanics: Operands are implicitly referenced from the top of a Last-In-First-Out (LIFO) stack managed via a dedicated Stack Pointer (SP) register.
Example: Stack addition pops the top two values ( and ), adds them to produce , and pushes back onto the stack top.

- Advantage: Zero memory references within the instruction format itself; compact zero-address machine format.
- Disadvantage: Severely limited applicability to general-purpose computing tasks.
ARM Architecture, Instruction Formats, and Bit Allocation
ARM Architectural Foundations:
- Advanced RISC Machine (ARM) is a microprocessor architecture family based upon Reduced Instruction Set Computer (RISC) design principles.
- Core RISC principles emphasize simple, highly optimized, uniform instructions designed for high-speed single-cycle execution.
- Operates on a load/store architecture: memory is accessed solely through explicit load and store instructions; all arithmetic and logic processing operates exclusively between registers.
ARM Data Access Addressing Mechanisms:
- Implements a uniform, regular addressing strategy across instructions (
Load,Store,Add,Subtract). - Three standard operand formats:
- Immediate: Direct constant embedded in instruction:
(adds literal to , writes to ). - Register: Value located inside a register:
(adds and , writes to ). - Shifted Register: Second register operand scaled on-the-fly via the internal barrel shifter before execution:
(shifts left by , effectively multiplying it by , adds to , writes to ). - The Five ARM Hardware Shift Operators:
: Logical Shift Left: Logical Shift Right: Arithmetic Shift Right (preserves sign bit): Rotate Right: Rotate Right Extended through the carry flag
- Implements a uniform, regular addressing strategy across instructions (
Comparison: Data Processing vs. Branch Instructions:
- Data Processing Instructions:
- Function: Computations and logical operations (
,,,). - Main Purpose: Process data inside the CPU.
- Addressing Type: Register addressing, immediate addressing, or shifted register addressing.
- Operands: Numeric data, raw values in registers.
- Execution Unit: Inside the Arithmetic Logic Unit (ALU).
- Branch Instructions:
- Function: Direct control transfer (
). - Main Purpose: Alter program execution flow.
- Addressing Type: Immediate addressing only.
- Operands: Memory destination addresses.
- Execution Unit: Inside the Control Unit and Program Counter ().
- Branch Mechanics: Contains a signed immediate offset. This field is shifted left by to achieve word alignment, yielding an effective branching displacement range of relative to the Program Counter.
ARM Instruction Length and Bit Allocation:
- Every ARM instruction has a fixed length of exactly (), simplifying instruction fetch, pipeline decoding, and execution alignment.
- Every instruction begins with a condition code field (
cond, bits ), allowing every instruction to be executed conditionally based on processor status flags.

Detailed Field Breakdown of ARM Instruction Formats:
- Data Processing (Immediate Shift): Bits :
cond; Bits :000; Bits :opcode; Bit :S; Bits :Rn; Bits :Rd; Bits :shift amount; Bits :shift; Bit :0; Bits :Rm. - Data Processing (Register Shift): Bits :
cond; Bits :000; Bits :opcode; Bit :S; Bits :Rn; Bits :Rd; Bits :Rs; Bit :0; Bits :shift; Bit :1; Bits :Rm. - Data Processing (Immediate): Bits :
cond; Bits :001; Bits :opcode; Bit :S; Bits :Rn; Bits :Rd; Bits :rotate; Bits :immediate. - Load/Store (Immediate Offset): Bits :
cond; Bits :01; Bit :0; Bits :P, U, B, W, L; Bits :Rn; Bits :Rd; Bits :immediate. - Load/Store (Register Offset): Bits :
cond; Bits :01; Bit :1; Bits :P, U, B, W, L; Bits :Rn; Bits :Rd; Bits :shift amount; Bits :shift; Bit :0; Bits :Rm. - Load/Store Multiple: Bits :
cond; Bits :100; Bits :P, U, S, W, L; Bits :Rn; Bits :register list. - Branch / Branch with Link: Bits :
cond; Bits :101; Bit :L; Bits :24-bit offset.
- Data Processing (Immediate Shift): Bits :
Function of Specific Control and Status Bits:
Bit:- In Data Processing instructions: specifies whether the execution updates the condition code flags ( updates; preserves flags).
- In Load/Store Multiple instructions: indicates whether execution is restricted to privileged supervisor mode.
Bits: Distinguish among addressing mode variants (Pre/Post indexing, Up/Down address offset arithmetic, Write-back to base register).Bit: Distinguishes between unsigned byte () and full word () memory transfers.Bit:- In Load/Store instructions: distinguishes between a Load () and a Store ().
- In Branch instructions: distinguishes between a standard Branch () and a Branch with Link (), which saves the return address into the Link Register ().
Processor Function, Organization, and Register Structure
Core Processor Requirements:
- The processor (Central Processing Unit) serves as the primary logic circuitry that interprets and processes basic instructions driving the computer.
- Five fundamental operational requirements:
- Fetch instruction: Reads an instruction from storage hierarchy (registers, cache, main memory).
- Interpret instruction: Decodes the fetched instruction to determine required actions.
- Fetch data: Reads operand data from memory or an I/O module as dictated by execution.
- Process data: Executes arithmetic or logical operations upon operands.
- Write data: Transmits operational results to memory or an I/O module.
Internal CPU Architecture and System Bus Interface:
- The processor connects to the broader system via three distinct bus structures:
- Control Bus: Carries command, synchronization, and timing signals.
- Data Bus: Carries raw data and instruction words between system components.
- Address Bus: Carries physical addresses determining memory cells or I/O ports targeted for access.
- Internal CPU blocks include the Arithmetic Logic Unit (ALU), Registers, and the Control Unit.

Internal Register Organization:
- Registers reside at the top of the storage hierarchy, providing rapid data storage.
- Dual architectural roles of internal registers:
- User-Visible Registers: Accessible by assembly/machine language programmers to minimize memory access overhead.
- Control and Status Registers: Utilized by the control unit to regulate processor operations and by operating system software to manage execution state.
Categories of User-Visible Registers:
- General Purpose: Flexible registers that can be assigned to diverse operations by programmers or compilers.
- Data Registers: Dedicated exclusively to storing data operands; cannot be used in calculating effective operand addresses.
- Address Registers: Dedicated to specific addressing modes or general address manipulation (e.g., segment pointers, index registers, stack pointers).
- Condition Codes (Flags): Individual status bits set automatically by hardware in response to arithmetic, logical, or comparison results.
Essential Control and Status Registers:
- Four registers are critical to instruction sequencing:
- Program Counter (PC): Contains the memory address of the next instruction to be fetched.
- Instruction Register (IR): Holds the instruction word most recently fetched from memory.
- Memory Address Register (MAR): Connects directly to the address bus; holds the physical memory address for an impending read or write cycle.
- Memory Buffer Register (MBR): Connects directly to the data bus; holds data received from memory or data ready to be written to memory.
Program Status Word (PSW):
- A dedicated register holding status flags and control bits that define the processor's current operational state.
- Key fields and condition flags:
- Sign: Records the sign bit of the most recent arithmetic calculation result (, ).
- Zero: Set to when the result of an operation evaluates to zero.
- Carry: Set to if an arithmetic operation results in a carry out of or borrow into the most significant bit.
- Equal: Set to if a logical comparison evaluates to equality.
- Overflow: Indicates an arithmetic overflow condition when a signed calculation exceeds the numeric limits of the target data width.
- Interrupt Enable/Disable: Global mask bit enabling or inhibiting the CPU from servicing maskable external interrupts.
- Supervisor: Flags whether the CPU runs in privileged Supervisor mode or restricted User mode.
The Instruction Cycle and Internal Micro-Operations
Stages of the Complete Instruction Cycle:
- The operational lifecycle of each instruction consists of four primary stages:
- Fetch Stage: Reads the next instruction from memory into the processor.
- Indirect Stage: If the instruction specifies indirect addressing, fetches the effective address of the operand via additional memory read operations.
- Execute Stage: Interprets the opcode and executes the specified operational logic.
- Interrupt Stage: If interrupts are enabled and an interrupt signal is pending, saves the current process context and invokes the appropriate interrupt service handler.
Data Flow During the Fetch Cycle:
- Sequence of micro-operations moving instruction data from memory into processor registers:
- 1. The Program Counter () contains the address of the next instruction to be fetched.
- 2. The address in is transferred to the Memory Address Register ().
- 3. asserts this address onto the Address Bus.
- 4. The Control Unit issues an explicit memory read command on the Control Bus.
- 5. Memory retrieves the instruction word and places it onto the Data Bus, which loads it into the Memory Buffer Register ().
- 6. The contents of are transferred to the Instruction Register ().
- 7. Simultaneously, the is incremented by the instruction word length to prepare for the subsequent fetch cycle.
Data Flow During the Indirect Cycle:
- Required when an instruction uses indirect addressing to resolve operand locations:
- 1. The address field portion of the instruction currently residing in (or ) is transferred into .
- 2. asserts this pointer address onto the Address Bus.
- 3. The Control Unit asserts a memory read signal on the Control Bus.
- 4. Memory returns the operand's true effective address across the Data Bus into the .
- 5. now holds the resolved effective address needed for execution.
Data Flow During the Interrupt Cycle:
- Executes upon completion of the execute cycle if an active interrupt is flagged and enabled:
- 1. The current contents of the must be preserved so execution can resume seamlessly post-interrupt.
- 2. The contents are transferred to .
- 3. The Control Unit loads the target save location address (e.g., system stack pointer or fixed reserve address) into .
- 4. asserts this address onto the Address Bus.
- 5. The Control Unit asserts a memory write command on the Control Bus.
- 6. The return address stored in is transmitted across the Data Bus and written to memory.
- 7. The is loaded with the start address of the designated Interrupt Service Routine (ISR), redirecting processor execution to the handler.