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.

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

  • STOSB saves 1 BYTE from AL
  • STOSW saves 1 WORD from AX.

These commands are limited to the current ES code segment.

This command has 1 part, the Instruction.


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