English 中文(简体)
Game: 什么构成“吸入”?
原标题:Game Boy: What constitutes a "half-carry"?

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.

我迄今理解的是,任何8个轨道增加、分立、转移或轮换作业(可能还有其他)都将其设定为成果第4项的范围,而DAA指令则将这一节奏/使用。 我不肯定的是,16项指示是如何影响到它的,它是否受到某些登记册的使用的影响。

最佳回答

它从第3轨到第4轨,就像正常的国旗记录从第7轨起一样。 因此,例如,在增加数中增加一半:

((a&0xf) + (value&0xf))&0x10

Which gives 0x10 if half carry should be set, 0 otherwise. Getting half carry from the other relevant ops follows naturally - the questions is whether there was carry from the low nibble to the high.

为了把事情看上去,z80有四比一的“ALU”,并且用两条四点眼镜进行8倍。 因此,由于中间结果,它自然会占一半。

DAA is interested in the flag because if half carry is set then two digits that add up to more than 16 were added in the low nibble; that will have correctly produced carry into the upper nibble but will have left the low nibble 6 lower than it should be, since there were six more values between 10, when it should have generated carry, and 16, when it did.

问题回答

在16个轨道操作中,在高度按吨位的登记册中,从第3轨到第4轨。 换言之,轨道11至轨道12。

(Note the above bits are labeled 0-15, from least to most significant)

See here: http://www.z80.info/z80code.htm

16 bit arithmetic

If  you want to add numbers that are more than the 0-255 that can
be stored in the A register,  then the HL, IX or IY registers can
be used. Thus LD HL,1000H:LD BC,2000H:ADD HL,BC will give

A  CZPSNH  BC   DE   HL   IX   IY  A  CZPSNH  BC   DE   HL   SP
00 000000 2000 0000 3000 0000 0000 00 000000 0000 0000 0000 0000

The flags are set as follows.

C or carry flag          1 if answer >65535 else 0
Z or zero flag           not changed
P flag                   not changed
S or sign flag           not changed
N flag                   0
H or half carry flag     1 if carry from bit 11 to bit 12 else 0

由于半边疆旗是博爱艺术家最常见的 blocks脚石之一,我冒着自由把与最近一个地雷问题联系起来作为答案:

Game:半衰期旗和16轨指示(特别是代码0xE8)


A summary of the above thread (answer by @gekkio):

It depends on the instruction, but the flags are always updated based on the same bit positions if you think in terms of 8-bit values...it just varies whether we re talking about the high or low byte of the 16-bit value. Bit 11 is just bit 3 of the high byte.

  • ADD SP, e: H from bit 3, C from bit 7 (flags from low byte op)
  • LD HL, SP+e: H from bit 3, C from bit 7 (flags from low byte op)
  • ADD HL, rr: H from bit 11, C from bit 15 (flags from high byte op)
  • INC rr: no flag updates (executed by the 16-bit inc/dec unit)
  • DEC rr: no flag updates (executed by the 16-bit inc/dec unit)




相关问题
Non-browser emulation of JavaScript - is it possible?

I have a new project I am working on that involves fetching a webpage, (using PHP and cURL) parsing the HTML and javascript out of it and then handling the data in the results. Basically I hit a ...

CLicking on the camera button in the android emulator

The camera button on the android emulator is disabled. I can t click on it and when I hover with the mouse the background is not blue like in the other buttons. I ve tried to add "camera support - ...

Windows Mobile 6 Emulator change storage?

How do i change the size of the Windows Mobile 6 Emulator. Its fixed at 32mb. I read this post: Increasing Windows Mobile 5 Emulator Storage But it only helps for the 5.0 version. Isnt there any way ...

热门标签