16 bit Assembly

Home   Site Map   Instruction Index  


MOVSB and MOVSW   - Move Far Instruction

The MOVSB and MOVSW instructions are used to move data between segments from the address pointed to by the DS:SI register to the address of the ES:DI Register. After each call the SI and DI Registers are incremented by one byte for byte operations or by two bytes for WORD.
This command has 1 part, the Instruction.

SI and DI are decremented backwards when the direction flag is set using the STD instruction.

MOVSB moves one byte at a time. Op Code A4. MOVSW moves 2 bytes at a time. Op Code A5

Unlike LODSB and LODSW it can be used to move data between sements.

This example moves 16 single bytes before exiting the LOOP.

Assembly Sample Description   16 bit Machine Code
MOV CX, 0x0010;  Assign 10h (16) to the Counter CX   B9 10 00
MOV SI, DataString;  Assign SI to point at a
  memory location to be read.
  BE 26 01
MOV DI, DataOut;  Assign DI to point at a
  memory location to save in.
  BF 36 01
MOVSB;  Load one byte into AL   A4
LOOP 0xFDLOOP back to LODSB to read
  each byte until CX = 0
  E2 FD




Last Update 06/02/2023