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
Step: 1
The length of a year is more or less 365242196 daysSo we have to subtract more o...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started