(Redirected from X86-assembly/Instructions/stosw)Jump to navigation Jump to search
|You are here:|
- The stos (Store String) instruction copies the value in AL, AX or EAX into the location pointed to by ES:DI or ES:EDI (depending on the address-size attribute of the instruction, 32 or 16, respectively). (E)DI is then incremented (if the direction flag is cleared) or decremented (if the direction flag is set), in preparation for storing AX in the next location.
- stosb stores a byte from the AL register into the destination operand.
- stosw stores a word from the AX register into the destination operand.
- stosd stores a doubleword from the EAX register into the destination operand.
stos stosb stosw stosd
When used in conjunction with the REP prefixes, the Store String instructions are useful for initializing a block of memory.
For example, the following code would initialize the 100-byte memory block at BUFFER to 0:
MOV AL,0 ;The value to initialize BUFFER to LEA DI,BUFFER ;Starting location of BUFFER MOV CX,100 ;Size of BUFFER CLD ;Let's move in forward direction REP STOS BUFFER ;Compare this line to example for STOSB