Elenco comandi Basic V2 del Commodore 64

Read in: IT 🇮🇹   EN 🇺🇸

Ecco la lista completa dei comandi, delle funzioni e delle variabili riservate del Basic V2 del Commodore 64, con una semplice spiegazione ed un esempio di utilizzo.

Iscriviti al mio canale YouTube: ValorosoIT. Retro tecnologia, impianti stereo vintage, retro computer, esperimenti e prove. Retroprogrammazione, Basic. Commodore, IBM, Atari, Apple, Texas Instruments, Amstrad, MSX.

Questo è un semplice compendio per ricordare tutti i comandi, le istruzioni e le funzioni, quando già si sa come utilizzarli! Il Basic V2 del Commodore 64 ha molte meno istruzioni rispetto al Basic V3.5 del Commodore 16, 116, Plus/4 e rispetto al Basic V7 del Commodore 128.

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
Iscriviti al gruppo Facebook. Retro tecnologia, Commodore, impianti stereo vintage, retro computer, esperimenti e prove. 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
Iscriviti al gruppo Facebook. Retro tecnologia, Commodore, impianti stereo vintage, retro computer, esperimenti e prove. 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)

 

Sul sito www.valoroso.it e sul canale YouTube ValorosoIT, sto pubblicando diverse puntate per imparare a programmare in Basic, con il Comodore 64, Commodore 128, GwBasic, QuickBasic, QB64, Atari, ecc...

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

Iscriviti al mio canale YouTube: ValorosoIT. Retro tecnologia, impianti stereo vintage, retro computer, esperimenti e prove. Retroprogrammazione, Basic. Commodore, IBM, Atari, Apple, Texas Instruments, Amstrad, MSX.

Pubblicato in Retro Computer, Retro Tecnologia ed Elettronica Vintage, Tutti gli articoli.

12 Commenti

  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. Ammetto che è molto interessante e mi piacerebbe scrivere un progetto da zero con il tuo aiuto più che altro perché sono completamente digiuno di qualsivoglia tipo di programmazione. I tuoi corsi sono interessanti ma spesso mi lasciano dei vuoti che stento a colmare. Da qualche giorno sto provando a scrivere un gioco ma senza successo e mi piacerebbe avere il tuo aiuto o qualche dritta.

    Intanto ti ringrazio per tutto il tuo prezioso lascito

  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.

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *