Home »
Embedded Systems
String Handling in the 8086 Microprocessor
In this tutorial, we will learn about string handling and various string manipulation instructions in the 8086 Microprocessor.
By Monika Sharma Last updated : May 22, 2023
String Handling
While talking about the 8086 microprocessors, the Strings can be defined as the collection of ASCII characters. Each ASCII character is of one byte, and each byte of a String is stored at successive memory locations.
Source Index (SI), Destination Index (DI) and the general-purpose register-CX (which functions as a counter) are the registers involved in performing string operations.
String Manipulation Instructions
The following are the various string manipulation instructions in the 8086 microprocessor:
1) REP
Stands for 'Repeat'. This instruction repeats the given instruction(s) till CX does not becomes zero, i.e. CX!=0
REP instruction_to_be_repeated
2) REPE
This instruction repeats the given instruction(s) till CX remains zero, i.e. CX=0
REPE instruction_to_be_repeated
3) REPZ
It repeats the given instruction(s) while ZF remains 1, i.e. ZF=1
REPZ instruction_to_be_repeated
4) REPNE
This instruction is same as REP. It repeats the given instruction(s) till CX remains zero, i.e. CX=0
REPZ instruction_to_be_repeated
5) REPNZ
It repeats the instructions while ZF=0
REPNZ instruction_to_be_repeated
6) MOVSB
Stands for 'Move String Byte'. It moves the contents of a byte (8 bits) from DS:SI to ES:DI
MOVSB
7) MOVSW
Stands for 'Move String Word'. It moves the contents of a word (16 bits) from DS:SI to ES:DI
MOVSW
8) MOVSD
Stands for 'Move String Double Word'. It moves the contents of a double word (32 bits) from DS:SI to ES:DI
MOVSD
9) CMPSB
Stands for 'Compare String Byte'. It moves the compares the contents of a byte (8 bits) at DS:SI with the contents of a byte at ES:DI and sets the flag.
CMPSB
10) CMPSW
Stands for 'Compare String Word'. It moves the compares the contents of the word (16 bits) at DS:SI with the contents of the word at ES:DI and sets the flag.
CMPSW
11) CMPSD
Stands for 'Compare String Double Word'. It moves the compares the contents of the double word (32 bits) at DS:SI with the contents of the double word at ES:DI and sets the flag.
CMPSD