ARCHITECTURE AND INSTRUCTIONS
Any:of the .primitive string instructions may be preceded with a
The repeat prefix byte also designates a value to compare with ZF flag. If the primitive operation is one which affeCts the ZF flag, and the ZF flag is unequal to the designated value after' any execution of the primitive operation, the repetition is terminated. This permits the scan operation to serve as a scan- while or a
During the execution of a repeated primitive operation the operand pointer registers (SI and DI) and the operation count register (CX) are updated after each repetition,
whereas the instruction pointer will retain the offset addres~ of the repeat prefix byte
(assuming it immediately precedes the string operation instruction). Thus, an interrupted repeated operation will be correctly resumed when control returns from the interrupted task.
You should avoid using the two other prefix bytes with a
Primitive String Operations
Five primitive string oper~tions are provided: | |
, "'," | ' |
MOVS transfers. a byte or word operand from the source operand to the destination operand. As a repeated operation this moves
a string from one location in memory to another.
CMPS subtracts the destination byte or word operand from the source operand and affects the flags but does not return the result. As a repeated operation this compares two strings. With the appropriate repeat prefix it is pos- sible to determine after which string element the two strings become unequal, thereby establishing an ordering between the strings.
SCAS subtracts the destination byte or word operand from AL (or AX) and affects the flags but does not return the result. As a repeated operation this scans for the occur- rence of, or departure from a given value in the string. .
LODS transfers a byte or word operand from the source operand to AL (or AX). This operation ordinarily would not be repeated.
STOS transfers a byte or word operand from AL (or AX) to the destination operand. As a repeated operation this fills a string with a given value.
In all cases above, the source operand is addressed by SI and the destination operand is addressed by DI.
Software Operation Control
The repeat prefix provides for rapid iteration in a
prefix provides. | , |
By combining the'primidve string operations and iteration control operations with other operations, it is possible to' build sophisti- cated yet efficient string manipulation routines. One instruction that is particularly useful in this context is XLAT; it permits a byte fetched from one string to be translated