Microprocessor Architecture

Chapter 3
Instruction Set Architecture and Programmer’s Model

Bachelors Program in Electronics and Communication
Microprocessor Architecture   •   Bachelor

Instruction Set Architecture and Programmer’s Model

Introduction

An instruction set architecture (ISA) is the programmer-visible specification of a processor. It defines the instructions that software may execute, the registers available to programs, data representations, memory addressing rules, exception behavior, and the binary encoding of instructions. The ISA forms the boundary between hardware implementation and software development. Two processors may implement the same ISA using different pipelines, caches, and internal control mechanisms, yet execute the same machine-language program correctly.

For electronics and communication engineers, the ISA is important because embedded controllers, digital signal processors, network processors, mobile processors, and general-purpose computers all depend on precise instruction behavior. Understanding an ISA enables a designer to interpret assembly language, optimize embedded software, evaluate processor families, and understand how compilers translate algorithms into hardware operations.

Learning Objectives

After completing this chapter, the reader should be able to:

  1. Explain the programmer’s model of a processor and identify its principal components.
  2. Interpret instruction formats, opcodes, operands, and encoding fields.
  3. Distinguish common addressing modes and select suitable modes for typical tasks.
  4. Explain data types, byte ordering, alignment, and memory access conventions.
  5. Classify instructions and describe procedure calls, stacks, interrupts, and exceptions.
  6. Compare RISC and CISC philosophies and relate them to ARM, x86, and RISC-V.
  7. Analyze ISA design trade-offs in embedded and general-purpose systems.

1. The Programmer’s Model

The programmer’s model is the set of processor resources directly visible to assembly-language programmers and compilers. It normally includes:

  • a program counter (PC), which identifies the address of the next instruction;
  • general-purpose registers (GPRs), used for operands and intermediate results;
  • a stack pointer (SP), which identifies the active stack area;
  • a status or condition-code register;
  • special-purpose registers, such as link, control, configuration, or floating-point registers; and
  • the address space and rules governing memory access.

A processor repeatedly performs instruction fetch, decode, operand access, execution, and write-back. This sequence is an implementation mechanism, whereas the ISA specifies the architectural effect. For example, an ADD instruction may be executed in one clock cycle in a simple processor or through several pipeline stages in a high-performance processor, but its specified result must be the same.

A typical register-transfer description of an addition is:

Rd ← Rs1 + Rs2

Here, Rd is the destination register and Rs1 and Rs2 are source registers. The expression describes an architectural operation, not necessarily the physical movement of data through the datapath.

1.1 Registers

General-purpose registers reduce the need to access memory. A processor with many registers can retain loop counters, addresses, function arguments, and temporary values close to the arithmetic logic unit. However, a larger register file increases instruction-encoding requirements, hardware area, and context-switching cost.

Common special registers include:

RegisterPrincipal function
PCAddress of the next instruction or current instruction, depending on ISA convention
SPTop or base of the active procedure stack
Status registerFlags and processor-state information
Link registerReturn address in architectures that support register-based calls
Instruction registerHolds the fetched instruction internally during decoding
Control registersPrivilege, memory-management, interrupt, or configuration state

Condition flags commonly include zero (Z), negative or sign (N), carry (C), and overflow (V). Carry concerns unsigned arithmetic; overflow concerns signed two’s-complement arithmetic. They are not interchangeable. For an n-bit addition, signed overflow occurs when two operands with the same sign produce a result with the opposite sign. Unsigned carry indicates that the arithmetic result exceeded the representable unsigned range.

1.2 Status and privilege

Many processors provide privilege levels. Operating-system code may execute instructions that application programs cannot, such as changing memory-management settings or disabling interrupts. A transition from unprivileged to privileged execution normally occurs through a controlled exception or system-call instruction. This separation supports protection, fault isolation, and secure resource management.

2. Instruction Structure and Encoding

An instruction consists conceptually of an opcode and operands. The opcode identifies the operation, while operand fields identify registers, immediate values, or memory locations. Additional fields may specify addressing mode, data size, condition behavior, privilege, or extension features.

A generic instruction can be represented as:

Instruction = opcode + addressing ext{-}mode ext{ fields} + operand ext{ fields}

This is a conceptual decomposition. Actual encodings vary considerably among ISAs.

