PROCESSOR
REGISTERS
A
processor includes a set of registers that provide memory that is faster and
smaller than main memory. Processor registers serve two functions:
Ø User-visible registers:
Enable the machine or assembly language programmer to minimize main memory
references by optimizing register use. For high-level languages, an optimizing
compiler will attempt to make intelligent choices of which variables to assign
to registers and which to main memory locations. Some high-level languages,
such as C, allow the programmer to suggest to the compiler which variables
should be held in registers.
Ø Control and status
registers: Used by the processor to control the
operation of the processor and by privileged OS routines to control the
execution of programs.
There
is not a clean separation of registers into these two categories. For example,
on some processors, the program counter is user visible, but on many it is not.
For purposes of the following discussion, however, it is convenient to use
these categories.
User-Visible Registers
A
user-visible register may be referenced by means of the machine language that
the processor executes and is generally available to all programs, including
application programs as well as system programs. Types of registers that are
typically available are data, address, and condition code registers.
Data registers
can be assigned to a variety of functions by the programmer. In some cases,
they are general purpose in nature and can be used with any machine instruction
that performs operations on data. Often, however, there are restrictions. For
example, there may be dedicated registers for floating-point operations and
others for integer operations.
Address registers
contain main memory addresses of data and instructions, or they contain a
portion of the address that is used in the calculation of the complete or
effective address. These registers may themselves be general purpose, or may be
devoted to a particular way, or mode, of addressing memory. Examples include
the following:
Ø Index register:
Indexed addressing is a common mode of addressing that involves adding an index
to a base value to get the effective address.
Ø Segment pointer:
With segmented addressing,memory is divided into segments, which are
variable-length blocks of words. A memory reference consists of a reference to
a particular segment and an offset within the segment; this mode of addressing
is important in our discussion of memory management. In this mode
of addressing, a register is used to hold the base address (starting location)
of the segment. There may be multiple registers; for example, one for the OS
(i.e., when OS code is executing on the processor) and one for the currently
executing application.
Ø Stack pointer:
If there is user-visible stack2 addressing, then there is a dedicated register
that points to the top of the stack.This allows the use of instructions that
contain no address field, such as push and pop.
For some processors,
a procedure call will result in automatic saving of all user visible registers,
to be restored on return. Saving and restoring is performed by the processor as
part of the execution of the call and return instructions.This allows each
procedure to use these registers independently. On other processors, the
programmer must save the contents of the relevant user-visible registers prior
to a procedure call, by including instructions for this purpose in the program.
Thus, the saving and restoring functions may be performed in either hardware or
software, depending on the processor.
No comments:
Post a Comment