Live data from Hacker News

Code Golfing in Commodore BASIC

imrannazar.com

1–10 of 42 posts

Re: Code Golfing in Commodore BASIC

#4
post #3

In a C64 BASIC program keywords like SAVE and PRINT can be abbreviated: https://www.c64-wiki.com/wiki/BASIC_keyword_abbreviation That would shave off some more precious bytes!

Doesn’t BASIC tokenize those abbreviations to the exact same in-memory bytes like the full keywords?

Re: Code Golfing in Commodore BASIC

#6
post #3

In a C64 BASIC program keywords like SAVE and PRINT can be abbreviated: https://www.c64-wiki.com/wiki/BASIC_keyword_abbreviation That would shave off some more precious bytes!

Doesn’t BASIC tokenize those abbreviations to the exact same in-memory bytes like the full keywords?

[deleted]

Re: Code Golfing in Commodore BASIC

#8
I don't know anything about C64 or C64 BASIC, but would it be possible to intentionally write a shorter binary which will break the interpreter and do what we want instead? For example jump directly to a middle of the kernel ROM routine (akin to ROP in the modern days), or use a bad address in the "next line" offset etc.

Re: Code Golfing in Commodore BASIC

#9
post #3

In a C64 BASIC program keywords like SAVE and PRINT can be abbreviated: https://www.c64-wiki.com/wiki/BASIC_keyword_abbreviation That would shave off some more precious bytes!

Doesn’t BASIC tokenize those abbreviations to the exact same in-memory bytes like the full keywords?

Yes it does but the amount of bytes the author speaks about regards the amount of characters used for storing the program. That's why he uses the : and removes the spaces.

Re: Code Golfing in Commodore BASIC

#10
post #3

In a C64 BASIC program keywords like SAVE and PRINT can be abbreviated: https://www.c64-wiki.com/wiki/BASIC_keyword_abbreviation That would shave off some more precious bytes!

Doesn’t BASIC tokenize those abbreviations to the exact same in-memory bytes like the full keywords?

Yes. Mentioned in the link as well: "As a program is typed into the BASIC interpreter, it's tokenised: any keywords in the line get replaced by token values before being stored in memory. We can see in this line that SAVE has been replaced by command token $94".
Post reply on HN