neilsf / xc-basic3

A BASIC cross compiler for MOS 6502-based machines
MIT License
42 stars 5 forks source link

Bug with the LONG type #238

Closed AGPX closed 11 months ago

AGPX commented 11 months ago

Hi again,

I'm stuck with a project in XC=Basic (I'm the author of the Pac-Man and Labyrinth-3D) due to a bug in the compiler. If you try the following code:

DIM A AS LONG, B AS LONG, C AS LONG

A = 0
B = 12000
C = 3000
PRINT (A - B) / C

It should print -4, but instead it print 4. If you replace LONG with INT, the result is correct (looks like that the division is the problem, because A - B is printed correctly as -12000).

Please support.

JJFlash-IT commented 11 months ago

Tried this myself, apparently it's something specific with division, all the other operations seem to work fine.

AGPX commented 11 months ago

Please double check how the sign is handled.

neilsf commented 11 months ago

Yes, the bug was in LONG division.

neilsf commented 11 months ago

Please download v3.1.9

AGPX commented 11 months ago

A new XC=Basic tech demo is coming, stay tuned :-)

neilsf commented 11 months ago

Cool! Keep us updated. Thanks.