informedcitizenry / 6502.Net

A .Net-based Cross-Assembler for Several 8-Bit Microprocessors
MIT License
58 stars 17 forks source link

Negative numbers not supported #4

Closed svallee-dev closed 4 years ago

svallee-dev commented 4 years ago

Sorry I hope you don't mind me filling up issues/requests, I'm just really excited by your project and using it a TON :)

This one is not as much an issue, but a request to support negative numbers. I have a few situations where it's easier to declare data as negative number, for instance:

spriteOffset
     .word  -10, -5

Currently 6502.Net trigger an error message on that one. I looked into it, and it seems that a very simple change could add support, although I'm not sure if my change is enough to handle ALL situations, you know way better than I do.

But what I'm doing on my local version was adding this little value adjustment right before the error check, in the file Evaluator.cs, in the DoEvaluation() method:

if (isMath && r < minValue)
     r += (maxValue + 1);  // wrap the value around

if (isMath && (r < minValue || r > maxValue))
     throw new IllegalQuantityException(tokens.First());

That seems to work great for my project!

svallee-dev commented 4 years ago

Omg I feel like an idiot. Immediately after writing this entry I suddenly had a doubt. I went back to your documentation, and yup, there it was. ".sint". I completely missed it, and it does work without my change. I will close and try to erase this entry!