IT-Berater Forum

CX32 and CX64 Compiler Project => Project Progress and Learning => Topic started by: Theo Gottwald on June 09, 2026, 10:58:58 PM

Title: Powerbasic PBXA64 Native x86-64 Multi-Language Compiler released
Post by: Theo Gottwald on June 09, 2026, 10:58:58 PM
PBXA64 V3 is here! - Native x86-64 Multi-Language Compiler (Alpha State)

---

Part 1: Overview

PBXA64 V3 is a native Windows compiler that translates PowerBASIC, C, PILOT, and inline assembly directly into x64 machine code - no GCC, no LLVM, no C transpilation. The output is PE32+ executables and DLLs.

Key facts:

- 110/110 tests - all CTest tests passing, 0 failures
- 4 language frontends - PowerBASIC, C (#CCODE), PILOT (#PCODE), Inline-ASM (#ASM)
- 20+ optimization passes - Constant Folding, DCE, Mem2Reg, GVN, SCCP, Inlining, LICM, Vectorization, PGO
- Own PE32+ linker - COFF objects, archives, imports, TLS, exceptions, relocations, LTO
- 408+ x64 mnemonics - Core GPR, SSE/AVX/AVX-512, BMI, AES-NI, VMX, FPU
- 44+ string builtins - TRIM$, UCASE$, LCASE$, REPEAT$, MID$, LEFT$, RIGHT$, CHR$, ASC, VAL, STR$
- Threading - THREAD FUNCTION, XLAUNCH with multi-parameter + string support
- DLL export - EXPORT, EXPORT ALIAS "Name", EXPORT ORDINAL n
- GUI / DDT - DIALOG NEW, CONTROL ADD, GRAPHIC WINDOW, menus
- Networking - TCP/UDP OPEN/SEND/RECV

Compiler pipeline:

Source (.pb/.bas/.pbi/.c/.pilot) -> Preprocessor -> Lexer -> Parser -> Semantic -> IR -> Optimizer (20+ passes) -> Codegen -> Assembler -> Linker -> PE32+ EXE/DLL

Download ZIP (9.8 MB):
https://smart-ai-robot.com/compilers/pbxa64/download/PBXA64_V3.zip

Documentation (CHM):
https://smart-ai-robot.com/compilers/pbxa64/help/index.html

Website:
https://smart-ai-robot.com/compilers/pbxa64/

---

Part 2: Detailed view with examples

Hello World (Console EXE):

#COMPILE EXE "hello.exe"
#DIM ALL

FUNCTION PBMAIN() AS LONG
    PRINT "Hello from PBXA64 V3!"
    FUNCTION = 0
END FUNCTION

Compile and run:
pbxa64 hello.pb
hello.exe

Threading with XLAUNCH (multi-parameter + strings):

THREAD FUNCTION Worker(n AS LONG, msg AS STRING) AS LONG
    PRINT "Thread " & STR$(n) & ": " & msg
    FUNCTION = n * 2
END FUNCTION

FUNCTION PBMAIN() AS LONG
    LOCAL h AS LONG
    XLAUNCH Worker(42, "Hallo aus dem Thread!") TO h
    WAITFOR h
    PRINT "Thread fertig"
    FUNCTION = 0
END FUNCTION

DLL with EXPORT/ALIAS/ORDINAL:

#COMPILE DLL "math.dll"
#DIM ALL

FUNCTION AddOne(BYVAL x AS LONG) EXPORT AS LONG
    FUNCTION = x + 1
END FUNCTION

SUB Ping() EXPORT ALIAS "PB_Ping"
END SUB

Usage:
DECLARE FUNCTION AddOne LIB "math.dll" _
    ALIAS "AddOne" (BYVAL x AS LONG) AS LONG

Inline assembler with PB variable binding:

LOCAL x AS LONG
x = 42
#ASM
    mov rax, %x
    add rax, 1
    mov %x, rax
#ENDASM

Macro preprocessor and #OVERRIDE:

#OVERRIDE TRIM$
FUNCTION MyTrim(s AS STRING) AS STRING
    FUNCTION = s
END FUNCTION

All string builtins (44+):

LEN, STRPTR, VARPTR, TRIM$, LTRIM$, RTRIM$, UCASE$, LCASE$,
REPEAT$, STRDELETE$, STRINSERT$, STRREVERSE$, BIN$, OCT$, HEX$,
REPLACE$, TALLY, VERIFY, SCAN$, MID$, LEFT$, RIGHT$, SPACE$,
CHR$, ASC, VAL, STR$, FORMAT$, BUILD$, CLIP$, RETAIN$, SHRINK$,
NUL$, DEC$, MKI$/MKL$/MKQ$/MKS$/MKD$, CVI/CVL/CVQ/CVS/CVD,
JOIN$, SPLIT, PEEK$, INPUT$, INKEY$, WAITKEY$, COMMAND$,
ENVIRON$, CURDIR$, TAB$

Command-line options:

-o <file>    Output filename
-c            Compile only (object)
-S            Assembly only
/exe / /dll  EXE or DLL
-O0 to -O3    Optimization levels
--pgo-generate/use  Profile-guided optimization
--flto=full|thin    Link-Time optimization
-g / /debug  Debug info
--dump-tokens/ast/ir  IR dumps
-Wall / -Wextra / -Werror  Warnings
--subsystem=console|windows  Subsystem

Data types:

BYTE    1    Unsigned 8-bit
WORD/INT 2    16-bit
DWORD/LONG 4  32-bit
QUAD    8    64-bit
SINGLE/DBL 4/8 Float
STRING  16  Dynamic (ptr + len)
WSTRING  16  UTF-16
VARIANT  16  COM

Control flow: IF/THEN/ELSE/END IF, SELECT CASE, FOR/NEXT, WHILE/WEND, DO/LOOP, GOTO, GOSUB/RETURN, ON ERROR/RESUME, DATA/READ/RESTORE

Full WinAPI integration:

DECLARE FUNCTION MessageBoxA LIB "user32.dll" _
    ALIAS "MessageBoxA" (BYVAL hWnd AS LONG, _
    lpText AS ASCIIZ, lpCaption AS ASCIIZ, _
    BYVAL uType AS LONG) AS LONG

FUNCTION PBMAIN() AS LONG
    MessageBoxA 0, "Hello from PBXA64!", "Info", 0
    FUNCTION = 0
END FUNCTION

# PBXA64 — Features

x64 Windows compiler: PB, C, PILOT, inline ASM → PE32+ executables
Version 0.65.0-B25 | Target: x86_64-pc-windows-msvc

---

## Frontend Languages

### PowerBASIC (`.pb`, `.bas`, `.pbi`, `.inc`)
Full PB syntax: `#DIM ALL`, `DECLARE`/`LIB`/`ALIAS`, `FUNCTION PBMAIN`, `SUB`/`FUNCTION`, `LOCAL`/`GLOBAL`/`SHARED`/`STATIC`, `TYPE`/`UNION`/`ENUM`, `MACRO`/`MACROFUNCTION`, `#INCLUDE`, conditional compilation, `#ASM`/`#CCODE`/`#PCODE` directives.

### C (via `#CCODE` / `#ENDC`)
C-style lexing/parsing → MGC IR: struct/union/typedef/enum/pointer/array, extern function decls, initializers.

### PILOT (via `#PCODE` / `#ENDP`)
Educational PILOT language: `T:`/`A:`/`M:`/`Y:`/`N:`/`J:`/`U:`/`E:` commands, conditional suffixes, pattern matching.

### Inline Assembler (`#ASM` / `#ENDASM`)
Intel-syntax x64 blocks with `CLOBBER`/`UNSAFE`/`ALLOW_PRIVILEGED`, variable binding (`%var`, `{var}`), ASMDATA.

---

## Data Types

| Type | Size | Description |
|------|------|-------------|
| `BYTE` | 1 | Unsigned 8-bit |
| `WORD` | 2 | Unsigned 16-bit |
| `INTEGER` | 2 | Signed 16-bit |
| `DWORD` | 4 | Unsigned 32-bit |
| `LONG` | 4 | Signed 32-bit |
| `QUAD` | 8 | Signed 64-bit |
| `SINGLE` | 4 | IEEE 754 32-bit float |
| `DOUBLE` | 8 | IEEE 754 64-bit float |
| `STRING` | 16 | Dynamic descriptor (ptr + len) |
| `WSTRING` | 16 | UTF-16 descriptor |
| `VARIANT` | 16 | COM VARIANT |
| `ASCIIZ PTR` | 8 | Pointer to NUL-terminated string |
| Pointer types | 8 | `BYTE PTR`, `WORD PTR`, `DWORD PTR`, `LONG PTR`, `QUAD PTR` |

---

## PB Language Features

### Control Flow
`IF`/`THEN`/`ELSE`/`ELSEIF`/`END IF`, `SELECT CASE`, `FOR`/`NEXT`, `WHILE`/`WEND`, `DO`/`LOOP`, `GOTO`, `GOSUB`/`RETURN`, `EXIT`/`ITERATE`, `ON ERROR`/`RESUME`, `DATA`/`READ`/`RESTORE`.

### String Builtins (44+)
`LEN`, `STRPTR`, `VARPTR`, `TRIM$`, `LTRIM$`, `RTRIM$`, `UCASE$`, `LCASE$`, `REPEAT$`, `STRDELETE$`, `STRINSERT$`, `STRREVERSE$`, `BIN$`, `OCT$`, `HEX$`, `REPLACE$`, `TALLY`, `VERIFY`, `SCAN$`, `MID$`, `LEFT$`, `RIGHT$`, `SPACE$`, `CHR$`, `ASC`, `VAL`, `STR$`, `FORMAT$`, `BUILD$`, `CLIP$`, `RETAIN$`, `SHRINK$`, `NUL$`, `DEC$`, `MKI$`/`MKL$`/`MKQ$`/`MKS$`/`MKD$`, `CVI`/`CVL`/`CVQ`/`CVS`/`CVD`, `JOIN$`, `SPLIT`, `PEEK$`, `INPUT$`, `INKEY$`, `WAITKEY$`, `COMMAND$`, `ENVIRON$`, `CURDIR$`, `TAB$`.

### Math Builtins
`ABS`, `MIN`, `MAX`, `CLAMP`, `INT`, `FIX`, `SGN`, `FRAC`, `SIN`/`COS`/`TAN`/`ATN`/`SQR`/`EXP`/`LOG`, `RND`/`RANDOMIZE`, `ROUND`, `POW`.

### Arrays
Fixed arrays (`DIM a(100)`), dynamic-style (`DIM a()` + `REDIM`), `LBOUND`/`UBOUND`, `ARRAY ASSIGN`/`SORT`/`COPY`/`SCAN`/`REVERSE`.

### File I/O
`OPEN` (OUTPUT/APPEND/INPUT/RANDOM/BINARY), `CLOSE`, `PRINT #`, `INPUT #`, `LINE INPUT #`, `GET`/`PUT`, `SEEK`, `LOF`/`EOF`/`LOC`, `KILL`, `NAME`, `MKDIR`, `CHDIR`, `DIR$`, `FILECOPY`, `RMDIR`, `GETATTR`/`SETATTR`, `RESET`, `FLUSH`, `SETEOF`, `REMAIN$`, `FREEFILE`.

### Threading
`THREAD FUNCTION`, `XLAUNCH`, `WAITFOR`, `THREAD CLOSE`/`SUSPEND`/`RESUME`/`STATUS`.

### COM/OOP
`CLASS` vtables, `IUnknown`, COM runtime: `VariantInit`/`VariantClear`, `CoCreateInstance`, `SysAllocStringByteLen`.

### GUI / DDT
`DIALOG NEW`, `CONTROL ADD`, `GRAPHIC WINDOW`, `LINE`, `BOX`, `PAINT`, `CIRCLE`, `MENU` system.

### Networking (Winsock)
`TCP`/`UDP` `OPEN`, `SEND`, `RECV`, `NOTIFY`.

---

## Compilation Pipeline

| Stage | Description |
|-------|-------------|
| Driver | CLI parsing, file discovery |
| Preprocessor | Macro expansion, `#INCLUDE`, `#IF` |
| Lexer | Tokenization |
| Parser | AST construction (recursive-descent) |
| Semantic | Type checking, symbol resolution, `#DIM ALL` |
| IR | PB HIR → MGC IR bridge |
| Optimizer | Pass manager + 20+ optimization passes |
| Codegen | Instruction selection, register allocation, MIR |
| Assembler | Intel-syntax encoding, COFF output |
| Linker | Object merge, symbol resolution, PE32+ write |

---

## Optimizer Passes (20+)

- Constant Folding
- Dead Code Elimination
- Mem2Reg (memory-to-register promotion)
- Copy Propagation
- CFG Cleanup
- Strength Reduction
- Instruction Combining
- Branch Simplification
- SCCP (sparse conditional constant prop)
- GVN (global value numbering)
- Dead Store Elimination
- ADCE (aggressive DCE)
- Reassociation
- Load Forwarding
- SROA (scalar replacement of aggregates)
- Inlining (CGSCC with cost model)
- LICM (loop-invariant code motion)
- FMA Contraction
- Auto-vectorization
- Profile-Guided Optimization (PGO)

---

## Assembler (408+ Mnemonics)

| ISA Family | Mnemonics |
|------------|-----------|
| Core GPR | ~400 |
| SSE/SSE2/SSE3/SSSE3/SSE4 | ~300 |
| AVX/AVX2/AVX-512/FMA | ~500 |
| BMI1/BMI2 | ~16 |
| AES-NI/SHA/Crypto | ~25 |
| System instructions | ~50 |
| SGX/VMX/CET | ~40 |
| MMX | ~60 |
| x87 FPU | ~80 |
| Cache control/Prefetch | ~20 |

Operand support: x64 GPRs (8/16/32/64-bit), XMM registers, 6 addressing modes, 21 operand kind variants, segment overrides, relative calls/jumps.

---

## Linker (PE32+)

- COFF object loading and merge
- Static library (`.lib`) archive extraction
- Symbol resolution (weak/strong/multiple-defined)
- Relocation processing (ADDR64, REL32, SECREL)
- Import table (IID/INT/ILT/IAT)
- PE32+ header + section table
- TLS directory (`.tls`)
- Load Config directory (`.lc`)
- Exception data (`.pdata`/`.xdata`)
- Debug directory + CodeView
- Base relocations (`.reloc`)
- DLL output (`.edata` export table)
- Resource compilation (`.res` → `.rsrc`)
- Post-link optimization (DCE, ICF, strip)
- Link-Time Optimization (LTO)
- PE verification

---

## Command-Line Options

### Output
| Flag | Description |
|------|-------------|
| `-o <file>` | Output filename |
| `-c` | Compile only (object file) |
| `-S` | Assembly only |
| `-E` | Preprocess only |
| `/exe` | Create executable (default) |
| `/dll` | Create DLL |

### Optimization
| Flag | Description |
|------|-------------|
| `-O0` | No optimization (default) |
| `-O1` | Safe scalar pipeline |
| `-O2` | SSA optimizer pipeline |
| `-O3` | O2 + late scalar cleanup |
| `--pgo-generate` | Profile-guided optimization |
| `--pgo-use=<file>` | Apply PGO profile |
| `--flto=full\|thin` | LTO mode |

### Diagnostics
| Flag | Description |
|------|-------------|
| `--diagnostic-format=text\|json\|sarif` | Output format |
| `--diagnostic-color=auto\|always\|never` | Color mode |
| `-Wall` / `-Wextra` / `-Werror` | Warning control |

### Debug
| Flag | Description |
|------|-------------|
| `-g` / `/debug` | Debug info |
| `-v` / `--verbose` | Verbose output |
| `--dump-tokens` / `--dump-ast` / `--dump-ir` | IR dumps |

---

## Test Coverage

**110/110 CTest tests passing** across:
- Frontend (PB lexer, parser, compiler versions, HIR bridge)
- C frontend (constexpr, prototypes, AST, IR lowering, codegen)
- Middle-end (CFG, SSA, optimizer, vectorize, mem2reg)
- Backend (ABI, instruction selection, register allocation, MIR)
- Assembler (mnemonic encoding, COFF writer)
- Linker (PE section layout)
- Driver (CLI, diagnostics)
- Runtime suite (end-to-end PB programs)
- Negative suite (error handling)
- ASM mnemonics suite (encoding verification)

---

## Help System

Compiled HTML Help (`.chm`) with 14 reference pages covering:
- Assembler overview (syntax, variable binding, macros)
- Directives reference
- 6 addressing modes, 21 operand variants
- 10 ISA family pages with mnemonic tables

Security and integrity:

- Digitally signed by Theo Gottwald
- 110 automated tests passing
- SHA256 checksums included

Download: https://smart-ai-robot.com/compilers/pbxa64/download/PBXA64_V3.zip (9.8 MB)

Questions, feedback, bug reports? -> info@it-berater.org


The first ALpha release is just to show you "its real" and you can play with it.
I just got this message from the responsible Agent.
The good news is - will be fixed soon.
Found 12 failures. Categories:
- File I/O parse errors (file_write_read.pb): PRINT #f, CLOSE #f, OPEN #f, LINE INPUT #f syntax not parsed
- Missing runtime stubs: SIN, COS, TAN, ATN, EXP, LOG, __pb_int, __pb_fix, ROUND, __pb_sgn, HEX, INSTR, STRING, __pb_space, __pb_left, FORMAT, __pb_freefile
Let me investigate the runtime stubs to understand which are missing vs. unimplemented.
# Todos
[✓] Explore testing infrastructure (TestingLane, CTest, test scripts)
[✓] Compile all existing samples with PBXA64, find compilation/runtime bugs
[ ] Investigate and fix: File I/O parse errors (PRINT#, CLOSE#, OPEN#, LINE INPUT#)
[ ] Investigate and fix: Missing math runtime stubs (SIN, COS, TAN, ATN, EXP, LOG, INT, FIX, ROUND, SGN, HEX)
[ ] Investigate and fix: Missing string runtime stubs (INSTR, STRING$, SPACE$, LEFT$, FORMAT$)
[ ] Rebuild compiler and re-test all samples
[ ] Write new stress-test programs for uncovered features
[ ] Add tests to TestingLane for any fixed bugs