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

Negative Flag: Difference between revisions

From SnesLab
Jump to: navigation, search
(clarify what kinds of instructions modify N)
Line 1: Line 1:
The '''Negative Flag''' (N) is bit 7 of the [[65c816]]'s [[status register]].  It is set or cleared to reflect the most significant bit of arithmetic results or transferred values.  Although there are no dedicated SEN or CLN instructions to set or clear it, it can be set with [[SEP]] and cleared with [[REP]]:
The '''Negative Flag''' (N) is bit 7 of the [[65c816]]'s [[status register]].  It is set or cleared to reflect the most significant bit of arithmetic/logical results or pulled/loaded/transferred values.  Although there are no dedicated SEN or CLN instructions to set or clear it, it can be set with [[SEP]] and cleared with [[REP]]:


<pre>
<pre>
Line 47: Line 47:
* [[XBA]]
* [[XBA]]


Also, [[LSR]] always clears the negative flag because it also shifts a zero into the operand's most significant bit, making it non-negative.
Also, [[LSR]] always clears the negative flag because it also shifts a zero into the operand's most significant bit, making it non-negative.  Push instructions do not affect the negative flag.


[[BPL]] and [[BMI]] examine the negative flag to decide whether or not to branch.
[[BPL]] and [[BMI]] examine the negative flag to decide whether or not to branch.

Revision as of 04:16, 16 August 2024

The Negative Flag (N) is bit 7 of the 65c816's status register. It is set or cleared to reflect the most significant bit of arithmetic/logical results or pulled/loaded/transferred values. Although there are no dedicated SEN or CLN instructions to set or clear it, it can be set with SEP and cleared with REP:

SEP #$80
REP #$80

These instructions also affect the negative flag (this bulleted list being 38 long):

Also, LSR always clears the negative flag because it also shifts a zero into the operand's most significant bit, making it non-negative. Push instructions do not affect the negative flag.

BPL and BMI examine the negative flag to decide whether or not to branch.

See Also

References