Question: so far i was able to get it mostly complete but I'm stuck on the day and mod my code is below. please help.. coding

 so far i was able to get it mostly complete but

so far i was able to get it mostly complete but I'm stuck on the day and mod

my code is below. please help.. coding is in MIPS

.data

year: .word 2021 month: .word 3 day: .word 17

.text

main: a: li $t0, 14 # sets register t0 = 14 lw $t1, month #loads word data sub $t0,$t0,$t1 #subtracs month from t1-t0 move $a0,$t0 #moves t0 into t5. div $a0,$a0,12 # divide 11/12 move $t4,$a0 #move $a0 value into $t4 (a value)

y:

lw $t2,year #loads year value into $t1 sub $a0,$t2,$t4 # $t2(2021)-$a0 (11/12) move $t5,$a0 #move $a0 value into $t5 (year value)

m:

lw $t1,month #load month value into $t1 mul $a0,$t4,12 add $a0,$a0,$t1 sub $a0,$a0,2 # subtract $t2 move $t6,$a0 #move $a0 into $t6 (m value) d:

lw $t3, day li $t2, 31 add $a0,$t3,$t5 #add day(17)+$t5(year 2021) li $v0, 1 #print code syscall div $a0,$t5,4 li $v0, 1 #print code syscall div $a0, $t5,100 li $v0, 1 #print code syscall div $a0,$t5,400 li $v0, 1 #print code syscall mul $a0,$t1,31 div $a0,$a0,12

li $v0, 1 #print code syscall

li $v0, 10 #end syscall

.end main

Description: Write the code to compute the day of the week for a given date in the Gregorian calendar using the following method: 14-month 12 y = year- in = month +12a - 2 31m mod 7 For Gregorian calendar: d = (day+y+1 - 1 + 8 + 31m) The value of d is 0 for a Sunday, 1 for a Monday, 2 for a Tuesday, etc. 1. Declare the variables day, month, year and initialize them with March 15, 2021. 2. Compute and output the day of the week value(d) for day, month, year. 3. Declare and store the result(d) in the variable dow. 4. Output the value of the variable dow

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!