解码 68k 指令
我正在编写一个解释型 68k 模拟器作为个人/教育项目。现在我正在尝试开发一种简单、通用的解码机制。
据我了解,每条指令的前两个字节足以唯一地标识操作(有两个罕见的例外)以及剩余要读取的字数(如果有)。
这是我在解码阶段想要完成的任务:
1. read two bytes
2. determine which instruction it is
3. extract the operands
4. pass the opcode and the operands on to the execute phase
我不能像处理 RISC 架构中的前几个位那样将前两个字节传递到查找表中,因为操作数“碍事”。我怎样才能以一般方式完成2
部分?
总的来说,我的问题是:如何从解码过程中消除操作数的可变性?
更多背景:
这是《程序员参考手册》第 8.2 节中的部分表格:
Table 8.2. Operation Code Map
Bits 15-12 Operation
0000 Bit Manipulation/MOVEP/Immediate
0001 Move Byte
...
1110 Shift/Rotate/Bit Field
1111 Coprocessor Interface...
这对我来说很有意义,但随后我查看每条指令的位模式,发现没有一条指令的位 15-12 是 0001、0010 或 0011。我失踪了。
这个 Decoding Z80 Opcodes 站点明确解释了解码,这是我在 68k 程序员的手册中没有找到的参考手册或通过谷歌搜索。
I'm writing an interpreted 68k emulator as a personal/educational project. Right now I'm trying to develop a simple, general decoding mechanism.
As I understand it, the first two bytes of each instruction are enough to uniquely identify the operation (with two rare exceptions) and the number of words left to be read, if any.
Here is what I would like to accomplish in my decoding phase:
1. read two bytes
2. determine which instruction it is
3. extract the operands
4. pass the opcode and the operands on to the execute phase
I can't just pass the first two bytes into a lookup table like I could with the first few bits in a RISC arch, because operands are "in the way". How can I accomplish part 2
in a general way?
Broadly, my question is: How do I remove the variability of operands from the decoding process?
More background:
Here is a partial table from section 8.2 of the Programmer's Reference Manual:
Table 8.2. Operation Code Map
Bits 15-12 Operation
0000 Bit Manipulation/MOVEP/Immediate
0001 Move Byte
...
1110 Shift/Rotate/Bit Field
1111 Coprocessor Interface...
This made great sense to me, but then I look at the bit patterns for each instruction and notice that there isn't a single instruction where bits 15-12 are 0001, 0010, or 0011. There must be some big piece of the picture that I'm missing.
This Decoding Z80 Opcodes site explains decoding explicitly, which is something I haven't found in the 68k programmer's reference manual or by googling.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我决定简单地创建一个查找表,其中包含每条指令的每种可能的模式。这是我的第一个想法,但我因为“浪费、不优雅”而放弃了它。现在,我接受它“非常快”。
I've decided to simply create a look-up table with every possible pattern for each instruction. It was my first idea, but I discarded it as "wasteful, inelegant". Now, I'm accepting it as "really fast".