This section will show you how Basic Programming examples can be taken apart and studied. This will allow you to become a better programmer in time since you will start to extract how parts of the code work to accomplish tasks.

The concept behind this is known as “debugging”. It’s an old school term that tells a programmer that although no syntax errors exist in code, the program is still not performing as it should. History even speaks about a machine breaking down in the early 50’s due to an actual insect getting caught among wires.

So I am going to tackle small programs, and eventually work up to larger programs that should help you enhance your skills as a programming. Eventually I am hopeful that you too will be able to load up VICE or boot up your favorite Commodore 64 system and get to work writing your own masterpiece.

So imagine if you could be the next person to right the hottest game on the market, or create a sound system that helps you become a better musician, or create an accounting budget/spreadsheet that allows you to balance data instead of learning tedious software like Microsoft Excel, or imagine creating fantastic artwork, plus you could even create utilities that extend your PET/VIC 20/Commodore 64 system to the max!

There was a time when I too felt I was never going to understand the complexity of merging statements together to create what I had already conceived in my mind as a plan. Work hard, be confident, and keep persistent and you too will be on the same or even better path.

I therefore dedicate my entire’s life of work here to help you become a master at programming.

VICE C64 Live Emulator

Feel free to use the VICE C64 Emulator below to load up Basic programs or files that were downloaded on this page.

To load a file, click on the menu C64/Attach D64 or you can also drop and drag a .D64 image onto the VICE window and it will load.

Analyzing Code Segments

For this session, we will analyze code from a program, taking it apart section by section. By separating the code into segments, you will start to understand it better. Programming is all about condensing a section of code, evaluate it, and start discovering what it does or is supposed to accomplish.

So let’s start off to examine a simple program. As we advance further, we will start to dig into debugging some longer programs to get you in a routine when learning to do this.

10 T=0




50 T=T+X


70 A=T/N




110 END

Let’s start reviewing at the beginning.

Line 10: sets T=0. This is the way of initializing a variable before it is used later in the program.

Line 20: writes a message “HOW MANY NUMBERS” and waits for the user to type in a response. Then the prompt stores the result in the N variable embedded on the end.

Line 30 starts what is known as a loop. This loop counts in a sequence until it finishes at the last part. So the statement FOR J=1 TO N starts the count at one and ends at the N variable we defined earlier. This allows the loop to be controlled in a range you requested from the prompt.

Line 40: another request from the user is created here. This one writes the message “PLEASE ENTER A NUMBER”, waits for the user of the program to type a number, and then the result is stored in the variable called X.

Line 50: here we are using the variable we set at line 10 and appending the results X to it in an accumulating manner. This is known as creating a total. The statement shows T = T + X.

Lines 60: here we finish the loop that began in line 30 by indicate a NEXT.  The NEXT statement is a call in the program that retrieves the next variable from the FOR loop.

Line 70: we are creating a brand new variable called A. This variable is receiving the result of the totals taken from line 70 and then they are divided by N. Essentially it is creating an average of the total numbers we pass to the input prompt.

Line 80: using the statement PRINT, which just moves the cursor to the next line down.

Line 90: show the message “YOU HAVE” first. Then get the result of the numbers we entered at line 20. Next show the message “NUMBERS TOTALING”. Finally append the variable T to the end, which represents the total accumulated from line 50.

Line 100: show the message “AVERAGE =” on the screen. then append the result of A to the end. This is displaying the average of the numbers obtained from our totals.

Line 110: ends the program.