[Mono-dev] ARM9 Soft Float Arithmetic
jaekim
jkim0130 at gmail.com
Tue Aug 17 13:57:52 EDT 2010
I'm developing for a Freescale ARM920T processor and I had to use a similar
hack described in "Arm9 NS9215 floating point troubles by Trevor Ackerman".
Floating point arithmetic does not work with my system.
This is the hack 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
unsigned char *ucp = (unsigned char *) ins->inst_p0;
unsigned char rawval[8];
rawval[0] = ucp[4];
rawval[1] = ucp[5];
rawval[2] = ucp[6];
rawval[3] = ucp[7];
rawval[4] = ucp[0];
rawval[5] = ucp[1];
rawval[6] = ucp[2];
rawval[7] = ucp[3];
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
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;
}
This is the C# test code to test multiply.
Code:
using System;
public class HelloWorld
{
static public void Main ()
{
double ftest = 1.1;
Console.WriteLine ("Hello Mono World");
if(ftest >= 1.0)
Console.WriteLine("ftest >= 1.0");
else
Console.WriteLine("ftest < 1.0");
ftest *= -32.52;
if(ftest >= 32.52)
Console.WriteLine("ftest >= 32.52");
else
Console.WriteLine("ftest < 32.52");
Console.WriteLine("ftest = {0}", ftest);
ftest = ftest * 33.33;
Console.WriteLine("ftest * 33.33 = {0}", ftest);
ftest = ftest * -33.33;
Console.WriteLine("ftest * -33.33 = {0}", ftest);
}
}
Output:
Hello Mono World
ftest >= 1.0
ftest < 32.52
ftest = 1,1
ftest * 33.33 = 1,1
ftest * -33.33 = 1,1
Jae
--
View this message in context: http://mono.1490590.n4.nabble.com/ARM9-Soft-Float-Arithmetic-tp2328767p2328767.html
Sent from the Mono - Dev mailing list archive at Nabble.com.
More information about the Mono-devel-list
mailing list