Reading The Status Register
Bob Sullivan
Oak Park IL
Here is a way to quickly analyze the flags in the 6502 Status Register. When you are working in machine language, the branch (BNE, BCC, etc.) instructions automatically check these flags for you and make their "decisions" based on the condition (or status) of a flag. However, there are times when you need to analyze the Status Register. When debugging, for example, you might place a BReaK instruction to stop the program and allow you to examine the condition of a flag.
Each flag is a bit within the Status Register byte. When you see that the SR has $F1 in it, how quickly can you determine that the Overflow flag is set? The table below does the job:
CARRY BIT - right digit Set if odd: 1, 3, 5, 7, 9, B, D, F Clear if even: 2, 4, 6, 8, A, C, E ZERO BIT - right digit Set if: 2, 3, 6, 7, A, B, E, F Clear if: 0, 1, 4, 5, 8, 9, C, D INTERRUPT BIT - right digit Set if: 4, 5, 6, 7, C, D, E, F Clear if: 0, 1, 2, 3, 8, 9, A, B DECIMAL MODE - right digit Set if: 8, 9, A, B, C, D, E, F Clear if: 0, 1, 2, 3, 4, 5, 6, 7 BREAK - left digit Set if odd: 1, 3, 5, 7, 9, B, D, F Clear if even: 0, 2, 4, 6, 8, A, C, E OVERFLOW Set if: $CO to $FF Clear if: $00 to BF SIGN BIT Positive: $00 to $7F Negative: $80 to $FF