urzur 0 Newbie Poster

Hello, I'm writing a program in assembly and am encountering a problem. I want to convert a double (floating type number) into an integer (ie. 3.1 into 3). So far, my attempts have been futile.

This is my code:

main:

li $v0, 7 #asking the user for a double

syscall

mov.d $f2, $f0

cvt.s.d $f4, $f2 #converting from double to single precision. I have a
                        #also tried to convert to word

li $v0, 3  #print the value

mov.d $f12, $f4  #move da converted value (ie.from 3.1 to 3) to f12

syscall

Can someone please help me out and point me in the right direction ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.