DocWaluigean wrote: ↑
Sat Jun 13, 2020 5:23 pm
Garth wrote: ↑
Sat Jun 13, 2020 4:59 pm
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?
Unless I'm forgetting something, the only instructions that will be affected
the oVerflow flag V are BVS and BVC. Arithmetic functions that actively set or clear the V flag are ADC and SBC, and then V's meaning is relevant for signed numbers, which you don't need to get into yet. V does have a nice benefit with the BIT instruction too. None of these involve X or Y.
Okay, A, X, and Y can turn on the Negative Flag. But NOT S nor PC.
Mostly right. Actions
on A, X, or Y can set the N flag.
Okay, ONLY Register A can use ADC and SBC, got it.
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?]
The flags are in the Processor status register P, not in A, X, or Y. They reflect the last action that affects them, regardless of whether that action was on A, X, or Y. So A does not have a C flag. P does. X does not have an N flag. P does. Etc.. There is only one C flag, one N flag, one Z flag, etc., not one for each 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.
I mean Flags when I said switches. Like I can turn on all Carry Flags using 3 Registers.
There is only one carry flag, and it's in the P register. There aren't separate ones in A, X, and Y. The C, N, Z, and V flags are used for conditional branch instructions to know whether to branch or not. These include BCC, BCS, BPL, BMI, BNE, BEQ, BVC, and BVS, respectively, for clear and set conditions.