如何确定目标文件中指令的开始和结束? [英] How do I determine the start and end of instructions in an object file?
问题描述
因此,我一直在尝试编写模拟器,或者至少了解东西的工作原理。我对汇编语言(尤其是z80和x86)有相当的了解,但是我从来没有真正理解过目标文件(或者我的情况是.gb ROM文件)如何指示指令的开始和结束。
So, I've been trying to write an emulator, or at least understand how stuff works. I have a decent grasp of assembly, particularly z80 and x86, but I've never really understood how an object file (or in my case, a .gb ROM file) indicates the start and end of an instruction.
我正在尝试为每条指令解析操作码,但是我发现这并不像每条指令后都有换行符。那么这是怎么发生的呢?对我来说,它看起来像是一堆字节,无法分辨操作码及其操作数之间的区别。
I'm trying to parse out the opcode for each instruction, but it occurred to me that it's not like there's a line break after every instruction. So how does this happen? To me, it just looks like a bunch of bytes, with no way to tell the difference between an opcode and its operands.
推荐答案
对于大多数CPU-我相信Z80属于此类-指令的长度是隐含的。
For most CPUs - and I believe Z80 falls in this category - the length of an instruction is implicit.
也就是说,您必须对指令进行解码才能弄清楚它有多长。
That is, you must decode the instruction in order to figure out how long it is.
这篇关于如何确定目标文件中指令的开始和结束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!