Your First 68k Program

Creating a program in the Program Editor

Time to make your first program in 68k Basic! In the APPS menu select #7, go to the "Program Editor", and then press "New". Enter a name for your program in the variable field, let's call it "hellowld". Press enter, and here we go!

Creating the Program

The following program, when executed, will display the phrase "Hello World!"

hellowld()
:Prgm
:ClrIO
:
:Disp "Hello World!"
:
:Pause
:ClrIO
:DispHome
:EndPrgm

Let's go through a line-by-line analysis of this code.

hellowld()
:Prgm

This is where the program starts. Every program you make will start with the name of the program, followed by parenthesis. The nest line contains an opening Prgm tag, which indicates the beginning of the program. Everything after it will contain the actual code that you write.

:ClrIO
:
:Disp "Hello World!"

The next command is ClrIO, which will clear the Input/Output buffer. For those who don't know what this is, it's basically a different section of the calculator where output is displayed (so output is not displayed on the Home screen, it is displayed here). After that, we have a new command Disp, which displays a string to the IO buffer.

:Pause
:ClrIO
:DispHome
:EndPrgm

We then pause the program, which will halt program execution until the ENTER key is pressed. More information on why we do this up ahead. After pressing the enter key, the program clears the IO buffer (which erases the "Hello World!" message from it) and goes back to the home screen using the DispHome command. This is the end of our program, which means that we can add the EndPrgm tag, which closes the program.

You may look back and ask, why did we include the pause command? This is because shortly after, we display the home screen using DispHome. This means that the "Hello World!" message will be printed the IO buffer, but it will display the home screen quickly before you can even try to read the message. We add the pause in there to allow the user to read the message before executing the rest of the code. This roadblock can be crossed by removing the DispHome command, but for ease of use, we keep the DispHome and make sure to throw in the pause command after we display the text.

<< Overview of 68k Basic Table of Contents Good Programming Practices >>
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 License.