Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Description: Write a program that prompts the user for the month and year and outputs a mini monthly calendar in QtSpim with mips assembly. You

Description:
Write a program that prompts the user for the month and year and outputs a mini monthly calendar in QtSpim with mips assembly.
You can assume the input month and year will be valid, but account for leap years
Required I/O:
Mini Calendar by F. Last
Enter the month? 3
Enter the year? 2024
March*2024
Sun * Mon * Tue * Wed * Thu * Fri * Sat I
.....................2 q
cdots3cdots4cdots5cdots6cdots7cdots8cdots99
*10cdots11cdots12*13cdots14cdots15cdots16|
.17cdots18*19*20*21*22*23 I
*24cdots25cdots26cdots27cdots28*29cdots30
.311
cdots are spaces, is new line character.
This is what I have so far, but I am having trouble starting the print from the correct day as well as making the alignment resemble the examples in picture: .data
text1: .asciiz "Mini Calendar by A. Palacios
"
mprompt: .asciiz "
Enter the month? "
yprompt: .asciiz "Enter the year? "
space: .asciiz ""
newline: .asciiz "
"
days: .word 31,28,31,30,31,30,31,31,30,31,30,31
dOfWeek: .asciiz "Sun Mon Tue Wed Thu Fri Sat
"
daySpace: .asciiz ""
oneSpace: .asciiz ""
twoSpaces: .asciiz ""
.text
.globl main
main:
li $v0,4
la $a0, text1
syscall
li $v0,4
la $a0, mprompt
syscall
li $v0,5
syscall
move $t1, $v0
li $v0,4
la $a0, yprompt
syscall
li $v0,5
syscall
move $t0, $v0
blt $t1,3, adjust_month
b calculate_day
adjust_month:
addi $t1, $t1,12
addi $t0, $t0,-1
b calculate_day
calculate_day:
li $t5,1
li $t6,13
addi $t7, $t1,1
mul $t6, $t6, $t7
div $t6, $t6,5
mflo $t6
andi $t7, $t0,0x63
srl $t8, $t0,2
add $t5, $t5, $t6
add $t5, $t5, $t7
srl $t6, $t7,2
add $t5, $t5, $t6
srl $t6, $t8,2
add $t5, $t5, $t6
li $t6,2
mul $t6, $t8, $t6
sub $t5, $t5, $t6
andi $t2, $t5,0x07
addi $t2, $t2,1
rem $t2, $t0,4
bnez $t2, not_leap
rem $t2, $t0,100
bnez $t2, leap
rem $t2, $t0,400
beqz $t2, leap
b not_leap
not_leap:
li $t2,0
b continue
leap:
li $t2,1
continue:
addi $t1, $t1,-1
sll $t1, $t1,2
lw $t3, days($t1)
beq $t1,1, check_leap
b print_calendar
check_leap:
beq $t2,1, feb_leap_year
b print_calendar
feb_leap_year:
addi $t3, $t3,1
b print_calendar
print_calendar:
li $v0,4
la $a0, dOfWeek
syscall
move $t4, $t2
li $t5,0
blt $t5, $t4, print_initial_spaces
b print_days
print_initial_spaces:
li $v0,4
la $a0, daySpace
syscall
addi $t5, $t5,1
blt $t5, $t4, print_initial_spaces
print_days:
li $t5,1
move $t6, $t4
print_days_loop:
ble $t5, $t3, print_day_number
b end_printing_days
print_day_number:
beqz $t6, print_newline
li $v0,1
move $a0, $t5
syscall
blt $t5,10, print_one_space
b update_day
print_one_space:
li $v0,4
la $a0, oneSpace
syscall
b update_day
print_newline:
li $v0,4
la $a0, newline
syscall
li $t6,0
li $v0,1
move $a0, $t5
syscall
blt $t5,10, print_one_space
b update_day
update_day:
addi $t5, $t5,1
addi $t6, $t6,1
rem $t6, $t6,7
b print_days_loop
end_printing_days:
li $v0,10
syscall
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago