Is there a Powerbasic Syntax Future?

Started by Bernard Kunzy, June 07, 2026, 09:38:37 AM

Previous topic - Next topic

0 Members and 7 Guests are viewing this topic.

Bernard Kunzy

For me, PowerBASIC is somewhat like PDS 7.1 a product from a previous generation that may eventually fade away as its user base continues to shrink.

That could explain why Jürgen didn't receive much feedback. Nowadays there are several good alternatives, including FreeBASIC, PureBasic, or simply plain C for developers who are familiar with the underlying Win32 API

José Roca

To be honest, the few PowerBASIC users who remain are perfectly happy with the old 32‑bit compiler, and they will continue using it indefinitely.

There is no real demand for a new compiler, because the existing one already does everything they need — and most of them are not interested in switching tools or workflows at this point.

That's also why community feedback is so limited: the user base is small, aging, and largely static. They are not looking for innovation; they are looking for stability.
  •  

Stan Duraham

Quote from: José Roca on June 07, 2026, 10:59:50 AMTo be honest, the few PowerBASIC users who remain are perfectly happy with the old 32‑bit compiler, and they will continue using it indefinitely.

There is no real demand for a new compiler, because the existing one already does everything they need — and most of them are not interested in switching tools or workflows at this point.

That's also why community feedback is so limited: the user base is small, aging, and largely static. They are not looking for innovation; they are looking for stability.


... and there can't be any new users.
  •  

Zlatko Vid

...and why not use Oxygen Basic ...far easier to use than FreeBasic and especially better than PureBasic.
  •  

Theo Gottwald

#4
If i would do the project again, i would take the Code from charles and teach it the PB-Syntax. That is right, @Zlatko Vid
This would have saved me many hours.

@Stan Duraham I have no doubt taht after 10 Years only some grandpa's will be interested in a Powerbasic like compiler. Yet i am one of them.

Here you see the specifications of the soon to release PBXA64 compiler (Just preparing the ALpha release).

I must admit that it is NOT as fast as Jürgens Compiler, it also may not produce as optimized executables as Jürgens compiler.

But Jürgen will not release until Oktober. I can release much faster (maybe later).

Advantages are that its a "Multi-Frontend-"Compiler that supports most of PB-Syntax and also has a C- and Assembler frontend,
you can code in any of these - you can intermix these and also share variables between these.

DETAILS:

# 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




Release V3 ALPHA complete. (Will be soon on the WEB-Site)

