Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * COSC 221: Lab 4 - Calculate Date of Easter
- * Author: Gilbert Fulmore
- * Date: 2015/02/16
- */
- define(c_r, l0)
- define(y_r, l1)
- define(m_r, l2)
- define(d_r, l3)
- define(g_r, l4)
- define(x_r, l5)
- define(z_r, l6)
- define(e_r, l7)
- define(n_r, l8)
- .global main
- main: !int main() {
- save %sp, -96, %sp !int c; //century
- !int y; //year
- !int m; //month
- !int d; //day
- !int g; //golden number
- !int x; //number of dropped leap years
- !int z; //synchronize easter with moon orbit
- !int e; //epact
- !int n; //find full moon
- !printf("Enter Year: ");
- mov 1984, %y_r !scanf("%d", &y);
- !//find golden number
- mov %y_r, %o0 !g = (y % 19) + 1;
- mov 19, %o1
- call .rem
- nop
- add %o0, 1, %g_r
- !//find century
- mov %y_r, %o0 !c = (y / 100) + 1;
- mov 100, %o1
- call .div
- nop
- add %o0, 1, %c_r
- mov %y_r, %o0 !if (y % 100 != 0) {
- mov 100, %o1
- call .rem
- nop
- cmp %o0, %g0
- be done
- nop
- mov 3, %o0 !x = (3 * c / 4) - 12;
- mov %c_r, %o1
- call .mul
- nop
- mov 4, %o1
- call .div
- nop
- sub %o0, 12, %x_r
- mov 8, %o0 !z = ((8 * c + 5) / 25) - 5;
- mov %c_r, %o1
- call .mul
- nop
- add %o0, 5, %o0
- mov 25, %o1
- call .div
- nop
- sub %o0, 5, %z_r
- done: !}
- !//find sunday
- mov 5, %o0 !d = (5 * y / 4) - x - 10;
- mov %y_r, %o1
- call .mul
- nop
- mov 4, %o1
- call .div
- nop
- sub %o0, %x_r, %o0
- sub %o0, 10, %d_r
- !//find the "epact" E
- mov 11, %o0 !e = (11 * g + 20 + z - x) % 30;
- mov %g_r, %o1
- call .mul
- nop
- add %o0, 20, %o0
- add %o0, %z_r, %o0
- sub %o0, %x_r, %o0
- mov 30, %o1
- call .rem
- nop
- mov %o0, %e_r
- !if (e == 25 && g > 11 || e == 24)
- subcc %e_r, 25, %o0 !if (e == 25)
- bne done
- nop
- subcc %g_r, 11, %o1 !if (g > 11)
- bl done
- nop
- and %o0, %o1, %o0 !if ((e == 25) && (g > 11))
- subcc %e_r, 24, %o1 !if (e == 24)
- bne done
- nop
- or %o0, %o1, %o0 !if ((e == 25 && g > 11) || (e == 24))
- cmp %o0, 1 !if (true)
- bne done
- nop
- add %e_r, 1, %e_r !++e;
- done:
- !//find full moon
- sub 44, %e_r, %n_r !n = 44 - e;
- cmp %n_r, 21 !if (n < 21)
- bg done
- nop
- add %n_r, 30, %n_r !n += 30;
- done:
- !//advance to sunday
- add %d_r, %n_r, %o0 !n = n + 7 - ((d + n) % 7);
- mov 7, %o1
- call .rem
- nop
- add %n_r, 7, %n_r
- sub %n_r, %o0, %n_r
- !//get month
- cmp %n_r, 31 !if (n > 31) {
- bl else
- nop
- mov 4, %m_r !m = 4;
- sub %n_r, 31, %d_r !d = n-31;
- ba done
- nop
- else: !} else {
- !m = 3;
- !d = n;
- done: !}
- !printf("Easter date: %d-%d-%d\n", y, m, d);
- mov 1, %g1 !return 0;
- ta 0
- !}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement