“rep stos"是什么意思?x86汇编指令序列做什么? [英] What does the "rep stos" x86 assembly instruction sequence do?

查看:42
本文介绍了“rep stos"是什么意思?x86汇编指令序列做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近偶然发现了以下汇编指令序列:

I recently stumbled across the following assembly instruction sequence:

rep stos    dword ptr [edi]

推荐答案

对于 ecx 重复,将 eax 的内容存储到 where edi每次都指向、增加或减少 edi(取决于方向标志)4 个字节.通常,这用于 memset 类型的操作.

For ecx repetitions, stores the contents of eax into where edi points to, incrementing or decrementing edi (depending on the direction flag) by 4 bytes each time. Normally, this is used for a memset-type operation.

通常,该指令简单地写成rep stosd.有经验的汇编编码员只需看到上面提到的所有细节就知道了.:-)

Usually, that instruction is simply written rep stosd. Experienced assembly coders know all the details mentioned above just by seeing that. :-)

完整性的预计到达时间(感谢 PhiS):每次迭代,ecx 递减 1,当它达到零时循环停止.对于 stos,您唯一会观察到的是 ecx 在最后被清除.但是,对于 scas 等,使用 repz/repnz 前缀时,ecx 可以大于如果操作在耗尽 ecx 字节/字/无论什么之前停止,则为零.

ETA for completeness (thanks PhiS): Each iteration, ecx is decremented by 1, and the loop stops when it reaches zero. For stos, the only thing you will observe is that ecx is cleared at the end. But, for scas or the like, where the repz/repnz prefixes are used, ecx can be greater than zero if the operation stopped before exhausting ecx bytes/words/whatevers.

在你问之前,scas 用于实现 strchr 类型的操作.:-P

Before you ask, scas is used for implementing strchr-type operations. :-P

这篇关于“rep stos"是什么意思?x86汇编指令序列做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