alex-quiterio / picoc

0 stars 0 forks source link

Problem with HEX literals #43

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. see additional info: C Source and Execution Results
2.
3.

What is the expected output? What do you see instead?
incorrect conversion of HEX literals

What version of the product are you using? On what operating system?

Please provide any additional information below.

C Source:

void PDQ(int d, int h)
{
    printf("%d, %d\r\n", d, h);
}

printf("\r");

int p;
int m;

p=0x7FFFFFFF;
m=p+1;
printf("%d, %d\r\n", p, m);

p=1;
for (m=1; m<=32; m++)
{
  printf("%d, %d, %d\r\n", m, p, p-1);
  p=p*2;
}

printf("%d, %d\r\n",    0,    0x00);
printf("%d, %d\r\n",    1,    0x01);
printf("%d, %d\r\n",    9,    0x09);
printf("%d, %d\r\n",   10,    0x0A);
printf("%d, %d\r\n",   15,    0x0F);
printf("%d, %d\r\n",   16,    0x10);
printf("%d, %d\r\n",   17,    0x11);
printf("%d, %d\r\n",  255,    0xFF);
printf("%d, %d\r\n",32767,  0x7FFF);
printf("%d, %d\r\n",32768,  0x8000);
printf("%d, %d\r\n",65535,  0xFFFF);
printf("%d, %d\r\n",65536, 0x10000);

PDQ(    0,    0x00);
PDQ(    1,    0x01);
PDQ(    9,    0x09);
PDQ(   10,    0x0A);
PDQ(   15,    0x0F);
PDQ(   16,    0x10);
PDQ(   17,    0x11);
PDQ(  255,    0xFF);
PDQ(32767,  0x7FFF);
PDQ(32768,  0x8000);
PDQ(65535,  0xFFFF);
PDQ(65536, 0x10000);

exit();

Execution Results:
##Version - SRV-1 Blackfin w/picoC 0.92 07:57:59 - Aug  2 2009

2621439, 2621440  *** ERROR
1, 1, 0
2, 2, 1
3, 4, 3
4, 8, 7
5, 16, 15
6, 32, 31
7, 64, 63
8, 128, 127
9, 256, 255
10, 512, 511
11, 1024, 1023
12, 2048, 2047
13, 4096, 4095
14, 8192, 8191
15, 16384, 16383
16, 32768, 32767
17, 65536, 65535
18, 131072, 131071
19, 262144, 262143
20, 524288, 524287
21, 1048576, 1048575
22, 2097152, 2097151
23, 4194304, 4194303
24, 8388608, 8388607
25, 16777216, 16777215
26, 33554432, 33554431
27, 67108864, 67108863
28, 134217728, 134217727
29, 268435456, 268435455
30, 536870912, 536870911
31, 1073741824, 1073741823
32, -2147483648, 2147483647
0, 0
1, 1
9, 9
10, 10
15, 15
16, 16
17, 17
255, 255
2588671, 2588671  *** ERROR
2588672, 2588672  *** ERROR
2621439, 2621439  *** ERROR
2555904, 2555904  *** ERROR
0, 0
1, 1
9, 9
10, 10
15, 15
16, 16
17, 17
255, 255
2588671, 2588671  *** ERROR
2588672, 2588672  *** ERROR
2621439, 2621439  *** ERROR
2555904, 2555904  *** ERROR
leaving picoC

Original issue reported on code.google.com by rcurt...@nwlink.com on 4 Oct 2009 at 9:05

GoogleCodeExporter commented 9 years ago
This seems to work fine on the current SVN version. 

Will recheck on SRV-1.

Original comment by zik.sale...@gmail.com on 4 Oct 2009 at 2:42

GoogleCodeExporter commented 9 years ago
Thanks for looking into this.

Another test result:

Perhaps there is a memory usage problem: one thing stepping on another?

CC##Xmodem success. Count: 768

void PDQ(int v, int d, int h)
{
        printf("%d, %d, %d\r\n", v, d, h);
}

int u;

PDQ(0,       0,     0x0);

u=15;
PDQ(u,      15,    0x0F);
PDQ(u+1,    16,    0x10);

u=u*2+1;
PDQ(u,      31,    0x1F);
PDQ(u+1,    32,    0x20);

u=16*16-1;
PDQ(u,     255,   0xFF);
PDQ(u+1,   256,   0x100);

