PBXB64 V23 detail

Verified examples and outputs

Complete historical PBXB64 V23 examples and outputs. The complete source/output blocks moved here from the overview and remain historical documentation; this page adds no new compiler or functional test claim.

Back to PBXB64 overviewDeutsch
The engine room

The machine room: verified features with code

Every program below was compiled and run with PBXB64 23.0.0-V23 from the V8 package on Windows 11 x64 (2026-10-05); the output blocks are the real output. Compile and link took 0.36-0.46 s per program (the DLL 16 ms). Twenty samples in total, twelve of them shown directly on this page (samples 1 and 3 appear in the sections above).

Intake valve for every number

1. Integers and big numbers

SBYTE to UINT512, exact sizes, and the UN family for arbitrary-precision integers (UNL), exact decimals (UNF) and complex numbers (UNC). Out-of-range constants are compile errors; run-time stores wrap in the declared width. UNL, UNF and UNC are run in sample 12; the other UN types are described on the types page.

Sample 2: Integer types

02_int_types.bas
#COMPILE EXE
#DIM ALL

TYPE Header                  ' binary record layout
    magic   AS DWORD         ' 4 bytes, unsigned
    version AS INTEGER       ' 2 bytes, signed  (V23: INTEGER is 16-bit)
    flags   AS WORD          ' 2 bytes, unsigned
    offset  AS SDWORD        ' 4 bytes, signed 32-bit (Win32 LONG)
END TYPE

FUNCTION PBMAIN() AS LONG
    LOCAL i AS INTEGER, sb AS SBYTE, u AS UINT64, q AS QUAD, big AS UINT128
    LOCAL h AS Header

    PRINT "INTEGER ="; SIZEOF(INTEGER); " | LONG ="; SIZEOF(LONG); " | SDWORD ="; SIZEOF(SDWORD)
    PRINT "UINT128 ="; SIZEOF(UINT128); " bytes | Header ="; SIZEOF(Header); " bytes"

    i = 32767 : i = i + 1                    ' run-time stores wrap in the declared width
    PRINT "INTEGER 32767+1 ="; i             ' -32768
    sb = -1 : i = -1
    PRINT "HEX$(SBYTE -1) = "; HEX$(sb); " | HEX$(INTEGER -1) = "; HEX$(i)   ' FF | FFFF

    q = &HFFFFFFFFFFFFFFFF : u = q
    PRINT "as QUAD:"; q; " | as UINT64:"; u  ' -1 | 18446744073709551615

    big = 1000000000000                      ' 10^12
    big = big * big                          ' 10^24 does not fit in 64 bits
    PRINT "UINT128 10^24 ="; big
    FUNCTION = 0
END FUNCTION

Build: PBXB64.exe 02_int_types.bas -o 02_int_types.exe

Output (verified)
INTEGER = 2 | LONG = 8 | SDWORD = 4
UINT128 = 16 bytes | Header = 16 bytes
INTEGER 32767+1 =-32768
HEX$(SBYTE -1) = FF | HEX$(INTEGER -1) = FFFF
as QUAD:-1 | as UINT64: 18446744073709551615
UINT128 10^24 = 1000000000000000000000000

From SDWORD to UINT128: exact sizes, wrap-around at run time, width-aware HEX$.

Verified with PBXB64 V23 (2026-10-05): compiled and run, 90,112-byte EXE, 377 ms compile and link.

Sample 12: Big numbers, exact decimals, complex numbers, regex

12_bignum_regex.bas
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    ' --- arbitrary-precision integer, exact decimal, complex ---------------
    LOCAL huge AS UNL, squared AS UNL
    LOCAL price AS UNF, tax AS UNF, total AS UNF
    LOCAL a AS UNC, b AS UNC, product AS UNC

    huge    = VALUNL("999999999999999999999999999999")
    squared = huge * huge
    PRINT "huge^2  = "; UNL$(squared)

    price = VALUNF("19.95") : tax = VALUNF("3.79")
    total = price + tax
    PRINT "total   = "; UNF$(total)                    ' 23.74 exactly

    a = VALUNC("1;2") : b = VALUNC("3;4")
    product = a * b
    PRINT "(1+2i)(3+4i) = "; UNC$(product)             ' -5;10

    ' --- built-in regular expressions (no extra DLL) ------------------------
    LOCAL src AS STRING, name AS STRING, swapped AS STRING
    src  = "User: Ada Lovelace, ID: 1843"
    name = REGEX$("User: ([A-Za-z]+ [A-Za-z]+)", src, 1)
    PRINT "captured: "; name                           ' Ada Lovelace
    swapped = REGEXREPLACE$("([A-Za-z]+) ([A-Za-z]+)", name, "$2, $1")
    PRINT "swapped : "; swapped                        ' Lovelace, Ada
    FUNCTION = 0
