Learning Assembler on Amiga #10 - Debugger

Let's practice how to debug our own code to find reasons to drink vodka to forget why we are even trying to learn assembler in the first place...

4 years ago

Latest Post The Great Escape Tunnel by Mario Esposito public

At the user's request, I built an index page of previous lessons. It’s here and as usual, read my disclaimer. Let’s begin…

In this lesson, we’re going to put together everything we learned in Lessons 6, 7, and 8. Buckle up!

No matter what type of language on which type of hardware you want to master your skills on, there’s a sanctioned truth that no one can escape. The Debugger!

If you can’t “look into” what your code does while it’s running or after it is executed then you are flying blind. And that is Russian roulette buddy.

Originally posted by reitija

There are multiple ways and tools to debug your code. Each way has bugs and inconveniences but in the end, once you develop your own methodology and muscle memory you adapt to anything that floats your boat best.

The most obvious way of debugging is with Asm One, the second most obvious way is to use Visual Studio Code with an extension that leverages vasm and vlink in combo with FS-UAE.  The debugger behind the scene for this “hack” is Capstone.

If you want to test things out directly into an Amiga environment, Asm One is the way to go as you experience and see things as back in the days. If you want the speed of execution (mechanical not digital) then you want to leverage more modern things like Visual Studio Code.

I am still learning my way through the Visual Studio Code option and since everyone that shares material around that subject online either assumes that the target audience was born in a chip factory or spells like someone that had plenty of vodka before puking some knowledge, I need more time to figure it out on my own.

Therefore, to put to the test what we learned in lesson #8, we are going to use Asm One.

Here are the things we have to learn before we start jamming code like maniacs!


Make sure that you have installed Asm One as per the version I have with the same settings.


Asm One has menus that you can access just like in another Amiga application. However, because you move a lot between the various parts of the developer IDE (debugger, editor, assembler…) it’s a lot more practical to memorize a few short commands that will make you be more focused on the code and debugging and less on “where’s that menu…”. The shortlist for today:

zs = zap source = new file
wn = save file
r = open file
h <address/symbol> memory dump with using the provided starting location in memory
a = assemble my source
j = run my code

Unless you have changed it, don’t worry about case-sensitive Unix typical nightmares.


MOVE = see lesson #7
ADD    = Add a value into a location (registry, else)
LEA     = It stands for load effective address. Takes data from a constant and puts it into an address you indicate
TST     = Test if an operand is zero
BEQ    = Branch if the result is zero. In lesson #7 you find more details about branching
BRA    = Branch always. Not it’s not an undergarment for women. It’s the equivalent of a GOTO in the old basic.
DC      = It’s a mechanism for storing constants/data into memory, you can give them names and then refer to such data using their mnemonic names.


Launch FS-UAE (or the actual machine) and launch Asm One. Then let’s start with what we learned in lesson #8, let’s put something arbitrary as 1234 into the D0 registry.

Here is the code:

hit the ESC button to go to the command line and enter A to assemble. If you didn’t mess anything up (spaces or other typical issues), you should see this output:

If you don’t have that output, then the most common issues that I have run into at the beginning were:

To execute the code you just built, just run the command J the output is expected to be like this.

Notice that in the D0 registry now you have our magic 1234. Time to celebrate!!! To stop running amok, we got more code to write, drop that Mojito and let’s go back to the keyboard.

In lesson #6 we learned the importance of offsets and how to shift information from one location to the other.

Perhaps the most important aspect of that lesson is that you can put some data into a location (e.g. A0) using this notation: move.b  $000010,$00002D, or you can use the indexing feature and add data to the existing targeting address. From lesson #8:

As you can see, a0 acts as a gateway to memory. The address registers support a feature called indexing.move.b    #$9B,$04(a0)The $04 you see right before the parenthesis, is the index value, this will add to the offset inside a0 to give you a new offset.  So a0 contains 00000039, you add 04 which gives you 0000003D, so, 9B is moved to offset 0000003D:

to be continued… (dinner is ready and it’s Christmas eve…)

Happy holidays!!!

Mario Esposito

Published 4 years ago