OVERVIEW OF THE 80C186 FAMILY ARCHITECTURE

Individual bits in bytes and words can also be rotated. The processor does not discard the bits ro- tated out of an operand. The bits circle back to the other end of the operand. The number of bits to be rotated is taken from the count operand, which can specify either an immediate value or the CL register. The carry flag can act as an extension of the operand in two of the rotate instructions. This allows a bit to be isolated in the Carry Flag (CF) and then tested by a JC (jump if carry) or JNC (jump if not carry) instruction.

2.2.1.4String Instructions

Five basic string operations process strings of bytes or words, one element (byte or word) at a time. Strings of up to 64 Kbytes can be manipulated with these instructions. Instructions are avail- able to move, compare or scan for a value, as well as to move string elements to and from the accumulator. Table 2-7 lists the string instructions. These basic operations can be preceded by a one-byte prefix that causes the instruction to be repeated by the hardware, allowing long strings to be processed much faster than is possible with a software loop. The repetitions can be termi- nated by a variety of conditions. Repeated operations can be interrupted and resumed.

Table 2-7. String Instructions

REP

Repeat

 

 

REPE/REPZ

Repeat while equal/zero

 

 

REPNE/REPNZ

Repeat while not equal/not zero

 

 

MOVSB/MOVSW

Move byte string/word string

 

 

MOVS

Move byte or word string

 

 

INS

Input byte or word string

 

 

OUTS

Output byte or word string

 

 

CMPS

Compare byte or word string

 

 

SCAS

Scan byte or word string

 

 

LODS

Load byte or word string

 

 

STOS

Store byte or word string

 

 

String instructions operate similarly in many respects (see Table 2-8). A string instruction can have a source operand, a destination operand, or both. The hardware assumes that a source string resides in the current data segment. A segment prefix can override this assumption. A destination string must be in the current extra segment. The assembler does not use the operand names to ad- dress strings. Instead, the contents of the Source Index (SI) register are used as an offset to address the current element of the source string. The contents of the Destination Index (DI) register are taken as the offset of the current destination string element. These registers must be initialized to point to the source and destination strings before executing the string instructions. The LDS, LES and LEA instructions are useful in performing this function.

2-22

Page 51
Image 51
Intel 80C186XL, 80C188XL user manual String Instructions