Commodore 64 Basic V2 Command List

Read in: IT 🇮🇹   EN 🇺🇸

Here is the complete list of the controls, functions and reserved variables of the Basic V2 of the Commodore 64, with a simple explanation and an example of use.

Subscribe my YouTube channel ValorosoIT. Retro technology, vintage audio, retro computers, experiments and tests. Retroprogramming, Basic. Commodore, IBM, Atari, Apple, Texas Instruments, Amstrad, MSX.

This is a simple compendium to remember all commands, instructions and functions, when you already know how to use them! The basic V2 of the Commodore 64 has much less instructions than the Commodore 16, 116, Plus/4 Basic V3.5 and compared to Commodore 128 Basic V7.

InstructionDescriptionType
ABSReturns the absolute value of a numberFunction, numerical
PRINT ABS(-5)
ANDReturns true if both conditions are trueOperator, logical
A=5: B=10
IF A=5 AND B=10 THEN PRINT "OK"
ASCReturns the numerical value of a charFunction, numerical
PRINT ASC("A")
ATNReturns the arctangent of a numberFunction, numerical
PRINT ATN(1)
CHR$Returns the character corresponding to the numberFunction, string
PRINT CHR$(65)
CLOSECloses a fileInstruction/command
10 OPEN 1,8,2,"FILE"
20 PRINT#1,"AMEDEO"
30 CLOSE 1
CLRDelete variables arrays, data, …Instruction/command
A=10
CLR
PRINT A
CMDChanges the data output to other peripheralInstruction/command

CMD 4
CONTResumes execution of a BASIC programCommand
10 PRINT "1"
20 END
30 PRINT "2"
RUN
CONT
COSReturns the cosine of an angle (rad)Function, numerical
PRINT COS(0)
DATAStores constant information in the program codeInstruction/command
10 DATA 5,10,15
20 READ A,B,C
30 PRINT A,B,C
DEF FNDefines a user-defined functionInstruction
10 DEF FNS(X)=X*2
20 PRINT FNS(4)
DIMAllocates space in array memory for a new arrayInstruction/command
10 DIM A(5)
20 A(1)=42: A(2)=36
30 PRINT A(1)
ENDEnds the processing of the current programInstruction/command
10 PRINT "1"
20 END
30 PRINT "2"
EXP"e" with the power given by the argumentFunction, numerical
PRINT EXP(1)
FNExecutes a function defined by DEF FNFunction, numerical, special

10 DEF FNA(X)=X+1
20 PRINT FNA(5)
FORProgram loop start (FOR … TO … STEP … NEXT)Instruction/command
10 FOR I=1 TO 8 STEP 3
20 PRINT I
30 NEXT I
FREReturns the number of unused bytes of BASIC RAMFunction, numerical, special
PRINT FRE(0)
GETReads one or more chars from the keyboardInstruction
10 GET A$: IF A$="" GOTO 10
20 PRINT A$
GET#Reads single characters from the specified deviceInstruction/command, special
10 OPEN 1,8,2,"FILE"
20 GET#1,A$
30 PRINT A$
40 CLOSE 1
GO TOJumps to a line numberInstruction/command
10 GO TO 100
20 PRINT "1"
100 PRINT "2"
GOSUBJumps to a subroutine … RETURNInstruction/command
10 GOSUB 100
20 END
100 PRINT "SUBROUTINE"
110 RETURN
GOTOJumps to a line numberInstruction/command
10 GOTO 100
20 PRINT "1"
100 PRINT "2"
IFTests a condition IF … THEN or IF … GOTOInstruction/command
Follow me on Instagram channel. Retro technology, Commodore, vintage audio, retro computers, experiments and tests. Retroprogramming, Basic. Commodore, IBM, Atari, Apple, Texas Instruments, Amstrad, MSX.

