[Mono-dev] Arm9 NS9215 floating point troubles

Trevor Ackerman t_ackerman at yahoo.com
Thu Jun 17 19:54:16 EDT 2010


I have more to report.

I wrote a quick native C program to print out the bytes of a float and double variable that were assigned the literal value 1.0f. 

Then in the mono 2.6.4 routine mono_method_to_ir in source code file mono/mini/method_to_ir.c I dumped out the bytes of ip (instruction pointer) used for the double value in the case for CEE_LDC_R8.

I discovered that the bytes in the double value used on mono had the high and low 32 bits swapped compared to those produced by the native C program. I hacked the routine decompose_soft_float to swap the high and low words and now I have no troubles and the basic-float regression test passes 100%.

Although this happens to work, I have a hard time believing that this is the correct solution to my problem. I feel that others are probably using ARM9 without
 floating point issues and that I am probably missing something in how I built mono for my platform. If anyone can shed some light on what I did wrong with building mono that'd be great. Of course if this is the correct action to take please let me know that too and how I may contribute the change back to the trunk (assuming that the trunk doesn't work which I haven't had time to test yet).

In the meantime here's my hack to decompose_soft_float in method-to-ir.c


 5073                 case OP_R8CONST: {
 5074             unsigned char *ucp = (unsigned char *) ins->inst_p0;
 5075             unsigned char rawval[8];
 5076                     printf("decompose_soft_float OP_R8CONST\n");
 5077             rawval[0] =
 ucp[4];
 5078             rawval[1] = ucp[5];
 5079             rawval[2] = ucp[6];
 5080             rawval[3] = ucp[7];
 5081             rawval[4] = ucp[0];
 5082             rawval[5] = ucp[1];
 5083             rawval[6] = ucp[2];
 5084             rawval[7] = ucp[3];
 5085                     DVal d;
 5086
 //                  d.vald = *(double*)ins->inst_p0;
 5087                     d.vald = *(double*)rawval;
 5088                     MONO_EMIT_NEW_I8CONST (cfg, ins->dreg, d.vall);
 5089                     break;
 5090                 }

--- On Thu, 6/17/10, Trevor Ackerman <t_ackerman at yahoo.com> wrote:

From: Trevor Ackerman
 <t_ackerman at yahoo.com>
Subject: Re: [Mono-dev] Arm9 NS9215 floating point troubles
To: mono-devel-list at lists.ximian.com
Date: Thursday, June 17, 2010, 11:31 AM

Good suggestion but that did not change the results.

--- On Thu, 6/17/10, Robert Jordan <robertj at gmx.net> wrote:

From: Robert Jordan <robertj at gmx.net>
Subject: Re: [Mono-dev] Arm9 NS9215 floating point troubles
To: mono-devel-list at lists.ximian.com
Date: Thursday, June 17, 2010, 10:53 AM

On 17.06.2010 18:07, Trevor Ackerman wrote:
> I have been able to cross-compile Mono 2.6.4 for the NS9215 (no fpu
> afaik) and I'm having trouble with floats when executing
 code.

...

> My CFLAGS and CPPFLAGS environment variables are
>   both
> -DARM_FPU_NONE=1 -DMONO_ARCH_SOFT_FLOAT=1

-DNO_UNALIGNED_ACCESS is probably needed as
 well.

Robert

_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list









      
-----Inline Attachment Follows-----

_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20100617/04f65ac7/attachment.html 


More information about the Mono-devel-list mailing list