• V0.0.5 5a24fa900e

    mmichlol released this 2026-02-07 11:02:18 +00:00 | 10 commits to main since this release

    ⚠️ IMPORTANT

    To make it work, you MUST run setup.bat as Administrator! (This adds PCC to your system PATH so the compiler can find the Standard Library).

    🚀 v0.0.5-beta - Preprocessor, Standard Library & x64 Assembly

    This major update transforms PCC from a simple interpreter into a fully modular native compiler ecosystem. It introduces the Preprocessor (for #include), a Standard Library, and expands mathematical capabilities using real x64 Assembly.

    New Features

    • Preprocessor System: Added support for #include "file.pcc" (local files) and #include <lib.pcc> (system libraries).
    • PCC Standard Library (std/): The compiler now ships with a built-in std folder. Included std/math.pcc provides functions like math_abs, power, cube, and square.
    • Expanded Math Operations: The compiler now natively generates Assembly for Multiplication (*) and Subtraction (-), in addition to Addition.
    • Smart Path Resolution: The compiler automatically locates the std/ folder relative to the PCC.exe location, allowing you to compile projects from any directory.
    • Function Arguments & Returns: Complete support for passing parameters (e.g., int add(int a, int b)) and returning values via the stack.
    • Recursion Support: Functions can now call themselves (e.g., the power function in std lib), thanks to proper stack frame management.
    • Interactive I/O: Added input() function (wrapping system getchar) to pause execution and accept user input.

    🛠 Architecture & Refactoring

    • Modular Codebase: Split source code into distinct modules: parser, codegen, preprocessor, and utils.
    • Local Scope & Stack Memory: Variables are now allocated on the stack ([rbp-offset]) enabling true function scope.
    • Runtime Evaluation: Math expressions are translated to x64 Assembly instructions (IMUL, SUB, ADD, CMP) executed by the CPU.
    • x64 Convention: Implemented Windows x64 calling convention elements (using RCX, RDX for argument passing).

    🐛 Bug Fixes

    • NASM Reserved Keywords: Fixed a crash where functions named abs or absolute conflicted with Assembly directives (renamed to math_abs in std).
    • Intermediate Variables: Fixed a critical bug where variables created during math operations (e.g., res = x * x) were not assigned stack memory correctly.
    • Parser Logic: Fixed issues with nested if blocks and function closing braces (}) that caused code to merge incorrectly.
    • Operand Size Mismatch: Fixed NASM errors by implementing movsxd for proper 32-bit to 64-bit integer promotion.

    📦 How to use:

    1. Download the latest release from the Assets section below.
    2. Unzip the archive to C:/PCC/.
    3. Run setup.bat as Administrator.
    4. Compile your code from anywhere:
      PCC.exe game.pcc
      
    Downloads