Home > CBM > BASIC > Keywords 181 Subpages: (divide), (equal), (less), (minus), (more), (multiply), (plus), (power), Abs, And, Append, Asc, Atn, Auto, Backup, Bank, Begin, Bend, Bload, Boot, Box, Bsave, Bump, Catalog, Char, Chr, Circle, Close, Clr, Cmd, Collect, Collision, Color, Concat, Cont, Copy, Cos, Data, Dclear, Dclose, Dec, Def, Delete, Dim, Directory, Dispose, Dload, Do, Dopen, Draw, Ds, Ds string, Dsave, Dverify, El, Else, End, Envelope, Er, Err, Exit, Exp, Fast, Fetch, Filter, Fn, For, Fre, Get, Get num, Getkey, Go, Gosub, Goto, Graphic, Gshape, Header, Help, Hex, If, Input, Input num, Instr, Int, Joy, Key, Left, Len, Let, List, Load, Locate, Log, Loop, Mid, Monitor, Movspr, New, Next, Not, Off, On, Open, Or, Paint, Peek, Pen, Pi, Play, Pointer, Poke, Pos, Pot, Print, Print num, Pudef, Quit, Rclr, Rdot, Read, Record, Rem, Rename, Renumber, Restore, Resume, Return, Rgr, Right, Rlum, Rnd, Rreg, Rspcolor, Rsppos, Rsprite, Run, Rwindow, Save, Scale, Scnclr, Scratch, Sgn, Sin, Sleep, Slow, Sound, Spc, Sprcolor, Sprdef, Sprite, Sprsav, Sqr, Sshape, St, Stash, Step, Stop, Str, Swap, Sys, Tab, Tan, Tempo, Then, Ti, Ti string, To, Trap, Troff, Tron, Until, Using, Usr, Val, Verify, Vol, Wait, While, Width, Window, Xor |
The BASIC language consists mainly of keywords along with rules for combining them
(additional factors are naming rules, literal values, and data formats).
The keywords can be classified according to use or "type".
One classification set (used here) is:
- Command (used outside a program [direct mode] to perform an action)
- Statement (used inside a program [run mode] to perform an action)
- Preposition (used along with other keywords; generates an error if used alone)
- Function (calculates a value; used in math expressions)
- Operator (usually not a word, but a symbol; used to combine math expressions)
- Reserved variable (these are really functions that take no arguments)
A more detailed listing follows, but here is a quick list of CBM BASIC Keywords:
Most of the keywords used by Commodore BASIC are "compressed" into (typically) a 1-byte code known as a token
(see the page on tokens for more details). Below is a table listing all keywords
ordered by their "name". The table also includes the token value(s), version number(s) to which it applies,
and a classification.
| Keyword | Token (hex) | Version(s) | Classification |
| ^ | AE | 1.0+ | Operator (1) |
| * | AC | 1.0+ | Operator (2) |
| / | AD | 1.0+ | Operator (2) |
| + | AA | 1.0+ | Operator (3) |
| - | AB | 1.0+ | Operator (3) |
| > | B1 | 1.0+ | Operator (4) |
| = | B2 | 1.0+ | Operator (4) |
| < | B3 | 1.0+ | Operator (4) |
| π (pi) | FF | 1.0+ | Reserved variable |
| ABS | B6 | 1.0+ | Function | | AND | AF | 1.0+ | Operator (6) | | APPEND | D4 | 4.x | Command and Statement | | APPEND | FE 0E | 7.0 | Command and Statement | | ASC | C6 | 1.0+ | Function | | ATN | C1 | 1.0+ | Function | | AUTO | DC | 3.5,7.0 | Command and Statement | | BACKUP | F6 | 3.5,7.0 | Command and Statement | | BACKUP | D2 | 4.x | Command and Statement | | BANK | DC | 4.7 | Command and Statement | | BANK | FE 02 | 7.0 | Command and Statement | | BEGIN | FE 18 | 7.0 | Preposition | | BEND | FE 19 | 7.0 | Command*, Preposition, and Statement* | | BLOAD | DD | 4.7 | Command and Statement | | BLOAD | FE 11 | 7.0 | Command and Statement | | BOOT | FE 1B | 7.0 | Command and Statement | | BSAVE | DE | 4.7 | Command and Statement | | BSAVE | FE 10 | 7.0 | Command and Statement | | BOX | E1 | 3.5,7.0 | Command and Statement | | BUMP | CE 03 | 7.0 | Function | | CATALOG | D7 | 4.x | Command and Statement | | CATALOG | FE 0C | 7.0 | Command and Statement | | CHAR | E0 | 3.5,7.0 | Command and Statement | | CHR$ | C7 | 1.0+ | Function | | CIRCLE | E2 | 3.5,7.0 | Command and Statement | | CLOSE | A0 | 1.0+ | Command and Statement | | CLR | 9C | 1.0+ | Command and Statement | | CMD | 9D | 1.0+ | Command and Statement | | COLLECT | F3 | 3.5,7.0 | Command and Statement | | COLLECT | D1 | 4.x | Command and Statement | | COLLISION | FE 17 | 7.0 | Command and Statement | | COLOR | E7 | 3.5,7.0 | Command and Statement | | CONCAT | CC | 4.x | Command and Statement | | CONCAT | FE 13 | 7.0 | Command and Statement | | CONT | 9A | 1.0+ | Command* and Statement | | COPY | F4 | 3.5,7.0 | Command and Statement | | COPY | D3 | 4.x | Command and Statement | | COS | BE | 1.0+ | Function | | DATA | 83 | 1.0+ | Command* and Statement | | DCLEAR | DB | 4.7 | Command and Statement | | DCLEAR | FE 15 | 7.0 | Command and Statement | | DCLOSE | CE | 4.x | Command and Statement | | DCLOSE | FE 0F | 7.0 | Command and Statement | | DEC | D1 | 3.5,7.0 | Function | | DEF | 96 | 1.0+ | Statement | | DELETE | F7 | 3.5,7.0 | Command and Statement | | DELETE | E0 | 4.7 | Command and Statement* | | DIM | 86 | 1.0+ | Command and Statement | | DIRECTORY | EE | 3.5,7.0 | Command and Statement | | DIRECTORY | DA | 4.x | Command and Statement | | DISPOSE | E4 | 4.7 | Command and Statement | | DLOAD | F0 | 3.5,7.0 | Command and Statement* | | DLOAD | D6 | 4.x | Command* and Statement | | DO | EB | 3.5,7.0 | Command and Statement | | DOPEN | CD | 4.x | Command and Statement | | DOPEN | FE 0D | 7.0 | Command and Statement | | DRAW | E5 | 3.5,7.0 | Command and Statement | | DS | 44 53** | 3.5+ | Reserved variable | | DS$ | 44 53 24** | 3.5+ | Reserved variable | | DSAVE | EF | 3.5,7.0 | Command and Statement | | DSAVE | D5 | 4.x | Command and Statement | | DVERIFY | FE 14 | 7.0 | Command and Statement | | EL | 45 4C** | 3.5, 4.7+ | Reserved variable | | ELSE | D5 | 3.5,7.0 | Command*, Preposition, and Statement* | | ELSE | E1 | 4.7 | Command*, Preposition, and Statement* | | END | 80 | 1.0+ | Command* and Statement | | ENVELOPE | FE 0A | 7.0 | Command and Statement | | ER | 45 52** | 3.5, 4.7+ | Reserved variable | | ERR$ | D3 | 3.5,7.0 | Function | | ERR$ | E7 | 4.7 | Function | | EXIT | ED | 3.5,7.0 | Command and Statement | | EXP | BD | 1.0+ | Function | | FAST | FE 25 | 7.0 | Command and Statement | | FETCH | FE 21 | 7.0 | Command and Statement | | FILTER | FE 03 | 7.0 | Command and Statement | | FN | A5 | 1.0+ | Function/Preposition | | FOR | 81 | 1.0+ | Command or Statement | | FRE | B8 | 1.0+ | Function | | GET | A1 | 1.0+ | Preposition | | GET# | A1 23 | 1.0+ | Statement | | GETKEY | A1 F9 | 3.5, 7.0 | Statement | | GO | CB | 2.0+ | Command and Statement | | GOSUB | 8D | 1.0+ | Command and Statement | | GOTO | 89 | 1.0+ | Command and Statement | | GRAPHIC | DE | 3.5,7.0 | Command and Statement | | GSHAPE | E3 | 3.5,7.0 | Command and Statement | | HEADER | F1 | 3.5,7.0 | Command and Statement | | HEADER | D0 | 4.x | Command and Statement | | HELP | EA | 3.5,7.0 | Command and Statement* | | HEX$ | D2 | 3.5,7.0 | Function | | IF | 8B | 1.0+ | Command and Statement | | INPUT | 85 | 1.0+ | Statement | | INPUT# | 84 | 1.0+ | Statement | | INSTR | D4 | 3.5,7.0 | Function | | INSTR | E8 | 4.7 | Function | | INT | B5 | 1.0+ | Function | | JOY | CF | 3.5,7.0 | Function | | KEY | F9 | 3.5,7.0 | Command, Preposition, and Statement | | KEY | DF | 4.7 | Command and Statement | | LEFT$ | C8 | 1.0+ | Function | | LEN | C3 | 1.0+ | Function | | LET | 88 | 1.0+ | Command and Statement | | LIST | 9B | 1.0+ | Command and Statement* | | LOAD | 93 | 1.0+ | Command* and Statement | | LOCATE | E6 | 3.5,7.0 | Command and Statement | | LOG | BC | 1.0+ | Function | | LOOP | EC | 3.5,7.0 | Command and Statement | | MID$ | CA | 1.0+ | Function | | MONITOR | FA | 3.5,7.0 | Command and Statement | | MOVSPR | FE 06 | 7.0 | Command and Statement | | NEW | A2 | 1.0+ | Command and Statement* | | NEXT | 82 | 1.0+ | Command, Preposition, and Statement | | NOT | A8 | 1.0+ | Operator (5) | | OFF | FE 24 | 7.0 | Preposition | | ON | 91 | 1.0+ | Preposition | | OPEN | 9F | 1.0+ | Command and Statement | | OR | B0 | 1.0+ | Operator (7) | | PAINT | DF | 3.5,7.0 | Command and Statement | | PEEK | C2 | 1.0+ | Function | | PEN | CE 04 | 7.0 | Function | | PLAY | FE 04 | 7.0 | Command and Statement | | POINTER | CE 0A | 7.0 | Function | | POKE | 97 | 1.0+ | Command and Statement | | POS | B9 | 1.0+ | Function | | POT | CE 02 | 7.0 | Function | | PRINT | 99 | 1.0+ | Command and Statement | | PRINT# | 98 | 1.0+ | Command and Statement | | PUDEF | DD | 3.5,7.0 | Command and Statement | | PUDEF | E5 | 4.7 | Command and Statement | | QUIT | FE 1E | 7.0 | Command and Statement | | RCLR | CD | 3.5,7.0 | Function | | RDOT | D0 | 3.5,7.0 | Function | | READ | 87 | 1.0+ | Command and Statement | | RECORD | CF | 4.x | Command and Statement | | RECORD | FE 12 | 7.0 | Command and Statement | | REM | 8F | 1.0+ | Command and Statement | | RENAME | F5 | 3.5,7.0 | Command and Statement | | RENAME | D8 | 4.x | Command and Statement | | RENUMBER | F8 | 3.5,7.0 | Command | | RESTORE | 8C | 1.0+ | Command and Statement | | RESUME | D6 | 3.5,7.0 | Statement | | RESUME | E3 | 4.7 | Statement | | RETURN | 8E | 1.0+ | Statement | | RGR | CC | 3.5,7.0 | Function | | RIGHT$ | C9 | 1.0+ | Function | | RLUM | CE | 3.5 | Function | | RND | BB | 1.0+ | Function | | RREG | FE 09 | 7.0 | Command and Statement | | RSPCOLOR | CE 07 | 7.0 | Function | | RSPPOS | CE 05 | 7.0 | Function | | RSPRITE | CE 06 | 7.0 | Function | | RUN | 8A | 1.0+ | Command and Statement | | RWINDOW | CE 09 | 7.0 | Function | | SAVE | 94 | 1.0+ | Command and Statement | | SCALE | E9 | 3.5,7.0 | Command and Statement | | SCNCLR | E8 | 3.5,7.0 | Command and Statement | | SCRATCH | F2 | 3.5,7.0 | Command and Statement | | SCRATCH | D9 | 4.x | Command and Statement | | SGN | B4 | 1.0+ | Function | | SIN | BF | 1.0+ | Function | | SLEEP | FE 0B | 7.0 | Command and Statement | | SLOW | FE 26 | 7.0 | Command and Statement | | SOUND | DA | 3.5,7.0 | Command and Statement | | SPC( | A6 | 1.0+ | Preposition | | SPRCOLOR | FE 08 | 7.0 | Command and Statement | | SPRDEF | FE 1D | 7.0 | Command and Statement | | SPRITE | FE 07 | 7.0 | Command and Statement | | SPRSAV | FE 16 | 7.0 | Command and Statement | | SQR | BA | 1.0+ | Function | | SSHAPE | E4 | 3.5,7.0 | Command and Statement | | ST | 53 54** | 1.0+ | Reserved variable | | STASH | FE 1F | 7.0 | Command and Statement | | STEP | A9 | 1.0+ | Preposition | | STOP | 90 | 1.0+ | Command* and Statement | | STR$ | C4 | 1.0+ | Function | | SWAP | FE 23 | 7.0 | Command and Statement | | SYS | 9E | 1.0+ | Command and Statement | | TAB( | A3 | 1.0+ | Preposition | | TAN | C0 | 1.0+ | Function | | TEMPO | FE 05 | 7.0 | Command and Statement | | THEN | A7 | 1.0+ | Preposition | | TI | 54 49** | 1.0+ | Reserved variable | | TI$ | 54 49 24** | 1.0+ | Reserved variable | | TO | A4 | 1.0+ | Preposition | | TRAP | D7 | 3.5,7.0 | Statement | | TRAP | E2 | 4.7 | Statement | | TROFF | D9 | 3.5,7.0 | Command and Statement | | TRON | D8 | 3.5,7.0 | Command and Statement | | UNTIL | FC | 3.5,7.0 | Preposition | | USING | FB | 3.5,7.0 | Preposition | | USING | E6 | 4.7 | Preposition | | USR | B7 | 1.0+ | Function | | VAL | C5 | 1.0+ | Function | | VERIFY | 95 | 1.0+ | Command* and Statement | | VOL | DB | 3.5,7.0 | Command and Statement | | WAIT | 92 | 1.0+ | Command and Statement | | WHILE | FD | 3.5,7.0 | Preposition | | WIDTH | FE 1C | 7.0 | Command and Statement | | WINDOW | FE 1A | 7.0 | Command and Statement | | XOR | CE 08 | 7.0 | Function |
Wow, you read all that?! A few notes about the the table. The "tokens" marked ** are really just
the ASCII code(s) for the letters that make up the name
(you should see this only applies to reserved variable names).
Most keywords can be used as commands (in direct mode) or as statements (in a running program),
although a few can only be used one way but not the other.
However, there are several that in theory could be used as either commands or statements,
but certain uses are uncommon in practice due to no effect or undesirable side-effects;
these are marked with an asterisk (*).
Expressions in BASIC are evaluated using a fixed precedence (order of operations)
for the different math operators. Each operator listed has its precedence level shown in parentheses.
For example, addition (+) is listed as "Operator (3)" which means it has 3rd (third) highest priority.
Precedence levels range from 1 (highest) to 7 (lowest).
Note that any sub-expressions enclosed in parentheses will be evaluated with an even higher precendence.
© H2Obsession, 2014, 2019
Thanks to Tiaan Geldenhuys for corrections on less-than ($b3) and greater-than ($b1) operators!!
|