Time-Travelling to Commodore 64: Hello World Program on C.
Tags: commodore64, c64, retrocomputing, retroprogramming
Published: 2023-08-07 06:14:19

---
title: Time-Travelling to Commodore 64: Hello World Program on C.
published: true
description: 
tags: #commodore64, #c64, #retrocomputing, #retroprogramming
# cover_image: https://cdn-images-1.medium.com/max/2000/1*3EiDFNItVQwExZIUDxX4fg.png
# Use a ratio of 100:42 for best results.
# published_at: 2023-08-07 06:08 +0000
---

![](https://cdn-images-1.medium.com/max/2000/1*3EiDFNItVQwExZIUDxX4fg.png)
This time I will review the possibilities of programming on the Commodore 64 and try to understand how a modern programmer would feel in the realities of the mid-80s.

In those years, I did not have a Commodore 64 but had a ZX Spectrum clone.

![](https://cdn-images-1.medium.com/max/2400/1*IKUvWM9g4qkFKIsW6N4EjA.jpeg)

There was no Internet, and there were few programming books.
So the maximum I then did on the Spectrum was writing simple scripts in BASIC to solve problems in mathematics and physics and games like Landing on the Moon.

![](https://cdn-images-1.medium.com/max/2000/1*LtRjIXhllPPJb2YyJwD2sQ.png)

Therefore, I have always been interested in the stories of my acquaintances who did more exciting things on 8-bit computers. I wanted to do it myself using the knowledge now available.

I'm starting an experiment. I'm in my mid-80s; I have a Commdore64 with a disk drive, some set of programs and books, there is no Internet, but the grass is greener, the sun is brighter, and the girls are more beautiful, and there is also a lot of time for experiments.

![](https://cdn-images-1.medium.com/max/2000/1*nJ-eFZR-RxkgIs8QE1svvw.png)

From the beginning, I needed to understand what the Commodore 64 offered for programming and try to write a "hello world" program.

The first thing that catches my eye is a different layout of special characters on the keyboard and a tiny resolution by modern standards.

![](https://cdn-images-1.medium.com/max/4088/1*SLiokUEYoXxPLxUzmPn65w.png)

If I get used to the layout, it's a matter of time, but how the developers in these conditions viewed and debugged extended programs; so far, the question is.

After turning on the C64, BASIC is launched. This is a programming environment and a shell with essential OS functions.
I can save and delete files to disk and make some adjustments by changing the values of variables in memory using the poke statement.

    // There is a command examples
    SAVE "MY_PRG",8
    LOAD "MY_PRG",8,1
    LIST
    RUN
    POKE 53280,1

Since BASIC starts immediately, let's try to do something about it, for example, "Hello world".
In BASIC, everything is simple. Compared to Spectrum, the C64 has a more advanced ability to edit text within the screen.
The first program looks like this.

![](https://cdn-images-1.medium.com/max/2000/1*R1Pbb7Tp3Dp9Z-etMTCpXA.png)

![](https://cdn-images-1.medium.com/max/2000/1*VXQcyjKSJ3-53TV-kZ43Cw.png)

I can save a program to disk and then load it back.
I figured out the BASIC, but there are too few tools here.

What else can I try? Assembly is still tricky because I need to learn a set of commands.
The C should be better here because I know it.
I have a set of two floppy disks for C with the "power c" compiler.

![](https://cdn-images-1.medium.com/max/2000/1*M9u0vB-uophqZhM5a0cZJg.jpeg)

After a short study of the manual, I started the shell.

![](https://cdn-images-1.medium.com/max/2000/1*basau7MYoWOHQsbhOu8Ncg.png)

![](https://cdn-images-1.medium.com/max/2000/1*vaIdlAihg2ve-WW7SeeLlg.png)

Compared to BASIC, it's much more comfortable; at least there are several Unix-like commands like 'ls' and 'rm'.

I launch the editor and enter the program's text. The non-standard layout still interferes, but it's not so scary anymore. Curly braces are placed on the "+" and "-" keys. I know it from the manual.

    // command to launch editor with spell checking
    
    ced

![](https://cdn-images-1.medium.com/max/2000/1*UjNcI_6AqqyGJqZIBI_Stw.png)

I have entered the program. The separate command performs a syntax check
Command mode is invoked by key (Hi VIM)

    // to enter command mode press [run/stop] button
    // command to start spelcheking 
    
    check
    
    //command to exit to shell
    
    quit
     
    

From the same mode, we save the program's text to disk just to the same disk where power c is located. It's worth saving to a separate floppy disk for more complex projects.

![](https://cdn-images-1.medium.com/max/2000/1*as73FEFFp_F3bldCWN32zQ.png)

I exit the editor and start the compiler. Here is a suggestion to use separate source and object file disks.

![](https://cdn-images-1.medium.com/max/2000/1*T2xNWNRtcP-Vl4Hi86qUAQ.png)

I run the linker to create a simple shell executable.

![](https://cdn-images-1.medium.com/max/2000/1*UwMXiyk6k37F7BNdxuxwFQ.png)

Then I enter a special character — arrow to top. At this stage, I need to change the disk to the second one because that is where the necessary libraries are located. After the prompt, change the disk back. Save the executable file. Everything is ready. Now I can run my program as a shell script.

![](https://cdn-images-1.medium.com/max/2000/1*DL33CS6gN9rJ1oCuvJBuKA.png)

Yes, the programmer is almost a DJ here, but if the project is large and the source and object files are stored on separate disks…..

This most straightforward program's compilation, linking and loading time could be more encouraging. I had time to read the manual during the process, but what will happen on a more advanced project?

I add the key -s to the link command, repeat the linking process, and get an independent executable file.

![](https://cdn-images-1.medium.com/max/2000/1*Buqm9xv8dDbNmvV9A_v7IA.png)

This executable I can now load and run from BASIC.

![](https://cdn-images-1.medium.com/max/2000/1*ezLYMbXmJa-DlmZLrZOeEg.png)

The inscription became an upper case for some reason, but this looks like some feature. I will deal with this later.

The "Hello World" program is not just a string output. It means 
the developer knows how to use the editor, compiler and linker. These days when it's all done automatically or in one command, it doesn't seem very relevant, but on C64, "hello world" is still an important step to start programming.

The first step is done, now I still need to make hello world in Assembly, and then it will be possible to say that I have all the tools in my hands.

I don't want to return from the 80s, so I'll rest here and take a walk.

Thank you for being a part of this journey.
I hope it was at least fun.
Warm regards.
Stay tuned for my next posts.