Category: x86

2.3.2 Basic 64-bit Execution Environment

  • Recall we only use 48 bits for addresses
  • Below are the most important registers
    • Sixteen 64 bit general purpose registers
    • 64 bit flags register (RFLAGS)
    • 64 bit instruction pointer (RIP)
    • Eight 64 bit MMX registers
    • Sixteen 128 bit XMM registers (versus 8 in 32 bit)
  • General Purpose Registers
    • Even in 64 bit mode there are only eight 32 bit registers by default
    • Adding REX prefix to the instruction you now get access to sixteen 64 bit registers
    • Capture.PNG
    • You cannot access a high-byte register at the same time as a new low-byte register
    • The upper 32 bits of RFLAGS is not used, old flags remain

2.3.1 64-Bit Operation Modes

  • New IA-32e mode which contains 2 sub modes
    • Compatibility Mode
      • Allows 16 bit and 32 bit applications to run without being recompiled
    • 64-bit Mode
      • Runs applications in a 64 bit linear address space

2.3 64 bit x86-64 Processors

  • Important Features
    • Backwards compatible with x86 instruction set
    • Allows addressing 2^64 bytes (currently only 48 bits are used)
    • Uses 64 bit general purpose registers
    • Eight more general purpose registers over 32 bit
    • 48 bit physical address space which supports up to 256 terabytes of RAM
    • 16 bit real mode and virtual 8086 mode have been removed

2.2.3 x86 Memory Management

  • Real Address Mode
    • 1Mb of memory addressed (0x00000 to 0xFFFFF)
    • Only one program can be run at a time
    • Interrupts allow scheduling
    • Programs can access any location
  • Protected Mode
    • 4Gb of memory can be addressed
    • Each program has 4Gb of virtual memory
  • Virutal 8086
    • Runs in protected mode with 1Mb of memory
    • Simulating a virtual 8086 machine

2.2.2 Basic Execution Environment

  • Address Space
    • 32-bit protected mode allows addressing of 4Gb of memory
    • PAE allows addressing up to 64Gb of memory
    • Real address mode allows addressing of 1Mb of memory
  • Basic Program Execution Registers
    • General Purpose Registers
      • EAX: Automatically used for multiply/divide called “extended accumulator register”
      • ECX: Automatically uses as a loop counter “extended counter register”
      • ESP: Contains of the address of the top of the stack in the current execution context, “extended stack pointer register”
      • EBP: Contains the bottom of the stack for the current execution context, “extended base pointer register”
      • ESI and EDI: Used for high speed memory transfer “extended source/destination index registers”
      • EBX, EDX
      • Segment Registers
        • Real Address Mode: 16 bit memory segments with predefined base addresses
        • Protected Mode: Holds pointers to segment descriptor tables which may contain code (instructions), data (variables), and stack segment for local variables and parameters
      • Instruction Pointer: EIP contains the address of the next instruction
      • EFLAGS Register: Binary bits with flags representing things like carry, interrupts, etc
  • MMX Registers
    • Used to improve the performance of multimedia applications (video/communication)
    • Eight 64 bit registers
    • Support for special SIMD (Single instruciton, multiple data) instructions
    • Allows parallel processing of the data
    • In fact all 8 registers are aliases for the same registers used for FP calculations
  • XMM Registers
    • Eight 128 bit registers
    • Floating Point Units
      • Labeled as ST(0) to ST(7)
      • Capture.PNG

2.2.1 Modes of Operation

  • 3 primary modes of operation
    1. Protected mode
      • Native state of processor
      • Programs are allocated segments
      • Programs are restricted from accessing memory outside its respective segment
    2. Real-address mode
      • Implements the early 8086 programming environment
      • Useful if a program requires direct access to system memory and hardware devices
    3. System management mode
      • Often used by computer manufacturers to implement low level functions such as system security or power management
    4. *Sub-mode, virtual-8086 a special version of protected mode
      • Allows the execution of very early MS-DOS programs safely, meaning no kernel panic if it crashes

2.1.3 Reading From Memory

  • 4 Simple Steps to read from Memory
    • 1. Place address of value you want to read on bus
    • 2. Assert the processor’s RD (read) pin
    • 3. Wait one clock cycle for the memory chips to respond
    • 4. Copy the data that has now appeared on the bus
  • Caches on the CPU
    • Used to store most recently used instructions
    • This is done because often the CPU is the true bottle neck to most processes
    • There are levels of cache the lower number=faster=closer to the actual CPU
    • Level 1 is directly on the CPU
    • Level 2 is connected to the CPU by a high speed memory bus
    • These are static RAM (SRAM) which is more expensive and faster than traditional RAM (DRAM)