Pointer and Index Registers 

Pointer and Index Registers

These registers contain the offsets of data and instructions

The offset refers to the distance of a variable, label, or instruction from its base segment

Are used with arrayed data (such as strings, arrays and other data structures containing multiple elements). They increase the processing speed of such data structures

Can be used in arithmetic and other operations

The index registers are:

  1. SP (stack pointer):
    Contains an assumed offset value of the top of the stack

    Combined with the SS register form the complete logical address of the top of the stack

    The stack is maintained as a LIFO with its bottom at the start of the stack segment (specified by the SS segment register)

    The top of the stack (the location of the last data in the stack) is specified by the offset stored in the SP register

  2. BP (base pointer):
    As it is with the stack pointer, this register can hold an offset from the SS register

    It is usually used by subroutines to locate variables that were passed on the stack by a calling program

    Unlike the SP register, the BP can be used to specify the offset of other program segments

  3. SI (source index):
    Used in conjunction with the DS register to point to data locations in the data segment

    Used with string movement instructions. It would point to the source string.

  4. DI (destination index):
    Similar function to the SI

    Used in conjunction with the ES register in string operations. In string movement instructions it points to the destination string

  5. IP (Instruction Pointer):
    This is the register used for accessing instructions

    While the CS register contains the segment number of the next instruction, the IP contains the offset of that instruction in the code segment

    As was shown in the section on the fetch-execute cycle in the first unit, the IP register gets updated by the control unit every time an instruction is executed such that it will always point to the next instruction

    Unlike other registers, the IP can not be manipulated by instructions (i.e. it cannot appear as an operand in any instruction)