Day of the Week Program

Skip to first unread message


Jul 16, 2021, 10:29:24 AM7/16/21
to uKenbak-1
When John Blankenbaker was demonstrating his KENBAK-1 Personal Computer back in 1971, one of the programs he always showed was a Day of the Week calculator. Given any date, it can tell you what day of the week that date fell on. It was something that was pretty cool that everyone could relate to. So as a test for my KENBAK-1 IDE I wrote a Day of the Week program. I managed to get it to fit with only a few bytes to spare. 

Over on Instructables GilDev, who also did a wonderful KENBAK-1 Replica, suggested that I should  "Feel free to send photos of your creation to John Blankenbaker, he replied to my mails and was very kind!"  So I did and he was. 

As part of my Email I said the following, "I also wrote a Day of the Week program. It took me 251 bytes to write. If I understand what you said in the VCF East keynote you gave in 2016, Day of the Week was one of three programs that you had simultaneously loaded into memory for demonstration purposes. Amazing!". 

Here is his reply. 

You overestimated my capability in programming the day of the week problem. I did it only for the 20th century. One reason for limiting it was the problem becomes more complicated very quickly since the English jumped ahead 12 days in 1753 to come into agreement with the European calendars. One of the interesting side aspects of demonstrating this problem was that most people could only verify two dates/day of the week. The were Pearl Harbor and their marriage day. Another interesting point is that only about half of the high school math teachers could quote the rules for skipping dates in the calendar. My most complex program was for three dimensional tic-tac-toe on  a 4 x 4 x 4 board. When the program was done, it did not have enough memory left to recognize  the end of the game.

I was so nice of John Blankenbaker to take the time to reply.

At any rate I wanted to share my program with you all. It should work for any Gregorian date past or future. You will find a 256 byte Day of the Week.bin file and a Day of the Week.txt file with the program encoded as comma separated octal values (suitable to loading via the serial port if I'm not mistaken) on GitHub. You will also see the Day of the Week.asm file used to create the executable image for reference. Here is the header for that file with the running instructions:


Program to calculate the day of the week for any date. To start this program you will have to input the date in four parts: Century, Year, Month, and Day. Each of the parts is entered as a two digit Binary Coded Decimal number (ie. the first digit will occupy bits 7-4 as a binary number, and the second digit bits 3-0) using the front panel data buttons. The steps to run this program are:

  1. Set the PC register (at address 3) to 4.
  2. Clear the input data then enter the date Century.
  3. Press Start.
  4. Clear the input data then enter the date Year.
  5. Press Start.
  6. Clear the input data then enter the date Month.
  7. Press Start.
  8. Clear the input data then enter the date Day.
  9. Press Start.

The day of the week will be returned via the data lamps using the following encoding:

       7-Sunday 6-Monday 5-Tuesday 4-Wednesday 3-Thursday 2-Friday 1-Saturday

All lamps turned on means the last item entered was invalid and you have to restart.


At one point I thought I saw a post about creating a repository for sharing programs. Did that ever happen? 


Jul 19, 2021, 2:44:37 PM7/19/21
to uKenbak-1
Wow, that's amazing.  You win the award for best Kenbak-1 program ever!

Now I have to start that repository...


Oct 25, 2021, 12:46:46 PM10/25/21
to uKenbak-1
Thanks for this program, I finally see it working ...
The problem was that "Century" is used to refers to the first two digits of the year not to the real Century. :-(
Reply all
Reply to author
0 new messages