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.
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 longword 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:
Notice at the end of the move instruction, 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:
As you can see, A0 acts as a gateway to memory. The address registers support a feature called indexing.
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 brains being 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 observing 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 play 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.