Discussion Forum
Is this a BUG?
Next Thread | Thread List | Previous Thread
Start a Thread | Settings
| Details |
Message |
|
Read-Only
Author Anderson Chen
Posted 26-Mar-2006 06:27 GMT
Toolset C51
|
 Is this a BUG?
Anderson Chen
In C51 v8.01 Compiler
void Fnc(BYTE * pT, WORD Dat, BYTE x, BYTE y)
{
BYTE Asc[6];
BYTE * pSource = Asc + 5 - (x + y);
.....
}
I got wrong "pSource", but it is OK in v7.50
I changed it to
BYTE * pSource = &Asc + 5 - (x + y);
It is OK, WHY?
|
|
|
Read-Only
Author Hans-Bernhard Broeker
Posted 26-Mar-2006 15:34 GMT
Toolset C51
|
 RE: Is this a BUG?
Hans-Bernhard Broeker
BYTE Asc[6];
BYTE * pSource = Asc + 5 - (x + y);
I got wrong "pSource",
That's a completely useless description of what you see. What did you actually get as pSource? What did you expect to get instead, and why?
The two ways of initializing pSource you show must yield different results in a correct C compiler. Which means neither of them is "correct" in and of itself --- it depends on what you wanted this code to do, but you didn't tell us what that is.
|
|
|
Read-Only
Author Anderson Chen
Posted 27-Mar-2006 01:27 GMT
Toolset C51
|
 RE: Is this a BUG?
Anderson Chen
The pSource point to the element in Asc[] array according to x and y
|
|
|
Read-Only
Author Jon Ward
Posted 26-Mar-2006 23:00 GMT
Toolset C51
|
 RE: Is this a BUG?
Jon Ward
I ran this code in V8.01 and it returned the results that I
expected.
Jon
|
|
|
Read-Only
Author Anderson Chen
Posted 27-Mar-2006 01:18 GMT
Toolset C51
|
 RE: Is this a BUG?
Anderson Chen
In v8.01, the compiler results:
void Func(BYTE *pT, WORD Dat, BYTE x,BYTE y)
C:0x08BD 8B30 MOV 0x30,R3
C:0x08BF 8A31 MOV 0x31,R2
C:0x08C1 8932 MOV 0x32,R1
C:0x08C3 8C33 MOV 0x33,R4
C:0x08C5 8D34 MOV 0x34,R5
{
BYTE Asc[6];
BYTE * pSource = Asc + 5 - (x + y);
C:0x08C7 C3 CLR C
C:0x08C8 E9 MOV A,R1
C:0x08C9 953D SUBB A,0x3D
C:0x08CB F9 MOV R1,A
C:0x08CC EA MOV A,R2
C:0x08CD 953C SUBB A,0x3C
C:0x08CF 8B3D MOV 0x3D,R3
C:0x08D1 F53E MOV 0x3E,A
C:0x08D3 893F MOV 0x3F,R1
and in v7.50, the result is:
void Func(BYTE *pT, WORD Dat, BYTE x,BYTE y)
C:0x08BD 8B30 MOV 0x30,R3
C:0x08BF 8A31 MOV 0x31,R2
C:0x08C1 8932 MOV 0x32,R1
C:0x08C3 8C33 MOV 0x33,R4
C:0x08C5 8D34 MOV 0x34,R5
{
BYTE Asc[6];
BYTE * pSource = Asc + 5 - (x + y);
C:0x08C7 E535 MOV A,0x35
C:0x08C9 2536 ADD A,0x36
C:0x08CB FF MOV R7,A
C:0x08CC C3 CLR C
C:0x08CD 743C MOV A,#0x3C
C:0x08CF 9F SUBB A,R7
C:0x08D0 F9 MOV R1,A
C:0x08D1 7400 MOV A,#0x00
C:0x08D3 9400 SUBB A,#0x00
C:0x08D5 753D00 MOV 0x3D,#0x00
C:0x08D8 F53E MOV 0x3E,A
C:0x08DA 893F MOV 0x3F,R1
|
|
|
Read-Only
Author Jon Ward
Posted 27-Mar-2006 02:10 GMT
Toolset C51
|
 RE: Is this a BUG?
Jon Ward
Hmmm,
That does look strange. I think it best that you contact Technical
Support about this problem. That's not at all the results that I get
from your code snippet.
Jon
|
|
|
Read-Only
Author Anderson Chen
Posted 27-Mar-2006 02:00 GMT
Toolset C51
|
 RE: Is this a BUG?
Anderson Chen
BYTE * pSource = Asc + (5 - (x + y));
It also is OK!
|
|
Next Thread | Thread List | Previous Thread
Start a Thread | Settings
|