u=u*2+1;
PDQ(u,     511,   0x1FF);
PDQ(u+1,   512,   0x200);

u=16*16*16-1;
PDQ(u,    4095,  0xFFF);
PDQ(u+1,  4096,  0x1000);

u=u*2+1;
PDQ(u,    8191,  0x1FFF);
PDQ(u+1,  8192,  0x2000);

u=u*2+1;
PDQ(u,   16383,  0x3FFF);
PDQ(u+1, 16384,  0x4000);

u=u*2+1;
PDQ(u,   32767,  0x7FFF);
PDQ(u+1, 32768,  0x8000);

u=u*2+1;
PDQ(u,   65535,  0xFFFF);
PDQ(u+1, 65536, 0x10000);

exit();

=====================
                     0, 0, 0
15, 15, 15
16, 16, 16
31, 31, 31
32, 32, 32
255, 255, 255
256, 2556160, 2556160
511, 2556415, 2556415
         ^
          JáÀ
             á2S•'á2: 'ÿ÷ÿïÿÿÿÿÿÿÿÿ¿ûÿÿÿÿÿÿþÿ?ýïÿßÿÿßÿÿÿ÷ÿÿÿÿÿÿÿþ÷ÿÿÿ¿ÿÿÿïÿÿûÿÿß
ÿûÿÿÿÿÿûýÿ½ïÿÿþÿÿÿÿÿþÿÿÿÿßÿÿÿÿÿÿÿÿÿÿý¿ÿÿ
ÿ¿ÿÿ~ßÿÿÿÿÿÿÿ÷û¿û÷Ëÿÿÿûÿßþÿÿÿßÿßÿÿûÿ÷ÿÿÿ
ÿÿÿýßÿÿÿÿþýÿÿÿÿÿÿÿÿÿÿÿ¯ÿÿÿëÿÿÿûÿßÿÿÿÿÿÿÿ
ÿÿÿßÿÿÿÿÿßûýÿÿÿÿÿÿÿïÿÿÿÿýýÿÿÿÿÿÿÿwÿÿÿÿÿï
ßÿÿÿÿÿÿÿÿßÿÿýÿÿÿÿÿÿÿß÷ÿÿÿÿÿÿÿÿÿÿ÷ÿýÿÿÿßÿ
ÿÿÿÿÿÿû÷ßÿÿÿûÿÿÿ¿wÿÿÿÿÿÿ÷ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿßÿÿÿÿÿýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿßÿ÷ýÿÿß¿ÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿþÿïïÿ_ýÿßÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¿ÿÿ
ÿÿÿÿÿÿÿÿÿÿÿßÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþÿÿÿÿÿÿÿÿ»ÿÿÿ
¿ÿ÷ÿ÷ûÿßßÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ÷ÿïÿÿÿÿÿÿÿÿÿ
¿ÿþÿþÿÿÿÿÿÿ?ýïÿßÿÿÿßÿÿÿ÷ÿÿÿÿÿÿÿþÿÿÿÿ¿ÿÿÿ�
�ÿÿûÿÿÿ{ÿÿÿÿÿÿÿýïÿÿÿþÿÿÿÿÿþÿÿÿÿßÿÿÿÿÿÿÿÿ
ÿÿÿý¿ÿÿÿ¿ÿÿÿÿÿÿÿÿÿÿû÷Ûÿÿýÿ÷ûÿßÿÿ÷ßÿßÿÿÿÿ
ÿÿÿÿÿÿÿýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿïÿÿÿëÿÿÿÿ}û÷ÿÿßÿ
ÿÿÿÿÿÿÿÿÿÿßÿÿÿÿÿýÿ÷ÿÿÿÿÿÿÿÿïýÿÿÿÿÿÿïwÿÿÿ�
�ÿÿÿÿÿ¿ÿÿÿÿ is undefined
                                                                leaving picoC

Original comment by rcurt...@nwlink.com on 4 Oct 2009 at 10:45

GoogleCodeExporter commented 9 years ago
Hi, Howard has recent found a problem with the memcpy() function on the SRV-1.
Updating to his new memcpy() may solve your memory corruption problem. I'd be
interested to know if you have any success with this.

Original comment by zik.sale...@gmail.com on 30 Oct 2009 at 7:48

GoogleCodeExporter commented 9 years ago
Calling this one closed unless I hear otherwise.

Original comment by zik.sale...@gmail.com on 1 Nov 2009 at 4:35