I recently stumbled across the following assembly instruction sequence:
rep stos dword ptr [edi]
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For
ecxrepetitions, stores the contents ofeaxinto whereedipoints to, incrementing or decrementingedi(depending on the direction flag) by 4 bytes each time. Normally, this is used for amemset-type operation.Usually, that instruction is simply written
rep stosd. Experienced assembly coders know all the details mentioned above just by seeing that. 🙂ETA for completeness (thanks PhiS): Each iteration,
ecxis decremented by 1, and the loop stops when it reaches zero. Forstos, the only thing you will observe is thatecxis cleared at the end. But, forscasor the like, where therepz/repnzprefixes are used,ecxcan be greater than zero if the operation stopped before exhaustingecxbytes/words/whatevers.Before you ask,
scasis used for implementingstrchr-type operations. 😛