Repository navigation
KickC Enhanced is a fork of the KickC compiler for the MOS 6502/6510 family (Commodore 64, VIC-20, Plus/4, NES, Atari XL/XE, MEGA65, Commander X16). This release adds C11/C23/C2Y language features, 24-bit and fixed-point integer types, an expanded optimizer and code generation pipeline, and a significantly expanded standard library.
Language features
static_assert/_Static_assert(C11/C23)countof()(C2Y N3169) as a type-safe alternative tosizeof(arr)/sizeof(arr[0])- Typed enums:
enum : uint8_tguarantees 1-byte storage - Digit separators (
1_000,0b1100_0011),nullptr, empty initialization ({}) - Named loops:
break outer;/continue outer;, including from inside nestedswitchblocks - Statement initializers in
if/switch(C2Y / C++17) _Generic(C11), anonymous structs and unions (C11)#embed(C23) for embedding binary resources into linker segments
New types
__int24/__uint24: 24-bit (tri-byte) integers, range up to 16.7M, full conversion matrix to byte/word/dword, division and modulo routines- Fixed-point family:
fixed8_8,fixed16_8,fixed8_16,fixed16_16,fixed8_24with<fixedpoint.h>and native literal suffixes (f8,f16,f24)
Optimizer and code generation
- Pass 5: loop index register pinning; zero-waste loop alignment (
.align $100, guarded against linear fall-through); split RTS jump tables for denseswitchstatements; multi-entry byte skipping - Pass 2: loop invariant code motion (LICM), cross-block GCSE, fast comparisons, dead stack pull fusion, inline
abs -fconvenience: constant-expression rewriting — shift-add multiplication, reciprocal division, and modulo reduction for 8/16-bit constants, with per-constant helper subroutine generationfast_mul8u()in<multiply.h>: quarter-square multiplication, about 24 cyclesdelay_cycles(N)in<6502.h>: cycle-exact delay viaBIT $00+NOPsequences__builtin_lut(size, expr): compile-time lookup table generation for array initializers- Carry-flag boolean returns (
__carry) __ax16-bit register pair calling convention#pragma segment_type(..., ROM): compile-time enforcement of ROM immutability and cross-bank call assertions- 6,000+ additional 6502 assembly fragments (byte/word/tri-byte/dword)
printf/sprintf8/16-bit fast paths- 2–4 byte assignment loop unrolling
- New
c64-baremetaltarget without default kernal zero-page reservations
Standard library and C64 hardware
<fixedpoint.h>: fixed-point arithmetic<c64-disk.h>: KERNAL disk and IEC bus I/O<c64-fastio.h>: high-speed disk I/O with drive probing and KERNAL fallback<c64-fade.h>: perceptual luminance fading<c64-mouse.h>: 1351 mouse driver<c64-raster.h>: raster sync<reu.h>: 17xx REU driver<zx02.h>: universal ZX02 decompressor<rle.h>: PackBits RLE compression<bcd.h>: BCD (binary-coded decimal) arithmetic<limits.h>,<stdbool.h>,<time.h>: standard C headers- PRNG suite (
rand8/rand32), faststrlen, fastprint_uchar_decimal
Bug fixes
- Pass 4: false register clobber warning on indexed pointer dereferencing
- Zero-waste loop alignment could emit misaligned code for blocks entered via linear fall-through
__axcalling convention: register X liveness validation, struct exclusion- Fixed-point: hex integer parsing conflict with
f8/f16literal suffixes c64-fastio: 1541/1581 directory sector offset constants