x86 Assembly

x86 Assembly Introduction
The intent of this section is to provide foundational knowledge which will be used for x86 assembly, as well as other architectures. You will install and configure your tools, write an x86 assembly program, assemble it, link it, run it, debug it, and understand every single byte contained in its code.
Memory Types
There are multiple levels of data storage available in a computer generally in the order of:

Cold storage such as magnetic or solid state flash drives:
  • Used for long term storage of data
  • Do not require electrical power to maintain data
  • Generally have the largest capacity but lowest seek and transfer speeds

Dynamic Random Access Memory (RAM or DRAM):
  • Stores data for use by the Operating System with currently running programs
  • Must have the data constantly refreshed with power (uses capacitors)
  • Faser seek and transfer speeds than cold storage, but lower capacity

Static Random Access Memory (SRAM or cache RAM):
  • Doesn't require constant refreshing
  • Will lose data with loss of voltage (uses transistors for storage)
  • Typically stores data for the CPU to operate on quickly and repeatedly
  • Typically stored on different levels (L1, L2, L3) in decreasing proximity to the CPU dye (but increasing capacity)

CPU Registers:
  • Provides the most immediate storage for the processor
  • Located directly in the CPU core (also transistors)
  • Smallest of all memory systems (sized based on the CPU architecture)

The original 8086 processor used 16-bit registers with four different function types:
  • General purpose registers, used for temporary data storage from other operations, addresses, variables, counters, etc.
  • Memory segment registers, used for managing segmented memory addressing (this is not used for modern RAM layouts which are flat)
  • Index and pointer registers, used to track memory locations for instructions, stack memory, and string operations
  • Flag register, used to hold state flags for operations