In: Computer Science
In MIPS assembly:
Ask the user to enter two numbers and an operation (+ - / *).
Print the expression back to the user with a blank after the = sign (since the calculation is not being completed.
Program:
.data
msg_1: .asciiz "Enter 2 numbers:\n"
msg_2: .asciiz "Enter operation to be
performed(+,-,*,/): "
result: .asciiz "\nExpression is:\n"
equal_sign: .asciiz "="
.text
.globl main
main:
#Printing the prompt to the user
li $v0,4
la $a0,msg_1
syscall
#Reading 2 numbers from user
li $v0,5
syscall
move $t0,$v0
li $v0,5
syscall
move $t1,$v0
#Printing the prompt to the user
li $v0,4
la $a0,msg_2
syscall
#Reading character(operation to be performed) from
user
li $v0,12
syscall
move $t3,$v0
#sb $v0,char
#Printing the expression to the user
li $v0,4
la $a0,result
syscall
li $v0,1
move $a0,$t0
syscall
li $v0,11
move $a0,$t3
syscall
li $v0,1
move $a0,$t1
syscall
li $v0,4
la $a0,equal_sign
syscall
Output: