neilsf / xc-basic3

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

Bug with the LONG type #238

Closed AGPX closed 1 year ago

AGPX commented 1 year 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 1 year ago

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

AGPX commented 1 year ago

Please double check how the sign is handled.

neilsf commented 1 year ago

Yes, the bug was in LONG division.

neilsf commented 1 year ago

Please download v3.1.9

AGPX commented 1 year ago

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

neilsf commented 1 year ago

Cool! Keep us updated. Thanks.