Every keyword
All 100 of them, alphabetically, each with an example you can type straight in. The output printed under each one is what the machine prints.
By what it does
| Job | Keywords |
|---|---|
| Writing and running | RUN, LIST, NEW, CLR, REM, END, STOP, CONT |
| Values | LET, DIM, DEF, FN |
| Showing things | PRINT, TAB, SPC, POS, HEX |
| Asking | INPUT, INKEY, JOY |
| Deciding | IF, THEN, ELSE, AND, OR, NOT |
| Repeating | FOR, NEXT, TO, STEP |
| Jumping | GOTO, GOSUB, RETURN, ON |
| Built-in lists | DATA, READ, RESTORE |
| Arithmetic | SGN, INT, ABS, SQR, RND, LOG, EXP, SIN, COS, TAN, ATN, MIN, MAX |
| Text | LEN, LEFT$, RIGHT$, MID$, CHR$, ASC, STR$, VAL |
| Screen and sound | CLS, LOCATE, COLOR, SOUND, VOL |
| The video card | SCREEN, VPOKE, VPEEK, VREG, VSTAT, PALETTE, VSYNC, VLOAD, SPRITE, SCROLL, LAYER |
| The memory card | DIR, LOAD, SAVE, DEL, DISK, FORMAT, BLOAD, BSAVE |
| Clock and lasting memory | TIME, DATE, SETTIME, SETDATE, NVRAM, NVSAVE, NVLOAD, NVERASE, NVSTAT, NVFIND |
| The machine underneath | PEEK, POKE, SYS, BANK, MEM, FRE, WAIT, PAUSE |
Operator precedence
Highest first. Anything on the same row goes left to right, and parentheses beat all of it.
| Operators | |
|---|---|
| Power | ^ |
| Unary | -+ |
| Multiplicative | */ |
| Additive | +- |
| Relational | =<><><=>= |
| Logical NOT | NOT |
| Logical AND | AND |
| Logical OR | OR |
The keywords
ABS
ABS(x)
The size of a number, ignoring its sign.
PRINT ABS(-5); ABS(5) 5 5AND
a AND b
True when both sides are true — and, underneath, a bit-by-bit AND of two whole numbers.
PRINT (5 > 3) AND (2 > 1)
PRINT 12 AND 10-1
8ASC
ASC(s$)
The code of the first character of a string.
PRINT ASC("A") 65ATN
ATN(x)
Arctangent, in radians. `ATN(1) * 4` is a serviceable π.
PRINT ATN(1) * 4 3.14159265BANK
BANK n
Choose which bank of extra RAM appears in the window at 32768.
BANK 1
POKE 32768, 42
BANK 0
PRINT PEEK(32768)
BANK 1
PRINT PEEK(32768) 0
42BLOAD
BLOAD addr, "name"
Read a file of raw bytes straight back into memory.
POKE 2560, 42
BSAVE 2560, 1, "SCORE.DAT"
POKE 2560, 0
BLOAD 2560, "SCORE.DAT"
PRINT PEEK(2560) 42BSAVE
BSAVE addr, len, "name"
Write raw bytes straight from memory to a file — a high score, a screen, a level.
POKE 2560, 42
BSAVE 2560, 1, "SCORE.DAT"
DIRSCORE .DAT 1CHR$
CHR$(n)
The character with code `n`.
PRINT CHR$(72); CHR$(73)HICLR
CLR
Clear the variables, arrays and strings but keep the program.
A = 5
CLR
PRINT A 0CLS
CLS
Clear the screen and put the cursor at the top left.
10 CLS
20 PRINT "A FRESH SCREEN"COLOR
COLOR fg[, bg[, border]]
Set the text and background colors, each 0 to 15, for everything printed from now on; the border follows the background unless a third number gives it its own.
10 CLS
20 COLOR 1, 15
30 PRINT "DARK ON WHITE"CONT
CONT
Carry on from a `STOP` or a stopped program, at the line after the one it stopped on. Editing any line first makes it impossible.
10 PRINT "A"
20 STOP
30 PRINT "B"A
BREAK IN 20
BCOS
COS(x)
Cosine of an angle in radians.
PRINT COS(0) 1DATA
DATA item [, item ...]
A list of values baked into the program for `READ` to work through. Skipped when the program runs past it.
10 DATA 262, 294, 330
20 READ A, B, C
30 PRINT A; B; C 262 294 330DATE
DATE
Print today's date from the battery-backed clock.
SETDATE 20, 26, 8, 3
DATE2026-08-03DEF
DEF FN name(var) = expr
Define your own one-line function.
10 DEF FN F(C) = C * 9 / 5 + 32
20 PRINT FN F(100) 212DEL
DEL "name"
Delete a file from the current disk.
DEL "HELLO.TXT"
DIRDISK 0DIM
DIM var(size) [, var(size) ...]
Make an array. One dimension only, and you get elements `0` to `size` — so `DIM S(9)` is ten of them.
10 DIM S(3)
20 S(0) = 10
30 S(3) = 40
40 PRINT S(0); S(3) 10 40DIR
DIR
List the files on the current disk, with their sizes in bytes.
DIRDISK 0
HELLO .TXT 6DISK
DISK n
Choose which of the card's 256 one-megabyte disks to work with.
DISK 3
MEMDISK 3ELSE
IF expr THEN stmt ELSE stmt
What to do when the test does not hold.
10 IF 1 = 2 THEN PRINT "YES" ELSE PRINT "NO"NOEND
END
Stop the program and return to the prompt. Variables keep their values.
10 PRINT "DONE"
20 END
30 PRINT "NEVER"DONEEXP
EXP(x)
`e` raised to the power `x`.
PRINT EXP(1) 2.71828183FN
FN name(expr)
Call a function you defined with `DEF`.
10 DEF FN D(N) = N * 2
20 PRINT FN D(21) 42FOR
FOR var = start TO limit [STEP step]
Count from one number to another, running everything up to `NEXT` each time through.
10 FOR N = 1 TO 4
20 PRINT N; " SQUARED IS"; N * N
30 NEXT N 1 SQUARED IS 1
4 SQUARED IS 16FORMAT
FORMAT
Erase the current disk and start it fresh. Asks first.
FORMATIt asks before erasing anything.
FRE
FRE(x)
How many bytes are left for variables, arrays and strings. The argument is ignored.
NEW
PRINT FRE(0) 30718GOSUB
GOSUB linenum
Jump to a subroutine, remembering where you came from. `RETURN` comes back.
10 GOSUB 100
20 PRINT "BACK"
30 END
100 PRINT "IN THE SUBROUTINE"
110 RETURNIN THE SUBROUTINE
BACKGOTO
GOTO linenum
Jump to a line and carry on from there.
10 PRINT "HELLO"
20 GOTO 40
30 PRINT "SKIPPED"
40 PRINT "END"HELLO
ENDHEX
HEX(n)
A number written in hexadecimal, always four digits with a `$` in front. `n` is 0 to 65535.
PRINT HEX(255); " "; HEX(4096)$00FF $1000IF
IF expr THEN stmt|linenum [ELSE stmt|linenum]
Do something only when a test holds. `THEN 100` is short for `THEN GOTO 100`.
10 A = 7
20 IF A > 5 THEN PRINT "BIG" ELSE PRINT "SMALL"BIGINKEY
INKEY
The code of a key being pressed right now, or `0` if none. Does not wait — put it in a loop.
PRINT INKEY 0INPUT
INPUT ["prompt";] var [, var ...]
Stop and wait for the person at the keyboard to type something. Only works inside a program.
10 INPUT "HOW OLD ARE YOU"; A
20 PRINT "IN DOG YEARS:"; A * 7IN DOG YEARS: 63INT
INT(x)
Round down to a whole number — down towards minus infinity, so `INT(-3.7)` is `-4`.
PRINT INT(3.7); INT(-3.7) 3-4JOY
JOY(n)
Read joystick 1 or 2. The bits are **active low** — a bit that reads `0` is a direction being pushed, so test with `= 0`, not with `<> 0`.
PRINT JOY(1)255 with nothing being pushed: every bit high.
LAYER
LAYER layer, on
Show layer 0 or 1, or hide it with `on` = 0. Layer 1 starts hidden, and its color 0 lets layer 0 show through.
10 SCREEN 2
20 FOR I = 0 TO 31 : VPOKE 16384 + I, 119 : NEXT I
30 FOR I = 0 TO 3 : VPOKE 32768 + I, 17 : NEXT I
40 LAYER 1, 1
50 IF INKEY = 0 THEN 50Layer 0 fills the screen with one color; layer 1, in front, draws a black line along the top of every one of its cells, and the rest of it lets layer 0 show through.
LEFT$
LEFT$(s$, n)
The first `n` characters of a string.
PRINT LEFT$("HELLO", 2)HELEN
LEN(s$)
How many characters are in a string.
PRINT LEN("HELLO") 5LET
[LET] var = expr
Give a variable a value. `LET` is optional and almost nobody types it.
LET P = 3
PRINT P * 100 300LIST
LIST
Show the program you have. It takes no line number — `LIST` lists the lot.
10 PRINT "HELLO"
20 GOTO 1010 PRINT "HELLO"
20 GOTO 10LOAD
LOAD "name" | LOAD
Read a program back off the card, replacing whatever is in memory. Bare `LOAD` receives one over the serial port by XModem.
10 PRINT "KEEP ME"
SAVE "KEEPER"
NEW
LOAD "KEEPER"
RUNKEEP MELOCATE
LOCATE row, col
Put the cursor somewhere. Rows are 0 to 23 down the screen, columns 0 to 39 across.
10 CLS
20 LOCATE 5, 10
30 PRINT "OVER HERE"LOG
LOG(x)
Natural logarithm.
PRINT LOG(1) 0MAX
MAX(a, b)
The larger of two numbers.
PRINT MAX(3, 7) 7MEM
MEM
Print free memory, which cards the machine found, and the current disk. A statement, not a function — `PRINT MEM` is a syntax error.
MEMFree bytes, the fitted-hardware byte, and the selected disk.
MID$
MID$(s$, start [, len])
Characters from the middle of a string, counting from 1. Leave `len` out to take the rest.
PRINT MID$("HELLO", 2, 3)
PRINT MID$("HELLO", 3)ELL
LLOMIN
MIN(a, b)
The smaller of two numbers.
PRINT MIN(3, 7) 3NEW
NEW
Throw the program away and clear the variables. There is no undo.
10 PRINT "HELLO"
NEW
PRINT FRE(0) 3071830718 bytes free — the same as a machine that has just been switched on, because the program is gone.
NEXT
NEXT [var]
End of a loop: add the step and go around again. One variable only — `NEXT J, I` is not accepted, so close each loop with its own `NEXT`.
10 FOR I = 1 TO 2
20 FOR J = 1 TO 2
30 PRINT I; J
40 NEXT J
50 NEXT I 1 1
2 2NOT
NOT expr
Flips every bit, which turns true (`-1`) into false (`0`) — but `NOT 1` is `-2`, not `0`, so use it on comparisons rather than on counts.
PRINT NOT (1 = 2)
PRINT NOT 1-1
-2NVERASE
NVERASE slot
Make a save slot free again, by zeroing all 16 of its bytes.
NVSAVE 3, 42, 20000
NVERASE 3
PRINT NVSTAT(3) 0NVFIND
NVFIND(id)
The lowest save slot owned by `id`, good or damaged, or -1 if there is none. `NVFIND(0)` finds a free one.
PRINT NVFIND(42)
NVSAVE 5, 42, 20000
PRINT NVFIND(42); NVFIND(0)-1
5 0NVLOAD
NVLOAD slot, addr
Copy a good save slot's 14 bytes back into memory at `addr`. A free or damaged slot copies nothing.
FOR I = 0 TO 13 : POKE 20000 + I, I * 10 : NEXT I
NVSAVE 3, 42, 20000
NVLOAD 3, 21000
PRINT PEEK(21013) 130NVRAM
NVRAM addr, value | NVRAM(addr)
256 bytes of memory on the clock card that survive a power cut. A statement to write one, a function to read one.
NVRAM 0, 123
PRINT NVRAM(0) 123NVSAVE
NVSAVE slot, id, addr
Save the 14 bytes of memory at `addr` in save slot 0 to 15 on the clock card, owned by `id`, 1 to 255.
FOR I = 0 TO 13 : POKE 20000 + I, I * 10 : NEXT I
NVSAVE 3, 42, 20000
PRINT NVSTAT(3); NVRAM(48) 1 42NVSTAT
NVSTAT(slot)
What save slot 0 to 15 holds: 0 free, 1 a good save, 2 damaged (0 with no clock card).
PRINT NVSTAT(0)
NVRAM 0, 7
PRINT NVSTAT(0) 0
2ON
ON expr GOTO l1 [,l2 ...] | ON expr GOSUB l1 [,l2 ...]
Pick a destination by number: 1 takes the first line in the list, 2 the second. Out of range falls through to the next line.
10 N = 2
20 ON N GOSUB 100, 200
30 END
100 PRINT "FIRST"
110 RETURN
200 PRINT "SECOND"
210 RETURNSECONDOR
a OR b
True when either side is true — and, underneath, a bit-by-bit OR.
PRINT (1 > 2) OR (3 > 2)
PRINT 12 OR 10-1
14PALETTE
PALETTE entry, r, g, b
Change color `entry` (row × 16 + color) to red, green and blue levels of 0 to 15, and everything drawn in it with it.
PALETTE 15, 15, 15, 0Everything white turns yellow at once — the whole background, since it was drawn in color 15.
PAUSE
PAUSE n
Do nothing for `n` hundredths of a second.
10 PRINT "WAIT FOR IT"
20 PAUSE 50
30 PRINT "THERE"WAIT FOR IT
THEREPEEK
PEEK(addr)
Read one byte of memory, 0 to 255.
PRINT PEEK(781)The byte at address 781 — the machine's record of which cards are fitted.
POKE
POKE addr, value
Write one byte of memory. `value` is 0 to 255.
POKE 2560, 42
PRINT PEEK(2560) 42POS
POS(x)
Which column the cursor is on. The argument is ignored; give it `0`.
PRINT "AB"; POS(0)AB 2PRINT [item] [;|, item ...]
Show numbers and text. `;` joins items tightly, `,` moves to the next 14-column zone, and a trailing `;` or `,` holds the cursor on the line.
PRINT "TOTAL:"; 6 * 7TOTAL: 42READ
READ var [, var ...]
Take the next value from the `DATA` lists and put it in a variable.
10 DATA 10, 20
20 READ X
30 READ Y
40 PRINT X + Y 30REM
REM [text]
A remark. Everything after `REM` on the line is for people, not the machine.
10 REM SCORE KEEPER
20 S = 100
30 PRINT S 100RESTORE
RESTORE
Go back to the first `DATA` item, so you can read the list again.
10 DATA 5, 6
20 READ A
30 RESTORE
40 READ B
50 PRINT A; B 5 5RETURN
RETURN
Go back to the line after the `GOSUB` that called this subroutine.
10 GOSUB 100
20 END
100 PRINT "AND BACK"
110 RETURNAND BACKRIGHT$
RIGHT$(s$, n)
The last `n` characters of a string.
PRINT RIGHT$("HELLO", 3)LLORND
RND(x)
A random number from 0 up to (but not including) 1. A negative argument reseeds from that number, so the same seed replays the same sequence.
10 FOR N = 1 TO 3
20 PRINT INT(RND(1) * 6) + 1;
30 NEXT NThree dice rolls, each from 1 to 6.
RUN
RUN [linenum]
Run the program from the top, or from a line number if you give one. Clears the variables first.
10 PRINT "ONE"
20 PRINT "TWO"
30 PRINT "THREE"TWO
THREESAVE
SAVE "name" | SAVE
Write the program to the card. Bare `SAVE` sends it over the serial port instead, by XModem.
10 PRINT "KEEP ME"
SAVE "KEEPER"
DIRKEEPER . 18SCREEN
SCREEN n
Choose what the video card shows: 0 is the text console, 1 to 3 are its graphics modes. A program that leaves the text console gets it back when it stops.
10 PRINT "THIS GOES"
20 SCREEN 0
30 PRINT "A FRESH TEXT SCREEN"SCROLL
SCROLL layer, x, y
Move layer 0 or 1 by `x` (0 to 319) and `y` (0 to 255) pixels, wrapping around at the edges.
10 SCREEN 2
20 FOR I = 0 TO 3 : VPOKE 16384 + I, 119 : NEXT I
30 SCROLL 0, 0, 4
40 IF INKEY = 0 THEN 40Cyan lines across the screen every eight pixels, moved up by four so they sit halfway down each row of tiles.
SETDATE
SETDATE cc, yy, mm, dd
Set the date: century, year within it, month, day. 2026 is `20, 26`.
SETDATE 20, 26, 12, 25
DATE2026-12-25SETTIME
SETTIME hh, mm, ss
Set the clock. It keeps running with the power off.
SETTIME 12, 30, 0
TIMEThe clock now reads half past twelve.
SGN
SGN(x)
`-1` for a negative number, `0` for zero, `1` for a positive one.
PRINT SGN(-4); SGN(0); SGN(9)-1 0 1SIN
SIN(x)
Sine of an angle in radians.
PRINT SIN(0) 0SOUND
SOUND voice, freq, dur
Play a note: `voice` 1 to 3, `freq` in hertz, `dur` in hundredths of a second. The program waits for the note to finish.
10 VOL 15
20 SOUND 1, 262, 20
30 SOUND 1, 330, 20
40 SOUND 1, 392, 20Three notes — the bottom of a C major chord.
SPC
SPC(n)
Inside `PRINT`, print `n` spaces from wherever the cursor is.
PRINT "A"; SPC(5); "B"A BSPRITE
SPRITE n, x, y, shape[, colors]
Put sprite 0 to 63 at `x`, `y`, drawn from `shape` (32 bytes at 49152 + 32 × shape) in palette row `colors`.
10 SCREEN 2
20 FOR I = 32 TO 63 : VPOKE 49152 + I, 119 : NEXT I
30 SPRITE 5, 124, 116, 1, 4
40 IF INKEY = 0 THEN 40A small yellow square in the middle of a black screen, until you press a key.
SQR
SQR(x)
Square root.
PRINT SQR(144) 12STEP
FOR var = start TO limit STEP step
How much to add each time through. Negative counts down.
10 FOR N = 10 TO 1 STEP -3
20 PRINT N;
30 NEXT N 10 7 4 1STOP
STOP
Pause the program and say where it stopped. `CONT` picks it up again.
10 PRINT "FIRST"
20 STOP
30 PRINT "SECOND"FIRST
BREAK IN 20STR$
STR$(n)
A number turned into a string — keeping the leading space that `PRINT` puts where a minus sign would go.
PRINT "[" + STR$(42) + "]"[ 42]SYS
SYS addr
Call machine code at an address and come back when it returns.
POKE 2560, 96
SYS 2560
PRINT "BACK FROM MACHINE CODE"BACK FROM MACHINE CODETAB
TAB(n)
Inside `PRINT`, move to column `n` of the line.
PRINT "NAME"; TAB(12); "SCORE"NAME SCORETAN
TAN(x)
Tangent of an angle in radians.
PRINT TAN(0) 0THEN
IF expr THEN stmt|linenum
The part of `IF` that says what to do when the test holds.
10 IF 2 + 2 = 4 THEN PRINT "ARITHMETIC WORKS"ARITHMETIC WORKSTIME
TIME
Print the time of day from the battery-backed clock.
TIMEThe time, as `HH:MM:SS`.
TO
FOR var = start TO limit
The part of `FOR` that says where to count to.
10 FOR N = 3 TO 5
20 PRINT N;
30 NEXT N 3 4 5VAL
VAL(s$)
A string turned into a number. Reads as far as it can and gives `0` if that is nowhere.
PRINT VAL("3.5"); VAL("12ABC"); VAL("ABC") 3.5 12 0VLOAD
VLOAD "name", addr
Copy a file from the memory card into the video card's memory at `addr`, however long it is.
10 CLS
20 FOR I = 0 TO 4 : POKE 20000 + I, ASC(MID$("HELLO", I + 1, 1)) : NEXT I
30 BSAVE 20000, 5, "HELLO.SCR"
40 VLOAD "HELLO.SCR", 205VOL
VOL n
Set the overall volume, 0 to 15.
10 VOL 8
20 SOUND 1, 440, 10
30 PRINT "THAT WAS A CONCERT A"THAT WAS A CONCERT AVPEEK
VPEEK(addr)
Read a byte of the video card's own memory, at 0 to 65535 (0 with no video card).
10 CLS
20 PRINT "HI"
30 PRINT VPEEK(0); VPEEK(1)VPOKE
VPOKE addr, value
Write a byte into the video card's own memory, at 0 to 65535. On a cleared text screen, byte 0 is the top left character.
10 CLS
20 VPOKE 125, 65VREG
VREG reg, value
Write one of the video card's registers, 0 to 127: the settings that decide how it draws. Register 7 is the border.
VREG 7, 4The border around the text turns dark blue. The text and its background stay as they were.
VSTAT
VSTAT(n)
Read the video card's status register 0 to 15. `VSTAT(4)` is 172 on the ACE's card; `VSTAT(0)` has 32 added after two sprites touch.
10 IF VSTAT(4) = 172 THEN PRINT "THE GRAPHICS ARE HERE"VSYNC
VSYNC
Wait for the video card to finish drawing a picture, which it does sixty times a second.
10 FOR I = 1 TO 60 : VSYNC : NEXT I
20 PRINT "ONE SECOND LATER"WAIT
WAIT addr, mask
Hold the program until reading `addr` and ANDing it with `mask` gives something other than zero. Nothing else happens while it waits.
POKE 2560, 1
WAIT 2560, 1
PRINT "BIT IS SET"BIT IS SET📄 BASIC Reference card — every keyword, the operator table and every error message, on three printable pages.

