Hardware Reference
In-Depth Information
instruction has a source and a destination operand, and that the destination is writ-
ten before the source.
The next general register is CX , the counter register . Besides fulfilling many
other tasks, this register is specifically used to contain counters for loops. It is auto-
matically decremented in the LOOP instruction, and loops are usually terminated
when CX reaches zero.
The fourth register of the general group is DX , the data register . It is used
together with AX in double word length (i.e., 32-bit) instructions. In this case, DX
contains the high-order 16 bits and AX contains the low-order 16 bits. Usually,
32-bit integers are indicated by the term long . The term double is usually reserved
for 64-bit floating point values, although some people use ''double'' for 32-bit inte-
gers. In this tutorial, there will be no confusion because we will not discuss float-
ing-point numbers at all.
All of these general registers can be regarded either as a 16-bit register or as a
pair of 8-bit registers. In this way, the 8088 has precisely eight different 8-bit reg-
isters, which can be used in byte and character instructions. None of the other reg-
isters can be split into 8-bit halves. Some instructions use an entire register, such
as AX , but other instructions use only half of a register, such as AL or AH . In gen-
eral, instructions doing arithmetic use the full 16-bit registers, but instructions deal-
ing with characters usually use the 8-bit registers. It is important, however, to real-
ize that AL and AH are just names for both halves of AX . When AX is loaded with a
new value, both AL and AH are changed to the lower and upper halves of the 16-bit
number put in AX , respectively. To see how AX , AH , and AL interact, consider the
instruction
MOV AX,258
which loads the AX register with the decimal value 258. After this instruction, the
byte register AH contains the value 1, and the byte register AL contains the number
2. If this instruction is followed by the byte add instruction
ADDB AH,AL
then the byte register AH is incremented by the value in AL (2) so that it now con-
tains 3. The effect on the register AX of this action is that its value is now 770,
which is equivalent to 00000011 00000010 in binary notation or 0x03 0x02 in hex-
adecimal notation. The eight byte-wide registers are almost interchangeable, with
the exception that AL always contains one of the operands in the MULB instruction,
and is the implied destination of this operation, together with AH . DIVB also uses
the AH : AL pair for the dividend. The lower byte of the counter register CL can be
used to hold the number of cycles in shift and rotate instruction.
Section C.8, example 2, shows some of the properties of the general registers
by means of a discussion of the program GenReg.s .
 
Search WWH ::




Custom Search