END FUNCTION

Build: PBXB64.exe 12_bignum_regex.bas -o 12_bignum_regex.exe

Output (verified)
huge^2  = 999999999999999999999999999998000000000000000000000000000001
total   = 23.74
(1+2i)(3+4i) = -5;10
captured: Ada Lovelace
swapped : Lovelace, Ada

UNL, UNF and UNC for exact arithmetic; REGEX$ and REGEXREPLACE$ without any extra DLL.

Verified with PBXB64 V23 (2026-10-05): compiled and run, 522,752-byte EXE, 386 ms compile and link.

Data types in detail

Control panel

2. GUI with DDT

Dialog Definition Tools: build a Windows dialog with DIALOG NEW and CONTROL ADD, handle events in a CALLBACK FUNCTION. Driven by UI automation in our test: clicking Greet gives "Hello, World!", Close exits with code 0. The help marks DDT as partially implemented.

Sample 5: A dialog with DDT

05_ddt_dialog.bas
#COMPILE EXE
#CONSOLE OFF
#DIM ALL
%IDC_NAME  = 101
%IDC_HELLO = 102
%IDC_OUT   = 103

CALLBACK FUNCTION DlgProc() AS LONG
    LOCAL txt AS STRING
    SELECT CASE CBMSG
        CASE %WM_COMMAND
            IF CBCTL = %IDC_HELLO AND CBCTLMSG = %BN_CLICKED THEN
                CONTROL GET TEXT CBHNDL, %IDC_NAME TO txt
                CONTROL SET TEXT CBHNDL, %IDC_OUT, "Hello, " + txt + "!"
            ELSEIF CBCTL = %IDCANCEL THEN
                DIALOG END CBHNDL
            END IF
    END SELECT
END FUNCTION

FUNCTION PBMAIN() AS LONG
    LOCAL hDlg AS QUAD
    DIALOG NEW PIXELS, 0, "PBXB64 DDT demo", 200, 200, 360, 150 TO hDlg
    CONTROL ADD LABEL,   hDlg, -1,         "Your name:", 12, 16, 80, 20
    CONTROL ADD TEXTBOX, hDlg, %IDC_NAME,  "World",      100, 12, 230, 24
    CONTROL ADD BUTTON,  hDlg, %IDC_HELLO, "&Greet",     100, 48, 100, 28
    CONTROL ADD BUTTON,  hDlg, %IDCANCEL,  "&Close",     250, 48, 80, 28
    CONTROL ADD LABEL,   hDlg, %IDC_OUT,   "",           12, 96, 330, 24
    DIALOG SHOW MODAL hDlg, CALL DlgProc
    FUNCTION = 0
END FUNCTION

Build: PBXB64.exe 05_ddt_dialog.bas -o 05_ddt_dialog.exe

UI test log (the program itself prints nothing)
window found: True exited early: None
title: PBXB64 DDT demo
ctl 101 True 'World'
ctl 102 True '&Greet'
ctl 103 True ''
ctl 2 True '&Close'
after click label: 'Hello, World!'
process exit code: 0

A real Windows dialog in about 25 lines: DIALOG NEW, CONTROL ADD, a CALLBACK FUNCTION and DIALOG SHOW MODAL. DDT is documented as partially implemented.

Verified with PBXB64 V23 (2026-10-05): compiled (GUI subsystem, 88,576-byte EXE, 382 ms); behaviour checked by UI automation.

Dialogs and controls

Multi-cylinder engine

3. Threads and parallel loops

THREAD CREATE / SUSPEND / RESUME / CLOSE ... TO, and PARALLEL FOR ... REDUCE in OpenMP style. In one measurement a CPU-bound loop took 1.33 s serial and 0.077 s parallel on a PC with 36 logical processors; the speed-up depends on your core count.

