Every programmer who has ever laid down code has read at least one Hello World tutorial. Welcome to the club.
Hello World tutorials are designed to show what the absolute minimum for a program is in a particular programming language. In CBM BASIC, that's not very much at all. I'm assuming you have a Commodore 64 and/or an emulator. If you do not have either, I recommend WinVICE.
Turning on Your c64
If you use WinVICE, make sure you click on the program named x64.exe. WinVICE comes with many emulators; x64.exe is the one that emulates the c64.
Once the emulator is started, it will boot up just like a real Commodore 64 will. You should see this shortly after you start the emulator :
**** COMMODORE 64 BASIC V2 ****
64K RAM SYSTEM 38911 BASIC BYTES FREE
If you've never used a c64 before, this is its way of saying hello. This is what the above means :
**** COMMODORE 64 BASIC V2 ****
The Commodore company just didn't sit and let its version of BASIC wither away throughout the years that it was being used in its computers. Like most of the programming languages of today, CBM BASIC was updated over time. This means you are using Version 2.
64K RAM SYSTEM
In total, the c64 has 64k of memory to work with. For comparison, one megabyte is 1024k.
38911 BASIC BYTES FREE
The c64's operating system (known as the kernel) and the BASIC interpreter take up some of that 64k. This leaves you with 38911 bytes, or just over 37k to work with.
Hello World
Now that you know a bit about the environment you are working in, let's get to coding. Here's the code to display the words Hello World on the screen. One thing to note, though, before typing in this code. On the c64, and for most emulators, the " character is found above the 2. Also note that the c64 by default uses all caps. Pressing SHIFT + any letter will give you an ASCII character rather than a letter.
PRINT "HELLO WORLD"
After you press ENTER, the c64 will immediately respond with
HELLO WORLD
This is what's known as the immediate mode. Whenever you type in code in the immediate mode, the c64 executes them immediately.
Line Numbers
To keep a program in memory so that you can run it any time you like, simply put a line number before each line. When you do this, the c64 will store the line and wait for you to tell it to execute the entire code of your game.
Type this in:
10 PRINT "I AM YOUR LOYAL ROBOT SLAVE."
and then hit ENTER.
As you can see, nothing appears to have happened. In fact, the line has been stored in memory. To see the code currently stored in memory, type
LIST
and hit ENTER.
To run the code, type :
RUN
and hit enter.