2.1 Fixed-length and variable-length formats

A fixed-length ISA uses one or a small number of instruction lengths, often 32 bits. Fixed length simplifies instruction fetching, alignment, and parallel decoding. ARM and RISC-V commonly use fixed 32-bit base instructions, although both support shorter encodings through extensions or compressed instruction sets.

A variable-length ISA permits instructions of different lengths. x86 instructions may contain prefixes, opcode bytes, addressing information, displacement fields, and immediate data. Variable length improves code density because simple operations can use fewer bytes, but instruction boundaries are more difficult to identify and decode.

2.2 Opcode and operand capacity

If an instruction format allocates k bits to an opcode, it can represent at most 2k distinct binary opcode patterns, subject to reserved encodings and extension rules. If a register field has r bits, it can identify 2r registers. These are encoding limits, not necessarily the number of operations or registers ultimately supported, because multi-level opcode fields and prefixes may extend the space.

2.3 Instruction classes

Most ISAs provide the following classes:

  1. Data-processing instructions: arithmetic, logical, shift, compare, and bit-manipulation operations.
  2. Data-transfer instructions: loads, stores, moves, and exchanges between registers and memory.
  3. Control-transfer instructions: conditional branches, unconditional jumps, calls, returns, and indirect transfers.
  4. System instructions: interrupt control, synchronization, cache management, and privilege transitions.
  5. Floating-point and vector instructions: operations on floating-point values or multiple data elements.
  6. Atomic and synchronization instructions: indivisible read-modify-write operations used in concurrent software.

A well-designed ISA defines not only normal results but also behavior for invalid operands, misaligned accesses, arithmetic exceptions, and privilege violations.

3. Addressing Modes

An addressing mode specifies how an instruction obtains an operand or computes an effective memory address. If the effective address is denoted by EA, common forms include the following.

Immediate addressing

The operand is encoded inside the instruction:

Rd ← Rs + constant

Immediate operands are efficient for constants such as loop increments, masks, and small offsets. Their range is limited by the number of bits available in the instruction.

Register addressing

The operand is held in a register. This mode is fast and compact, but the value must first be loaded into a register.

Direct or absolute addressing

The instruction contains a memory address or an address field from which the memory address is formed. It is useful for fixed memory-mapped registers, although modern systems often restrict or extend it through relocation and address-generation mechanisms.

Register-indirect addressing

A register contains the effective address:

EA = Rb

This mode is fundamental for pointers and arrays.

Base-plus-displacement addressing

The effective address is calculated as:

EA = Rb + d

Here, Rb is a base register and d is a signed or unsigned displacement encoded in the instruction. It is widely used for structure fields, stack-frame variables, and array elements.

Indexed and scaled-index addressing

An index may be added to a base, sometimes after multiplication by an element-size scale:

EA = Rb + s × Ri + d

Here, Ri is an index register, s is a permitted scale factor, and d is a displacement. This mode is convenient for arrays, but not all ISAs provide arbitrary scaling.

PC-relative addressing

The target is calculated relative to the program counter:

EA = PC + d

PC-relative addressing supports position-independent code and is especially useful for branches, constants, and shared libraries.

Auto-increment and auto-decrement

A memory access uses a register as an address and then updates that register. Such modes are useful for stacks, buffers, and sequential data processing. The ISA must specify whether the update occurs before or after the access.

Addressing-mode trade-offs

Rich addressing modes can reduce instruction count and improve code density, but they complicate decoding and may lengthen execution paths. Simpler modes facilitate regular pipelines and compiler scheduling. The best choice depends on technology, target applications, code-size requirements, and implementation cost.

4. Data Types and Representation

An ISA defines the sizes and interpretations of data supported by instructions. Typical integer widths are 8, 16, 32, and 64 bits. A bit pattern has no inherent type; its interpretation depends on the instruction and software context.

4.1 Unsigned and signed integers

An n-bit unsigned integer represents values from 0 through 2n − 1. Two’s-complement signed representation represents values from −2n−1 through 2n−1 − 1. For example, an 8-bit two’s-complement value ranges from −128 to +127.

The same bit pattern may represent an unsigned number, a signed number, a character, a memory address, or packed Boolean data. Programmers must therefore select instructions that match the intended interpretation, especially for comparisons and extensions.

4.2 Floating-point and vector data

