Question: In this task you will write a program in MARIE assembly language, to work out if a given year is leap year or not. Leap

 In this task you will write a program in MARIE assembly language, to work out if a given year is leap year or not. Leap years are those that are divisible by 4, except the years that are divisible by 100. But the centurial years are leap years if they are divisible by 400. For example 1980 is a leap year because it is divisible by 4 only, 2100 is not a leap year because it is divisible by both 4 and 100, and 2000 is a leap year because it is divisible by 400. 

 

The program will ask user for an input year (e.g. 1996) and work out and display a ‘1’ or ‘0’ in the output to indicate if given year is leap or not. An algorithm to determine leap year is given below (with comments). Implement this algorithm in MARIE.

if (year modulo 4 ≠ 0) / if year is not divisible by 4

then output 0 and exit / then it is a common year

else if (year modulo 100 ≠ 0) / if year is not divisible by 100

then output 1 and exit / then it is a leap year

else if (year modulo 100 ≠ 0) / if year is not divisible by 400

then output 0 and exit / then it is a common year

else output 1 and exit / otherwise it is a leap year

As you can see from the pseudo code, the modulo calculation is applied three times to get the final result.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To implement the given algorithm for determining a leap year in MARIE assembly language we will perform the steps required to check the divisibility o... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Biology Questions!