ô > 6502.ProgTips.DofWeek16a 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-39999 x*\ On exit A=day of week 0=Sun, 6=Sat ‚\ X=corrupted Œ\ Y=corrupted –,\ Size 160 bytes, 4 bytes workspace  0\ 129 bytes if zero page workspace ª\ ´\ Uses the formula: ¾\ if (m < 3) then y = y-1 È;\ return (y + y/4 - y/100 + y/400 + t[m-1] + d) mod 7 Ò\ Ü.DayOfWeek æLDA day:LDX month ðDCLC:ADC DofWOffsets-1,X:STA day :\ acc=t[m]+d, offset to prevent úBLDA #1:STA month :\ overflow with small numbers 5CPX #3:BCS DayOfWeekMarch :\ March or later : /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 zero 6.DayOfWeekSub1 @í ÿ