Background

Programming

  • Machine code is the raw bytes executed by a CPU; pain for humans to write

  • Assembly is a text representation of machine code; easy for humans to write

  • Programs called assemblers translates that text to machine code

  • High-level languages (like C++) are translated by a compiler to assembly, and then translated to machine code

CPUs

  • Executes sequential bytes of machine code (instructions) each cycle

  • Clock speed (e.g., 4GHz) refers to the number of cycles/second

  • Registers are fast (access time: <1 cycle), named values easily accessible in machine code. Extremely limited number (<32 per core)

  • The bitness (e.g., 64-bit) usually refers to the number of bits in a normal register

  • Main memory is slow (access time: 100s-10,000s cycles) and often difficult to access in machine code. Often 8-128GB total in a computer

  • An Instruction Set Architecture (ISA) is an abstract model of a CPU describing supported instructions, available registers, and interactions with main memory E.g., x86-64 is the ISA Intel implements across its different concrete CPU hardware implementations

  • Assembly language targets a particular ISA, not a specific CPU

  • Complex Instruction sets (CISC) perform many operations per instruction, variable byte count / instruction

    • For example: Load into register A from memory address in register X, multiple A by B, then add C

  • Reduced Instruction sets (RISC) perform one operation per instruction, fixed byte count / instruction

    • For Example: Add register A to B

Last updated

Was this helpful?