stardot / beebasm

A portable 6502 assembler with BBC Micro style syntax
http://www.retrosoftware.co.uk/wiki/index.php/BeebAsm
GNU General Public License v3.0
83 stars 26 forks source link

PUTBASIC mangles hexadecimal values that contain BASIC keywords, e.g. &3DEF #101

Open markmoxon opened 1 week ago

markmoxon commented 1 week ago

Hexadecimal values that contain BASIC keywords get mangled by PUTBASIC, as it converts them to BASIC tokens. For example, &3DEF gets converted to &3<token for DEF>, which obviously breaks things (though the listings still look correct, which makes it really difficult to spot!).

test.zip

Attached in the zip are two example .bas files (test1.bas and test2.bas) that demonstrate the problem, one in BASIC and the other in assembler. You can build these into the test.ssd disc image using test.asm, like this:

beebasm -i test.asm -do test.ssd

The zip contains test.asm and test.ssd. To see the problem, load test.ssd and try CHAINing the test1 and test2 programs. The BASIC example in test1 gives up with an error, while the assembly example in test2 assembles, but the value of &3DEF is incorrectly put into memory as &3. The listings look OK, but that's because BASIC is showing the DEF token as "DEF", which is indistinguishable from the letters "D", "E" and "F". If you re-enter the offending lines within BASIC, the problem goes away.