Floating-point formats represent approximate real numbers using sign, exponent, and significand fields. Floating-point arithmetic is subject to rounding and exceptional values such as infinity and NaN. Vector or SIMD instructions treat one register as multiple independent lanes, allowing the same operation to be applied to several samples simultaneously. This is valuable in communications, image processing, and signal filtering.

4.3 Alignment

An aligned object begins at an address appropriate to its size or natural boundary. Some processors handle unaligned accesses transparently; others generate an exception or require multiple instructions. Even when permitted, unaligned access may be slower and may complicate atomicity. Portable systems software should follow the alignment rules of the target ABI and ISA.

5. Endianness and Memory Organization

Memory is byte-addressable in many modern systems. When a multi-byte value is stored, the ISA or platform specifies the order of its bytes.

  • Little-endian: the least significant byte is stored at the lowest address.
  • Big-endian: the most significant byte is stored at the lowest address.

For the 32-bit hexadecimal value 0x12345678, little-endian memory order is 78, 56, 34, 12, while big-endian order is 12, 34, 56, 78. Endianness does not change the numerical value when the bytes are interpreted according to the same convention. It becomes important when exchanging binary files, communicating over networks, mapping hardware registers, or examining memory with a debugger.

Network protocols frequently specify a canonical byte order, commonly called network byte order. Software must explicitly convert between host representation and protocol representation when they differ.

6. Control Flow, Procedures, and Stacks

Sequential execution is interrupted by branches, calls, returns, traps, and exceptions. A conditional branch tests a condition and changes the PC if the condition is true. A call transfers control to a procedure while preserving a return address. A return restores that address and resumes the caller.

6.1 Procedure-call conventions

A calling convention is an agreement between compiler-generated code and procedures. It specifies:

  • where arguments are placed;
  • where return values are placed;
  • which registers a callee must preserve;
  • how the stack is aligned;
  • how local variables are allocated; and
  • how the return address is preserved.

Some architectures use a link register for the return address. Others push the return address onto a stack or store it in a designated register as part of the call instruction. A procedure that needs the link register for another call must save it, commonly in its stack frame.

6.2 Stack operation

A stack is a last-in, first-out data structure. It supports nested procedure calls, local variables, saved registers, and temporary values. Depending on convention, the stack may grow toward lower or higher addresses. The direction is less important than consistent implementation.

A typical procedure has a prologue that saves required registers and allocates local storage, followed by a body and an epilogue that restores state. Stack corruption can cause incorrect returns, data leakage, or security vulnerabilities. Stack-pointer alignment is particularly important for efficient memory access and vector instructions.

6.3 Recursion and reentrancy

Recursion requires each invocation to receive separate parameters, return information, and local storage. A stack naturally supports this requirement. Reentrant procedures must avoid unsafe shared mutable state or protect it with synchronization mechanisms.

7. Exceptions, Interrupts, and System Calls

An exception is a control transfer caused by the current instruction or its execution context. Examples include divide-by-zero, invalid instruction, page fault, alignment fault, and arithmetic overflow where the ISA defines trapping behavior. An interrupt is generally an externally signaled event, such as a timer or peripheral request.

The processor typically performs some combination of the following actions:

  1. records a return PC and status information;
  2. changes privilege or execution state;
  3. identifies an exception or interrupt vector;
  4. transfers control to a handler; and
  5. returns using a special instruction after the cause has been serviced.

Precise exceptions have the useful property that the architectural state appears as if instructions before the fault completed and instructions after it did not. This property simplifies operating-system recovery and debugging, although it can be difficult to maintain in deeply speculative processors.

A system call is a deliberate software-generated exception used to request an operating-system service. It provides a controlled boundary between application software and privileged resources.

8. RISC, CISC, and Major ISA Families

8.1 RISC and CISC principles

RISC, or Reduced Instruction Set Computer, emphasizes a relatively small set of regular instructions, load/store organization, many registers, and formats that are easy to decode. The goal is not merely to minimize the number of instructions, but to simplify common instruction behavior and support efficient pipelining.

CISC, or Complex Instruction Set Computer, traditionally emphasizes richer instructions, numerous addressing modes, compact code, and variable operation complexity. Modern CISC processors may translate complex instructions into simpler internal micro-operations, while modern RISC processors also include sophisticated extensions. Therefore, the distinction is architectural and historical rather than an absolute description of implementation complexity.

