SoFunction
Updated on 2025-04-09

Explanation of string processing instructions in assembly language instruction set

String processing instructions

The classification of string processing instructions is as follows:

Directive Type
MOVS move string Transmission
CMPS compare string String comparison
SCAS scan string String scan
LODS load from string Get from the string
STOS store in to string Save string
INS input from port to string String input
OUTS output string to port String output
REP repeat repeat
REPE/REPZ repeat while equal/zero If equal/zero, repeat
REPNE/REPNZ repeat while not equal/zero If not equal / if not zero, repeat

Format:
 MOVS  DST,SRC
MOVSB ​​(bytes)
MOVSW   (word)
MOVSD  (Double Word) (386 and its successor models are available)
 
usage:
The instruction can pass a byte, word or double word (DS:SI) in the data segment pointed to by SI to a byte, word or double word (ES:DI) in the additional segment pointed to by DI, without affecting the conditional flag bits, and modify the SI and DI according to the DF and data format.

Format:
 CMPS  SRC,DST
CMPSB (bytes)
CMPSW   (word)
CMPSD (double-word) (386 and its successor models are available)
 
usage:
The instruction subtracts the data in the memory unit pointed to by DS:SI with the data in the memory unit pointed to by ES:SI, does not save the result but affects the condition flag bits, and modifies SI and DI according to the value of DF.

Format:
 SCAS     DST
SCASB (bytes)
SCASW   (word)
SCASD (double word) (386 and its successor models are available)
 
usage:
The instruction subtracts the data in AL, AX or EAX from the data in the memory unit pointed to by ES:DI, does not save the result but affects the condition flag bits, and modifies SI and DI according to the value of DF.

Format:
 LODS     SRC
LODSB (bytes)
LODSW   (word)
LODSD (double-word) (386 and its successor models are available)
 
usage:
The instruction sends the data in the memory unit pointed to by DS:SI to AL, AX, or EAX, and modifies the SI according to the value and data type of the condition flag bit DF.

Format:
 STOS     DST
STOSB (bytes)
STOSW   (word)
STOSD  (Double Word) (386 and its successor models are available)
 
usage:
The instruction stores the contents in AL, AX and EAX into the storage unit pointed to by DS:SI, and modifys the SI according to the value and data type of DF.

Format:
 INS  DST,DX
INSB (bytes)
INSW   (word)
INSD  (Double Word) (386 and its successor models are available)
 
usage:
The instruction sends the data of the I/O space ported in the DX register to the memory unit pointed to by ES:DI, and modifies the DI according to the value and data type of DF.

Format:
 OUTS  DX,SRC
OUTSB (bytes)
OUTSW   (word)
OUTSD  (Double Word) (386 and its successor models are available)
 
usage:
The instruction sends the data in the memory unit pointed to by DS:SI to the I/O port in the DX register, and changes the SI according to the value and data type of DF.

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.