|
Content
|
MMIX Programming Competitions
The Date of Easter Sunday
In The Art of Computer Programming, Volume 1, Section 1.3.2, exercise 14,
(see also exercise 32 in Fascicle 1) Donald Knuth describes an Algorithm to compute
the date of Easter Sunday for any year after 1582.
Competition: Write a PUSHJ subroutine Easter with the following
specification:
Entry condition: | $0 contains the year in the range 1582 to 9999.
| Return value: | The address of a zero terminated string containing the date of Easter.
This string should have the following format "dd Mmmmm, yyyy",
where dd is the day and yyyy is the year (in decimal notation)
and Mmmmm is the English name of the month (March, April).
|
Your program should be as fast as possible.
To measure your program use the following procedure:
- Complement your subroutine with the following Main program:
first IS 1582
last GREG 2009 MMIX
year IS $0
t IS $1
NL BYTE #A0,0
Main SET year,start Initialize year with first value.
SET t+1,year Pass year to Easter.
1H PUSHJ t,Easter Compute the date string.
SET $255,t
TRAP 0,Fputs,StdOut Output date.
GETA $255,NL
TRAP 0,Fputs,StdOut Output newline.
INCL year,1
CMP t,year,last Compare year to last value.
PBNP t,1B
TRAP 0,Halt,0 Done.
This Main program will run your program for all years in the range 1582 to 2009.
- Check the output of your program. It should match this file.
- Measure the running time of your program using this procedure:
(Assuming that your program is in the file easter.mms)
- Assemble your program (creating an object file and a listing file) using
mmixal -l easter.mml easter.mms
- Create a binary file using
mmix -Deaster.mmb easter.mmo
- Run the program using the meta-simulator with the deluxe configuration like this
mmmix deluxe.mmconfig easter.mmb
mmmix> 100000
Running 100000 at time 0
18 April, 1582
10 April, 1583
01 April, 1584
...
08 April, 2007
23 March, 2008
12 April, 2009
Halted at time 37628
mmmix> q
Simulation ended at time 37629.
Predictions: 1296 in agreement, 3 in opposition; 1269 good, 30 bad
Instructions issued per cycle:
0 12918
1 13418
2 5647
3 5646
- Submit your program by email not later than October 20, 2015 (20/09/2015)
and report the number of cycles as given in the
Halted at time ... line and the number of bytes required by your program
(which you can deduce from the information in the listing file.)
Add up running time and size to obtain the "total cost" of your program.
- Your program will win the competition and you will receive a free MMIX T-shirt
if your program has the smallest total cost among all submissions.
Note: We will publish all submission as soon as we receive them on this page.
This is an open competition in the sense, that you are free to incorporate
improvements that you see in other programs into your own program and resubmit
the improved version.
|