16 bit Assembly

Home   Site Map   Instruction Index  


STOSB and STOSW   - Store Instruction

The STOSB and STOSW instructions are used to save data in AX to the memory pointed to by the DI register. After each call to the DI register is incremented by one byte for STOSB or by two bytes for STOSW.
This command has 1 part, the Instruction.

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

STOSB saves one byte from AL
STOSW saves 2 bytes from AX.

These commands are limited to the current ES code segment.

This example reads 16 single bytes from SI and saves them in DI 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
LODSB;  Load one byte into AL from SI   AC
STOSB;  Save one byte from AL to DI   AA
LOOP 0xFCLOOP back to LODSB to read
  each byte until CX = 0
 E2 FC




Last Update 06/02/2023