Intel x86 Assembly Language & Microarchitecture Register Fundamentals 16-bit Registers


Example

When Intel defined the original 8086, it was a 16-bit processor with a 20-bit address bus (see below). They defined 8 general-purpose 16-bit registers - but gave them specific roles for certain instructions:

  • AX The Accumulator register.
    Many opcodes either assumed this register, or were faster if it was specified.
  • DX The Data register.
    This was sometimes combined as the high 16 bits of a 32-bit value with AX - for example, as the result of a multiply.
  • CX The Count register.
    This was used in a number of loop-oriented instructions as the implicit counter for those loops - for example LOOPNE (loop if not equal) and REP (repeated move/compare)
  • BX The Base register.
    This could be used to index the base of a structure in memory - none of the above registers could be used to directly index into memory.
  • SI The Source Index register.
    This was the implicit source index into memory for certain move and compare operations.
  • DI The Destination Index register.
    This was the implicit destination index into memory for certain move and compare operations.
  • SP The Stack Pointer register.
    This is the least general-purpose register in the set! It pointed to the current position in the stack, which was used explicitly for PUSH and POP operations, implicitly for CALL and RET with subroutines, and VERY implicitly during interrupts. As such, using it for anything else was hazardous to your program!
  • BP The Base Pointer register.
    When subroutines call other subroutines, the stack holds multiple "stack frames". BP could be used to hold the current stack frame, and then when a new subroutine was called it coould be saved on the stack, the new stack frame created and used, and on return from the inner subroutine the old stack frame value could be restored.

Notes:

  1. The first three registers cannot be used for indexing into memory.

  2. BX, SI and DI by default index into the current Data Segment (see below).

     MOV    AX, [BX+5]     ; Point into Data Segment
     MOV    AX, ES:[DI+5]  ; Override into Extra Segment
    
  3. DI, when used in memory-to-memory operations such as MOVS and CMPS, solely uses the Extra Segment (see below). This cannot be overridden.

  4. SP and BP use the Stack Segment (see below) by default.