10 A=5
20 IF A=2 THEN PRINT "2!!!"
30 IF A=5 THEN PRINT "A = 5!!!"
INPUTReads data from the keyboardInstruction
10 INPUT "WHAT IS YOUR NAME";A$
20 PRINT A$
INPUT#Reads data from a file stored on peripheral deviceInstruction
10 OPEN 1,8,2,"FILE"
20 INPUT#1,A$
30 PRINT A$
40 CLOSE 1
INTRounds a numberFunction, numerical
PRINT INT(5.7)
LEFT$Left chars of a stringFunction, string
10 A$="AMEDEO"
20 PRINT LEFT$(A$,3)
LENReturns the number of characters in a stringFunction, numerical
PRINT LEN("TEST")
LETAssigns values in a variableInstruction/command
LET A=10
PRINT A
LISTDisplays the BASIC program in memoryInstruction/command
10 PRINT "HELLO"
20 GOTO 10
LIST
LOADLoads a programInstruction/command

LOAD"PROGRAM",8
LOGNatural logarithm with the basis eFunction, numerical
PRINT LOG(10)
MID$Inner chars of a stringFunction, string
10 A$="HELLO"
20 PRINT MID$(A$,2,3)
NEWClears RAM and programInstruction/command
NEW
NEXTProgram loop end (FOR … TO … STEP … NEXT)Instruction/command
10 FOR I=1 TO 5
20 PRINT I
30 NEXT I
NOTReverses true to falseOperator, logical
PRINT NOT 0
ONContruct ON … GOTO, ON … GOSUBInstruction/command
10 X=2
20 ON X GOTO 100,200,300
30 END
100 PRINT "1": END
200 PRINT "2": END
300 PRINT "3": END
OPENOpens a file or a channelInstruction/command
10 OPEN 1,8,2,"FILE"
20 PRINT#1,"AMEDEO"
30 CLOSE 1
ORReturns true if one or both conditions are trueOperator, logical
A=0: B=10
IF A=5 OR B=10 THEN PRINT "OK"
PEEKReturns the memory contentFunction, numerical
PRINT PEEK(53280)
POKEChanges the content of any memory addressInstruction/command
POKE 53280,0
POSDetermines the actual position of the cursorFunction, numerical, special
PRINT "  ";POS(0)
PRINTPrints data to the current output deviceInstruction/command
PRINT "AMEDEO"
PRINT#Stores data in a fileInstruction/command
10 OPEN 1,8,2,"FILE"
20 PRINT#1,"AMEDEO"
30 CLOSE 1
READReads constant values from DATAInstruction
10 DATA 42, 100, 232
20 READ A
30 PRINT A
REMCommentsInstruction/command
REM THIS IS A COMMENT
RESTOREClears the pointer of the next data valueInstruction/command

