如何读取汇编指令的方向位和源或目标
因此,我正在编写一些代码(针对 x86),我需要在其中获取指令的源点或目标点。为此,我需要指示 ModRM 或 REG 是目的地还是源的方向位。我还需要能够处理即时值。到目前为止,我可以处理指令及其主要操作码(以及前缀)。我想知道最简单的方法是什么,或者是否有人可以向我指出一些确定目标/源的良好代码示例(例如寄存器、内存地址或立即操作数)。我见过很多解码器,但大多数解码器都是专门为一件事而构建的,并且包含大量功能的解码器非常复杂。
So I'm working on some code (for x86) where I need to get the source or destination point of an instruction. For this I need the direction bit which says whether ModRM or REG is the destination or source. Also I need to be able to handle immediate values. So far I can process the instruction and it's primary opcode (along with prefixes). I'm wondering what the easiest way to go about this is or if anyone can point me to some good code examples where the destination/source is determined (such as a register, memory address, or immediate operand). I've seen a lot of decoders but most of them are built specifically for one thing and the ones that do include a lot of functionality are very complex.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不直接使用反汇编引擎呢?您可以查看它们如何解码字节(规范位于英特尔开发人员手册第 1 卷中),也可以让它们为您完成所有繁重的工作,这样您就可以处理它们的输出(可能是纯文本和一些标志)。值得关注的两个开源引擎是 BeaEngine(包含所有指令,界面简单易用)和 ollydbg 的 disasm 引擎(简单紧凑,仅支持 SSE1 指令)。
Why not just use a disassembler engine? You can either see how they decode bytes(the specification is in the intel developers manual vol. 1) or get them to do all the heavy lifting for you, so you can instead process their output(which would probably be plain text and a few flags). The two open source engines to look at would be BeaEngine (includes every instruction under the sun, simple to use interface) and ollydbg's disasm engine (simple and compact, only goes up to SSE1 instructions).