Question: . data num 1 _ prompt: . asciiz Enter the first number: num 2 _ prompt: . asciiz Enter the second number: prompt: . asciiz

.data
num1_prompt: .asciiz "Enter the first number:"
num2_prompt: .asciiz "Enter the second number:"
prompt: .asciiz "Choose an operation (+,-,*,/) or 'Z' to quit:"
operation: .space 2
result_prompt: .asciiz "Result:"
newline: .asciiz "
"
.text
main:
li $t4,122
loop:
read_num1:
# Read the first number from user input
li $v0,4
la $a0, num1_prompt
syscall
li $v0,5
syscall
move $t0, $v0 # Store the first number in $t0
# Print an empty line
li $v0,4
la $a0, newline
syscall
j read_num2
read_num2:
# Read the second number from user input
li $v0,4
la $a0, num2_prompt
syscall
li $v0,5
syscall
move $t1, $v0 # Store the second number in $t1
# Print an empty line
li $v0,4
la $a0, newline
syscall
j print_prompt
print_prompt:
# Print the prompt
li $v0,4
la $a0, prompt
syscall
# Print an empty line
li $v0,4
la $a0, newline
syscall
# Read the operation from user input
li $v0,12 # Read character
syscall
move $t3, $v0 # Store the user input in $t3
lb $t2, operation
# Check if user pressed 'Z' to quit
li $t4,'Z'
li $t4,'z'
beq $t3, $t4, exit_program
# Print an empty line
li $v0,4
la $a0, newline
syscall
# Read the operation from user input
li $v0,12 # Read character
syscall
j perform_operation
perform_operation:
# Perform the chosen operation
beq $t3,'+', perform_addition
beq $t3,'-', perform_subtraction
beq $t3,'*', perform_multiplication
beq $t3,'/', perform_division
perform_addition:
add $t2, $t0, $t1 # Add the numbers: $t3= $t0+ $t1
j print_result
perform_subtraction:
sub $t2, $t0, $t1 # Subtract the numbers: $t3= $t0- $t1
j print_result
perform_multiplication:
mult $t0, $t1 # Multiply the numbers: $t0* $t1
mflo $t2 # Store the result in $t3
j print_result
perform_division:
div $t0, $t1 # Divide the numbers: $t0/ $t1
mflo $t2 # Store the result in $t3
j print_result
print_result:
# Print the result
li $v0,4
la $a0, result_prompt
syscall
move $a0, $t2 # Move the result to $a0 for printing
li $v0,1
syscall
# Print an empty line
li $v0,4
la $a0, newline
syscall
beq $t4,'C', loop
exit_program:
# Exit the program
li $v0,10
syscall
i want a codnition in this code when the user enter Z the loop end, and i want to be when the result is shown

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!