AArch64/ARM64 Tutorial

Chapter 5: Assembler Installation & Quick Overview

We must install an Assembler. We will use the GNU AAarch64 Assembler. It's a great Assembler with the abilities to specify the Cortex A-57 CPU (Nintendo Switch CPU). Therefore, if there's anything Cortex A-57 specific that you need to test, it can be done. Let's install the Assembler. Unfortunately I only use Linux Machines, so I do not know how to do the following install via Windows. I'm sure Google can find it for you....

Linux only~
sudo apt-get update
sudo apt-get install gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu binutils-aarch64-linux-gnu-dbg
 

To make sure your installation of GNU worked, test the following terminal command...

aarch64-linux-gnu-as --help

You should see an array of information pertaining to assistance in various Assembler commands.

The Assembler itself is actually just one specific tool (out of 3) that were installed. The 3 tools are...

The executable file is the actual program that will execute the AArch64 instructions that were present in the Source Text File.

There are a slew of symbols that can be used in the Source File for the Assembler (commas, hashtags, asterisks, etc). Some of these symbols are required to write out actual Assembly Instructions in the Source file. There are also what is called Assembler Directives which are Assembler specific "commands" to tell the Assembler how to assemble the file. We're not going to dive into all of that for now as you will need to learn basic Instruction Format first (covered in the next Chapter).

For now, let's just go over two topics. Writing numerical values correctly, and writing notes/comments.

Writing Numerical Values in a Source File:
When writing decimal values, there are no special requirements. You can simply write out the number. For negative numbers, simply make sure the decimal value is appended with a minus symbol (i.e. -100). 

When writing hexadecimal values, you *must* pre-pend the number with "0x". Example: 0xAC. Regarding negative hex numbers, that will be covered in the next Chapter.

You have the ability to write values in binary form. To do this, you *must* pre-pend the number with "0b". Example: 0b0101

Hex vs Decimal for writing Values:
When writing Instructions in a Source File for the Assembler, some instructions require a numerical value to be written out. If the value is small enough to be shown as a hex byte, then it's easier in my opinion to write it in Decimal form. For the case you need to write out Negative numbers, writing in Decimal form is fine too. Other than those situations, it's easier (visually) to use Hex over Decimal. However, at the end of the day, this is User Preference. Choose what's easier for you.

Writing notes/comments in the Assembler:
There are two different methods to write notes/comments.

Examples:
// This is a comment.
/* This is a comment. */

The double slash method requires the double slash on every line where a comment is placed. The 2nd method allows you some flexibility like this....
/*This
is a
comment.*/

You can use notes/comments adjacent to instructions or in their own line within a Source File to help explain why certain instructions were utilized or what purpose they serve.


Final NOTE: In something like C/C++ tutorials, the Reader is shown a "Hello World" program or something similar. Then the author explains a brief summary of what every line of code does. For learning Assembly, in my opinion, this isn't the best approach. You need to learn the "under the hood" stuff first before we can even tackle a "Hello World" program. Therefore, we won't be revisiting the Assembler until Chapter 19.


Next Chapter

Tutorial Index