Sample 6: Threads and parallel loops

06_threads_parallel.bas
#COMPILE EXE
#DIM ALL

FUNCTION Worker(BYVAL value AS LONG) AS LONG
    FUNCTION = value * value               ' becomes the thread exit code
END FUNCTION

FUNCTION PBMAIN() AS LONG
    LOCAL h AS QUAD, prev AS LONG, code AS LONG
    LOCAL i AS LONG, total AS QUAD

    ' 1) worker thread: create suspended, resume, wait and read the exit code
    THREAD CREATE Worker(12), SUSPEND TO h
    IF h <> 0 THEN
        THREAD RESUME h TO prev                 ' previous suspend count (1)
        THREAD CLOSE h TO code                  ' with TO: waits, then closes
        PRINT "worker exit code ="; code        ' 144
    END IF

    ' 2) data-parallel loop over all logical processors
    PARALLEL FOR i = 1 TO 1000000 REDUCE + total
        total = total + i
    NEXT
    PRINT "sum 1..1000000 ="; total             ' 500000500000
    FUNCTION = 0
END FUNCTION

Build: PBXB64.exe 06_threads_parallel.bas -o 06_threads_parallel.exe

Output (verified)
worker exit code = 144
sum 1..1000000 = 500000500000

THREAD CREATE with suspend, resume and exit code; PARALLEL FOR with REDUCE sums a million numbers on all cores.

Verified with PBXB64 V23 (2026-10-05): compiled and run, 96,768-byte EXE, 386 ms compile and link.

Threading in detail

Direct line to the metal

4. Inline assembler and X-Code

#ACODE blocks with {var} bindings (at most 14 bindings per block), #ASM blocks, and the typed X-Code dialect #XCODE.

X-Code (excerpt)
 X.VREG value:U32
 X.LOAD V(value), DWORD PTR [counter]
 X.INC V(value)
 X.STORE DWORD PTR [counter], V(value)
#ENDX

This representative bridge pattern is documented below and on the X-Code detail page. APX is hardware-dependent: AUTO/EMULATE translate to ordinary x64; NATIVE requires APX hardware and was not newly qualified here.

Inline assembler. #ACODE binds BASIC variables into explicit x64 instructions; #ASM is the source block form. Inline assembly details
X-Code. #XCODE ... #ENDX is a typed dialect with virtual registers, typed variable binding and automatic register allocation. It is separate from #ASM/#ACODE and is not another file frontend. X-Code details Graphics overview Draw-To Set Pixel

APX is hardware-dependent: AUTO/EMULATE translate to ordinary x64; NATIVE requires APX hardware and was not newly qualified here.

Sample 7: Inline assembler

07_inline_asm.bas
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL n AS QUAD, sum AS QUAD, bits AS QUAD
    n = &HF0F0F0F0F0F0F0F0

    #ACODE
        mov rcx, qword ptr {n}
        popcnt rax, rcx                 ; POPCNT instruction
        mov qword ptr {bits}, rax

        xor eax, eax                    ; sum = 1 + 2 + ... + 100
        mov ecx, 100
    sum_loop:
        add rax, rcx
        dec ecx
        jnz sum_loop
        mov qword ptr {sum}, rax
    #AEND

    PRINT "bits set ="; bits               ' 32
    PRINT "sum 1..100 ="; sum              ' 5050
    FUNCTION = 0
END FUNCTION

Build: PBXB64.exe 07_inline_asm.bas -o 07_inline_asm.exe

Output (verified)
bits set = 32
sum 1..100 = 5050

#ACODE blocks bind BASIC variables with {name}; here the CPU's POPCNT instruction counts bits.

Verified with PBXB64 V23 (2026-10-05): compiled and run, 76,288-byte EXE, 405 ms compile and link.

Inline assembly in detail X-Code

Tool cabinet

5. Macros, modules, compile-time extensions

MACRO / MACROFUNCTION, #IF %DEF, #OVERRIDE; MODULE / USES / INITIALIZE; COMPILETIME FUNCTION with user-defined #DIRECTIVE and #CONTROL (documented as a bounded subset). Statement macros: one statement per line. Samples 14, 14b and 15 are in the collapsed list below.

Sample 8: Macros and conditional compilation

