Skip to content

Releases

KickC Enhanced 0.10.1

Choose a tag to compare

@AndreR AndreR released this 10 Nov 06:20

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 to sizeof(arr)/sizeof(arr[0])
  • Typed enums: enum : uint8_t guarantees 1-byte storage
  • Digit separators (1_000, 0b1100_0011), nullptr, empty initialization ({})
  • Named loops: break outer; / continue outer;, including from inside nested switch blocks
  • 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_24 with <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 dense switch statements; 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 generation
  • fast_mul8u() in <multiply.h>: quarter-square multiplication, about 24 cycles
  • delay_cycles(N) in <6502.h>: cycle-exact delay via BIT $00 + NOP sequences
  • __builtin_lut(size, expr): compile-time lookup table generation for array initializers
  • Carry-flag boolean returns (__carry)
  • __ax 16-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/sprintf 8/16-bit fast paths
  • 2–4 byte assignment loop unrolling
  • New c64-baremetal target 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), fast strlen, fast print_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
  • __ax calling convention: register X liveness validation, struct exclusion
  • Fixed-point: hex integer parsing conflict with f8/f16 literal suffixes
  • c64-fastio: 1541/1581 directory sector offset constants

KickC Enhanced 0.9.0

Choose a tag to compare

@AndreR AndreR released this 07 Nov 07:38

KickC Enhanced 0.9.0

KickC Enhanced is an optimizing C99 compiler fork for the MOS 6502/6510 family (C64, VIC-20, Plus/4, NES, Atari XL, Mega65). This release introduces major performance leaps, advanced peephole optimization passes, and 267 new MOS 6502 ASM synthesis fragments.

Highlights & Key Improvements

  • 267 New / Repaired MOS 6502 ASM Fragments:

    • Native struct-pointer decrements and member comparisons (if (arr[i].val > 0) arr[i].val--;).
    • Optimal zero-branch boolean NOT (!) lowerings.
    • Direct 32-bit (dword) comparisons against zero.
    • 16-bit word byte-aligned shifts lowered to 4-instruction transfers without shift loops.
    • Word pointer indexing, memory-offset arithmetic, and complementary signed/unsigned casts.
  • NMOS-6510 Undocumented / Illegal Opcode Synthesis:

    • Active when targeting mos6502x / rom6502x.
    • Synthesizes deterministic green opcodes: LAX, SAX (3-cycle zero-page stores), ALR #{imm}, DCP, ISC.
    • Redundant CMP #0, CPX #0, CPY #0 elimination and branch flag predication.
    • 16-to-8 bit right-shift by 2 folding via accumulator (lsr; lsr).
  • Tail Call Optimization (TCO) & Return Trampoline Relaxation:

    • Converts function tail calls (jsr target; rts) into jmp target.
    • Analyzes conditional long branch trampolines jumping to function return blocks and relaxes them directly to local inverted branches and returns.
  • Dead Store & Dead Load-and-Store Pair Elimination:

    • Linear $O(1)$ elimination of unused temporary stores and dead function returns.
    • Recursive CanonicalResolver tracks all .label Name = Target definitions and address aliases to ensure variables read under aliases are never falsely eliminated.
    • Safe register A tracking preserves preceding loads when subsequent instructions consume register A.
  • Static Register Tracking Across Anonymous Forward Labels:

    • Tracks static values of A, X, and Y across local forward-only labels (!:) when skipped instructions do not modify the registers, eliminating thousands of redundant loads in tight loops.
  • Multi-Core Compiler Architecture & Speedups:

    • Parallel dominator tree calculation and multi-core register uplift analysis.
    • Reduces compilation times for massive multi-bank codebases from >20 minutes down to ~90 seconds.

Installation & Usage

Download and extract kickc-release.zip. Requires Java 8 or higher.