Programming Assignment 4 (Assembly Language)
Due November 10, 2002 at 11:59pm
1. Background. What day of the week were you born? How about
your parents? Were they married on a Saturday or a Sunday (or some other
day)? The day Bobby Thompson hit the home run to break the Brooklyn Dodgers'
backs in the National League pennant race, what day of the week was that?
Curiosity is such that people often want to know these things.
2. Assignment. Your job is to write a program in LC-2 assembly
language that provides the day of the week for any date between January
1, 1901 and the present day.
Your program will start at address x3000 and will work with other modules that will load x31F0, x31F1, x31F2 before your program computes the day of the week. You can assume that before your program executes, x31F0, x31F1, and x31F2 will contain data as follows:
x31F0: the day of the month (a number from 1 to 31). x31F1: the month (a number from 1 to 12, corresponding to Jan to Dec). x31F2: the year (a four digit number)For example October 2, 1989 will be stored as,
x31F0 : #2 x31F1 : #10 x31F2 : #1989You should test your program by supplying values in these three memory locations and then running your program.
Hint: 01-01-1901 (January 1, 1901) was a "Tuesday."
Hint: Since a non leap year has 365 days, if 01 01 1901 was a Tuesday then 01 01 1902 was a Wednesday, 01 01 1903 was a Thursday, 01 01 1904 was a Friday, and 01 01 1905 was a Sunday. [Why on Sunday, instead of Saturday?]
Hint: January 1, 1901 was a Tuesday, February 1, 1901 was a Friday (since
Tuesday+31 = Tuesday+3 = Friday), and April 1 was a Monday (since Tuesday
+ 31 + 28 + 31 = Tuesday + 90 = Tuesday + 6 = Monday). [Why is that?]
Sunday = 0 Monday = 1 Tuesday = 2 Wednesday = 3 Thursday = 4 Friday = 5 Saturday = 6
3. A full example, before you are on your own.
x31F0 : #4 x31F1 : #7 x31F2 : #1999.Since 1999 - 1901 = 98, and January 1, 1901 was a Tuesday,
Since January 1, 1999 was a Friday,
July 1 was a Thursday.
Since July 1, 1999 was a Thursday,
July 4 was a Sunday.
Thus, the program stores 0 in x31F3, and displays
The day is Sunday
on the screen. 4. More Details.