SymbiSoft / mosync

Automatically exported from code.google.com/p/mosync
0 stars 0 forks source link

Bitwise right shift fails on Android #1141

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
From the forum - tested and verified on Android using MoSync 2.6

http://www.mosync.com/content/c-language-left-shift-operator-android

 I found the condition, but it's a RIGHT shift, and involves a value to shift very high.

Below is  the code, which on MoRe (MoSync version  2.5) gives this output :

result=0x000000df
result=0x000001bf 

On Android (build V0.18ECLAIR) it gives this output :

result=0x00000000
result=0x00000000

it's compile with -O9 but I'm not sure if it is relevant...

volatile unsigned int valuea;
volatile unsigned int valueb;

void initTestValue()
{
    valuea=0xdfdfdfdf;
    valueb=8;
}

int MAMain()
{
    MAFrameBufferInfo info;
    //MAExtent e = maGetScrSize();

    unsigned int a,b,loop,result;

    initTestValue();

    a=valuea;
    b=valueb;

    for (loop=0;loop<2;loop++)
    {
        result=a>>(32-b);
        printf("result=0x%08x",result);
        b++;
    }

    while (1);

    return 0;
}
I'll check tomorrow if I have the same result with 2.6.

Original issue reported on code.google.com by samuel.p...@mobilesorcery.com on 27 Sep 2011 at 7:33

GoogleCodeExporter commented 8 years ago
As far as I can tell, the MoSync output is correct, and the Android output is 
wrong.

Original comment by fredrik....@gtempaccount.com on 27 Sep 2011 at 10:31

GoogleCodeExporter commented 8 years ago
Will progress this

Original comment by miles.mi...@mobilesorcery.com on 17 Nov 2011 at 10:08