Subject: TOY set program miscalculates day of week (#367) Index: pdpstand/toyset.s 2.11BSD Description: The program used to set the TOY (Time Of Year) clock on PDP-11/93 and 94 (and possibly some machines produced by QED) miscalculates the "day of week". Repeat-By: Set the TOY clock on a Saturday. Fix: The routine which calculates the day of week produces -1 instead of 6 for Saturday (and 6 instead of 7 for Sunday). Thanks to Alan Sieving of Quickware Engineering Design for bringing this to my attention - it's hard to believe this code, after all this time, is being read by someone. Cut where indicated saving to a file (/tmp/367) and then: patch -p0 < /tmp/367 cd /sys/pdpstand make toyset install -s toyset /toyset As always this and previous updates to 2.11BSD are available via anonymous FTP to either FTP.IIPO.GTEGSC.COM or MOE.2BSD.COM in the directory /pub/2.11BSD. --------------------------cut here-------------------------- *** /sys/pdpstand/toyset.s.old Thu Feb 6 22:12:55 1997 --- /sys/pdpstand/toyset.s Thu Apr 10 20:14:08 1997 *************** *** 1,5 **** --- 1,10 ---- TOYCSR = 177526 + / April 10, 1997 - sms@moe.2bsd.com + / The day of week calculation was incorrect and would return -1 for Saturday + / rather than 6. Alan Sieving spotted this one too (toyset.s must be favorite + / reading material ;-)) + / / February 6, 1997 - sms@moe.2bsd.com / Forgot that May has 31 days. Thanks to Alan Sieving (ars@quickware.com) for / spotting this. *************** *** 289,300 **** mov r4,r1 clr r0 div $7,r0 / divide total by 7 ! dec r1 / Sunday? ! bne 3f / no - br ! mov $7,r1 / yes - set it to day 7 3: mov r1,r0 / put return value in right place ! jmp cret / (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0) --- 294,305 ---- mov r4,r1 clr r0 div $7,r0 / divide total by 7 ! dec r1 / Saturday or Sunday? ! bgt 3f / no - br ! add $7,r1 / yes - set Saturday to 6, Sunday to 7 3: mov r1,r0 / put return value in right place ! jmp cret / 1 = Monday ... 7 = Sunday / (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0) *** /VERSION.old Fri Feb 14 23:05:48 1997 --- /VERSION Fri Mar 28 20:05:40 1997 *************** *** 1,5 **** ! Current Patch Level: 366 ! Date: February 14, 1997 2.11 BSD ============ --- 1,5 ---- ! Current Patch Level: 367 ! Date: April 10, 1997 2.11 BSD ============