In: Computer Science
(Make sure in Mips!!!) Use the correct “syscall” to create MIPS programs for the following.
!!! please use comments and ALWAYS use the correct syscall program code to end the program. !!!
1) Write a program to prompt, read, and then print a floating point number. ALSO NEEDED: What is strange about the registers used for this program???
CODE:
.data
#Defining the variable to store messages and default
value of float.
message1: .asciiz "Enter the value of PI: "
message2: .asciiz "Value of PI entered: "
zeroAsFloat: .float 0.0
.text
lwc1 $f4, zeroAsFloat #Load the value in variable
zeroAsFloat in $f4.
#Display message1
li $v0,4
la $a0,message1
syscall
#Read user's input in $f0 by default.
li $v0,6
syscall
#Display message1
li $v0,4
la $a0,message2
syscall
#Display value.
li $v0,2
add.s $f12, $f0, $f4 #$f12 = $f0 + $f4 and in $f4
value is 0.0 therefore $f12 = $f0.
syscall #Print the value in $f12.
CODE SCREENSHOT:
CODE OUTPUT:
Strange about the register used for this program is that float
are stored by
the coprocessor1 registers instead of general purpose register
present in
Registers section