Answered step by step
Verified Expert Solution
Question
1 Approved Answer
User Change the function time 2 string so that DING is shown instead of time, every minute at xx: 0 0 . At xx: 0
User
Change the function timestring so that "DING" is shown instead of time, every minute at xx: At xx: time should be shown normally again. You are not allowed to change any other function or subroutine.
Example printout:
:
:
:
DING
:
:
:
:
The code is:
global timestring, delay
macro PUSH reg
addi $sp$sp
sw reg$sp
endm
macro POP reg
lw reg$sp
addi $sp$sp
endm
#
# Please add your own code below this line
#
text
hexasc:
andi $v $axF # Mask out all but the least significant bits
li $t # Compare with to determine if it's a digit or a letter
blt $v $t isdigit # Branch if less than its a digit
addi $v $v # Adjust for letters A starts at ASCII
isdigit:
addi $v $v # Adjust for ASCII digits starts at ASCII
jr $ra # Return
delay:
# Save registers
addi $sp $sp
sw $s$sp
sw $s$sp
sw $s$sp
# Initialize loop counter
li $s # The constant adjust as needed
# Outer loop: decrement ms
outerloop:
bnez $a innerloop # if ms is not zero, go to inner loop
j enddelay # if ms is zero, exit the delay
innerloop:
# Inner loop: decrement inner loop counter
bnez $s innerloop # if counter is not zero, continue inner loop
addi $a $a # decrement ms
li $s # reset inner loop counter
j outerloop # go to outer loop
# Restore registers and return
enddelay:
lw $s$sp
lw $s$sp
lw $s$sp
addi $sp $sp
jr $ra
timestring:
PUSH $s
PUSH $s
PUSH $t
move $s $a
move $s $a
# x:
andi $a $sxF
srl $a $a
jal hexasc
sb $v$s
# x:
andi $a $sxF
srl $a $a
jal hexasc
sb $v$s
# colon
li $axA
sb $a$s
# :X
andi $a $sxF
srl $a $a
jal hexasc
sb $v$s
# :X
andi $a $sxF
jal hexasc
sb $v$s
# nullbyte
li $ax
sb $a$s
# Restore original s s and s values
POP $t
POP $s
POP $s
jr $ra
nop
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