08_macros.bas
#COMPILE EXE
#DIM ALL
%DEBUG_BUILD = 1

MACRO Square(x) = ((x) * (x))                    ' expression macro
MACROFUNCTION Clamp(v, lo, hi)                   ' macro function: expands inline
    MACROFUNCTION = IIF((v) < (lo), (lo), IIF((v) > (hi), (hi), (v)))
END MACROFUNCTION
MACRO Swap2(a, b)                                ' statement macro (one statement per line)
    tmp = a
    a = b
    b = tmp
END MACRO

FUNCTION PBMAIN() AS LONG
    LOCAL a AS QUAD, b AS QUAD, tmp AS QUAD
    a = 7 : b = 9
    PRINT "Square(a+1) ="; Square(a + 1)           ' 64
    PRINT "Clamp(150,0,100) ="; Clamp(150, 0, 100) ' 100
    Swap2(a, b)
    PRINT "after swap:"; a; b                      ' 9 7
#IF %DEF(%DEBUG_BUILD)
    PRINT "debug build"
#ENDIF
    FUNCTION = 0
END FUNCTION

Build: PBXB64.exe 08_macros.bas -o 08_macros.exe

Output (verified)
Square(a+1) = 64
Clamp(150,0,100) = 100
after swap: 9 7
debug build

MACRO, MACROFUNCTION and a statement macro, plus #IF %DEF for debug builds.

Verified with PBXB64 V23 (2026-10-05): compiled and run, 76,288-byte EXE, 405 ms compile and link.

Preprocessor and #OVERRIDE

Translation unit

6. Unicode

WSTRING holds UTF-16 text; UCODE$, WCHR$ and CHRBYTES convert and inspect it.

Sample 9: Unicode with WSTRING

09_unicode.bas
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL w AS WSTRING, a AS STRING, i AS LONG
    w = "Gr" + WCHR$(&HFC) + WCHR$(&HDF) + "e " + WCHR$(&H4E16) + WCHR$(&H754C)   ' G r u-umlaut sharp-s e, space, two CJK characters
    PRINT "LEN (UTF-16 units) ="; LEN(w)             ' 8
    PRINT "bytes per char     ="; CHRBYTES(w)        ' 2
    FOR i = 1 TO LEN(w)
        PRINT HEX$(ASC(MID$(w, i, 1)), 4); " ";      ' U+0047 U+0072 ...
    NEXT
    PRINT
    a = UCODE$("ABC")                                ' ANSI -> UTF-16 bytes
    PRINT "UCODE$ length ="; LEN(a)                  ' 6 bytes
    FUNCTION = 0
END FUNCTION

Build: PBXB64.exe 09_unicode.bas -o 09_unicode.exe

Output (verified)
LEN (UTF-16 units) = 8
bytes per char     = 2
0047 0072 00FC 00DF 0065 0020 4E16 754C 
UCODE$ length = 6

WSTRING holds UTF-16: eight characters, two bytes each, shown as code units.

Verified with PBXB64 V23 (2026-10-05): compiled and run, 82,944-byte EXE, 382 ms compile and link.

Strings in detail

Dock to Windows

7. WinAPI, DLL, resources, classes

CLASS / INTERFACE / METHOD / PROPERTY. Calling the Windows API (sample 10), building a DLL with #COMPILE DLL (sample 17) and the built-in .rc resource compiler (sample 18) are in the collapsed list below.

Sample 13: Classes and interfaces

13_class.bas
#COMPILE EXE
#DIM ALL

CLASS Counter
    INSTANCE m_name  AS STRING
    INSTANCE m_count AS LONG

    INTERFACE ICounter
        INHERIT IUNKNOWN

        METHOD Init(BYVAL s AS STRING)
            ME.m_name = s
        END METHOD

        METHOD Hit()
            ME.m_count = ME.m_count + 1
        END METHOD

        PROPERTY GET Count() AS LONG
            PROPERTY = ME.m_count
        END PROPERTY

        PROPERTY GET Name() AS STRING
            PROPERTY = ME.m_name
        END PROPERTY
    END INTERFACE
END CLASS

FUNCTION PBMAIN() AS LONG
    LOCAL c AS ICounter
    LET c = CLASS "Counter"                ' create the object
    c.Init("page views")
    c.Hit() : c.Hit() : c.Hit()
    PRINT c.Name; " ="; c.Count            ' page views = 3
    FUNCTION = 0
