> 6502.ProgTips.DofWeek16b 5 Calculate day of week for 16-bit Gregorian date 4 Works for any date in Gregorian 400-year cycle (: 2 mc% 200 < P=0 1 FP%=mc%:O%=P% P[OPT P*2+4 Z+\ On entry day = day, 1-31 d+\ month = month, 1-12 n.\ year+0,year+1 = year, 0-65535 x*\ On exit A=day of week 0=Sun, 6=Sat \ X=corrupted \ Y=preserved ,\ Size 139 bytes, 4 bytes workspace 0\ 116 bytes if zero page workspace \ \ Uses the formula: \ if (m < 3) then y = y-1 ;\ return (y + y/4 - y/100 + t[m-1] + d + fudge) mod 7 3\ where fudge is an adjustment for year n*400+0 \ .DayOfWeek SEC:LDX year+0:LDY year+1 .DayOfWeekMod400 3TXA:SBC #400 255:TAX :\ Get year 400 TYA:SBC #400 256:TAY BCS DayOfWeekMod400 "!TXA:ADC #400 255:STA year+0 ,!TYA:ADC #400 256:STA year+1 6LDA day:LDX month @: J5\ Enter here with A=day, X=month, year=year 400 T.DayOfWeek1 ^-CLC:ADC DofWOffsets-1,X:STA day :\ t[m]+d h5CPX #3:BCS DayOfWeekMarch :\ March or later r: |/LDX year+0:BNE DayOfWeekSub2 :\ Year>255 7LDA year+1:BNE DayOfWeekSub1 :\ Not year n*400+0 >LDX #5:INC year+1 :\ Adjust for year n*400+0 .DayOfWeekSub1  H