http://beebwiki.mdfs.net/index.php?title=Day_Of_Week_in_6502_machine_code&feed=atom&action=historyDay Of Week in 6502 machine code - Revision history2024-03-29T14:53:52ZRevision history for this page on the wikiMediaWiki 1.30.0-rc.0http://beebwiki.mdfs.net/index.php?title=Day_Of_Week_in_6502_machine_code&diff=1466&oldid=prevWikiSysop: 1 revision2015-03-08T18:12:41Z<p>1 revision</p>
<table class="diff diff-contentalign-left" data-mw="interface">
<tr style="vertical-align: top;" lang="en">
<td colspan="1" style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: white; color:black; text-align: center;">Revision as of 18:12, 8 March 2015</td>
</tr><tr><td colspan="2" style="text-align: center;" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>WikiSysophttp://beebwiki.mdfs.net/index.php?title=Day_Of_Week_in_6502_machine_code&diff=238&oldid=prevWikiSysop: 1 revision2015-03-08T00:13:04Z<p>1 revision</p>
<table class="diff diff-contentalign-left" data-mw="interface">
<tr style="vertical-align: top;" lang="en">
<td colspan="1" style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: white; color:black; text-align: center;">Revision as of 00:13, 8 March 2015</td>
</tr><tr><td colspan="2" style="text-align: center;" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>WikiSysophttp://beebwiki.mdfs.net/index.php?title=Day_Of_Week_in_6502_machine_code&diff=3&oldid=prevWikiSysop: Created page with "Category:6502 Based on code at http://6502.org/source/misc/dow.htm by Paul Guertin. \ This routine works for any date from 1900-03-01 to 2155-12-31. \ No range ch..."2015-03-07T23:04:43Z<p>Created page with "<a href="/Category:6502" title="Category:6502">Category:6502</a> Based on code at http://6502.org/source/misc/dow.htm by Paul Guertin. \ This routine works for any date from 1900-03-01 to 2155-12-31. \ No range ch..."</p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr style="vertical-align: top;" lang="en">
<td colspan="2" style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: white; color:black; text-align: center;">Revision as of 23:04, 7 March 2015</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[Category:6502]]</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[Category:6502]]</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>Based on code at http://6502.org/source/misc/dow.htm by Paul Guertin.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>Based on code at http://6502.org/source/misc/dow.htm by Paul Guertin.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
</table>WikiSysophttp://beebwiki.mdfs.net/index.php?title=Day_Of_Week_in_6502_machine_code&diff=1465&oldid=prevWikiSysop: 1 revision2013-08-28T22:58:11Z<p>1 revision</p>
<table class="diff diff-contentalign-left" data-mw="interface">
<tr style="vertical-align: top;" lang="en">
<td colspan="1" style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: white; color:black; text-align: center;">Revision as of 22:58, 28 August 2013</td>
</tr><tr><td colspan="2" style="text-align: center;" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>WikiSysophttp://beebwiki.mdfs.net/index.php?title=Day_Of_Week_in_6502_machine_code&diff=237&oldid=prevJgharston at 17:43, 29 September 20072007-09-29T17:43:41Z<p></p>
<p><b>New page</b></p><div>[[Category:6502]]<br />
<br />
Based on code at http://6502.org/source/misc/dow.htm by Paul Guertin.<br />
<br />
\ This routine works for any date from 1900-03-01 to 2155-12-31.<br />
\ No range checking is done, so validate input before calling.<br />
\<br />
\ It uses the formula<br />
\ Weekday = (day + offset[month] + year + year/4 + fudge) mod 7<br />
\ where the value of fudge depends on the century.<br />
\<br />
\ On entry, A=day, 1..31<br />
\ X=month, 1..12<br />
\ Y=year-1900, 0..255<br />
\ On exit, A=day of week 0..6 for Sun..Sat, Carry will be Set<br />
\ Needs incrementing with ADC #0 after calling to<br />
\ become standard 1..7 range<br />
<br />
.DayOfWeek<br />
CPX #3:BCS dow_march :\ Year starts in March to bypass leap year problem<br />
DEY :\ If Jan or Feb, decrement year<br />
.dow_march<br />
EOR #&7F :\ Invert A so carry works right<br />
CPY #200 :\ Carry will be 1 if 22nd century<br />
ADC dow_months-1,X :\ A is now day+month offset<br />
STA dow_tmp<br />
TYA:JSR dow_mod7 :\ Get the year MOD 7<br />
SBC dow_tmp:STA dow_tmp :\ Combine with day+month<br />
TYA:LSR A:LSR A :\ Get the year DIV 4<br />
CLC:ADC dow_tmp :\ Add it to y+m+d and fall through to MOD 7<br />
.dow_mod7<br />
ADC #7:BCC dow_mod7 :\ Reduce A to A MOD 7<br />
RTS<br />
.dow_months<br />
EQUB 1:EQUB 5:EQUB 6:EQUB 3 :\ Month offsets<br />
EQUB 1:EQUB 5:EQUB 3:EQUB 0<br />
EQUB 4:EQUB 2:EQUB 6:EQUB 4<br />
.dow_tmp<br />
EQUB 0 :\ Temporary storage<br />
<br />
You can test this with:<br />
<br />
FOR Y%=1 TO 255<br />
FOR X%=1 TO 12<br />
FOR A%=1 TO 31<br />
PRINT A%;"/";X%;"/";1900+Y%;" ";<br />
PRINT MID$("SunMonTueWedThuFriSat",((USRDayOfWeek)AND&FF)*3+1,3)<br />
NEXT A%:NEXT X%:NEXT Y%<br />
<br />
I must say that this is an impressive bit of code!<br />
<br />
<br />
[[User:Jgharston|Jgharston]] 01:56, 29 September 2007 (BST)</div>Jgharston