END FUNCTION

Build: PBXB64.exe 13_class.bas -o 13_class.exe

Output (verified)
page views = 3

CLASS, INTERFACE and METHOD with real vtable dispatch.

Verified with PBXB64 V23 (2026-10-05): compiled and run, 101,888-byte EXE, 395 ms compile and link.

Classes in detail Resource compiler

Storage rack

8. Containers and regex

H-Lib native containers (SSSHSH hash table, LNARR array, sorting with a code pointer, FOR EACH) and the built-in REGEX$ / REGEXREPLACE$ (see sample 12, no extra DLL). The regex engine is the integrated REGEXPR runtime.

Sample 11: Native containers

11_containers.bas
#COMPILE EXE
#DIM ALL

FUNCTION Compare(BYVAL a AS QUAD, BYVAL b AS QUAD) AS LONG   ' for SortUsing
    IF a < b THEN FUNCTION = -1 ELSE IF a > b THEN FUNCTION = 1 ELSE FUNCTION = 0
END FUNCTION

FUNCTION PBMAIN() AS LONG
    LOCAL stock AS SSSHSH          ' hash table: STRING key -> STRING value
    LOCAL nums  AS LNARR           ' growable array of 64-bit integers
    LOCAL n     AS LONG, s AS STRING

    stock = stock.New
    stock["apple"]  = "12 crates"
    stock["pear"]   = "7 crates"
    PRINT "apple  ="; stock.Get("apple")
    PRINT "kiwi   ="; stock.TryGet("kiwi", "none")      ' default for a missing key
    PRINT "count  ="; stock.Count

    nums = nums.New
    nums.Push 42 : nums.Push 7 : nums.Push 19 : nums.Push 3
    nums.SortUsing CODEPTR(Compare)                      ' comparator callback
    FOR EACH n IN nums
        s = s + STR$(n) + " "
    NEXT
    PRINT "sorted ="; s

    stock.Final : nums.Final                             ' release (also automatic at scope exit)
    FUNCTION = 0
END FUNCTION

Build: PBXB64.exe 11_containers.bas -o 11_containers.exe

Output (verified)
apple  =12 crates
kiwi   =none
count  = 2
sorted = 3  7  19  42 

Hash maps, arrays, sorting with a code pointer and FOR EACH, built into the runtime.

Verified with PBXB64 V23 (2026-10-05): compiled and run, 303,104-byte EXE, 457 ms compile and link.

Containers in detail REGEX details

Assembly line

9. Mixed builds: BASIC + C

BASIC and C in one build with BRIDGE EXPORT / BRIDGE IMPORT (also at module level), BASIC plus assembler, and the built-in C17 frontend (sample 19, collapsed below).

Sample 16: BASIC and C in one program

16_mixed_main.bas
#COMPILE EXE
#DIM ALL
DECLARE FUNCTION c_add(BYVAL a AS LONG, BYVAL b AS LONG) AS LONG
FUNCTION PBMAIN() AS LONG
    BRIDGE EXPORT bridge_counter AS LONG ALIAS "bridge_counter"
    bridge_counter = 41
    PRINT "before C: "; bridge_counter
    PRINT "C says  : "; c_add(40, 2)
    PRINT "after C : "; bridge_counter
    FUNCTION = 0
END FUNCTION
16_mixed_helper.c
extern long long bridge_counter;
long long c_add(long long a, long long b) { bridge_counter += 1; return a + b; }

Build: PBXB64.exe 16_mixed_main.bas 16_mixed_helper.c -o 16_mixed.exe

Output (verified)
before C:  41
C says  :  42
after C :  42

BRIDGE EXPORT shares a 64-bit variable with C (long long, not int).

Verified with PBXB64 V23 (2026-10-05): compiled and run, 76,288-byte EXE, 361 ms compile and link.

C frontend

More samples

The rest of the tool shed

Eight more verified samples, collapsed to keep the page short.

Sample 4: Pointers and raw memory
Sample 4: Pointers and raw memory
04_pointers.bas
#COMPILE EXE
#DIM ALL

TYPE Point
    x AS LONG
    y AS LONG
END TYPE

