[Mono-dev] Arm9 NS9215 floating point troubles
jaekim
jkim0130 at gmail.com
Mon Aug 16 19:35:51 EDT 2010
There seems to be an endianness problem when the floating point value goes to
the JIT. I used Trevor's code and changed the byte order and my problems
disappeared.
In method-to-ir.c:
case OP_R8CONST: {
DVal d;
// ORIGINAL CODE
//d.vald = *(double*)ins->inst_p0;
//MONO_EMIT_NEW_I8CONST (cfg, ins->dreg, d.vall);
// NEW CODE TO CHANGE ENDIANNESS
unsigned char *ucp = (unsigned char *) ins->inst_p0;
unsigned char rawval[8];
rawval[0] = ucp[7];
rawval[1] = ucp[6];
rawval[2] = ucp[5];
rawval[3] = ucp[4];
rawval[4] = ucp[3];
rawval[5] = ucp[2];
rawval[6] = ucp[1];
rawval[7] = ucp[0];
d.vald = *(double*)rawval;
MONO_EMIT_NEW_I8CONST (cfg, ins->dreg, d.vall);
break;
}
case OP_R4CONST: {
DVal d;
// ORIGINAL CODE
/* We load the r8 value */
//d.vald = *(float*)ins->inst_p0;
//MONO_EMIT_NEW_I8CONST (cfg, ins->dreg, d.vall);
// NEW CODE TO CHANGE ENDIANNESS
unsigned char *ucp = (unsigned char *) ins->inst_p0;
unsigned char rawval[4];
rawval[0] = ucp[3];
rawval[1] = ucp[2];
rawval[2] = ucp[1];
rawval[3] = ucp[0];
d.vald = *(double*)rawval;
MONO_EMIT_NEW_I8CONST (cfg, ins->dreg, d.vall);
break;
}
Thanks Trevor!
--
View this message in context: http://mono.1490590.n4.nabble.com/Arm9-NS9215-floating-point-troubles-tp2259090p2327614.html
Sent from the Mono - Dev mailing list archive at Nabble.com.
More information about the Mono-devel-list
mailing list