PassiBASIC is a portable, C64-inspired BASIC dialect with scientific calculator-style functions like TAN(), LOG(), SQR(), SQRT(), SIN(), COS(), and ATN().
From the repository root:
make
This produces the passibasic executable and auto-generates buildinfo.h with a random PASSIBASIC_BUILD_NUMBER string for the BUILD banner. Set BASIC_BE_BUILDVER=... when invoking make if you need to override the displayed build string.
./passibasic
Commands supported in the shell:
RUN- execute the stored programLIST- show stored program linesNEW- clear the programLOAD_CORE <module>- load a numbered module fromcore/by name, e.g.LOAD_CORE APPLEBUSQUIT/EXIT/BYE- leave the shell- C64-style lines, e.g.
10 PRINT 2+2 LET A = 5,A = 10INPUT AGOTO 20IF A > 5 THEN 50END
- Modular interpreter core in
src/passibasic.c - Host front-end in
src/main.c - Line-numbered program storage compatible with BASIC-80 and C64 BASIC style
- Variable names limited to
AthroughZ - String variables with
$suffix (e.g.,A$,COLOR_RED$) - String concatenation with
+operator CHR$()function for character codes- Arithmetic parser with precedence and relational operators
- Mathematical functions for scientific calculator behavior
- Apple Business BASIC-style console commands:
HOME,HTAB,VTAB,TAB(n),SPC(n),TEXT,GR,HGR,NORMAL,INVERSE, andFLASH - Apple-style byte memory access with
POKE address,valueandPEEK(address) - Simple built-in shape drawing with
DRAW(SHAPE(n)); optional positioning is available asDRAW(SHAPE(n)),x,y
PassiBASIC includes a small compatibility layer for Apple Business BASIC-inspired programs:
10 HOME
20 HTAB 10
30 VTAB 5
40 PRINT "APPLE-STYLE TEXT"
50 POKE 1000,42
60 PRINT PEEK(1000)
70 DRAW(SHAPE(3))
80 DRAW(SHAPE(4)),20,8Supported commands and functions:
HOMEclears the terminal and moves the cursor to the upper-left corner.HTAB nandVTAB nposition the terminal cursor column and row.TAB(n)andSPC(n)can be used inPRINTto emit spaces.NORMAL,INVERSE, andFLASHmap to ANSI terminal text attributes.TEXT,GR, andHGRswitch PassiBASIC's text/graphics mode flag for Apple-style source compatibility.POKE address,valuewrites an 8-bit value to PassiBASIC's 64K byte memory array.PEEK(address)reads an 8-bit value from that memory array.SHAPE(n)selects one of ten built-in ASCII shapes, andDRAW(SHAPE(n))renders it.DRAW(SHAPE(n)),x,ymoves the cursor before drawing.
Core modules for these extensions live in core/: INIT.BAS sets default text state, GRAPHIN.BAS prepares graphics mode, and APPLEBUS.BAS initializes the Apple-style memory metadata used by demos. Load one with LOAD_CORE APPLEBUS and run it with RUN.
PassiBASIC supports string variables:
10 A$ = "HELLO"
20 PRINT A$
30 B$ = CHR$(27) + "[31m" : REM ANSI escape sequence
40 PRINT B$ + "RED TEXT" + CHR$(27) + "[0m"String variables can have single-letter names (A$) or multi-character names (COLOR_RED$).
PassiBASIC supports loading assembly/machine code programs that can register USR functions callable from BASIC:
LOAD_BINARY <filename>- Load an assembly binary to register USR functionsUSR(n)(value)- Call USR functionnwith the given value
Assembly programs use the pb_binary_header_t structure defined in src/passibasic_portable.h:
typedef struct {
uint16_t magic; // Must be 0xBE42 (PB_BINARY_MAGIC)
uint16_t version; // Must be 0x0100 (PB_BINARY_VERSION)
uint16_t func_count; // Number of USR functions (max 16)
uint16_t reserved; // Must be 0
void (*entry_point)(void); // Optional entry point
void (*func_pointers[16])(void); // USR function pointers
// ... callbacks for interacting with BASIC
} pb_binary_header_t;arch/dos/USR_EXAMPLE.ASM- MS-DOS real-mode example with video mode switchingarch/dos/ENTRY.ASM- MS-DOS .COM entry with POKE-based video controlarch/avr/USR_EXAMPLE.S- AVR microcontroller exampleexamples/USR_EXAMPLE.c- Native platform C example
On the MS-DOS port, POKE can change video resolutions to Apple IIc-like modes:
10 POKE 49152, 0 : REM 80x24 text with bigger fonts (default)
20 POKE 49152, 1 : REM Lowres Graphics 40 x 48
30 POKE 49152, 2 : REM Highres Graphics 280 x 192
40 POKE 49152, 3 : REM Double Highres 560 x 192
50 POKE 49152, 4 : REM Standard 80x25 textOn native platforms (C), USR functions take a double argument and return a double:
double my_usr_func(double value) {
return value * 2.0; // Double the input
}Then register and call:
LOAD_BINARY USR_EXAMPLE.C
PRINT USR(0)(21) rem Prints 42.0The core interpreter is intentionally separated from the host I/O layer so it can be adapted to smaller systems or calculator-like environments.