Instruction Set Architecture

Instruction Set Architecture

  • “Interface from the programmer to the processor”
  • Processors are binary compatible if they support the same ISA

Data Types and formats #

  • Integer types
  • Fixed / Floating point types
  • String formats

Operands #

  • Number of operands (0, 1, 2, 3)

  • Types of operands

    1. Immediate operands (part of the instruction)
    2. Register operands (content of the register is the operand)
    3. Memory operands (content of a memory address is the operand)
  • Alignment of operands

    • Memory operand is aligned at a n-bit boundary if the address is a multiple of n
    • Usually memory operands have to be aligned according to their own size
    • Can be required by the ISA to only access size-aligned data

    -> Needed for cache lines: If cach lines are instruction_set_architecture_8b5c9d6c0dd49502d3f83edb311746a0d2fb4829.svg byte sized and aligned, for a reasonably large instruction_set_architecture_f667223b68166ff6137c14bb805036ab348537db.svg, then smaller data will always fit in a cache line if it is also aligned.

Addressing modes #

  1. Immediate operands (part of the instruction)
  2. Register operands (content of the register is the operand)
  3. Direct (memory address is part of the instruction)
    • Only if you know the address of a constant or something in the data segment
  4. Register indirect: (memory address is in a register)
  5. Indexed: (register indirect plus fixed offset)
    • Can be used for PC-relative jumps (maybe for jump tables like for switch statements?)

Classes of Instructions #

  • data transfer
  • arithmetic and logic operations
  • control flow: calls, jumps, …
  • I/O instructions
  • System level instructions: interrupts, stack, priviledge level

Instruction format #

  • structure of opcode and operands
  • either single format for all instructions (Von Neumann Architecture )
  • or more flexible ones (complex decoding)
  • (NOTE: instruction size depends on operand types (registers really small, memory address much bigger))

Registers #

  • Memory in the processor

  • Fast access (fastest access)

  • Types:

    1. General registers: interges, addesses
    2. Floating point registers
    3. Special refisters: multimedia, loop control register, …
    4. System registers: program counter, status, control register
  • Only few registers defined by ISA to keep names as short as possible

  • Register file = set of (same type) registers

  • Sliding window register file:

    • Attempt to have a lot of registers, but still have instuction length short:
      • Have a “Window” you can move over the full register file. All register access then only acts on the active window
      • Special operations to slide the window of addresses over the real registers

Execution Modes #

  • Motivation: Applications and data need to be protected from other running programs

  • OS manages hardware -> Assigns memory ranges to processes

  • Two execution modes:

    1. Supervisor mode:
      • Reserved for OS
      • Full access to all components
        • Can modyfiy virtual address table
    2. User mode:
      • Limited access
      • Access to memory only through memory translations (Virtual address space)
      • No priviledged instruction for I/O or accerss to control registers

Exception Handling #

  • Exception (Interrupt) triggered by the program

    • Executing a priviledged instruction in user mode
    • Division by Zero
    • Access virtual page with wrong permissions
  • Exception handled by the OS:

    1. Interrupt the currently executed instruction
    2. save processor state (all registers and immediate values)
    3. jump to handler for the exception
    4. switch to supervisor mode
    5. handle the exception
    6. return to original instruction in user mode
  • Precise exceptions:

    • Assume all previous instructions are complete
    • Assume no future instructions have been exectuted
    • Assumes no piplining
  • Imprecise exceptions:

    • Exceptions can happen out of order

CISC vs RISC #

CISC
Complex instruction set architecture
  • variable instuction format

  • Instructions can have prefixes

    • Opcode can start in the first 5 bytes
  • memory and register operands

  • specialized instuctions

RISC
Complex instruction set architecture
  • single instruction format (fetch / decode simpler)
  • load/store architecture
  • limited addressing modes
  • one cycle machine instructions

Comparison - CISC leads to shorter programs - CISC is more flexible - RISC is faster - RISC needs to emulate more complex instuctions

Endianness #

  • Order of the bytes
  • least significant byte first
  • most significant byte first
Calendar October 22, 2023