We've just updated MediaWiki and its underlying software. If anything doesn't look or work quite right, please mention it to us. --RanAS

Zero Flag: Difference between revisions

From SnesLab
Jump to: navigation, search
(SPC700+GSU)
(Flag valid in decimal mode)
 
(18 intermediate revisions by the same user not shown)
Line 1: Line 1:
The '''Zero Flag''' (Z) exists on the [[65c816]].  It is affected by these 41 instructions:
The '''Zero Flag''' (Z) is bit 1 of the [[65c816]]'s [[status register]].  It indicates whether the last value computed, transferred, or pulled is zero: set if it is and clear if not.  Although there are no dedicated SEZ or CLZ instructions to set or clear it, it can be directly set with [[SEP]] and cleared with [[REP]]:
 
<pre>
SEP #$02
REP #$02
</pre>
 
It is also affected by these 41 instructions:


* [[ADC]]
* [[ADC]]
Line 42: Line 49:
* [[TYX]]
* [[TYX]]
* [[XBA]]
* [[XBA]]
The [[BEQ]] and [[BNE]] instructions examine the zero flag to decide whether or not to branch.  Push instructions do not affect the zero flag.


The [[SPC700]] and [[Super FX]] chips also have a zero flag.
The [[SPC700]] and [[Super FX]] chips also have a zero flag.


=== Reference ===
The zero flag is invalid in [[decimal mode]] on the NMOS 6502, but it is valid in the 65c816's decimal mode.
* Labiak, page 108 https://archive.org/details/Programming_the_65816/page/n118
 
=== See Also ===
* [[Negative Flag]]
* [[Carry Flag]]
* [[Overflow Flag]]
 
=== References ===
* [[Labiak]], [https://archive.org/details/Programming_the_65816/page/n118 page 108]
* [[Eyes & Lichty]], "Branching Based on the Zero Flag" on [https://archive.org/details/0893037893ProgrammingThe65816/page/146 page 146]
* Table 7-1 Caveats of 65c816 datasheet


[[Category:ASM]]
[[Category:ASM]]
[[Category:Flags]]
[[Category:Flags]]
[[Category:Inherited from 6502]]
[[Category:Inherited from 6502]]
[[Category:Condition Codes]]

Latest revision as of 03:08, 20 September 2024

The Zero Flag (Z) is bit 1 of the 65c816's status register. It indicates whether the last value computed, transferred, or pulled is zero: set if it is and clear if not. Although there are no dedicated SEZ or CLZ instructions to set or clear it, it can be directly set with SEP and cleared with REP:

SEP #$02
REP #$02

It is also affected by these 41 instructions:

The BEQ and BNE instructions examine the zero flag to decide whether or not to branch. Push instructions do not affect the zero flag.

The SPC700 and Super FX chips also have a zero flag.

The zero flag is invalid in decimal mode on the NMOS 6502, but it is valid in the 65c816's decimal mode.

See Also

References