lecture21
lecture21
2. REGISTER SET
Registers are essentially extremely fast memory locations within the CPU
that are used to create and store the results of CPU operations and
other calculations. Different computers have different register sets. They
differ in the number of registers, register types, and the length of each
register. They also differ in the usage of each register. General-purpose
registers can be used for multiple purposes and assigned to a variety of
functions by the programmer. Special-purpose registers are restricted
to only specific functions. In some cases, some registers are used only to
hold data and cannot be used in the calculations of operand addresses.
The length of a data register must be long enough to hold values of most
data types. Some machines allow two contiguous registers to hold
double-length values. Address registers may be dedicated to a particular
addressing mode or may be used as address general purpose. Address
registers must be long enough to hold the largest address. The number
of registers in a particular architecture affects the instruction set design.
A very small number of registers may result in an increase in memory
references. Another type of registers is used to hold processor status
bits, or flags. These bits are set by the CPU as the result of the execution
of an operation. The status bits can be tested at a later time as part of
another operation.
2.1 General-Purpose Registers
The main tools to write programs in x86 assembly are the processor
registers. The registers are like variables built in the processor. Using
registers instead of memory to store values makes the process faster
and cleaner. The problem with the x86 serie of processors is that there
are few registers to use. This section describes the main use of each
register and ways to use them. That in note that the rules described here
are more suggestions than strict rules. Some operations need absolutely
some kind of registers but most of the you can use any of the freely.
Here is a list of the available registers on the 386 and higher processors.
This list shows the 32 bit registers. Most of the can be broken down to
16 or even 8 bits register.
As the title says, general register are the one we use most of the time
Most of the instructions perform on these registers. They all can be
broken down into 16 and 8 bit registers.
1
University of Babylon/College of IT S/W Dept. 1st Class/Computer Organization
The "H" and "L" suffix on the 8 bit registers stand for high byte and low
byte. With this out of the way, let's see their individual main use
1. The word to be stored into the memory location is first loaded by the
CPU into MDR.
2. The address of the location into which the word is to be stored is
loaded by the CPU into a MAR.
2
University of Babylon/College of IT S/W Dept. 1st Class/Computer Organization
Similarly, to perform a memory read operation, the MDR and MAR are
used as follows:
1. The address of the location from which the word is to be read is
loaded into the MAR.
2. A read signal is issued by the CPU.
3. The required word will be loaded by the memory into the MDR ready
for use by the CPU.
Segment registers hold the segment address of various items. They are
only available in 16 values. They can only be set by a general register or
special instructions. Some of them are critical for the good execution of
the program and you might want to consider playing with them when
you'll be ready for multi-segment programming
3
University of Babylon/College of IT S/W Dept. 1st Class/Computer Organization
Indexes and pointer and the offset part of and address. They have
various uses but each register has a specific function. They some time
used with a segment register to point to far address (in a 1Mb range).
The register with an "E" prefix can only be used in protected mode.
4
University of Babylon/College of IT S/W Dept. 1st Class/Computer Organization
5
University of Babylon/College of IT S/W Dept. 1st Class/Computer Organization