Learning Assembler on Amiga #5

From lesson 1 to 4 we have focused on preparing the development environment. If you expect this lesson being one where you start jamming some code in Asm-One then my dear friend, you are wrong :-)
In this lesson, we are going to learn about 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 with others, it is to learn how to speak the things that 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 follow 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

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 basic elements of a system, like centimeters for the metric system) is pretty important. To the minimum to 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 to 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.

Mama isn’t the first word for a baby computer

Nibbles can be grouped together to represent multiple data types. The ones used in 68K assembler are:
  • two nybbles (e.g. 0100 1101), forms ONE “byte”.
  • two “bytes” (e.g. 0100 1101 1011 0000), makes ONE “word”.
  • two “words” (e.g. 0100 1101 1011 0000 1111 0001 0000 0110), is known as “long-word”.
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 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.


Popular posts from this blog

Bring Boxee Box back to life

Postgres on Synology

Zen-inification - The art of decluttering