10 DATA 5,10,15
20 READ A,B
30 PRINT A,B
40 RESTORE
50 READ A,B
60 PRINT A,B
RETURNFinishes a subroutine: GOSUB …  RETURNInstruction/command
10 GOSUB 100
20 PRINT "1"
30 END
100 PRINT "2"
110 RETURN
RIGHT$Right chars of a stringFunction, string
10 A$="HELLO"
20 PRINT RIGHT$(A$,2)
RNDGenerates a random floating point numberFunction, numerical
PRINT RND(1)
RUNStarts a programInstruction/command
RUN
SAVESaves a programInstruction/command
SAVE"PROGRAM",8
SGNReturns the sign of a number (-1, 0, 1)Function, numerical
PRINT SGN(-5)
SINReturns the sine of an angle (rad)Function, numerical
PRINT SIN(0)
SPC(Sets a number of spacesFunction, PRINT (Carry = 0!)

PRINT SPC(5);"HELLO"
SQRCalculates square root of a numberFunction, numerical
PRINT SQR(9)
STGets I/O status byteReserved variable
PRINT ST
STEPProgram loop increment/decrement (FOR … TO … STEP … NEXT)Instruction/command, special
10 FOR I=1 TO 8 STEP 3
20 PRINT I
30 NEXT I
STOPBreaks a programInstruction/command
STOP
STR$Converts numerical values or variables into a stringFunction, string
PRINT STR$(123)
SYSCalls an assembly language subroutineInstruction/command
SYS 64738
TAB(Sets the cursor columnFunction, PRINT (Carry = 1!)
PRINT TAB(10);"HELLO"
TANReturns the tangent for a given angle (rad)Function, numerical
Follow me on Instagram channel. Retro technology, Commodore, vintage audio, retro computers, experiments and tests. Retroprogramming, Basic. Commodore, IBM, Atari, Apple, Texas Instruments, Amstrad, MSX.

PRINT TAN(1)
THENTests a condition IF … THENInstruction/command, special
10 A$="H"
20 IF A$="H" THEN PRINT "OK!"
30 IF A$<>"H" THEN PRINT "NO!"
TIGets the system time (seconds/60)Reserved variable
PRINT TI
TI$Gets or Sets the system time (HHMMSS)Reserved variable
PRINT TI$
TOProgram loop target (FOR … TO … STEP … NEXT)Instruction/command, special
10 FOR I=1 TO 5
20 PRINT I
30 NEXT
USRCalls an assembly language subroutine with argumentFunction, numerical/string
10 POKE 785,254: POKE 786,186
20 PRINT USR(85): REM DIVIDE BY 10
VALReturns the numerical value of a stringFunction, numerical
PRINT VAL("123")
VERIFYVerifies a saved programInstruction/command
VERIFY"PROGRAM",8
WAITWaits for a memory location to assume specific valuesInstruction/command

10 POKE 198,0
20 WAIT 198,1
30 PRINT "KEY PRESSED"
+SumOperator, numerical/string
PRINT 5+3
-SubtractionOperator, numerical
PRINT 5-3
*MultiplicationOperator, numerical
PRINT 5*3
/DivisionOperator, numerical
PRINT 6/3
^ExponentOperator, numerical
PRINT 2^3
GreaterOperator, logical
IF A>5 THEN PRINT "GREATER"
=EqualOperator, logical
IF A=5 THEN PRINT "EQUAL"
LessOperator, logical

IF A<5 THEN PRINT "LESS"
π (pi)3.1415926…Function, numerical, special
PRINT "PRINT " + CHR$(222)
π MUST BE GENERATED BY CHR$(222)

 

On the website www.valoroso.it and on the ValorosoIT YouTube channel, I am publishing several episodes to learn how to program in Basic, with the Commodore 64, Commodore 128, Gwbasic, Quickbasic, QB64, Atari, etc ...

YouTube: https://www.youtube.com/@ValorosoIT
Instagram: https://www.instagram.com/valorosoit/

Subscribe my YouTube channel ValorosoIT. Retro technology, vintage audio, retro computers, experiments and tests. Retroprogramming, Basic. Commodore, IBM, Atari, Apple, Texas Instruments, Amstrad, MSX.

Posted in Retro Computer, Retro Technology and Vintage Electronics, All articles.

12 Comments

  1. This is vегy interesting, You're a very skilled blogger.
    I've joined your fеed and look forwarԁ to seeking more of your wonderful post.
    Also, I have shared your website in my social networks!

  2. I've learn some excellent stuff here. Definitely bookmarking for revisiting.
    I surprise how so much effort you place to make one of these great informative website.

  3. I admit that it is very interesting and I would like to write a project from scratch with your help mostly because I am completely new to any type of programming. Your courses are interesting but often leave me with gaps that I struggle to fill. For a few days I've been trying to write a game but without success and I'd like to have your help or some advice.

    In the meantime, I thank you for all your precious legacy

  4. Imparare la programmazione non è facile, soprattutto all'inizio. Poi, quando si capisce la logica che c'è alla base, tutto diventa più semplice. Purtroppo, per mancanza di tempo, non riesco a seguire progetti individuali. Ti consiglio di partire da listati già esistenti online, andando poi a modificare qualcosa, giusto per capire come si interviene sul listato. Solo in un secondo tempo potresti partire da un nuovo progetto.

Leave a Reply

Your email address will not be published. Required fields are marked *