Content #
将AL、AX或EAX的值存入es:di指定的位置,不能使用segment override prefix。然后根据D标记递增或递减di的值。
stosb es:[di]=al; di=di \(\pm\) 1 stosw es:[di]=al; di=di \(\pm\) 2 stosd es:[di]=al; di=di \(\pm\) 4
stos之前可使用repeat prefix(rep),rep前缀每次会将cx减1,重复执行stos指令,直到cx值为0。lods指令之前使用rep是没有任何意义的。
下面的代码用stosw指令清除Buffer指定的区域:
void ClearBuffer (int count, short* buffer)
{
_asm{
push edi ;save registers
push es
push ds
mov ax,0
mov ecx, count
mov edi, buffer
pop es ;load ES with DS
rep stosw ;clear Buffer
pop es ;restore registers
pop edi
}
}
From #
The Intel Microprocessors