Garth wrote: ↑Sat Jun 13, 2020 4:59 pm
DocWaluigean wrote: ↑Sat Jun 13, 2020 3:38 pm
So Zero Flag can turn on if the latest operation [A, X, Y, and S] is 0 right now? If X and Y is number 20 and 50, but A is 0, the Flag is on, and will remain on until A equals something other than 0?
If the latest operation was on X, Z will reflect the X result. If the latest operation was on Y, Z will reflect the Y result. If the latest operation wan on A, Z will reflect the A result.
That's partly correct. C=1 if the result of an addition won't fit in 8 bits, so there's a carry into the 9th bit. It also tells what bit was shifted or rotated out the left end; for example 10000000 in binary, shifted left, will be 1 00000000, where the 1 is now in the carry bit. It also reflects whether a borrow happened in a subtraction; but there it's the inverse, meaning C=1 means a borrow did not happen. It's best not to use the word "overflow" though, because the overflow flag is separate and has a different function, as discussed earlier.
I'm guessing it's a yes that it includes A, X, and Y [and S?] Registers.
You cannot rotate, shift, or add in the X & Y registers, nor S. You can compare X or Y with CPX or CPY, and that can affect the C flag. You cannot compare S though.
N=1 if the last load, logic, or arithmetic function resulted in the high bit set. For example, if X=0 and you DEcrement X (with the DEX instruction), the result if 11111111 in binary, the high bit being set.
Can be turn on by A, X, Y [and S] Register?
X and Y, yes; but not S. As turboxray pointed out, TSX affects N and Z. (Neither TSX nor TXS affect C though.)
Code: Select all
LDA #$09 - Put HEX number 9 into A.
SBC #$0A - Subtract 10 [HEX number A] into Register A.
;;; The A Register is now carrying HEX number FF, and the Negative Flag is turned on.
Right.
Okay, I'm wondering if it applies to X, Y, S, and PC Register too.
You cannot subtract from X, Y, S, or PC, only A.
Is there any Flag that's affected by store operations?
No.
Does it affect with X, Y, and S Register also?
Load, increment, and decrement instructions on X and Y affect the status. The only direct access the programmer has to S is TXS and TSX; so it's kind of in a different category.
Sorry for repeating questions so much. So all three Register (Usually A X and Y) affect the status?
It's the
action on them that affects the status. For example, if you act on A, the status reflects that. Then if you act on X, the status is overwritten with that action. Then if you act on Y, the status is overwritten again. So status reflects the latest action, not necessarily the current state of any one register.
I can turn on 3 switches using 3 Registers? Which Registers can't turn on certain Flags? And I'm wondering the Stack Pointer as a different Register, as it's not part of 3 Registers.
Right. The stack pointer has a very specific purpose that's separate from what A, X, and Y are used for. As for switches, I'm not sure what you're asking.
===================
DocWaluigean wrote: ↑Sat Jun 13, 2020 5:38 pm
So Zero Flag can turn on if the latest operation [A, X, Y, and S] is 0 right now? If X and Y is number 20 and 50, but A is 0, the Flag is on, and will remain on until A equals something other than 0?
If the latest operation was on X, Z will reflect the X result. If the latest operation was on Y, Z will reflect the Y result. If the latest operation wan on A, Z will reflect the A result.
Oooooh, I get it. It will reflect mostly on the LATEST operations of most recent usages of Registers.
That's partly correct. C=1 if the result of an addition won't fit in 8 bits, so there's a carry into the 9th bit. It also tells what bit was shifted or rotated out the left end; for example 10000000 in binary, shifted left, will be 1 00000000, where the 1 is now in the carry bit. It also reflects whether a borrow happened in a subtraction; but there it's the inverse, meaning C=1 means a borrow did not happen. It's best not to use the word "overflow" though, because the overflow flag is separate and has a different function, as discussed earlier.
I'm guessing it's a yes that it includes A, X, and Y [and S?] Registers.
You cannot rotate, shift, or add in the X & Y registers, nor S. You can compare X or Y with CPX or CPY, and that can affect the C flag. You cannot compare S though.
This one, I'm a little confused... I'm thinking the X and Y Register will NOT be affected by Overflow Flag?
N=1 if the last load, logic, or arithmetic function resulted in the high bit set. For example, if X=0 and you DEcrement X (with the DEX instruction), the result if 11111111 in binary, the high bit being set.
Can be turn on by A, X, Y [and S] Register?
X and Y, yes; but not S. As turboxray pointed out, TSX affects N and Z. (Neither TSX nor TXS affect C though.)
Okay, A, X, and Y can turn on the Negative Flag. But NOT S nor PC.
LDA #$09 - Put HEX number 9 into A.
SBC #$0A - Subtract 10 [HEX number A] into Register A.
;;; The A Register is now carrying HEX number FF, and the Negative Flag is turned on.
Right.
Okay, I'm wondering if it applies to X, Y, S, and PC Register too.
You cannot subtract from X, Y, S, or PC, only A.
Okay,
ONLY Register A can use ADC and SBC, got it.
Is there any Flag that's affected by store operations?
No.
Very, very, very good to know, so I'll try to keep that in mind.
Does it affect with X, Y, and S Register also?
Load, increment, and decrement instructions on X and Y affect the status. The only direct access the programmer has to S is TXS and TSX; so it's kind of in a different category.
Sorry for repeating questions so much. So all three Register (Usually A X and Y) affect the status?
It's the action on them that affects the status. For example, if you act on A, the status reflects that. Then if you act on X, the status is overwritten with that action. Then if you act on Y, the status is overwritten again. So status reflects the latest action, not necessarily the current state of any one register.
This one brings me interesting questions. Let's say that Register A has Carry Flag turn on, Register X has Negative Flag turn on, and Register Y has Zero Flag turn on. Through most recent operations, will the flag turn off and on many times when I use certain Registers?
-I use the Register A. The Carry Flag is turned on.
-Then I use Register X, which has Negative Flag turned on.
[Either Carry Flag is also turn on because Register A is still carrying number? Or if it turns off because I'm using Register X right now.]
-Then I use the Register A.
[Does the Negative Flag still remains on at this point? Or NOW it turns off the Negative Flag but it turns ON the Carry Flag?]
Then I used the Register Y, which has Zero Flag turn on.
[Does it turns off both the Negative Flag and Carry Flag, but NOW turns on the Zero Flag?]
Then I used the Register X Flag.
[Does it turn off the Zero Flag, and turns off the Carry Flag, but NOW turns on the Negative Flag?]
[[[Selected Flags will be constantly turning on and off many times?]]]
OR
-Register A
-Register X
[Carry Flag is turned on, and Negative Flag is turned on, because A and X is now active.]
-Register A
[Still both turn on]
Register Y
[Zero Flag is now turned on, as Register Y is now actively holding number zero.]
Register X
Register A
Register X
Register Y
Register A...
[Doesn't matter...]
[[[All three Flags will be turning on as they're all active anyway?]]]
I can turn on 3 switches using 3 Registers? Which Registers can't turn on certain Flags? And I'm wondering the Stack Pointer as a different Register, as it's not part of 3 Registers.
Right. The stack pointer has a very specific purpose that's separate from what A, X, and Y are used for. As for switches, I'm not sure what you're asking.
I mean Flags when I said switches. Like I can turn on all Carry Flags using 3 Registers.
=========================
I'm writing something really big about what I learned.