• mmichlol released this 2026-02-06 20:26:19 +00:00 | 13 commits to main since this release

    ⚠️ IMPORTANT

    To make it work, you MUST run setup.bat as Administrator!

    🚀 v0.0.3-beta - Modular Architecture & x64 Assembly Overhaul

    This major update transforms PCC from a simple calculator/interpreter into a true native compiler that generates optimized x64 assembly code.

    New Features

    • Function Arguments & Returns: Complete support for passing parameters (e.g., int add(int a, int b)) and returning values using return.
    • Local Scope & Stack Memory: Variables are now allocated on the stack ([rbp-offset]) instead of global maps, enabling true function scope.
    • Runtime Evaluation: Math expressions (+, -, ==) are now translated to Assembly instructions (ADD, CMP, SETE) and executed by the CPU, not pre-calculated by the compiler.
    • Interactive I/O: Added input() function (wrapping standard getchar) to pause execution and accept user input.
    • Improved Boolean Logic: if statements now correctly handle comparisons (==) using jump instructions (JMP, JZ).

    🛠 Architecture & Refactoring

    • Modular Codebase: Split the monolithic source code into distinct modules:
      • parser.cpp (Syntax analysis)
      • codegen.cpp (Assembly generation)
      • utils.cpp (String helpers)
    • Intermediate Representation (IR): Replaced direct execution with an Instruction struct system, decoupling parsing from code generation.
    • x64 Convention: Implemented Windows x64 calling convention elements (using RCX, RDX for argument passing).

    🐛 Bug Fixes

    • Parser Ambiguity: Fixed issues where variable declarations with assignments (int a = b) were sometimes mistaken for function definitions.
    • Operand Size Mismatch: Fixed NASM errors by implementing movsxd for proper 32-bit to 64-bit integer promotion.
    • Label Redefinition: Fixed logic for generating unique jump labels (L_1, L_2) in control flow statements.

    📦 How to use:

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