From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jonathan Larmour To: javelina , ecos-discuss@sourceware.cygnus.com Subject: Re: [ECOS] twothreads.c not working correctly on ARM AEB1 Date: Sun, 02 Jul 2000 15:53:00 -0000 Message-id: <395FC7D0.1630D628@redhat.co.uk> References: <3945AF98.2C962EAD@home.com> <39464D44.A31E032@redhat.co.uk> <3949A6A1.E2B8765C@home.com> <3949A99E.155337F7@redhat.co.uk> <39554E7A.D19FF193@home.com> <395621FA.C551538F@redhat.co.uk> <39582AA3.43ED0EF6@home.com> <39586C8C.49F02D4B@redhat.co.uk> <395F84B1.269DB524@home.com> X-SW-Source: 2000-07/msg00002.html [ stuff about twothreads delay not being computed correctly, traced to dodgy % behaviour ] javelina wrote: > > As a sanity check on the bad behavior of the % operator, I wrote a tiny program to > isolate the problem > >////////////////////////////////////////////// > > #include > > int main(void) > { > int i; > int m; > for (i=0; i < 21; i++) { > m = i % 5; > printf("%d %d\n", i, m); > } > } >////////////////////////////////////////////// > > The ouput looks like: > > (gdb) continue > Continuing. > 0 0 > 1 1 > 2 2 > 3 3 > 4 4 > 5 5 > 6 6 [snip] > So it realy does look like a mod operator problem. Let me know what you think. Aha! I found it, and it's interesting. Basically, for the AEB, you *must* compile with -mcpu=arm7di as used in the example makefile. However, you didn't compile this program, nor twothreads with this option. Whenever I compile the above with -mcpu=arm7di it works, and without it, it behaves as you saw. The reason is that without -mcpu=arm7di, the compiler will default to -mcpu=arm7tdmi, which assumes you have a fast multiplier unit, which the arm7di (as used on the AEB) doesn't. As a result the compiler uses the "smull" instruction, which fails silently - unfortunately the ARM doesn't raise an exception when this instruction is not supported. So compile with -mcpu=arm7di and all will be well. Jifl -- Red Hat, 35 Cambridge Place, Cambridge, UK. CB2 1NS Tel: +44 (1223) 728762 "Plan to be spontaneous tomorrow." || These opinions are all my own fault