Giter Club home page Giter Club logo

easter's Introduction

easter

Sparc assembly program to calculate the date of easter for a given year

the algorithm

The following easter algorithm taken from "SPARC Architecture Assembly Language Programming Language, and C" Second Edition By Richard P. Paul.

This algorithm is historically significant as it was one of the main applications of arithmitec in the middle ages, used by the Catholic Church to calculate the date of easter each year.

1. Start by setting the Year Y for the date we want to find easter on
    Y = 1984

2. Compute the golden number G for the year Y
    G = (Y mod 19) + 1


3. Compute the century C for year Y
    C = (Y / 100) + 1


4. Compute X (the number of years, such as 1900, in which the leap year was dropped in order to keep up with the sun)
    X = (3C / 4) - 12


5. Compute Z (a special correction designed to synchronize Easter with the moons orbit)
    Z = ((8C + 5) / 25) - 5


6. Compute Sunday 
    D = (5Y / 4) - X - 10


7. Find the "epact" E. 
    E = (11G + 20 + Z - X) mod 30
    if (E == 25 and G > 11) or E == 24:
        E++
    

8. Now find the full moon, N
    N = 44 - E
    if N < 21:
        N += 30


9. Now Advance N to be a sunday
    N = N + 7 - ((D + N) mod 7)
    

10. Extract the month M
    if N > 31:
        M = 4
        N -= 31
    else:
        M = 3

to run

bash$ m4 easter.m4 > easter.s 
bash$ gcc -g easter.s -o easter
bash$ gdb easter

(gdb) break input
Breakpoint 1 at 0x10710

(gdb) break end
Breakpoint 2 at 0x1080c

(gdb) r
Starting program: /home/oksun6/student/mwallace/easter
(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...
Breakpoint 1, 0x00010710 in input ()

(gdb) set $i0 = 1998

(gdb) c
Continuing.

Breakpoint 2, 0x0001080c in out ()

(gdb) printf "Easter occurs on %d/%d/%d\n", $l6, $l7, $i0
Easter occurs on 12/4/1998

easter's People

Watchers

James Cloos avatar Martin Wallace avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.