# PBXB64 — Pure-C Multi-Language Compiler for Windows x64

PBXB64 is a self-contained compiler toolchain producing PE32+ executables. All frontends (PB/BASIC, PILOT, B64, C, x64 ASM) compile directly through native C17 code — **no Python, no external translators**.

## Native input paths

| Input | Frontend |
|---|---|
| `.b64` | Native B64 frontend → IR → x64 → COFF → PE |
| `.asm`, `.s` | Native x64 assembler → COFF → PE |
| `.pil` | Native PILOT frontend → IR → x64 → COFF → PE |
| `.pb`, `.bas`, `.pba`, `.basic`, `.pbas` | Native PB/BASIC frontend → IR → x64 → COFF → PE |
| `.c`, `.h` | Native C17 frontend |
| `.obj`, `.lib` | Native linker input |

## V6 validation status (2026-06-14)

Validated from `core/build/PBXB64`, rebuilt from the V6 source tree:

```
PBXB64 version 0.50.0-V6
```

### Test pass summary

| Category | Pass | Expected fails | Total |
|----------|------|---------------|-------|
| Assembly (-S) | 291 | 0 | 291 |
| PB Link+Run | 92 | 0 | 92 |
| B64 Link+Run | 13 | 0 | 13 |
| C Compile (-S) | 97 | 33 (c_hlib sources without `main()`) | 130 |
| C Link+Run | 2 | 0 | 2 |
| **Total** | **495** | **33** | **528** |

**Zero unexpected fails. Zero regressions. All tests pass for real.**

### Key milestones in V6

| Area | Milestone |
|------|-----------|
| **H-Lib containers** | 22 native container families (`Arr`, `Stk`, `Que`, `Lst`, `Str`, `2D`, `Hsh`, `Tre`, `DTre`, `Tri`, `Heap`, `Deque`, `Set`, `Graph`, `Multiset`, `UnionFind`, `LRU`, `Ring`, `SkipList`, `BPTree`, `Quadtree`, `Bloom`, `Safe`) with auto-init/final and method dispatch. |
| **Container params & returns** | Containers can be passed `BYVAL`/`BYREF` and returned from `FUNCTION`; ownership is moved automatically. 23 per-family regression tests cover every H-Lib family. |
| **Container subscripts** | `a[1]` / `a[1] = x` syntax for indexed/keyed containers; `a[r, c]` for 2D grids. |
| **UDT payloads** | `Arr`, `Lst`, Long-keyed `Hsh`, and Long-keyed `Tre` accept `OF MyType` payloads. |
| **CODEPTR** | `CODEPTR(FunctionName)` now returns the real function address, enabling `Arr.SortUsing CODEPTR(Comparator)`. |
| **C frontend H-Lib parity** | Public C header `core/include/c17/pbxb64/hlib.h` and `examples/c/c_hlib_lnarr.c`. |
| **Quicksort fix** | Replaced the broken iterative quicksort in `c_hlib_arr.c` that hung on arrays with 4+ elements. |
| **VARIANT types** | Full `VARIANT` scalar, fixed arrays, dynamic arrays, `VARIANTVT`, `REDIM PRESERVE`, and element-wise lifecycle management. |
| **P0 runtime** | `ERROR$`, `UCODE$` / `UCODEPAGE`, and `PRINT USING` implemented. |
| **Z64 bug sweep** | 25 frontend/backend/diagnostic bugs fixed; all previously-documented limitations cleared. |

## Version

```
PBXB64 version 0.50.0-V6 (Release V6)
```

## Quick start

### Build (Windows + MinGW)

```batch
cd core
build_mingw64.bat
.\build\PBXB64.exe --version
```

### Compile a PB program

```batch
.\PBXB64.exe examples\basic\for_int_basic.pb -o for_int_basic.exe
.\for_int_basic.exe
```

### Compile a B64 program

```batch
.\PBXB64.exe examples\b64\answer.b64 -o answer.exe
.\answer.exe
```

### Compile a C program

```batch
.\PBXB64.exe -std=c17 examples\c\simple.c -o simple.exe
.\simple.exe
```

### Run the full test lane

```powershell
cd core
.\run_pb_tests.ps1                # build + test
.\run_pb_tests.ps1 -SkipBuild     # test only
```

## Contents of this release

- `PBXB64.exe` — UPX-packed compiler executable (sign before distribution).
- `PBXB64_Help.chm` — compiled Windows help file.
- `Includes\` — PowerBASIC include files (.pbi).
- `c17_headers\` — C17 standard headers for the C frontend.
- `examples\` — sample programs for PB, B64, C, and ASM.
- `README.md` — this file.
- `SHA256.txt` — hashes of `PBXB64.exe` and `PBXB64_Help.chm`.
- `V5` — version marker.
