Hacker News new | past | comments | ask | show | jobs | submit login

Hmm this makes me wonder what are the pros/cons of Forth on the Z80 versus the 6502?



Good question! I have a ton of time on both of those CPUs and have written my own FORTH for both of them (as well as the 6809, 68K and another one in C just for the heck of it). The 6502 has an easier instruction set to work with but I don't think that makes all that much difference for the implementation of FORTH, it is so incredibly small that you're out of the scaffolding after the first few hours and it's all FORTH after that point.

The register sets are roughly comparable.

The hard part is dealing with interrupts (which FORTH does not have any particular method of handling), if you want to do high level (so in FORTH) interrupt service routines you're going to deal with the CPU state in a tiny bit of assembly and then run the threaded interpreter loop until you're ready to exit the ISR. IIRC this was much harder to do cleanly on the Z80 than it was on the 6502 (or maybe I just knew the 6502 better).

FORTH's tiny language core means you are abstracting out the CPU quirks very early on to the point that it is almost irrelevant which CPU it runs on. The lack of a clear dividing line between 'system' and 'user/application' programming makes it ideal for control tasks but it is hard to remain disciplined as the line count goes up.


One nice implementation of a Forth on the 6502 is Tali Forth. The documentation is wonderful too. And it's easy to extend. One thing to keep in mind when adding any assembly code of your own is that it uses part of the zero page and the X register to implement the data stack and pointer, so the X register always needs to be saved.

https://github.com/SamCoVT/TaliForth2




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: