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

Carry Flag: Difference between revisions

From SnesLab
Jump to: navigation, search
(mention INX, DEX, INY, DEY)
(added INC/DEC)
Line 3: Line 3:
It can be set with [[SEC]] and cleared with [[CLC]].  Or, [[SEP]] and [[REP]] can be used.
It can be set with [[SEC]] and cleared with [[CLC]].  Or, [[SEP]] and [[REP]] can be used.


The following other 10 instructions have side effects that directly affect the carry flag, which includes all arithmetic instructions (except those that increment/decrement index registers) and all shift/rotate instructions:
The following other 10 instructions have side effects that directly affect the carry flag, which includes all arithmetic instructions (except those that can only increment/decrement by one) and all shift/rotate instructions:


* [[ADC]] (becomes set when an addition overflows)
* [[ADC]] (becomes set when an addition overflows)
Line 23: Line 23:
The carry flag influences whether [[BCS]] and [[BCC]] branch or not.
The carry flag influences whether [[BCS]] and [[BCC]] branch or not.


As mentioned above, none of [[INX]], [[DEX]], [[INY]] nor [[DEY]] modify the carry flag.
As mentioned above, none of [[INC]], [[DEC]], [[INX]], [[DEX]], [[INY]] nor [[DEY]] modify the carry flag.


=== See Also ===
=== See Also ===

Revision as of 20:22, 12 August 2024

The Carry Flag (C) is bit 0 of the 65c816's status register.

It can be set with SEC and cleared with CLC. Or, SEP and REP can be used.

The following other 10 instructions have side effects that directly affect the carry flag, which includes all arithmetic instructions (except those that can only increment/decrement by one) and all shift/rotate instructions:

  • ADC (becomes set when an addition overflows)
  • ASL (becomes whatever the most significant bit was)
  • CMP
  • CPX
  • CPY
  • LSR (becomes whatever bit 0 was)
  • ROL (becomes whatever the most significant bit was)
  • ROR (becomes whatever bit 0 was)
  • SBC (where it is often called the "borrow flag" instead)
  • XCE (becomes whatever the e flag was)

The following two instructions indirectly affect the carry flag by loading the status register:

The carry flag influences whether BCS and BCC branch or not.

As mentioned above, none of INC, DEC, INX, DEX, INY nor DEY modify the carry flag.

See Also

Reference