> They are not when I check. I checked the addresses loaded (doing the pointer
> calculations wit gdb stopped at the start of main()), and I end up at
> addresses
> that are not those of 'a' or 'b'. And there are the values loaded into the fp
> registers, which are not those set at 'a' or 'b'.
>
> I see the pointer arithmetic in the generated assembly is done from the 'gp'
> register, that maybe is not loaded properly?
You are right as usual.
I though gp would already been set by the _init.
I've fixed the program and added some code to demonstrate your point
about NaN quietness inversion :
--[ test.S ]--
/* This program shows that Lluis is right and Lemote manual is wrong
* about the encoding of quiet vs signaling NaN.
* Compile with : gcc -march=loongson2f test.S -o test */
#include "asm/unistd.h"
.text
.global main
.ent main
main:
/* .cpload $25 emits no code for some reason ? */
lui $24, %hi(%neg(%gp_rel(main)))
addiu $24, $24, %lo(%neg(%gp_rel(main)))
daddu $gp, $25, $24
.set reorder
ldc1 $f0, zero
ldc1 $f1, one
madd.d $f0, $f0, $f1
la $a0, str1
dmfc1 $a1, $f0
jal printf
ldc1 $f0, one
ldc1 $f1, one
madd.d $f0, $f0, $f1
la $a0, str2
dmfc1 $a1, $f0
jal printf
ldc1 $f0, zero
ldc1 $f2, nan
madd.d $f0, $f0, $f2 // this will happyly display "nan"
la $a0, str3
dmfc1 $a1, $f0
jal printf
ldc1 $f0, zero
ldc1 $f2, qnan
madd.d $f0, $f0, $f2 // this will result in a sigill, cause=15 (FPU
exception)
la $a0, str4
dmfc1 $a1, $f0
jal printf
li $a0, 66
li $v0, __NR_exit
syscall
.size main, .-name
.end main
.rdata
zero: .double 0
one: .double 1
/* Loongson2f manual p97: for all FP formats, if v is nan, the most-significant
* bit of f determines whether the value is a signaling or quiet nan: v is a
signaling
* nan if the most-significant bit of f is set, otherwise, v is a quiet nan */
nan: .quad 0x7fffffffffffffff
qnan: .quad 0x7ff7ffffffffffff
str1: .asciz "0 + 0*1 = %f\n"
str2: .asciz "1 + 1*1 = %f\n"
str3: .asciz "0 + zero*nan = %f\n"
str4: .asciz "0 + zero*qnan = %f\n"
--[ end of test.S ]--
--
You received this message because you are subscribed to the Google Groups
"loongson-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/loongson-dev?hl=en.