What does the "rep stos" x86 assembly instruction sequence do? -


i stumbled across following assembly instruction sequence:

rep stos    dword ptr [edi] 

for ecx repetitions, stores contents of eax edi points to, incrementing or decrementing edi (depending on direction flag) 4 bytes each time. normally, used memset-type operation.

usually, instruction written rep stosd. experienced assembly coders know details mentioned above seeing that. :-)


eta completeness (thanks phis): each iteration, ecx decremented 1, , loop stops when reaches zero. stos, thing observe ecx cleared @ end. but, scas or like, repz/repnz prefixes used, ecx can greater 0 if operation stopped before exhausting ecx bytes/words/whatevers.

before ask, scas used implementing strchr-type operations. :-p


Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -