String Insruction
String Insruction
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.
The CMPS instruction can be used to compare two strings of byte or words. The
length of the string must be stored in the register CX. If both the byte or word strings are
equal, zero Flag is set. The REP instruction Prefix is used to repeat the operation till CX
(counter) becomes zero or the condition specified by the REP Prefix is False.
This instruction scans a string of bytes or words for an operand byte or word
specified in the register AL or AX. The String is pointed to by ES: DI register pair. The
length of the string stored in CX. The DF controls the mode for scanning of the string.
Whenever a match to the specified operand is found in the string, execution stops and the
zero Flag is set. If no match is found, the zero flag is reset.
The LODS instruction loads the AL / AX register by the content of a string pointed
to by DS: SI register pair. The SI is modified automatically depending upon DF, If it is a
byte transfer (LODSB), the SI is modified by one and if it is a word transfer (LODSW),
the SI is modified by two. No other Flags are affected by this instruction.