# # program to get a float from user and echo, using SPIM system calls # .text .globl main main: # # opening linkage (save return address) # addi $sp, $sp, -4 sw $ra, 0($sp) # # prompt # la $a0, prompt li $v0, 4 # "print string" syscall syscall # # get input # li $v0, 6 # "read float" syscall syscall mov.s $f2, $f0 # save result in $f2 # # echo # la $a0, echo li $v0, 4 # "print string" syscall syscall mov.s $f12, $f2 # get saved result (input) li $v0, 2 # "print float" syscall syscall la $a0, nl li $v0, 4 # "print string" syscall syscall # # closing linkage (get return address and restore stack pointer) # lw $ra, 0($sp) addi $sp, $sp, 4 jr $ra .end main # # area for variables and constants # .data prompt: .asciiz "Enter a float:\n" echo: .asciiz "You entered:\n" nl: .asciiz "\n"