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

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

问题描述

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

I recently stumbled across the following assembly instruction sequence:

rep stos    dword ptr [edi]

推荐答案

对于ecx重复,将eax的内容存储到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. :-)

ETA的完整性(感谢PhiS):每一次迭代,ecx都会减1,并且当循环达到零时,循环会停止.对于stos,您将观察到的唯一情况是最后清除了ecx.但是,对于使用repz/repnz前缀的scas等,如果操作在耗尽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天全站免登陆