Artifact   Location   Size
PBXA64.exe   Release\V3\PBXA64_V3\   998 KB (UPX'd, signed)
PBXA64_Help.chm   Release\V3\PBXA64_V3\   94 KB
README.md   Release\V3\PBXA64_V3\   Updated hashes
SHA256.txt   Release\V3\PBXA64_V3\   Fresh hashes
PBXA64.zip   Release\   9.8 MB
version.txt   Release\   V3
Deployed   PBX-Editor\TestUsage\PBXA64\   exe + chm
V2 archived   Release\Archive\V2\   Moved

Stan Duraham

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

Let me get this straight, it will compile 64-bit apps?
Do the strings behave like PB strings, can hold binary data, but are null terminated for Win32?
If so, can't wait.
PB string manipulation beats every compiler out there. I could go on a long rant about this.
  •  

José Roca

#6
It is clear that you haven't tried DWSTRING, the class that I wrote for FreeBasic. It implements a dynamic unicode string for FreeBasic and works transparently with all the intrinsic functions and operatores of this language.

For binary data or ansi strings, you can use FreeBasic's STRING.

Also check out my collection of string procedures:
https://github.com/JoseRoca/AfxNova/blob/main/docs/String%20Management%20/DWString%20Procedures.md
  •  

Stan Duraham

You're right, I haven't tried it. I have, and still am, considering it. Fantastic job, but it's a lot to take in. I fed all your files to AI to get detailed descriptions.
Just now, I feed the two DWSTRING files to DeepSeek.
---
### **DWSTRING Class** (Dynamic Wide String)
```freebasic
TYPE DWSTRING EXTENDS WSTRING
  m_pBuffer AS WSTRING PTR    ' Pointer to buffer
  m_BufferLen AS ssize_t      ' Current length in characters
  m_Capacity AS ssize_t        ' Total allocated capacity
```
Interestingly, I was just building a library for C, exactly same format, but for all number types.
The char array doubles as a string container. The unsigned short array doubles as a wide sting container.
But there's no way to have easy BASIC like string manipulation in C.
Probably have to give FreeBasic a stronger look. The constructor and destructor in a UDT are extremely powerful.
---
Note: Files can't have a .bi extension for DeepSeek. Renamed it, DWSTRING.bi.inc
It wouldn't accept .bi as a drop file.
  •  

José Roca

#8
Strange limitation. The extension should not matter.

I have extensive documentation of all my wrappers:

DWSTRING: https://github.com/JoseRoca/AfxNova/blob/main/docs/String%20Management%20/DWSTRING%20Class.md

BSTRING: https://github.com/JoseRoca/AfxNova/blob/main/docs/String%20Management%20/BSTRING%20Class.md

String procedures: https://github.com/JoseRoca/AfxNova/blob/main/docs/String%20Management%20/DWString%20Procedures.md

As all my code is Unicode aware, I use mainly DWSTRING, which is faster. I reserve the use of BSTRING, that it is what PowerBasic uses, for COM programming. FreeBasic's STRING, wich is Ansi, can be used also as binary buffers.

In the documentation for DWSTRING I only have explained the additional features over FreeBasic's native string data types. The reason is that it works transparently with all the intrinsic functions and operators of FreeBasic. Therefore, what the FreeBasic manual says is applicable to DWSTRING and BSTRING too.

Conversions are automatic, so you can freely mix string + dwstring + bstring + literal + zstring + wstring. If the tarhet is an ansi string, you will get ansi; if the target is a dwstring, you will get unicode.

DIM s AS STRING = string + dwstring + bstring + literal + zstring + wstring  ' the resulting string is ansi

DIM dws AS DWSTRING = string + dwstring + bstring + literal + zstring + wstring  ' the resulting string is unicode

As the documentation explains, it can be used in arrays and UDTs.

There are also properties to allow to work with Utf-8 and OEM.

And besides all the available functions to manipulate strings (that work with all the string data types) you can also use VBScript regular expressions to build your own ones.

So, please, take a look at AfxNova and you will find some treasures, like CWindow to build DPI aware GUIs.

Currently I'm working into building a powerful graphics library using the WebView2 control as the canvas:

https://www.planetsquires.com/protect/forum/index.php?topic=4818.msg36604#msg36604

  •  

Theo Gottwald

#9
Quote from: Stan Duraham on June 09, 2026, 11:41:04 PM"x64 Windows compiler: PB, C, PILOT, inline ASM → PE32+ executables"
" Version 0.65.0-B25 | Target: x86_64-pc-windows-msvc"

@Stan Duraham
Let me get this straight, it will compile 64-bit apps?
Do the strings behave like PB strings, can hold binary data, but are null terminated for Win32?
If so, can't wait.
PB string manipulation beats every compiler out there. I could go on a long rant about this.


Of course, i would not use something else myself and i am my first customer.
Most bugs should be removed by today.

PS: If i would understand what Jose's datatypes are good for i could add them also.
I also plan to include Jose's AFX-Library native into the compiler in the future.
What will definitely be add (if its not in yet) are your HLIB Datatypes,
thats one of the next steps when we are bugfree.

Six known issues remain in V5:
1. HEX$/OCT$/BIN$ empty — __pb_hex stub works but descriptor not returned correctly
2. STRING$ garbled/times out — __pb_string stub calling convention mismatch
3. FORMAT$ always "00000" — stub ignores format string, only uses width
4. SIN/COS/TAN return 0/1 — math CRT functions get wrong double value (same MOVD bug family)
5. file_write_read reads empty — file I/O stubs not fully implemented
6. INT(-3.14) = -2 instead of -4 — __pb_int comparison logic wrong for negatives


2026-06-10 11_42_09-Greenshot.png

Theo Gottwald

Quote from: José Roca on June 07, 2026, 10:59:50 AMTo be honest, the few PowerBASIC users who remain are perfectly happy with the old 32‑bit compiler, and they will continue using it indefinitely.

There is no real demand for a new compiler, because the existing one already does everything they need — and most of them are not interested in switching tools or workflows at this point.

That's also why community feedback is so limited: the user base is small, aging, and largely static. They are not looking for innovation; they are looking for stability.


Of course you are right, Jose.
But ME I want to stick with the old PB Syntax. So i made this mainly for me.
Other people can use whatever they want.

But the main point is:
I can now extend it in any direction I decide.

José Roca

Good for you. Personally, one of the things that hated the most from PowerBasic was its syntax. This is why I always have used the Windows API. I can't love a syntax that uses statements instead of functions.
  •  

Theo Gottwald

#12
My new system has a multi-language frontend.
So you can choose which function you write in C or in Basic. They can interchange Variables.
Or in #ASM ...?
ASM-Code can also use the Variables.

We have the strongest Macro-Preprocessor - not available elsewhere - so you can largely define your language yourself.
We will also support the #OVERRIDE Directive to change compiler behavior.

And you have Options to get the final Assembler Output so you see what you get.

My DIALOG Implementations and also the Graphics Implementations (depending which compiler -) should be in a way tht they can directly be mixed with SDK Style programming. Giving you all Handles and are mostly sort of SDK Wrappers.

And you can talk to me if you miss some features, i am much opener then those Freebasic people.
1 week later in the next update - your wish - whatever it is - can be true.

I know that Jürgen had problems with the Freebasic people they did not understand his
wishes and therefore he canceled FB from his editor. So thats not a problem with me.

I am open for intelligent suggestions.

Today:
2 Compilers for x64 released, 1 Compiler still on hold.
3 Compilers for x32 still on hold

Not counting Jürgens very good compiler, that is also planned to be released in the Compilers Workshop when he decides to do so.

SO the question is also: Which one to choose finally. They are all complete different developments.