CS 210
PROJECT #3 Due: Noon Tuesday 03/31/2009
This project introduces students to the design of programs that act
on one or more command-line arguments (transmitted via the stack).
PROBLEM STATEMENT
Design an assembly language program that will calculate and display
the date on which Easter Sunday falls in a specified year. Your program
should reside in a file named 'easter', so that it can be executed using
a command-line which includes the desired year (e.g.: ./easter 2009 ).
ALGORITHM AND BACKGROUND
Western churches determine the date of Easter Sunday (for all years
since 1582) by using an algorithm devised during the 16th Century by the
German Jesuit mathematician Christopher Clavius with the help of Italian
astronomer Aloysius Lilius. (Easter, supposedly, is to be on "the first
Sunday following the first full moon that occurs on or after March 21.")
The details of computing this date (as described by Donald Knuth in "The
Art of Computer Programming," vol. 1, pp. 155-6) are as follows:
THE DATE-OF-EASTER ALGORITHM: Assume Y denotes the year for which
the date of Easter is desired.
E1. [Golden Number.] Set G <-- (Y mod 19) + 1. (Here G is the
year's so-called "golden number" in the 19-year Metonic cycle.)
E2. [Century.] Set C <-- [Y/100] + 1. (If Y is not a multiple of
100, then C is the century number; e.g., for the year 1989, the
value of C equals 20.)
E3. [Corrections.] Set X <-- [3C/4] - 12, Z <-- [(8C+5)/25] - 5.
(Here X counts the number of those years, such as 1900, in which
leap-year was dropped in order to keep the calendar in step with
the sun, and Z is a special correction designed to synchronize
Easter with the orbit of the moon.)
E4. [Find Sunday.] Set D <-- [5Y/4] - X - 10. (Here the day of
March ((-D) mod 7) will actually be a Sunday.)
E5. [Epact.] Set E <-- (11G + 20 + Z - X) mod 30. Then, in case
E = 25 and G > 11, or in case E = 24, increment E by 1. (Here
E is the so-called "epact" specifying when a full moon occurs.)
E6. [Find full moon.] Set N <-- 44 - E. Then, if N < 21, set
N <-- N + 30. (The Nth of March will be a full moon.)
E7. [Advance to Sunday.] Set N <-- N + 7 - ((D + N) mod 7).
E8. [Get month.] If N > 31 , Easter will be on (N - 31) APRIL;
otherwise, Easter will be on N MARCH. (End of algorithm.)
________________________________________________________________________
Allan B. Cruse University of San Francisco Spring 2009
|
Originál je zde.