8.2 ARM

ARM architectures are widely used in mobile, embedded, automotive, and increasingly server systems. Classical ARM designs used a load/store model with regular registers and conditional execution features. Modern AArch64 provides 64-bit registers, fixed-width primary instruction encodings, PC-relative addressing, and separate instruction families for scalar, floating-point, and SIMD operations. ARM’s ecosystem emphasizes energy efficiency, scalable implementations, and strong compiler support.

8.3 x86

The x86 family evolved from early 16-bit processors to 32-bit IA-32 and 64-bit x86-64 systems. It retains variable-length instructions, many addressing forms, and extensive backward compatibility. High-performance x86 processors commonly decode instructions into internal micro-operations, allowing out-of-order execution while preserving the external ISA. Its strengths include mature software compatibility and code density; its costs include decoder complexity, architectural legacy, and substantial implementation effort.

8.4 RISC-V

RISC-V is an open standard ISA based on a small base integer ISA with optional extensions. Common extensions support multiplication and division, atomic operations, single- and double-precision floating point, compressed instructions, and vector processing. Its modularity permits application-specific processors and academic experimentation without requiring a proprietary ISA license. Designers must nevertheless address software ecosystem maturity, verification, security, and extension compatibility.

FeatureTypical RISC approachTypical CISC approachARMx86RISC-V
Instruction lengthFixed or limited setOften variableMostly regularVariableRegular base, optional compressed
Memory operationsOften load/storeMay combine memory and ALU operationLoad/storeRich memory operandsLoad/store
Register organizationMany GPRsHistorically fewer visible registersRegister-richEvolutionary and mixedRegister-rich
ExtensibilityStructured extensionsOften historical accumulationProfile and extension basedLarge legacy baseExplicit modular extensions
Typical strengthsDecode simplicity, pipelinesCode density, compatibilityEfficiency and scalabilityCompatibility and performanceOpenness and customization

9. ISA Design Principles

An ISA designer balances competing objectives:

  • Expressiveness: common algorithms should be representable efficiently.
  • Regularity: consistent formats reduce compiler and hardware complexity.
  • Code density: fewer bytes reduce memory cost and instruction-fetch energy.
  • Performance: instructions should expose useful parallelism without imposing excessive dependencies.
  • Scalability: the ISA should support different implementation sizes and future extensions.
  • Compatibility: stable encodings protect software investment.
  • Security: privilege separation, controlled transitions, atomicity, and predictable fault behavior are essential.
  • Verifiability: precise specifications and modular extensions reduce design and testing risk.
  • Energy efficiency: embedded systems must consider instruction-fetch activity, register-file access, and memory traffic.

There is no universally best ISA. A battery-powered sensor node, a high-performance server, and a software-defined radio may favor different balances among code size, vector capability, real-time behavior, and implementation complexity.

10. Worked Example: Translating an Array Operation

Consider the operation:

sum = sum + a[i]

Assume each array element occupies four bytes, register R1 contains the base address of array a, R2 contains the integer index i, and R3 contains sum. The address of element a[i] is:

EA = R1 + 4 × R2

A processor with scaled-index addressing may express the operation using one load followed by an add:

LOAD R4, [R1 + R2 × 4]
ADD  R3, R3, R4

On a simpler load/store ISA without scaled addressing, software may first calculate the byte offset:

SHIFT R4, R2, 2       ; multiply index by 4
ADD   R4, R1, R4      ; form address
LOAD  R5, [R4]
ADD   R3, R3, R5

The second sequence uses more instructions but has regular operations that may be easy to pipeline. The first sequence may improve code size and reduce explicit address-generation instructions, but it requires richer addressing hardware.

11. Applied Case: Choosing an ISA for a Wireless Sensor Node

Background. An illustrative engineering team is designing a battery-powered wireless sensor node. The device samples an analogue signal, performs digital filtering, encrypts packets, and sleeps between measurements.

Problem. The processor must provide low energy consumption, predictable interrupt response, adequate arithmetic performance, and a toolchain suitable for long-term maintenance. Large application-processor features would increase cost and power.

