Maybe I'm missing something, maybe I'm doing this the wrong way, or maybe there's a bug?
This code:
(p_t3 and p_t5 just print numbers using neslib, 3 and 5 digits).
pry should b 160, right? If I use the old cc65 I've been using for quite a long time (2.13), the numbers "160" and "10240" are displayed on screen. But when I use the latest cc65 snapshot from here, I get wrong results: pry now equals 224. Numbers "224" and "10240" are printed on screen.
Screenshot: Above, the ROM compiled using the old 2.13, below, the ROM compiled using the latest win32 snapshot.
wtf.png [ 29.18 KiB | Viewed 1356 times ]
So it seems that "pry = a >> 6;" is not working for some reason.
The most interesting thing is that I get exactly the same results if I use *64 and /64 (I guess the optimizer is replacing them with shifts).
Am I doing something wrong?
Attached is a ZIP with two folders, cc65new and cc65old. There's a .NES file inside each, one compiled with the latest snapshot, the other with the old version. The code is slightly different 'cause different crt0.s / neslib revisions are used, but the important bit is the same.
These are just tests. This thing has surfaced while porting an old project to the latest version of cc65/neslib. Am I doing something wrong? I'm using fixed point math and I'm bit-shifting quite a lot. Never had a problem (I use several compilers and very similar code for different platforms).
EDIT:
I did some more tests. It seems to be wrong, and it seems there's a logic in the results I get. Maybe should I report it to the cc65 team? The snapshot was released quite a long ago, I'm surprised nobody has noticed *if* this is a bug and not myself doing it wrong...
This code:
Code:
unsigned char prx, pry;
signed int a;
...
void main (void) {
[...]
a = 160 << 6;
pry = a >> 6;
[...]
p_t3 (4, 1, pry);
p_t5 (8, 1, a);
}
signed int a;
...
void main (void) {
[...]
a = 160 << 6;
pry = a >> 6;
[...]
p_t3 (4, 1, pry);
p_t5 (8, 1, a);
}
(p_t3 and p_t5 just print numbers using neslib, 3 and 5 digits).
pry should b 160, right? If I use the old cc65 I've been using for quite a long time (2.13), the numbers "160" and "10240" are displayed on screen. But when I use the latest cc65 snapshot from here, I get wrong results: pry now equals 224. Numbers "224" and "10240" are printed on screen.
Screenshot: Above, the ROM compiled using the old 2.13, below, the ROM compiled using the latest win32 snapshot.
Attachment:
wtf.png [ 29.18 KiB | Viewed 1356 times ]
So it seems that "pry = a >> 6;" is not working for some reason.
The most interesting thing is that I get exactly the same results if I use *64 and /64 (I guess the optimizer is replacing them with shifts).
Am I doing something wrong?
Attached is a ZIP with two folders, cc65new and cc65old. There's a .NES file inside each, one compiled with the latest snapshot, the other with the old version. The code is slightly different 'cause different crt0.s / neslib revisions are used, but the important bit is the same.
Attachment:
These are just tests. This thing has surfaced while porting an old project to the latest version of cc65/neslib. Am I doing something wrong? I'm using fixed point math and I'm bit-shifting quite a lot. Never had a problem (I use several compilers and very similar code for different platforms).
EDIT:
I did some more tests. It seems to be wrong, and it seems there's a logic in the results I get. Maybe should I report it to the cc65 team? The snapshot was released quite a long ago, I'm surprised nobody has noticed *if* this is a bug and not myself doing it wrong...
Code:
10240 -> 10100000000000 / 64 ( >> 6)
160 -> 10100000 <- expected
224 -> 11100000 <- got this
5120 -> 1010000000000 / 64 ( >> 6)
80 -> 1010000 <- expected
16 -> 0010000 <- got this
9920 -> 10011011000000 / 64 ( >> 6)
155 -> 10011011 <- expected
27 -> 11011 <- got this
160 -> 10100000 <- expected
224 -> 11100000 <- got this
5120 -> 1010000000000 / 64 ( >> 6)
80 -> 1010000 <- expected
16 -> 0010000 <- got this
9920 -> 10011011000000 / 64 ( >> 6)
155 -> 10011011 <- expected
27 -> 11011 <- got this