The string instructions are summarized in Fig.5-1.Because the string instructions can operate on only a single byte or word unless they are used with the REP prefiks discussed in Sec. 5-2 they are often referred to as string primitives.
Figure 5-1 String primitives Name Mnemonic and Format* Description** Move string MOVS DST, SRC ((DI)) <- ((SI)) Byte operands (SI) <- (SI)±1, (DI) <- (DI)±1 Word operands (SI) <- (SI)±2, (DI) <- (DI)±2 Move byte string MOVSB Move word string MOVSW Compare string CMPS SRC, DST ((SI)) <- ((DI)) Byte operands (SI) <- (SI)±1, (DI) <- (DI)±1 Word operands (SI) <- (SI)±2, (DI) <- (DI)±2 Compare byte string CMPSB Compare word string CMPSW Scan string SCAS DST Byte operand ((AL)) - ((DI)), (DI) <- (DI)±1 Word operand ((AX)) - ((DI)), (DI) <- (DI)±2 Scan byte string SCASB Scan word string SCASW Load string LODS SRC Byte operand (AL) <- (SI), (SI) <- (SI)±1 Word operand (AX) <- (SI), (SI) <- (SI)±2 Load byte string LODSB Load word string LODSW Store string STOS DST Byte operand ((DI)) <- ((AL)), (DI) <- (DI)±1 Word operand ((DI)) <- ((AX)), (DI) <- (DI)±2 Store byte string STOSB Store word string STOSW *The B suffix indicates byte operands and the W suffix indicates. **Incrementing (+) is used if DF=0 and decrementing (-) is used if DF=1. Flags: CMPS and SCAS affect all condition flags and MOVS,LODS and STOS affect no flags. Addresing modes: Operands are implied.All of the primitives are 1 byte long, with bit 0 indicating whether a byte (bit 0=0) or a word (bit 0=1) is being manipulated.
There are five basic primitives and eachmay appear in one of the following
three forms:
Operation Operand(s)
or
OperationB
or
OperationW
In the first form is used, whether bytes or words are to be operated on is determined
implicitly by the type of the operand(s).The second and third forms explicitly
indicate byte and word operations, respectively.
For instance, if DF=0, then
MOVSBwould cause the byte in (SI)+(DS) X 16d to be moved to (DI)+(ES) X 16d and the contents of both SI and DI to be incremented by 1.
SADRZAJ | SLEDECA FOLIJA |