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

How would I write an MIPS program that accepted a string input such as \"2+9=\"

ID: 3828616 • Letter: H

Question

How would I write an MIPS program that accepted a string input such as "2+9=" and then solve to have the display show "2+9=11"?

We are expected to use keyboard interrupt to read the keyboard input and polling on transmitter data and control to send the output to the display.

This was on the HW: "Please use keyboard interrupt to read the keyboard input from the receiver data, compute the result Z and use polling (on the transmitter control and transmitter data) to send the output X+Y=Z to the display."

Explanation / Answer

.data
prompB: .asciiz " Enter the first Number:"
prompZ: .asciiz "Enter the second Number:"
result: .asciiz "The result is:"

.text
main:
#A-to hold first integer
#B-to hold second integer
#Z- used to hold the sum of t$1 and t$2
#first number
li $v0, 4 #syscall to print string
la $a0, prompB #address of string to print
syscall
#
li $v0, 5 #syscall to read an integer
syscall
move $A, $v0 #move the number to read into $A
#second number
li $v0, 4
la $a0, prompZ
syscall
#
li $v0,5
syscall
move $B,$v0
#
#print out sum of $Z
li $v0, 4
la $a0, result
syscall
#
add $a0, $B, $A #compute the sum
li $v0, 1
syscall
#
li $v0, 10
syscall

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