GB Programming: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
>ISSOtm
(→‎Instructions get!: Remove instructions that don't exist on the Game Boy)
>ISSOtm
(→‎Flags: Remove flags that don't exist on Game Boy)
Line 465: Line 465:
|7||6||5||4||3||2||1||0
|7||6||5||4||3||2||1||0
|-
|-
|S||Z||-||H||-||P/V||N||C
|Z||N||H||C||-||-||-||-
|}
|}
Both "-" are unused flags. Their behavior is very complicated, and they aren't "official". Treat them as random.
All "-" are unused flags. They are set to 0 at all times.

===S : Sign===
If the accumulator is negative (from a signed perspective), the flag is set. You can also view it as a copy of the accumulator's 7th bit.


===Z : Zero===
===Z : Zero===
Line 477: Line 474:
===H : Half-Carry===
===H : Half-Carry===
Works like the Carry flag, but referring to the least-significant ''nibble''. It is only used with the DAA instruction, so... forget it until then.
Works like the Carry flag, but referring to the least-significant ''nibble''. It is only used with the DAA instruction, so... forget it until then.

===P/V : Parity/Overflow===
This flag's meaning depends on the last operation.

If it means parity, it is set if the number of 1 in the accumulator is even. If it is odd, then it is reset.

If it means overflow, it is set if the last operation caused the accumulator's sign to change.


===N : Add/Subtract===
===N : Add/Subtract===