FUNCTION SumArray(BYVAL p AS QUAD PTR, BYVAL n AS LONG) AS QUAD
    LOCAL i AS LONG, total AS QUAD
    FOR i = 1 TO n
        total = total + @p                 ' read through the pointer
        p = p + 1                          ' scaled by the target size: 8 bytes
    NEXT
    FUNCTION = total
END FUNCTION

FUNCTION PBMAIN() AS LONG
    LOCAL a(1 TO 5) AS QUAD
    LOCAL i AS LONG, pt AS Point, pp AS Point PTR, addr AS QUAD, ignored AS QUAD
    FOR i = 1 TO 5 : a(i) = i * 1000000000000 : NEXT   ' values above 2^32

    PRINT "sum ="; SumArray(VARPTR(a(1)), 5)

    pp = VARPTR(pt)                        ' typed pointer to a UDT
    @pp.x = 40 : @pp.y = 2
    PRINT "x+y ="; pt.x + pt.y

    addr = ALLOCATE(64)                    ' heap block, 64-bit address
    POKE QUAD, addr, &H1122334455667788
    PRINT "PEEK QUAD = "; HEX$(PEEK(QUAD, addr))
    PRINT "PEEK BYTE = "; HEX$(PEEK(BYTE, addr))   ' little endian: 88
    ignored = FREE(addr)
    FUNCTION = 0
END FUNCTION

Build: PBXB64.exe 04_pointers.bas -o 04_pointers.exe

Output (verified)
sum = 15000000000000
x+y = 42
PEEK QUAD = 1122334455667788
PEEK BYTE = 88

Pointer arithmetic scales by the target size; ALLOCATE, PEEK, POKE and FREE work on 64-bit addresses.

Verified with PBXB64 V23 (2026-10-05): compiled and run, 81,920-byte EXE, 370 ms compile and link.

Sample 10: Calling the Windows API
Sample 10: Calling the Windows API
10_winapi.bas
#COMPILE EXE
#DIM ALL

' Win32 "int"/"LONG" values are 32-bit: declare them SDWORD (LONG is 64-bit here).
DECLARE FUNCTION GetTickCount64 LIB "kernel32.dll" ALIAS "GetTickCount64" () AS QUAD
DECLARE FUNCTION GetComputerNameA LIB "kernel32.dll" ALIAS "GetComputerNameA" _
    (BYREF buf AS ASCIIZ, BYREF size AS DWORD) AS SDWORD
DECLARE FUNCTION GetSystemMetrics LIB "user32.dll" ALIAS "GetSystemMetrics" _
    (BYVAL nIndex AS SDWORD) AS SDWORD

FUNCTION PBMAIN() AS LONG
    LOCAL name AS ASCIIZ * 64, size AS DWORD
    size = 64
    IF GetComputerNameA(name, size) THEN PRINT "Computer: "; name
    PRINT "Uptime (s):"; GetTickCount64() \ 1000
    PRINT "Screen:"; GetSystemMetrics(0); " x"; GetSystemMetrics(1)  ' SM_CXSCREEN, SM_CYSCREEN
    FUNCTION = 0
END FUNCTION

Build: PBXB64.exe 10_winapi.bas -o 10_winapi.exe

Output (verified)
Computer: MINIPC
Uptime (s): 437336
Screen: 4096 x 2160

DECLARE ... LIB with SDWORD and QUAD types calls kernel32 and user32 directly. Output is machine-specific.

Verified with PBXB64 V23 (2026-10-05): compiled and run, 76,288-byte EXE, 394 ms compile and link.

Sample 14: Compile-time function and own directive
Sample 14: Compile-time function and own directive
14_compiletime.bas
#COMPILE EXE
#DIM ALL

' A pure callback that runs INSIDE the compiler and returns PB source text.
COMPILETIME FUNCTION MakeConstant(Tokens AS STRING, SpanStart AS DWORD, SpanEnd AS DWORD) AS STRING
    MakeConstant = "CONST answer = " + Tokens
END FUNCTION
#DIRECTIVE LITERAL PHASE TOPLEVEL USING MakeConstant

#LITERAL 42                       ' expands to: CONST answer = 42

FUNCTION PBMAIN() AS LONG
    PRINT "answer ="; answer
    FUNCTION = 0
END FUNCTION

Build: PBXB64.exe 14_compiletime.bas -o 14_compiletime.exe

