# leap.s - Determine if a given year number is a leap year. # Use the Gregorian definition # # Suggested register use: # $s0 = the year number # $s1 = remainder by 400 # $s2 = remainder by 100 # $s3 = remainder by 4 .data prompt: .asciiz "Which year are you curious about? " is_msg: .asciiz "It is a leap year.\n" is_not_msg: .asciiz "It is NOT a leap year.\n" .text main: li $v0, 4 # Prompt the user for a year to test. la $a0, prompt syscall li $v0, 5 # Input an integer value -> $s0 syscall move $s0, $v0 # ------------------------------------------------------------------- # Use branch instructions to solve the problem. # ------------------------------------------------------------------- # This is the code to say it's not a leap year. not_leap_year: li $v0, 4 la $a0, is_not_msg syscall # ------------------------------------------------------------------- # This is the code to print the affirmative message. is_leap_year: li $v0, 4 la $a0, is_msg syscall # ------------------------------------------------------------------- # End of program the_end: li $v0, 10 syscall