Analysis. The workload contains frequent loads and stores, multiply-accumulate operations, bit manipulation, interrupt handling, and occasional vector-like operations. Code memory is limited, so compressed instruction encodings are valuable. Security requires privilege separation, protected memory, and reliable exception behavior.

Approach. The team evaluates a microcontroller-class ARM processor and a RISC-V implementation. It measures interrupt latency, energy per sample, code size, cryptographic throughput, development-tool maturity, and availability of verified security libraries. It does not select an ISA solely from its instruction count; the complete platform, including compiler quality, peripherals, debug tools, and verification evidence, is considered.

Outcome. The final choice depends on measured application performance and supply-chain requirements. A compressed instruction extension can reduce program memory traffic, while dedicated multiply, bit-manipulation, or cryptographic extensions can reduce energy per packet. The team documents the selected ABI and avoids nonstandard instructions unless their long-term maintenance cost is acceptable.

Learning points. ISA selection is a system-level decision. Code density, real-time behavior, security support, toolchains, licensing, verification, and energy efficiency must be evaluated together. A theoretically elegant ISA may be unsuitable if the development ecosystem or peripheral integration is weak.

12. Challenges, Security, and Contemporary Developments

ISA evolution must preserve compatibility while addressing new requirements. Vector extensions support machine learning, communications, and multimedia. Compressed encodings reduce instruction memory traffic. Hardware virtualization allows multiple operating systems or isolated workloads to share a processor. Memory-tagging and capability-oriented approaches attempt to detect invalid pointers or constrain authority more precisely than conventional addresses.

Security issues arise at both ISA and microarchitectural levels. An ISA may specify privilege modes and memory permissions, but speculative execution, caches, branch predictors, and timing behavior can create side channels. Secure design therefore requires documented architectural behavior, careful microarchitectural analysis, constant-time software where appropriate, and disciplined update processes.

For engineers, best practice includes consulting the official ISA manual, distinguishing architectural guarantees from implementation-specific behavior, respecting the ABI, testing boundary conditions, checking alignment and endianness explicitly, and using disassemblers and simulators to validate assumptions. Assembly should be used when it delivers a demonstrated benefit or accesses hardware features unavailable through higher-level languages; otherwise, maintainable compiler-generated code is generally preferable.

Chapter Summary

An instruction set architecture defines the software-visible contract of a processor. Its programmer’s model includes registers, the program counter, status information, memory rules, privilege state, and exception behavior. Instruction formats encode operations and operands, while addressing modes determine how values and effective addresses are obtained. Immediate, register, base-plus-displacement, indexed, scaled-index, and PC-relative modes support different programming patterns.

Data representations include signed and unsigned integers, floating-point values, vectors, and packed fields. Endianness determines byte order in memory, and alignment affects correctness, performance, and portability. Instruction classes include data processing, data transfer, control transfer, system, vector, and atomic operations. Procedure calls depend on calling conventions, stacks, saved registers, and return-address mechanisms. Exceptions, interrupts, and system calls provide controlled changes of execution context.

RISC emphasizes regularity and efficient decoding; CISC emphasizes expressive instructions and code density. ARM combines a load/store tradition with scalable modern extensions, x86 provides extensive compatibility through a variable-length ISA, and RISC-V offers a modular open standard. ISA selection is a system-level engineering decision involving performance, energy, security, code size, tools, compatibility, and verification.

Key Terms

Instruction set architecture: The programmer-visible specification of a processor.

Programmer’s model: Registers, memory, status, and control resources visible to software.

Opcode: The encoded field identifying an instruction operation.

Operand: A value, register, or address used by an instruction.

Program counter: Register identifying the instruction-flow location.

General-purpose register: Register available for ordinary data or address operations.

Addressing mode: Rule used to obtain an operand or calculate an effective address.

Effective address: Computed memory address used by a load or store.

Immediate operand: Constant encoded within an instruction.

Endianness: Ordering of bytes within a multi-byte value in memory.

Alignment: Placement of an object at an appropriate address boundary.

Calling convention: Agreement governing procedure arguments, registers, stack, and returns.

Stack pointer: Register identifying the active procedure stack.

Exception: Control transfer caused by an instruction or execution condition.

Interrupt: Externally signaled request for processor service.

RISC: Instruction-set philosophy emphasizing regular, efficient operations.

CISC: Instruction-set philosophy traditionally emphasizing rich operations and encodings.