Output (verified)
answer = 42

A COMPILETIME FUNCTION runs inside the compiler and feeds a user-defined #DIRECTIVE (documented as a bounded subset).

Verified with PBXB64 V23 (2026-10-05): compiled and run, 75,776-byte EXE, 361 ms compile and link.

Sample 14b: A user-defined control structure
Sample 14b: A user-defined control structure
14b_control_form.bas
#COMPILE EXE
#DIM ALL

' Define a new loop statement: "KeepGoing <condition> ... EndKeepGoing"
COMPILETIME FUNCTION BuildLoop(Tokens AS STRING, SpanStart AS DWORD, SpanEnd AS DWORD) AS CONTROL
    LOCAL condition AS EXPR
    LOCAL graph AS CFG
    condition = CONTROL.EXPR(Tokens)         ' parse the condition text
    graph = CFG.WHILE(condition)             ' lower it as a WHILE loop
    BuildLoop = graph
END FUNCTION
#CONTROL KeepGoing END EndKeepGoing KIND WHILE EXIT LeaveKeepGoing CONTINUE NextKeepGoing PHASE STATEMENT USING BuildLoop

FUNCTION PBMAIN() AS LONG
    LOCAL i AS LONG
    KeepGoing i < 5
        i = i + 1
    EndKeepGoing
    PRINT "i ="; i                           ' 5
    FUNCTION = 0
END FUNCTION

Build: PBXB64.exe 14b_control_form.bas -o 14b_control_form.exe

Output (verified)
i = 5

#CONTROL defines a new block statement. The name RepeatWhile was rejected (it shadows a core statement); KeepGoing works.

Verified with PBXB64 V23 (2026-10-05): compiled and run, 75,776-byte EXE, 367 ms compile and link.

Sample 15: Modules
Sample 15: Modules
15_modules.bas
#COMPILE EXE
#DIM ALL

MODULE Geometry
    PUBLIC GLOBAL calls AS QUAD
    INITIALIZE
        calls = 0
    END INITIALIZE
    PUBLIC FUNCTION Area(BYVAL w AS DOUBLE, BYVAL h AS DOUBLE) AS DOUBLE
        calls = calls + 1
        FUNCTION = w * h
    END FUNCTION
END MODULE

USES Geometry

FUNCTION PBMAIN() AS LONG
    PRINT "area ="; Geometry.Area(3, 4.5)
    PRINT "calls ="; Geometry.calls
    FUNCTION = 0
END FUNCTION

Build: PBXB64.exe 15_modules.bas -o 15_modules.exe

Output (verified)
area = 13.5
calls = 1

MODULE and USES give namespaces without separate files.

Verified with PBXB64 V23 (2026-10-05): compiled and run, 76,800-byte EXE, 387 ms compile and link.

Sample 17: Building a DLL
Sample 17: Building a DLL
17_dll_mylib.bas
#COMPILE DLL
#DIM ALL
FUNCTION AddQ ALIAS "AddQ" (BYVAL a AS QUAD, BYVAL b AS QUAD) AS QUAD EXPORT
    FUNCTION = a + b
END FUNCTION
17_dll_user.bas
#COMPILE EXE
DECLARE FUNCTION AddQ LIB "mylib.dll" ALIAS "AddQ" (BYVAL a AS QUAD, BYVAL b AS QUAD) AS QUAD
FUNCTION PBMAIN() AS LONG
    PRINT AddQ(40, 2)
END FUNCTION

Build: PBXB64.exe 17_dll_mylib.bas -o mylib.dll | PBXB64.exe 17_dll_user.bas -o 17_dll_user.exe

Output (verified)
 42

#COMPILE DLL with EXPORT produces a 3,072-byte DLL; a second program calls it.

Verified with PBXB64 V23 (2026-10-05): compiled and run; DLL 3,072 bytes in 16 ms, user EXE 375 ms.

Sample 18: Embedded resources
Sample 18: Embedded resources
18_app.rc
STRINGTABLE
BEGIN
  1 "Hello from a resource string"
