News for hackers. Stuff that matters.
Re:How I learned to program a Commodore 64 in BASIC and comp... by tyingq on Sunday February 26, 2023 @08:16AM (#34945279)
Made me recall this article on why the 6502 isn't great as a C target, including a follow up with some pointers on avoiding some issues with it.

https://www.xtof.info/coding-c-8-bit-6502-cpu.html

Re:How I learned to program a Commodore 64 in BASIC and comp... by lifepillar on Sunday February 26, 2023 @08:57AM (#34945571)
Yeah, it’s better to use a “high-level” language designed for the architecture, such as this: https://github.com/dschmenk/PLASMA
Re:How I learned to program a Commodore 64 in BASIC and comp... by ajross on Sunday February 26, 2023 @11:31AM (#34946783)
FWIW: really the best example of that kind of thought was OSS's "Action!" language for the Atari computers. Unlike all the modern ideas in this space, this was actually a contemporary product (released in 1983). It's a little like K&R C in terms of semantics, with a bunch of concessions[1] to the limitations of the device.

Alas it came at a time in history where it couldn't make much impact. The Atari platform was being eclipsed by Commodore at the time, and the market for Serious Tool Development in the desktop world was swinging hard toward IBM (Turbo Pascal for MSDOS was arriving right about the same time).

[1] Like a more pascal-ish syntax. Atari didn't have curly braces on its keyboard! Also IIRC "POINTER" types were limited to being statically linked into the zero page, as that matched the operation of the hardware without requiring the runtime to move stuff around for you every time you wanted in do a load.

Re:How I learned to program a Commodore 64 in BASIC and comp... by zozbot234 on Sunday February 26, 2023 @12:17PM (#34947225)
> Atari didn't have curly braces on its keyboard!

Isn't that why C also allows the <% and %> digraphs as alternatives?

Re:How I learned to program a Commodore 64 in BASIC and comp... by ajross on Sunday February 26, 2023 @12:27PM (#34947331)
Not the Atari itself, which never had a C compiler. But systems like that, yeah. Lots of 70's systems were designed for non-ASCII or ASCII-subset[1] character sets, whereas Unix had made very comfortable use of every funny symbol it could find.

[1] e.g. the original Apple II character ROM had only the 64 characters from 0x20 to 0x5f (no lower case, even) squished into 6 bits of addressing. The keyboard reflected that limitation, as did those from Atari and Commodore. This wasn't rectified by Apple itself until the IIe, though there were 80 column cards on the market from 1980 on that implemented the full

Re:How I learned to program a Commodore 64 in BASIC and comp... by zozbot234 on Sunday February 26, 2023 @09:21AM (#34945743)
CC65 is just not a very good compiler by modern standards. There's an experimental 6502 backend for LLVM that outputs fairly good code. (A Z80 backend also exists, AIUI.)
Re:How I learned to program a Commodore 64 in BASIC and comp... by AlexeyBrin on Sunday February 26, 2023 @09:51AM (#34945959)
Do you know if the 6502 LLVM backend has floating point support ? A big problem with CC65 is the lack of floating point support.

EDIT: The answer is no:

https://github.com/llvm-mos/llvm-mos-sdk#notably-missing-fea...

Re:How I learned to program a Commodore 64 in BASIC and comp... by royjacobs on Sunday February 26, 2023 @10:25AM (#34946227)
What kind of stuff do you want to do on a 6502 that requires emulated floating point support?
Re:How I learned to program a Commodore 64 in BASIC and comp... by AlexeyBrin on Sunday February 26, 2023 @10:28AM (#34946250)
It is nice to have, most BASIC versions that run on 6502 micros had floating point support.
Re:How I learned to program a Commodore 64 in BASIC and comp... by zozbot234 on Sunday February 26, 2023 @12:03PM (#34947091)
The "floating point" support that's in 6502 BASIC ROMs is not real IEEE 754 floating point though, see https://en.wikipedia.org/wiki/Microsoft_Binary_Format So it shouldn't be used to replace that, though of course one can use it for other purposes with some care. (It goes without saying that this is not hardware floating point, so the only potential gain from piggybacking on these ROM routines will be some saving in code size.)
Re:How I learned to program a Commodore 64 in BASIC and comp... by diydsp on Sunday February 26, 2023 @03:05PM (#34948828)
I wouldnt mind generating lookup tables at run time rather than my present system of exporting them via python etc... the algs could be more dynamic!
Re:How I learned to program a Commodore 64 in BASIC and comp... by galangalalgol on Sunday February 26, 2023 @10:00AM (#34946040)
So maybe someday we could do rust for the c64?
Re:How I learned to program a Commodore 64 in BASIC and comp... by ipaddr on Sunday February 26, 2023 @12:34PM (#34947394)
The people old enough to want to program on the c64 are not the same group of younger hipster who want to rustify the world. It would take someone to bridge these groups.
Re:How I learned to program a Commodore 64 in BASIC and comp... by zozbot234 on Sunday February 26, 2023 @12:47PM (#34947509)
Yup, it's fun to think that the rust_embedded ecosystem could be repurposed with comparable ease to support bare-metal retro programming. Similar to how Rust itself bridges the "low-level C/C++" and "hipster high level language" worlds.
Re:How I learned to program a Commodore 64 in BASIC and comp... by galangalalgol on Monday February 27, 2023 @07:28PM (#34964119)
I guess I'm an old hipster that wants to rustify the world? I started on c64 basic as a tiny kid.
Re:How I learned to program a Commodore 64 in BASIC and comp... by mysterymath on Wednesday March 01, 2023 @01:52AM (#34979499)
Re:How I learned to program a Commodore 64 in BASIC and comp... by 0xcde4c3db on Sunday February 26, 2023 @10:01AM (#34946045)
There's a great talk [1] in which C++17 features are used to build an efficient Pong clone on C64. As I recall, the author wound up writing an (obviously limited) x86-to-6502 translator to get around the lack of 6502 support.

[1] https://www.youtube.com/watch?v=zBkNBP00wJE

Re:How I learned to program a Commodore 64 in BASIC and comp... by AlexeyBrin on Sunday February 26, 2023 @03:53PM (#34949305)
Last year, the author tried a slightly different approach: use GCC to compile for AVR 8 bits, than translate the AVR assembly to 6502:

https://www.youtube.com/watch?v=EIKAqcLxtT0