ABI: Application binary interface defining binary-level software conventions.

Atomic instruction: Operation that appears indivisible to concurrent observers.

PC-relative addressing: Address calculation using the program counter and a displacement.

Review Questions

Short Answer Questions

  1. What is the difference between an ISA and a processor microarchitecture?
  2. Define immediate addressing and give one practical use.
  3. Distinguish carry from signed overflow.
  4. What is the purpose of a calling convention?
  5. State one difference between little-endian and big-endian storage.

Long Answer Questions

  1. Explain the principal components of a processor’s programmer’s model and their roles during procedure execution.
  2. Describe at least five addressing modes, including their effective-address calculations and typical applications.
  3. Explain how procedure calls, stack frames, saved registers, and return addresses cooperate in nested calls.
  4. Compare RISC and CISC philosophies and discuss why modern processors blur the traditional distinction.
  5. Compare ARM, x86, and RISC-V with respect to encoding, extensibility, compatibility, and typical applications.

Analytical / Application Questions

  1. A data-processing loop accesses 16-bit samples using a base address and an integer index. Derive the effective-address expression and propose instruction sequences for an ISA with and without scaled-index addressing.
  2. A communication device exchanges 32-bit values with a network protocol using big-endian order, while its processor is little-endian. Explain the conversion required and identify risks if conversion is omitted.
  3. A design team must choose between a proprietary embedded ISA and an open modular ISA for a ten-year product. Develop a decision framework including technical, commercial, security, toolchain, and maintenance criteria.

Multiple Choice Questions with Answers

Question 1

Which component identifies the location from which instruction execution proceeds?

A. Program counter

B. Stack pointer

C. Status register

D. Instruction decoder

Correct Answer: A. Program counter

Question 2

In base-plus-displacement addressing, the effective address is normally formed as:

A. PC minus opcode

B. Base register plus displacement

C. Stack pointer multiplied by status flags

D. Immediate value divided by operand size

Correct Answer: B. Base register plus displacement

Question 3

What is the little-endian byte order for the 32-bit value 0x12345678?

A. 12 34 56 78

B. 78 56 34 12

C. 34 12 78 56

D. 56 78 12 34

Correct Answer: B. 78 56 34 12

Question 4

Which statement correctly distinguishes carry from signed overflow?

A. They are always identical

B. Carry applies only to floating-point operations

C. Carry concerns unsigned range exceedance, while overflow concerns signed representation

D. Overflow is used only for address calculation

Correct Answer: C. Carry concerns unsigned range exceedance, while overflow concerns signed representation

Question 5

What is the principal purpose of a calling convention?

A. To define transistor dimensions

B. To specify binary agreements for arguments, registers, stack use, and returns

C. To select cache replacement policies

D. To determine network byte order exclusively

Correct Answer: B. To specify binary agreements for arguments, registers, stack use, and returns

Question 6

Which instruction class changes the normal sequence of instruction execution?

A. Control-transfer instructions

B. Data-transfer instructions only

C. Register-clear instructions only

D. Bitwise instructions only

Correct Answer: A. Control-transfer instructions

Question 7

Which characteristic is most strongly associated with a load/store RISC organization?

A. Arithmetic instructions operate directly on arbitrary memory operands

B. Only load and store instructions normally access memory

C. Every instruction has a variable length

D. There are no general-purpose registers

Correct Answer: B. Only load and store instructions normally access memory

Question 8

What is a system call?

A. A deliberate software request that commonly enters privileged operating-system code

B. An automatic cache refresh after every instruction

C. A hardware reset caused by power failure

D. A floating-point rounding mode

Correct Answer: A. A deliberate software request that commonly enters privileged operating-system code

Question 9

For an array of four-byte elements, which expression gives the address of element i when R1 is the base address?

A. R1 + i

B. R1 + 2i

C. R1 + 4i

D. R1 ÷ 4i

Correct Answer: C. R1 + 4i

Question 10

Which feature is a defining characteristic of RISC-V?

A. A closed, unmodifiable instruction set required by the standard

B. A modular open ISA with a base instruction set and optional extensions

C. Exclusive dependence on variable-length instructions

D. Absence of integer registers

Correct Answer: B. A modular open ISA with a base instruction set and optional extensions

Microprocessor Architecture
Chapter 3 of 15