movsb movsw movsd instruction details
These three instructions are all data transfer instructions, all of which transfer data from the source address to the destination address.
In 16-bit mode:
source address is DS: SI, destination address is ES: DI In
32-bit mode:
source address is DS: ESI, destination address is ES: EDI
Note: After the transfer is complete, SI and DI (or ESI and EDI) will increase or decrease.
When DF = 0, it means forward transmission, the value of SI and DI (or ESI and EDI) will increase
after transmission ; when DF = 1, it means reverse transmission, SI and DI (or ESI and EDI) after transmission The value will decrease;
The difference between them is:
MOVSB: send a byte, then SI and DI (or ESI and EDI) plus / minus 1
MOVSW: send a word, then SI and DI (or ESI and EDI) plus / minus 2
MOVSD: send a Double word, then SI and DI (or ESI and EDI) plus / minus 4
Simple movsb / movsw / movsd can only be executed once. If you want the processor to automatically execute repeatedly, you can add the instruction prefix rep; set the number of transfers in the register CX (16-bit mode) or ECX (32-bit mode). When CX / ECX is not equal to 0, then execute movsb / movsw / movsd, after execution, the value of CX / ECX is reduced by one until it is reduced to 0.