END
1 VERSIONINFO
FILEVERSION 1,2,3,4
PRODUCTVERSION 1,2,3,4
BEGIN
  BLOCK "StringFileInfo"
  BEGIN
    BLOCK "040904B0"
    BEGIN
      VALUE "ProductName", "RC demo"
      VALUE "FileVersion", "1.2.3.4"
    END
  END
  BLOCK "VarFileInfo"
  BEGIN
    VALUE "Translation", 0x409, 1200
  END
END
18_rcdemo.bas
#COMPILE EXE
FUNCTION PBMAIN() AS LONG
    PRINT "built with an .rc resource"
END FUNCTION

Build: PBXB64.exe 18_app.rc 18_rcdemo.bas -o 18_rc.exe

Output (verified)
built with an .rc resource

The built-in resource compiler embeds a STRINGTABLE and VERSIONINFO (resource types 6 and 16 found in the EXE).

Verified with PBXB64 V23 (2026-10-05): compiled and run, 76,800-byte EXE, 378 ms compile and link.

Sample 19: Built-in C17 frontend
Sample 19: Built-in C17 frontend
19_c17.c
#include <stdio.h>
#include <stdint.h>

static uint64_t fib(unsigned n) { return n < 2 ? n : fib(n - 1) + fib(n - 2); }

int main(void) {
    printf("Hello from the built-in C17 frontend\n");
    printf("sizeof(void*) = %zu, fib(40) = %llu\n", sizeof(void *), (unsigned long long)fib(40));
    return 0;
}

Build: PBXB64.exe -std=c17 19_c17.c -o 19_c17.exe

Output (verified)
Hello from the built-in C17 frontend
sizeof(void*) = 8, fib(40) = 102334155

Plain C17 with printf and stdint.h; the headers are built into the compiler.

Verified with PBXB64 V23 (2026-10-05): compiled and run, 76,288-byte EXE, 397 ms compile and link.

Quick Examples

The same algorithm - sum 1 to 5 - in every frontend. The "Inline ASM" example is PowerBASIC source with an #ASM block, not a separate assembler frontend. BASIC and C17 are ready to use; the other frontends are experimental.

B64

fn main(): i64 {
    let sum: i64 = 0;
    let i: i64 = 1;
    while i <= 5 {
        sum = sum + i;
        i = i + 1;
    }
    return sum;   // 15
}

PowerBASIC

FUNCTION PBMAIN() AS LONG
    LOCAL sum AS LONG
    LOCAL i AS LONG
    sum = 0
    FOR i = 1 TO 5
        sum = sum + i
    NEXT
    FUNCTION = sum   ' = 15
END FUNCTION

C

#include <stdio.h>
int main(void) {
    int sum = 0;
    for (int i = 1; i <= 5; i++) {
        sum += i;
    }
    return sum;   /* 15 */
}

LOGO

MAKE "sum 0
MAKE "i 1
REPEAT 5 [
    MAKE "sum :sum + :i
    MAKE "i :i + 1
]
PRINT :sum

FORTH

5 4 + 3 + 2 + 1 +
.
\ 15

SPR

VAR.$$SUM=0
FOR.$$III|1|5|1
    VIC.$$SUM|$$III
NEX.
ENR.

Inline ASM

FUNCTION PBMAIN() AS LONG
    LOCAL sum AS LONG
    #ASM
        xor eax, eax      ; sum = 0
        mov ecx, 5        ; counter = 5
    add_loop:
        add eax, ecx      ; sum += counter
        dec ecx           ; counter--
        jnz add_loop      ; loop until 0
        mov %sum, eax     ; store result
    #ENDASM
    FUNCTION = sum        ' = 15
END FUNCTION

PILOT

T: "Sum 1 to 5"
C: #sum=1+2+3+4+5
E:

COBOL

       IDENTIFICATION DIVISION.
       PROGRAM-ID. QuickSum.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 TOTAL PIC 9(2).
       PROCEDURE DIVISION.
           COMPUTE TOTAL = 1 + 2 + 3 + 4 + 5
           DISPLAY TOTAL
           STOP RUN.

RUST

fn main() -> i64 {
    let mut sum: i64 = 0;
    let mut i: i64 = 1;
    loop {
        sum = sum + i;
        if i >= 5 { break; }
        i = i + 1;
    }
    return sum;   // 15
}

All ten examples compiled and ran with PBXB64 V23 (2026-10-05).

PBXB64 is part of the PBX-Compiler package. Free for private use, cleanly licensed for business.