STRING MANIPULATION INSTRUCTIONS Set
STRING MANIPULATION INSTRUCTIONS
A series of data byte or word available in memory at consecutive locations, to be referred as byte string or word string. A string of characters may be located in consecutive memory locations, where each character may be represented by its ASCII equivalent.
The 8086 supports a set of more powerful instructions for string manipulations for referring to a string , two parameters are required.
- Starting and end address of a string
- length of a string.
The length of the string is usually stored as count in the CX register. The incrementing or decrementing of the pointer , in string instructions, depends upon the direction flag (DF) status. If it is a byte string operation, the index registers are updated by one . On the other hand , if it is a word string operation, the index registers are updated by two.
REP : Repeat Instruction Prefix
This instruction is used as a prefix to other instructions , the instruction to which the REP prefix is provided is executed repeatedly until the CX register becomes zero (at each iteration the CX is automatically decremented by one).
- REPE / REPZ – Repeat operation while equal / zero.
- REPNE / REPNZ – Repeat operation while not equal / zero.
These are used for CMPS , SCAS instructions only as instruction prefixes.
STOS : Store string byte or string word.
The STOS instruction stores the AL /AX register contents to a location in the string pointed by the ES : DI pair . The DI is modified accordingly . No falgs are affected by this instruction .
The direction flag controls the string instruction execution. The SI and DI are modified after each iteration automatically. If DI = 1, then the execution follows auto decrement mode, SI and DI are decremented automatically after each iteration. IF DS = 0, then the execution follows auto increment mode. In this mode, SI and DI are incremented automatically after each iteration.