#PCODE / #ENDP Directive
#PCODE ... PILOT code block ...#ENDP
Description
The #PCODE ... #ENDP block embeds raw PILOT intermediate representation code directly within PBXA64 BASIC source. PILOT (Portable Intermediate Language for Object Translation) is the compiler's internal representation language, allowing developers to write or override low-level code generation when the BASIC-to-native translation needs manual guidance.
This directive is an advanced feature intended for performance-critical sections, direct hardware access, and runtime library implementation. The code within the #PCODE block is processed directly by the PILOT engine and emitted into the final binary at the insertion point.
The #PCODE block must always be terminated by #ENDP. These blocks can appear inside or outside procedures, though placement affects the code's scope and stack context.
Parameters
| Parameter | Description |
|---|---|
| (block content) | PILOT intermediate instructions placed between #PCODE and #ENDP. Each line typically represents one PILOT instruction with its operands. Refer to the PILOT reference for the full instruction set. |
Example
FUNCTION FastMultiply(BYVAL a AS LONG, BYVAL b AS LONG) AS LONG
LOCAL result AS LONG
#PCODE
LOD a ; Load a into register
MUL b ; Multiply by b
STO result ; Store into result
#ENDP
FUNCTION = result
END FUNCTION
Notes
#PCODEblocks are compiled as-is without BASIC syntax validation. Syntax errors within the PILOT code are reported by the PILOT engine.- Variables declared in the enclosing BASIC scope are accessible by name within
#PCODEblocks. - PBXA64 also supports Intel-syntax
#ASMblocks for direct native x86 or x64 instructions. - The command-line option
--target=win32selects x86/i686 PE32 output;--target=win64selects x64 PE32+ output. - Misuse of
#PCODEcan corrupt the stack or produce invalid binaries. Always verify with small isolated tests.