Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need to write a program in mips assembly that will create a mini calendar with inputs for month and year. The code I have
I need to write a program in mips assembly that will create a mini calendar with inputs for month and year. The code I have so far is below, but I am having trouble moving the first day to align correclty as well as printing the rest of the days as the example shows in the picture:
data
text: asciiz "Mini Calendar by A Palacios
mprompt: asciiz
Enter the month?
yprompt: asciiz "Enter the year?
space: asciiz
newline: asciiz
days: word
dOfWeek: asciiz "Sun Mon Tue Wed Thu Fri Sat
daySpace: asciiz
oneSpace: asciiz
twoSpaces: asciiz
text
globl main
main:
li $v
la $a text
syscall
li $v
la $a mprompt
syscall
li $v
syscall
move $t $v
li $v
la $a yprompt
syscall
li $v
syscall
move $t $v
blt $t adjustmonth
b calculateday
adjustmonth:
addi $t $t
addi $t $t
b calculateday
calculateday:
li $t
li $t
addi $t $t
mul $t $t $t
div $t $t
mflo $t
andi $t $tx
srl $t $t
add $t $t $t
add $t $t $t
srl $t $t
add $t $t $t
srl $t $t
add $t $t $t
li $t
mul $t $t $t
sub $t $t $t
andi $t $tx
addi $t $t
rem $t $t
bnez $t notleap
rem $t $t
bnez $t leap
rem $t $t
beqz $t leap
b notleap
notleap:
li $t
b continue
leap:
li $t
continue:
addi $t $t
sll $t $t
lw $t days$t
beq $t checkleap
b printcalendar
checkleap:
beq $t febleapyear
b printcalendar
febleapyear:
addi $t $t
b printcalendar
printcalendar:
li $v
la $a dOfWeek
syscall
move $t $t
li $t
blt $t $t printinitialspaces
b printdays
printinitialspaces:
li $v
la $a daySpace
syscall
addi $t $t
blt $t $t printinitialspaces
printdays:
li $t
move $t $t
printdaysloop:
ble $t $t printdaynumber
b endprintingdays
printdaynumber:
beqz $t printnewline
li $v
move $a $t
syscall
blt $t printonespace
b updateday
printonespace:
li $v
la $a oneSpace
syscall
b updateday
printnewline:
li $v
la $a newline
syscall
li $t
li $v
move $a $t
syscall
blt $t printonespace
b updateday
updateday:
addi $t $t
addi $t $t
rem $t $t
b printdaysloop
endprintingdays:
li $v
syscall
example:
Mini Calendar by F Last
Enter the month?
Enter the year?
March n
Sun.Mon.Tue.Wed.Thu.Fri.Sat.Sun N
N
N
N
N
N
N
are spaces, N is new line character.
must be written in MIPS Assembly.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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