public

Learning Assembler on Amiga #5 - Memory Addressing

In this lesson, we learn how addressing works and what are the various classifications of memory size that allow us to move data across memory blocks.

5 years ago

Latest Post The Great Escape Tunnel by Mario Esposito public

From lessons 1 to 4 we have focused on preparing the development environment. If you expect this lesson to be one where you start jamming some code in Asm-One then my dear friend, you are wrong :-) the journey is long, and I promise it will be like a trip.

If you never had LSD, then you should learn about Ayahuasca LOL.

Memory Addressing

It’s pointless to start learning a language if you don’t know some basics about its grammar. That is not to sound accurate to others, and it is to learn how to speak the things you haven’t learned yet and use logic and rules to go beyond what you have memorized already.

We’re not going to have a computer class like for a paid university; if you want to fall asleep, you can take one of those. I intend to keep it light and fun while still touching the basics to get somewhere.

From Code to Binary

how things work behind the scenes

Both an assembler and a compiler translate source files into object files.

Object files are effectively an intermediate step before the final binary output generated by the linker.

The linker takes the specified object files and resolves relocation or correct records. This is what makes the 10100101 for the CPU that you are targeting.

These relocation records are made when the compiler/assembler doesn’t know the address of a function or variable used in the source code and generates a reference for it by name, which can be resolved by the linker.

You will be dealing with memory addresses; they are not exactly the easiest thing to remember. Therefore understanding units (the essential elements of a system, like centimeters for the metric system) is important. But, to the minimum, do not lose your mind. So here is a quick way to understand the foundational pieces of it.

Entering the machine

Once the machine code has been generated, you are looking at a bunch of 1010101. Each digit is called “bit” and they can have only two values. ZERO to indicate OFF (like a light switch) or ONE to indicate ON.

They normally come in quadruplets, that is four-digit, grouped together like this: 1010. That is called nibble which forms 1 byte. You can represent a nibble in multiple counting systems, binary, hexadecimal, and decimal (and more).

Every row that you see above is an alternative way of representing the same value.

If you think like an Imperial rather than in metric think inches are bit and bytes are feet. Miles are words and so on...

Mama isn’t the first word for a baby computer

Nibbles can be grouped together to represent multiple data types. The ones used in the 68K assembler are:

If your brain is scrambling, don’t worry that is a sign that you still have neurons to cook. Keep going; the worst is ahead of us, you are good for now. Below there’s a summary to hit brain rehab above for what we just smashed our brain on.

In any higher language, you might have programmed before you never had to worry about all these details because the abstraction level in higher languages is such that everything else is taken care of you.

In this lesson, we have addressed the foundational pieces that will allow us to understand “addressing” which is a fancy way of saying where and how memory is stored.

Keep retroing.

#A99

Mario Esposito

Published 5 years ago