'Ho to convert base 10 floating point input to base 2 in MIPS?

I have been tasked with writing a program in MIPS that converts a user-inputted base 10 floating point number to base 2. I am a relatively inexperienced programmer and have almost no prior experience with MIPS, so I quite frankly wasn't really sure where to begin with this task. I studied some documentation in an attempt to get a grasp on the assignment, and ended up writing some code that at this moment does not compile, as it is clear that I misunderstood the functionality of the cvt.s.w instruction. I have provided my code below with comments in case any of it is salvageable, but I will most likely have to start anew, and am hoping for some guidance on where to start.

.data

.text
li $v0, 6 # read float
syscall

cvt.s.w $f0, $v0 # convert to float
li $v0, 2 # print float
syscall

cvt.w.s $v0, $f0 # convert back to int
li $v0, 1 # print int
syscall

li $v0, 10 # exit
syscall

.text
li $v0, 6 # read float syscall
cvt.s.w $f0, $v0 # convert to float
li $v0, 2 # print float
syscall

cvt.w.s $v0, $f0 # convert back to int
li $v0, 1 # print int
syscall

li $v0, 10 # exit
syscall

.text
cvt.s.w $f0, $a0 # convert to float
cvt.w.s $v0, $f0 # convert back to int
jr $ra

cvt.s.w $f0, $a0 # convert to float
cvt.w.s $v0, $f0 # convert back to int
jr $ra

main:
li $v0, 5 # read int
syscall

jal convert
li $v0, 1 # print int
syscall

li $v0, 10 # exit
syscall

convert:
cvt.s.w $f0, $v0 # convert to float
li $v0, 2 # print float
syscall

cvt.w.s $v0, $f0 # convert back to int
jr $ra
li $v0, 1 # print int
syscall

li $v0, 10 # exit
syscall


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source