John B. Matthews wrote:
F800: 4A 102 PLOT LSR ;Y-COORD/2 F801: 08 103 PHP ;SAVE LSB IN CARRY F802: 20 47 F8 104 JSR GBASCALC ;CALC BASE ADR IN GBASL,H F805: 28 105 PLP ;RESTORE LSB FROM CARRY F806: A9 0F 106 LDA #$0F ;MASK $0F IF EVEN F808: 90 02 107 BCC RTMASK F80A: 69 E0 108 ADC #$E0 ;MASK $F0 IF ODD F80C: 85 2E 109 RTMASK STA MASK F80E: B1 26 110 PLOT1 LDA (GBASL),Y ;DATA F810: 45 30 111 EOR COLOR ; EOR COLOR F812: 25 2E 112 AND MASK ; AND MASK F814: 51 26 113 EOR (GBASL),Y ; EOR DATA F816: 91 26 114 STA (GBASL),Y ; TO DATA F818: 60 115 RTS
[...]
Any speculation on why Woz used ADC #$E0 at F80A instead of LDA #$F0? They both take two bytes and two cycles.
Perhaps...1. To teach us how to use tricks in code? (Not too useful here, but these types of tricks can be useful elsewhere. I wondered about this when I read this code back in the day; after you figure it out, it sort of expands your assembly-language horizons.) 2. To make sure the carry was always clear when the subroutine finished. (Not that I have any reason for this either).
:) -- Jerry Penner e-mail: remove the blips and _