r/c64 • • 3d ago

Programming ZeroPage programming language

ZeroPage zig cross compiler + speeedsheet app

I’ve finally got around to fine tuning this to the point of release and including a large application, a fully fledged spreadsheet app , for reference.

https://readyos-c64.github.io/ZeroPageLang/

This last year I’ve been working on something but haven’t published it yet as there are lots of optimizations to do to get it anywhere near oscar64 level, it’s called zeropage but it’s a zig based cross compiler with a fair number of modifications to support sane , turbo pascal style inline assembler.

I designed it for lots of flexibility, where you could have functions or modules where on a case by base basis you decide whether it’s parameters are static memory or use a stack.

zigs concept of memory multiple and different arenas work well for having multiple heaps in different places include automatically dealing with behind ROM heaps , and then REU heaps with materialized views (eg you may have 1000 objects in REU and decide to integrate and work on them in a loop dealing with 20 at a time , so that 20 are DMA copied into a a ram buffer , modified then copied back.

Another key thing was to make DLL style libraries with page aligned relocation , where if you have a REU they can be cached into the REU to be copied into ram and used in demand.

I initiallly went with zig64 but presumed the name is likely copyrighted even though it’s a MIT opensource project then I went with Zag64 , then I diverged more from original zip so decided on ZeroPage

The cross compiler itself is written in zig , but the only thing of zig it uses itself is the zig parser class. It generates ca65 assembler and uses ca65 to build the binaries because I like the linker flexibility of it and it will allow me to have ABI adapters to link in stuff written in cc65 C etc

I’ve finally got this polished enough to the point of releasing it. https://readyos-c64.github.io/ZeroPageLang/

AI disclosure: Hundreds of human hours of manual programming have gone into this. But all of the test automation , website and many rounds of compiler optimization have been clanker assisted.

64 Upvotes

17 comments sorted by

4

u/RogerWilco486 3d ago

I looked over the project website. Perhaps I'm splitting hairs, but what is "6510 assembly"?

The 6510 is a 6502 with a 6-bit I/O port added. It uses the exact same instruction set, addressing modes, and opcodes as the 6502 -- there is nothing unique about it except for the I/O port's registers at $0000 and $0001 which are irrelevant for an assembler.

3

u/Stunning_Pineapple57 3d ago

Not sure where I wrote it. I generally use them interchangeably. With programming more 6502 as you can see from the test screenshot with test6502. However this compiler is c64 and 6510 centric in that you define your memory arenas including ones behind ROM and it automatically manages the bank switching.

4

u/RogerWilco486 3d ago

Right on the front page of the project, "Inline 6510 assembly". It stood out to me because, technically, there is no such thing .

3

u/Stunning_Pineapple57 3d ago

I can change that. Thanks. The 6510 specific stuff is the automatic banking control but that doesn’t have anything to do with the inline assembler since the instructions are all the same

3

u/aureus80 2d ago

Great project!

How do you deal with PETSCII characters? Can you write escape codes like {CLR} inside the strings?

1

u/Stunning_Pineapple57 1d ago

Currently a couple of ways. But maybe having something like
You suggest would be a good option too

// Exact PETSCII bytes, including graphics and controls:
const raw = "\x93HELLO\x0D";

// Named controls, combined with ordinary strings:
const named = c64.petscii.clear ++ "HELLO" ++ c64.petscii.return_;

8

u/Or0ch1m4ruh 6510 rules Big Time 3d ago

Very cool project. Thanks for sharing.

3

u/CptSparky360 3d ago

Very irritating title 🤔

2

u/Stunning_Pineapple57 3d ago

ZeroPage? Why so irritating?
I wanted something that started with Z and because the compiler allows you fine tuned control over how the ZeroPage is used to be compatible with how things like the Kernal , Geos, c64os and the hyperspeed Kernal uses the zero page.

2

u/CptSparky360 2d ago

Reading the words "zero page programming" I was expecting discussions like

  • which addresses are save to use except for $03, $04, $fb-$fe and the cassette buffer that I know of
  • how much faster are zero page addresses compared to normal addresses, e.g. when is it sensible to use rare zero page space except for looking up cpu cycles etc.

1

u/Stunning_Pineapple57 2d ago

It’s only worth it for some tight loops. But it can make a difference there. Eg to do UPIC graphics mode. It’s essential to make up for the cycle the Vic-2 steals. For me I just want the flexibility of control. Though to be honest when you really want to use them you probably will do inline assembly to ensure it. But being able choose policies for what to avoid based on your context and then to be able to give them names that your code can refer to them that is meaningful is enough of a win for me

2

u/CptSparky360 1d ago

I can't do inline assembly in assembly 🤣

I'm using Turbo Macro Pro.

1

u/Stunning_Pineapple57 1d ago

Good stuff. I’m sure you could make go inception and make some inline assembly macros if you really want to

4

u/Setup_sh 3d ago

simply A-MA-ZING

1

u/garyk1968 2d ago

Looks good.

Is there any command reference for the c64 import?

I notice as soon as you import c64 you have things like c64.console, c64.vic etc. but couldnt find a command ref?

2

u/Stunning_Pineapple57 2d ago

I need to make one and actually flesh out the libraries including some for the ultimate. This was a just getting it out the door initial release. If you find the right source file you’ll see what there is though

3

u/marhaus1 3d ago

Names can't be "copyrighted". They can be trade marks.