Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem: Create a MIPS asm program that requests for three numbers from the user

ID: 3864773 • Letter: P

Question

Problem: Create a MIPS asm program that requests for three numbers from the user. Month, Day, and Year. You may assume that a valid date is given. Your program will return the DAY number of the year. Your program should accurately calculate leap years. Your program function should accept the month (1 through 12), day, and year as unsigned integers As an example, January 1, 1994 is day 1. December 31, 1993 is day 365. December 31, 1996 is day 366 since 1996 is a leap year. A year is a leap year if it's divisible by four except that any year divisible by 100 is a leap year only if it's also divisible by 400. You should use the modulus function you wrote in lab 5 for this assignment.

OUTPUT :

IT HAS TO BE ASSEMBLY MIPS , NOT ANYTHING DIFFERENT THAN THAT

Problem: Create a MIPS asm program that requests for three numbers from the user. Month, Day, and Year. You may assume that a valid date is given. Your program will return the DAY number of the year. Your program should accurately calculate leap years. Your program function should accept the month (1 through 12), day, and year as unsigned integers As an example, January 1, 1994 is day 1. December 31, 1993 is day 365. December 31, 1996 is day 366 since 1996 is a leap year. A year is a leap year if it's divisible by four except that any year divisible by 100 is a leap year only if it's also divisible by 400. You should use the modulus function you wrote in lab 5 for this assignment. Notes: Comment your code Assignments should be submitted via Blackboard by due date and time o Include only the asm file Assignment must be printed and handed in See second page for expected output

Explanation / Answer

Given below is the MIPS program for calculating the Julian day. Output is also shown. If the answer helped, please don't forget to rate it . Thank you very much.


.data
prompt1: .asciiz "Enter month: "
prompt2: .asciiz "Enter day: "
prompt3: .asciiz "Enter year: "
msg: .asciiz "The Julian day is "
is_leap: .word 0
MONTH_DAYS: .word 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31

.text

#show prompt to enter month
li $v0, 4
la $a0, prompt1
syscall

#get user inptu for month and store in t0
li $v0, 5
syscall
move $t0, $v0

#show prompt to enter day
li $v0, 4
la $a0, prompt2
syscall

#get user input for day and store in t1
li $v0, 5
syscall
move $t1, $v0

#show prompt to enter year
li $v0, 4
la $a0, prompt3
syscall

#get user input for year and store in t2
li $v0, 5
syscall
move $t2, $v0

#check if its leap year

rem $t3, $t2, 400
beqz $t3, SetLeap
rem $t3, $t2, 4
bnez $t3, CalculateJulian
rem $t3, $t2, 100
beqz $t3, CalculateJulian

SetLeap:
li $t3, 1
sw $t3, is_leap

CalculateJulian:
li $t3, 0 #intialize julian day to 0
li $t4, 1 #initialzie month counter to 1
la $t5, MONTH_DAYS #base address of the array of days

loop1:
bge $t4, $t0, end_loop1
lw $t6, ($t5) #get number of days for current month
add $t3, $t3, $t6 #add to julian day
add $t5, $t5, 4 #next month in array
add $t4, $t4, 1 #increment month counter
b loop1

end_loop1:

add $t3, $t3, $t1 #add the day of the given date
ble $t0, 2, display #if the input month is less tahn or equal to 2, just display the julian calculated
lw $t4, is_leap #input month is more than 2, i.e after feb, so add the computed leap value
add $t3, $t3, $t4

display:

#display the message and the julian day stored in t3
li $v0, 4
la $a0, msg
syscall
li $v0, 1
move $a0, $t3
syscall

#exit
li $v0, 10
syscall

output

Enter month: 12
Enter day: 31
Enter year: 1993
The Julian day is 365
-- program is finished running --

Enter month: 2
Enter day: 5
Enter year: 1993
The Julian day is 36
-- program is finished running --


Reset: reset completed.

Enter month: 6
Enter day: 1
Enter year: 1996
The Julian day is 153
-- program is finished running --


Reset: reset completed.

Enter month: 3
Enter day: 1
Enter year: 1996
The Julian day is 61
-- program is finished running --


Reset: reset completed.

Enter month: 3
Enter day: 1
Enter year: 1997
The Julian day is 60
-- program is finished running --


Reset: reset completed.

Enter month: 12
Enter day: 31
Enter year: 1996
The Julian day is 366
-- program is finished running --


Reset: reset completed.

Enter month: 12
Enter day: 31
Enter year: 1999
The Julian day is 365
-- program is finished running --

Enter month: 8
Enter day: 2
Enter year: 2017
The Julian day is 214
-- program is finished running --


Reset: reset completed.

Enter month: 12
Enter day: 31
Enter year: 2010
The Julian day is 365
-- program is finished running --

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote