Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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.

THIS NEEDS TO BE ASSEMBLED WITH JASMIN. its a .jfile not a .java file NOT JASMINE, IF YOU DON'T KNOW DON'T ANSWER IVE POSTED TOO MANY TIMES PLEASE HELP! Also a simple program as Iam just learning Jasmin assembly language

Butcher's Easter Algorithm

Butcher's Algorithm to calculate Easter day for any year in the Gregorian Calendar.

All values and calculations are integer only.

For a given year:

a=year%19 b=year/100 c=year%100 d=b/4 e=b%4 f=(b+8)/25 g=(b-f+1)/3 h=(19*a+b-d-g+15)%30 i=c/4 k=c%4 x=(32+2*e+2*i-h-k)%7 m=(a+11*h+22*x)/451 Easter Month =(h+x-7*m+114)/31 [3=March, 4=April] p=(h+x-7*m+114)%31 Easter Date=p+1 (date in Easter Month

.....................COUNT.J...........................................................

.class public examples/Count .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 4 .limit stack 3

; 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 istore_2

; now loop 10 times printing out a number

Loop:

; compute 10 - ... bipush 10 iload_2 isub 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

...........................this is my code that won't work.........................................

.class public example/Easterdeb

.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

sipush 2017

bipush 10

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

iload 4

bipush 100

idiv

istore 6 ; b is in 6

iload 4

bipush 100

irem

istore 7 ; c is in 7

iload 6

bipush 4

idiv

istore 8 ; d is in 8

iload 6

bipush 4

irem

istore 9 ; e is in 9

iload 6

bipush 8

iadd

bipush 25

idiv

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

imul

iload 6

iadd

iload 8

isub

iload 11

isub

bipush 15

iadd

bipush 30

irem

istore 12 ; h is in 12

iload 7

bipush 4

idiv

istore 13 ; i is in 13

iload 7

bipush 4

irem

istore 14 ; k is in 14

bipush 32

bipush 2

iload 9 ;load e

imul

iadd

bipush 2

iload 13 ; load i

imul

iadd

iload 12 ; load h

isub

iload 14 ; load k

isub

bipush 7

irem

istore 15 ; x is in 15

iload 5

bipush 11

iload 12

imul

iadd

bipush 22

iload 15

imul

iadd

sipush 451

idiv

istore 16 ; m is in 16

iload 12

iload 15

bipush 7

iload 16

imul

isub

iadd

bipush 114

iadd

bipush 31

idiv

istore 17 ; easter month is in 17

iload 12

iload 15

bipush 7

iload 16

imul

isub

iadd

bipush 114

iadd

bipush 31

irem

istore 18 ; p is in 18

iload 18

bipush 1

iadd

istore 19 ; day

iload 17

bipush 4

isub

ifeq Print_April

aload_1

ldc "March"

goto PRINT_IT

Print_April:

aload_1

ldc "April"

PRINT_IT:

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 4 1 ;increment year

iinc 2 -1

iload_2

ifne Loop

; done

return

.end method

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Temporal Databases Research And Practice Lncs 1399

Authors: Opher Etzion ,Sushil Jajodia ,Suryanarayana Sripada

1st Edition

3540645195, 978-3540645191

More Books

Students also viewed these Databases questions

Question

1. Design an effective socialization program for employees.

Answered: 1 week ago