Starting with the Count.j example, implement Butcher\'s Easter Algorithm to calc
ID: 3872249 • Letter: S
Question
Starting with the Count.j example, implement Butcher's Easter Algorithm to calculate and print the date of Easter for the next 10 years in JVM assembly language.
I keep getting errors on line 67, 68, 70. I dont understand why!!! any help much appreciated
my code so far
.class public Easter
.super java/lang/Object
;
; standard initializer
.method public ()V
aload_0
invokenonvirtual java/lang/Object/()V
return
.end method
.method public static main([Ljava/lang/String;)V
; set limits used by this method
.limit locals 20
.limit stack 6
; setup local variables:
; 1 - the PrintStream object held in java.lang.System.out
getstatic java/lang/System/out Ljava/io/PrintStream;
astore_1
; 2 - the integer 10 - the counter used in the loop
bipush 10
sipush 2017
istore_2 ;count is in 2
istore 4 ;year is in 4
; now loop 10 times printing out a number
Loop:
; compute 10 - ...
iload 4 ;year
bipush 19
irem
istore 5 ; a is in 5
bipush 100
dup2
iinc 4 1 ;increment year
idiv
istore 6 ; b is in 6
irem
istore 7 ; c is in 7
iload 6
bipush 4
dup2
idiv
istore 8 ; d is in 8
irem
istore 9 ; e is in 9
iload 6
bipush 8
iadd
istore 10 ; f is in 10
iload 6
iload 10
isub
bipush 1
iadd
bipush 3
idiv
istore 11 ;g is in 11
bipush 19
iload 5
imult
iload 6 ;line 67
iadd
iload 8
isub ; line 70
iload 11
isub
bipush 15
iadd
bipush 30
irem
istore 12 ;h is in 12
iload 7
bipush 4
dup 2
idiv
istore 13 ;i is in 13
irem
istore 14 ;k is in 14
bipush 32
bipush 2
iadd
iload 9
imult
bipush 2
iadd
iload 13
imult
iload 12
isub
iload 14
isub
bipush 7
irem
istore 15 ;x is in 15
iload 5
bipush 11
iadd
iload 12
imult
bipush 22
iadd
iload 15
imult
bipush 451
idiv
istore 16 ; m is in 16
iload 12
iload 15
iadd
bipush 7
isub
iload 16
imult
bipush 114
iadd
bipush 31
idiv
istore 17 ; easter month is in 17
invokestatic java/lang/String/valueOf(I)Ljava/lang/String;
astore_3
; ... and print it
aload_1 ; push the PrintStream object
aload_3 ; push the string we just created - then ...
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
; decrement the counter and loop
iinc 2 -1
iload_2
ifne Loop
; done
return
.end method
Explanation / Answer
Hi,
I tried to analyse your issue. i couldnt understand the code properly.
I guess there are few sytntax errors. I can give you guidance of butcher algorithm , please go through and try again.
The following is the code of Butcher Gregorian algorithm / Meeus / Jones for easter Sunday:
public static DateTime EasterDate(int year)
{
int Y = year;
int a = Y%19;
int b = Y/100;
int c = Y%100;
int d = b/4;
int e = b%4;
int f = (b+8)/25;
int g =(b-f+1)/25;
int h = (19*a+b-d-g+15)%30;
int i = c/4;
int k = c%4;
int L = (32+2*e+2*i-h-k)%7;
int m = (a+11*h+22*L)/451;
int month =(h+L-7*m+114)/31;
int day = ((h+L-7*m+114)%31)+1;
DateTime dt = new DateTime(year, month, day);
return dt;
}
using the above code u might get an idea .
Hope this will be helpful, apologies for not giving proper solution.
All the best!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.