KickC is a C-compiler for 6502-based platforms creating readable assembler code
63 points by muterad_murilax 1 year ago | 14 comments- dzdt 1 year agoThe 6502 is somewhat famously a hard target for the C language, and KickC does quite well at producing good results in spite of this. The C language is heavily based around pointers and stack usage. The 6502 has a minimal hardware stack: 256 bytes with no stack-relative addressing. So a "stack frame" is an alien concept that requires slow workarounds to emulate. And the 6502 only has pointers in the form of words stored in the first 256 bytes of RAM ("zero page") and also requires the use of one of the three registers to dereference.
- WalterBright 1 year agoThe way to do it is to make a C-like language that has types and operators that map easily onto the 6502 architecture.
After all, C was designed to map onto the PDP-11 architecture - things like postincrement.
- polymipisexp 1 year agoThe PDP-11 postincrement thing is very often repeated, and I'm sure there are good reasons to suspect it, but here is one bit of evidence to the contrary I find convincing
- billyjobob 1 year ago
- flohofwoe 1 year agoThere's also millfork which is a "mid-level" language specifically for 8-bit CPUs:
- flohofwoe 1 year ago
- polymipisexp 1 year ago
- Joker_vD 1 year agoThe 6502's stack is intended to be mostly a call stack, with maybe a temporary or two stored while you juggle the registers, not a place for your data frames. From what I vaguely recollect, the cc65 uses Y as the stack pointer, but only when it actually needs stack-like behaviour; at other times it uses static allocation a la Fortran, or so I think.
- WalterBright 1 year ago
- ruk_booze 1 year agoHeh, the repo comes with the cruncher plugins I once hacked up for Kick Assembler. Cool!
https://gitlab.com/camelot/kickc/-/tree/master/repo/se/triad...
- NonEUCitizen 1 year agoThe README says:
"KickC is currently in beta, and at times crash or creates ASM code that does not work properly."
- omoikane 1 year agoIt's also lacking support for 2D arrays, recursive functions, etc.:
https://docs.google.com/document/d/1JE-Lt5apM-g4tZN3LS4TDbPK...
- snvzz 1 year agoSounds like your average compiler.
- omoikane 1 year ago
- pjmlp 1 year agoGiven the 6502 limitations, performance with good comments is much more relevant.
Otherwise, kudos for the effort.
- ok123456 1 year agoIs there a comparison against cc65?
- dzdt 1 year agocc65 aims for full C language support, which kickC does not have, but cc65 code will never look like hand assembly which kickC often does.
- NonEUCitizen 1 year ago
- dzdt 1 year ago
- KingLancelot 1 year ago[dead]