z80

How do I determine the start and end of instructions in an object file?

只愿长相守 提交于 2019-11-28 11:13:29
问题 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

GBZ80: What constitutes a “half-carry”?

我们两清 提交于 2019-11-27 11:42:37
问题 The Game Boy Z80 CPU has a half-carry flag, and I can't seem to find much information about when to set/clear it. What I understand so far is that any 8-bit add, subtract, shift, or rotate operation (and maybe others?) set it to bit 4 of the result(?), and the DAA instruction sets/uses this somehow. What I'm not sure is how 16-bit instructions affect it and whether it's affected or not by the use of certain registers. 回答1: It's the carry from bit 3 to bit 4, just like the normal carry flag

Z80 ASM BNF structure… am I on the right track?

為{幸葍}努か 提交于 2019-11-27 01:59:45
I'm trying to learn BNF and attempting to assemble some Z80 ASM code. Since I'm new to both fields, my question is, am I even on the right track? I am trying to write the format of Z80 ASM as EBNF so that I can then figure out where to go from there to create machine code from the source. At the moment I have the following: Assignment = Identifier, ":" ; Instruction = Opcode, [ Operand ], [ Operand ] ; Operand = Identifier | Something* ; Something* = "(" , Identifier, ")" ; Identifier = Alpha, { Numeric | Alpha } ; Opcode = Alpha, Alpha ; Int = [ "-" ], Numeric, { Numeric } ; Alpha = "A" | "B"

Z80 ASM BNF structure… am I on the right track?

痞子三分冷 提交于 2019-11-26 09:51:45
问题 I\'m trying to learn BNF and attempting to assemble some Z80 ASM code. Since I\'m new to both fields, my question is, am I even on the right track? I am trying to write the format of Z80 ASM as EBNF so that I can then figure out where to go from there to create machine code from the source. At the moment I have the following: Assignment = Identifier, \":\" ; Instruction = Opcode, [ Operand ], [ Operand ] ; Operand = Identifier | Something* ; Something* = \"(\" , Identifier, \")\" ; Identifier

Overflow and Carry flags on Z80

你。 提交于 2019-11-26 03:58:16
问题 I have gotten round to implementing the ADD A,r set of opcodes on my Z80 core. I had a bit of confusion about the carry and overflow flags which I think I\'ve nailed, but I wanted to put it to the community to check that I\'m right. Basically, from what I can see, the ALU in the Z80 doesn\'t care about signed/unsigned operations, it just adds bits. This means that if two 8-bit values are added together and cause a 9-bit value as a result of their addition, the carry flag will be set. This