MIPS - Round Number

190 Views Asked by At

I am trying to develop the execution of a simple program in MIPS, but I am breaking my head on a topic. How do I get the system to return or show me a rounded number?

EXAMPLE

I enter a data number equal to 1.876542 and I want the system to show me the following:

The rounded number is: 1.88

CODE

*.data
txt1: .asciiz "Enter number: "
txt2: .asciiz "The rounded number is: "
  
.text
li $v0, 4
la $a0, txt1
syscall
li $v0, 6
syscall
movf.s $f1, $f0
.globl begin
begin
jal print_roundnumber
j exit
    
print_roundnumber:
li $v0, 4
la $a0, txt2
syscall
movf.s $f12, $f1
li $v0, 2   
syscall     
jr $ra      
exit:
li $v0, 10 
syscall
0

There are 0 best solutions below