I'm editing this program so it will print out values in double point precision format. I was told to use two words to define the numbers in the double precision format. However, that's not working. The result I get is 0.0, 0.0, 0.0, 0.0. What am I doing wrong? Any help would be appreciated! thanks!
.data
ZERO: .double 0
ONE: .double 1
POSITIVE_MIN_DBL: .word 0x00000000 0x00100000 #2.2250738585072014 E -308
LARGEST: .word 0x000000 0x7f7fffff
POSITIVE_MIN: .word 0x00000000 0x00800000 # -3.4028235E38
POSITIVE_DENOR_MIN: .word 0x00000000 0x00000001 # denormal min, +1.4E-45
NL: .asciiz "\n"
.text
l.d $f0, ZERO
l.d $f2, ONE
div.d $f12, $f0, $f0 # f12 = 0/0 = NaN
jal printFloat
div.d $f12, $f2, $f0 # f12 = 2/0 = +infinity
jal printFloat
l.d $f12, LARGEST
jal printFloat
l.d $f12, POSITIVE_MIN
jal printFloat
l.d $f12, POSITIVE_DENOR_MIN
jal printFloat
j exit
printFloat:
li $v0, 2
syscall
la $a0, NL
li $v0, 4
syscall
jr $ra
exit:
You're using the wrong system call.
System call 2 is print_float
. What you want is system call 3 (print_double
).
Also, I don't know how you came up with those hex values. They don't match the values in your comments anyway. For example, -3.4028235e38
ought to be 0xC7EFFFFFE54DAFF8
, not 0x0080000000000000
(0x0080000000000000
would be 2.8480945388892180e-306
).
User contributions licensed under CC BY-SA 3.0