| Command | Syntax | Effect |
|---|---|---|
PRINT [item [sep item …]] | Output to console. ;=no sep (trailing ; suppresses CRLF), ,=14-col zone. Bare PRINT=CRLF only | |
| INPUT | INPUT ["prompt"{;|,}] var [,var…] | Read value(s) from user. ?REDO FROM START on bad numeric input; ?EXTRA IGNORED if too many |
| LET | [LET] var = expr | Assign expression to variable. LET keyword is optional |
| GOTO | GOTO linenum | Jump unconditionally to line |
| GOSUB | GOSUB linenum | Push position and jump. ≥20 levels always, ~27 for a simple one; beyond → OUT OF MEMORY |
| RETURN | RETURN | Pop GOSUB stack and resume after calling GOSUB |
| IF | IF expr THEN stmt [ELSE stmt] | Execute THEN if expr non-zero, else ELSE branch. THEN/ELSE linenum = GOTO linenum |
| FOR | FOR var=init TO limit [STEP n] | Counted loop. Default step 1. Up to 8 nested. Limit tested at NEXT, so the body always runs once |
| NEXT | NEXT [var [,var…]] | Increment loop var and branch back to matching FOR if condition holds |
| REM | REM [text] | Comment — rest of line ignored |
| END | END | Stop execution and return to OK. Variables preserved |
| STOP | STOP | Stop and print BREAK IN nnnn. Resume with CONT |
| CONT | CONT | Continue after STOP, END or Ctrl+C (immediate mode only); FOR and GOSUB frames survive. CAN’T CONTINUE after an error, NEW, CLR or RUN |
| ON | ON expr GOTO l1,l2… | Evaluate expr, branch to nth target. Also ON … GOSUB. Out-of-range silently continues |
| DATA | DATA v1,v2,… | Inline data (numeric or string literals) for READ. Skipped during normal execution |
| READ | READ var [,var…] | Read next value(s) from DATA. OUT OF DATA if exhausted |
| RESTORE | RESTORE | Reset DATA pointer to start of program |
| LIST | LIST | Print program in detokenized form. Ctrl+C interrupts |
| RUN | RUN [linenum] | Clear variables and run program, optionally from linenum |
| NEW | NEW | Erase program and clear variables |
| CLR | CLR | Clear variables and arrays; reset stacks. Program is kept |
| DIM | DIM var(size) [,var(size)…] | Dimension a 1-D array (numeric or string). Valid indices 0..size. REDIM'D ARRAY if already done |
| DEF FN | DEF FN A(X) = expr | Define single-argument numeric user function. Call with FN A(value) |
| POKE | POKE addr, value | Write byte value to memory address addr |
| BRK | BRK | Drop into machine-code monitor. Return to BASIC with X |
| Command | Effect |
|---|---|
| SYS <addr> | Call machine-code routine at addr; RTS returns to BASIC |
| LOAD "name" | Load named file from CompactFlash to $0800 |
| SAVE "name" | Save current program to CompactFlash |
| LOAD | Receive program via XModem on serial port |
| SAVE | Transmit current program via XModem |
| DIR | List current disk's directory (prints DISK n header) |
| DEL "name" | Delete named file from current disk |
| DISK <n> | Select CF disk bank 0–255. Each disk = 1MB (2048 sectors); 256 disks = 256MB total. Resets to 0 on boot |
| BLOAD <addr>,"name" | Load file's raw bytes from current disk to memory address addr |
| BSAVE <addr>,<len>,"name" | Save len bytes from address addr to a named file on current disk |
| FORMAT | Erase current disk's file directory (prompts ERASE DISK n? Y/N) |
| BANK <n> | Select 1KB RAM bank n at $8000–$83FE |
| MEM | Print free bytes, HW_PRESENT (hex), and current DISK n |
| Command | Effect |
|---|---|
| CLS | Clear screen; reset cursor to (0,0) |
| LOCATE <row>,<col> | Move cursor to row 0–23, col 0–39 |
| COLOR <fg>,<bg> | Set TMS9918 text foreground/background colours (0–15 each) |
| Command | Effect |
|---|---|
| SOUND <v>,<f>,<d> | Play tone on voice 1–3 at freq Hz for dur centiseconds, then silence (Kernal SidPlayNote numbers them 0–2) |
| VOL <n> | Set SID master volume (0–15) |
| Command | Effect |
|---|---|
| PAUSE <n> | Pause for n centiseconds (~10 ms each) |
| WAIT <addr>,<mask> | Spin until (addr) AND mask is non-zero; Ctrl+C aborts |
| Command | Effect |
|---|---|
| TIME | Print current RTC time as HH:MM:SS |
| DATE | Print current RTC date as CCYY-MM-DD |
| SETTIME <hh>,<mm>,<ss> | Set the RTC time |
| SETDATE <cc>,<yy>,<mm>,<dd> | Set the RTC date |
| NVRAM <addr>,<val> | Write byte to RTC NVRAM at address 0–255 |
| Function | Returns |
|---|---|
| ABS(x) | Absolute value of x |
| SGN(x) | Sign of x: 1, 0, or −1 |
| INT(x) | Floor — largest integer ≤ x |
| SQR(x) | Square root of x (error if negative) |
| EXP(x) | e raised to x |
| LOG(x) | Natural logarithm (error if x ≤ 0) |
| SIN(x) / COS(x) / TAN(x) | Trig functions, radians |
| ATN(x) | Arctangent, radians |
| RND(x) | Float [0,1) for x>0; repeats last for x=0; reseeds for x<0 |
| PEEK(addr) | Byte value at memory address addr |
| FRE(x) | Free bytes between top of var space and string heap (arg ignored) |
| POS(x) | Current print column (arg ignored) |
| LEN(s$) | String length |
| VAL(s$) | Parse s$ as number; returns 0 if not numeric |
| ASC(s$) | ASCII code of first character of s$ |
| CHR$(n) | One-character string with ASCII code n |
| STR$(n) | Numeric value n formatted as a string |
| LEFT$(s$,n) | First n characters of s$ |
| RIGHT$(s$,n) | Last n characters of s$ |
| MID$(s$,start[,len]) | Substring from 1-based index start, optional length len |
| TAB(n) | In PRINT: advance cursor to column n (no-op if already past) |
| SPC(n) | In PRINT: emit n spaces |
| INKEY | Non-blocking key: ASCII code or 0. No parentheses |
| JOY(1) / JOY(2) | Joystick bitmask, bits R L D U Y X B A (7→0). Active low — a held button reads 0, an untouched stick reads $FF. Test with IF (JOY(1) AND 16) = 0 |
| NVRAM(addr) | Read byte from RTC NVRAM; returns 0 if RTC absent |
| HEX(n) | In PRINT: output n as $xxxx hex; in expressions: returns n unchanged |
| MIN(a,b) / MAX(a,b) | Smaller / larger of a and b |
| FN A(value) | Call user function defined with DEF FN A(X) |
| var(index) | Array element access. Array must be DIM-med first |
| Operator | Description |
|---|---|
| + − * / | Standard arithmetic |
| ^ | Exponentiation |
| + (strings) | String concatenation |
| = <> < > <= >= | Comparisons — work on numbers and strings; return −1 (true) or 0 (false) |
| AND OR NOT | Bitwise logical on integer parts of operands |
| Level | Operators |
|---|---|
| Power | ^ |
| Unary | − (negate) + |
| Multiplicative | * / |
| Additive | + − |
| Relational | = <> < > <= >= |
| Logical NOT | NOT |
| Logical AND | AND |
| Logical OR | OR |
| Hardware Absent | BASIC Behavior |
|---|---|
| CompactFlash | LOAD, SAVE, DIR, DEL, BLOAD, BSAVE, FORMAT print NO DEVICE |
| Serial | XModem LOAD/SAVE return error |
| GPIO/VIA | JOY() returns $FF — every line released, as an untouched stick reads. PAUSE falls back to a calibrated software loop |
| SID | SOUND, VOL silently return |
| Video | CLS, LOCATE, COLOR silently skip; console auto-switches to serial |
| RTC | TIME, DATE, SETTIME, SETDATE, NVRAM (write) print NO DEVICE; NVRAM() read returns 0 |
NO DEVICE, because there the program asked for something it did not get. Either way arguments are parsed and range-checked first — LOCATE 24,0 and VOL 16 are ILLEGAL QUANTITY even on a machine with neither card, so a program is wrong or right everywhere.
DIM var(size) — indices 0..size, 1-D only.:.OUT OF MEMORY.MEM reports free bytes.LOAD/SAVE without filename uses XModem (128-byte blocks, checksum). System prints XMODEM RX/TX READY and waits ~60 s for terminal to begin transfer.−..bas/.prg both just mean the bytes at $0800; the extension is cosmetic. A .prg is a 10 SYS 2060 stub with machine code attached. LOAD/SAVE round-trip it intact — don't edit its BASIC line, since that shifts the attached code.
| Bit | Mask | Card / Device |
|---|---|---|
| 0 | $01 | RAM card low (IO 1) |
| 1 | $02 | RAM card high (IO 2) |
| 2 | $04 | RTC DS1511Y (IO 3) |
| 3 | $08 | CompactFlash (IO 4) |
| 4 | $10 | Serial R65C51 (IO 5) |
| 5 | $20 | GPIO / VIA 65C22 (IO 6) |
| 6 | $40 | SID / ARMSID (IO 7) |
| 7 | $80 | Video TMS9918 (IO 8) |