Learning Assembler on Amiga #8

By user's request, I built an index page of previous lessons. It’s here and as usual, read my disclaimer. Let’s begin… In lesson #7 we touched on the

3 years ago

Latest Post Running an old mac (g4) nowadays by Mario Esposito public

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

In lesson #7 we touched on the subject of registers, however, we didn’t go into the details of that. Let’s address that (such a pun!). The 68K processor has two types of registers. Data and Addressing registers.

The data registers are 8 and they are named d0,d1,d2…d7. The way you use them is something that at this point if you have been following along with the other lesson, shouldn’t be a surprise.

move.w    #$04F0,d0

That line of code moves a word (04F0) into data registry D0. The final result is  00 00 04 F0. You can perform byte, word and long word operations over data registries type at any time and most instructions are supported.

The address registers are 8 and they are a0,a1,a2…a7.

They can be used in much the same way as data registers, except, you cannot perform byte instructions on them. Some instructions that work on data registers won’t work on address registers too. These registers are used for storing addresses (i.e. offsets). You can write to or read from those offsets, for example:

movea.l   #$00000039,a0

Notice at the end of move, not a minor thing. Above, we moved the value 00000039 to address register a0. Now, if we want to move some arbitrary value into the location hosted in the registry a0 we would use the following notation:

move.b   #$44,(a0)

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:

On the “paper” this is all somewhat clear to understand. However, when dealing with things that are hard to stick in mind due to our brain accustomed to having the easy way out. Thanks, language interpreters. Damn you! The best way to crystallize this new information is by writing some code and observe what happens in memory as those instructions play out.

In lesson #10 will be doing just that. That will give us an opportunity to see live code performing what we learned here and at the same time playing with the debugger and monitor. Two essential tools of your virtual ami toolbox.

In lesson #4 we have set up the environment for coding, which is using Asm One. That would allow you to code and debug directly from the Amiga OS and the steps are identical if done on actual hardware. However, there is another form of setup that can be quite useful when you want to have all the comfort of the modern age (macOS) and run the code in the Amiga world once it’s done. In lesson #9 I will explore that option so that you can pick and choose your style as you follow along.

I hope you enjoyed this lesson. Keep retroing.


Mario Esposito

Published 3 years ago