Home
CBM
  ASCII-X
  BASIC
    Disk Commands
    Enter RUN mode
    Program Format
    Secret Variables
    Variable Format
    Expressions
    Keywords
    Syntax
    Tokens
  C128
  D64plus
  Disk
  Escape Codes
  Hardware
  PCxface
  PETSCII
  Pet2asc
Futurama
IBM PC-AT
Contact
Games
Glossary
Hall of fame
Hall of shame
Miscellaneous
Privacy policy
Programming
Twisty puzzles
Most of the keywords used by Commodore BASIC are "compressed" into (typically) a 1-byte code known as a token (rarely a 2-byte code).  This has several advantages: longer programs can be stored in memory, scanning through a program line is faster, program files are smaller, loading/saving the program is faster, and executing the program is faster.  Although Commodore BASIC is said to be an interpreter, the conversion into tokens is essentially a form of compilation.  So when the program runs, BASIC does not need to parse the text of "PRINT" for example, it instead just does a quick look-up based on the token.  (Off-topic, the main reason it is called an interpreter is because the variables and line numbers must be searched when the program runs; a compiler would hard-code such references.)
 
Below is a table listing all keywords ordered by their token value (if it has one).  (Here you can find a table ordered by name.) This table also includes the version number(s) to which it applies, and a classification.
Token (hex)KeywordVersion(s)Classification
44 53**DS3.5+Reserved variable (read only)
44 53 24**DS$3.5+Reserved variable (read only)
45 4C**EL3.5+Reserved variable (read only)
45 52**ER3.5+Reserved variable (read only)
53 54**ST1.0+Reserved variable (read only)
54 49**TI1.0+Reserved variable
54 49 24**TI$1.0+Reserved variable
80END1.0+Command* and Statement
81FOR1.0+Command and Statement
82NEXT1.0+Command, Preposition and Statement
83DATA1.0+Command* and Statement
84INPUT#1.0+Statement
85INPUT1.0+Statement
86DIM1.0+Command and Statement
87READ1.0+Command and Statement
88LET1.0+Command and Statement
89GOTO1.0+Command and Statement
8ARUN1.0+Command and Statement
8BIF1.0+Command and Statement
8CRESTORE1.0+Command and Statement
8DGOSUB1.0+Command and Statement
8ERETURN1.0+Statement
8FREM1.0+Command and Statement
90STOP1.0+Command* and Statement
91ON1.0+Preposition
92WAIT1.0+Command and Statement
93LOAD1.0+Command* and Statement
94SAVE1.0+Command and Statement
95VERIFY1.0+Command* and Statement
96DEF1.0+Statement
97POKE1.0+Command and Statement
98PRINT#1.0+Command and Statement
99PRINT1.0+Command and Statement
9ACONT1.0+Command* and Statement
9BLIST1.0+Command and Statement*
9CCLR1.0+Command and Statement
9DCMD1.0+Command and Statement
9ESYS1.0+Command and Statement
9FOPEN1.0+Command and Statement
A0CLOSE1.0+Command and Statement
A1GET1.0+Statement
A1 23GET#1.0+Statement
A1 F9GETKEY3.5, 7.0 Statement 
A2NEW1.0+Command and Statement*
A3TAB(1.0+Preposition
A4TO1.0+Preposition
A5FN1.0+Function/Preposition
A6SPC(1.0+Preposition
A7THEN1.0+Preposition
A8NOT1.0+Operator (5)
A9STEP1.0+Preposition
AA+1.0+Operator (3)
AB-1.0+Operator (3)
AC*1.0+Operator (2)
AD/1.0+Operator (2)
AE^1.0+Operator (1)
AFAND1.0+Operator (6)
B0OR1.0+Operator (7)
B1>1.0+Operator (4)
B2=1.0+Operator (4)
B3<1.0+Operator (4)
B4SGN1.0+Function
B5INT1.0+Function
B6ABS1.0+Function
B7USR1.0+Function
B8FRE1.0+Function
B9POS1.0+Function
BASQR1.0+Function
BBRND1.0+Function
BCLOG1.0+Function
BDEXP1.0+Function
BECOS1.0+Function
BFSIN1.0+Function
C0TAN1.0+Function
C1ATN1.0+Function
C2PEEK1.0+Function
C3LEN1.0+Function
C4STR$1.0+Function
C5VAL1.0+Function
C6ASC1.0+Function
C7CHR$1.0+Function
C8LEFT$1.0+Function
C9RIGHT$1.0+Function
CAMID$1.0+Function
CBGO2.0+Command and Statement
CCRGR3.5,7.0Function
CCCONCAT4.xCommand and Statement
CDRCLR3.5,7.0Function
CDDOPEN4.xCommand and Statement
CERLUM3.5Function
CEDCLOSE4.xCommand and Statement
CE 02POT7.0Function
CE 03BUMP7.0Function
CE 04PEN7.0Function
CE 05RSPPOS7.0Function
CE 06RSPRITE7.0Function
CE 07RSPCOLOR7.0Function
CE 08XOR7.0Function
CE 09RWINDOW7.0Function
CE 0APOINTER7.0Function
CFJOY3.5,7.0Function
CFRECORD4.xCommand and Statement
D0RDOT3.5,7.0Function
D0HEADER4.xCommand and Statement
D1DEC3.5,7.0Function
D1COLLECT4.xCommand and Statement
D2HEX$3.5,7.0Function
D2BACKUP4.xCommand and Statement
D3ERR$3.5,7.0Function
D3COPY4.xCommand and Statement
D4INSTR3.5,7.0Function
D4APPEND4.xCommand and Statement
D5ELSE3.5,7.0Command*, Preposition, and Statement*
D5DSAVE4.xCommand and Statement
D6RESUME3.5,7.0Statement
D6DLOAD4.xCommand* and Statement
D7TRAP3.5,7.0Statement
D7CATALOG4.xCommand and Statement
D8TRON3.5,7.0Command and Statement
D8RENAME4.xCommand and Statement
D9TROFF3.5,7.0Command and Statement
D9SCRATCH4.xCommand and Statement
DASOUND3.5,7.0Command and Statement
DADIRECTORY4.xCommand and Statement
DBVOL3.5,7.0Command and Statement
DBDCLEAR4.7Command and Statement
DCAUTO3.5,7.0Command and Statement
DCBANK4.7Command and Statement
DDPUDEF3.5,7.0Command and Statement
DDBLOAD4.7Command and Statement
DEGRAPHIC3.5,7.0Command and Statement
DEBSAVE4.7Command and Statement
DFPAINT3.5,7.0Command and Statement
DFKEY4.7Command and Statement
E0CHAR3.5,7.0Command and Statement
E0DELETE4.7Command
E1BOX3.5,7.0Command and Statement
E1ELSE4.7Preposition
E2CIRCLE3.5,7.0Command and Statement
E2TRAP4.7Statement
E3GSHAPE3.5,7.0Command and Statement
E3RESUME4.7Statement
E4SSHAPE3.5,7.0Command and Statement
E4DISPOSE4.7Command and Statement
E5DRAW3.5,7.0Command and Statement
E5PUDEF4.7Command and Statement
E6LOCATE3.5,7.0Command and Statement
E6USING4.7Preposition
E7COLOR3.5,7.0Command and Statement
E7ERR$4.7Function
E8SCNCLR3.5,7.0Command and Statement
E8INSTR4.7Function
E9SCALE3.5,7.0Command and Statement
EAHELP3.5,7.0Command and Statement*
EBDO3.5,7.0Command and Statement
ECLOOP3.5,7.0Command and Statement
EDEXIT3.5,7.0Command and Statement
EEDIRECTORY3.5,7.0Command and Statement
EFDSAVE3.5,7.0Command and Statement
F0DLOAD3.5,7.0Command and Statement*
F1HEADER3.5,7.0Command and Statement
F2SCRATCH3.5,7.0Command and Statement
F3COLLECT3.5,7.0Command and Statement
F4COPY3.5,7.0Command and Statement
F5RENAME3.5,7.0Command and Statement
F6BACKUP3.5,7.0Command and Statement
F7DELETE3.5,7.0Command and Statement
F8RENUMBER3.5,7.0Command
F9KEY3.5,7.0Command, Preposition, and Statement
FAMONITOR3.5,7.0Command and Statement*
FBUSING3.5,7.0Preposition
FCUNTIL3.5,7.0Preposition
FDWHILE3.5,7.0Preposition
FE 02BANK7.0Command and Statement
FE 03FILTER7.0Command and Statement
FE 04PLAY7.0Command and Statement
FE 05TEMPO7.0Command and Statement
FE 06MOVSPR7.0Command and Statement
FE 07SPRITE7.0Command and Statement
FE 08SPRCOLOR7.0Command and Statement
FE 09RREG7.0Command and Statement
FE 0AENVELOPE7.0Command and Statement
FE 0BSLEEP7.0Command and Statement
FE 0CCATALOG7.0Command and Statement
FE 0DDOPEN7.0Command and Statement
FE 0EAPPEND7.0Command and Statement
FE 0FDCLOSE7.0Command and Statement
FE 10BSAVE7.0Command and Statement
FE 11BLOAD7.0Command and Statement
FE 12RECORD7.0Command and Statement
FE 13CONCAT7.0Command and Statement
FE 14DVERIFY7.0Command and Statement
FE 15DCLEAR7.0Command and Statement
FE 16SPRSAV7.0Command and Statement
FE 17COLLISION7.0Command and Statement
FE 18BEGIN7.0Preposition
FE 19BEND7.0Command* and Statement*
FE 1AWINDOW7.0Command and Statement
FE 1BBOOT7.0Command and Statement
FE 1CWIDTH7.0Command and Statement
FE 1DSPRDEF7.0Command and Statement
FE 1EQUIT7.0Command and Statement
FE 1FSTASH7.0Command and Statement
FE 21FETCH7.0Command and Statement
FE 23SWAP7.0Command and Statement
FE 24OFF7.0Preposition
FE 25FAST7.0Command and Statement
FE 26SLOW7.0Command and Statement
FFπ (pi)1.0+Reserved variable
Wow, you read all that?! A few notes about the the table. The "tokens" marked ** are really just the character 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 (*).
 
For example, LIST is classified as "Command or Statement*" (note the * following Statement).  This is because you wouldn't normally include LIST as a statement within a program.  The reason is, when it is used inside a program, it has the (usually undesired) side-effect of ending the program.  Another example would be END; classified as "Command* or Statement" (note * by Command) because it is normally only used as a statement within a program.  Commanding the computer to END in direct mode does not cause any error, but it doesn't do anything useful because (by definition) no program is running in direct mode.
 
Expressions in BASIC are evaluated using a fixed precedence (order of operations) for the different math operators.  For example, LET Y= 1+2*X would evaluate 2 times X before adding 1.  This is because multiplication (* operator) has higher precedence than addition (+ operator).  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.  One obscure/interesting thing to note is that although most operators are 1-character symbols (thus only need 1 byte to encode), their token values are radically different from their ASCII/PETSCII codes.

© H2Obsession, 2014, 2019
Thanks to Tiaan Geldenhuys for correction of token values of less (<) and more (>)!!