Tutorial 1

Your first running program

Most tutorials start with a "Hello World" program. Not this one. Hello World on the Genesis in ASM takes a lot more code and knowledge of the hardware compared to other computers. This is because the Genesis doesn't have any built in font, or method of drawing text on the screen.

What you will need:

The tutorial starter files.

Gens KMod

A text editor such as notepad++. Notepad works too, but lacks syntax highlighting.

Z80 & 60K syntax highlighting plug-in (optional, for notepad++)

I would also recommend reading sonicretro's 68k instruction documentation.

What is our goal?

Our goal is to make a running program, even if it doesn't do anything to show that it's running.

Let's start!

Start by opening up the "source.asm" in the .zip provided in your editor of choice.

You will see a file header at the beginning of the file. You can ignore this for now. There is also some code to clear out the system registers and RAM. This can also be ignored for now. For now, we will be adding a single instruction in between the "loop:" label and the "bra loop" instruction. This is the loop that the program runs after it's finished with clearing the RAM and registers.

Logo

We will be adding one simple instruction here. "add.l #$01,d0" (or any other data register). This increments data register zero by one every time the loop is run.

Logo

Easy peasy! Now save the .asm, and double click the "make.bat" included in the .zip download. This will compile your program. If all goes well, it should spit out a file named "output.bin".

Now, open up Kmod Gens and open up your newly compiled program. Once it's opened, you will only get a black screen. Go to the "CPU" tab in Gens, choose "debug", then "genesis", then click "Genesis - 68K". A window will come up and you should see the D0 register counting up very quickly.

Logo

I know it's not much, but I want to start my tutorials as simple as possible. There is a lot you need to know before you get any sort of graphic or sound output.

Go back to tutorials