Your first ARM Assembly Program
This is a simple guide to writing your first ARM assembly program for linux. This guide will show you how to write a simple program that will print Hello World
to the console.
Installing required packages
You will need to install the following packages:
These packages are required to compile the program.
Writing the program
Open a text editor like vim
or nano
and create a new file called hello.s
:
Or if you prefer vim
:
This should put you in a text editor. Copy the following into it:
Then save the file.
Compiling the program
To compile our program we are going to use as
ans ld
. Run the following commands:
This will create an executable called hello
.
Running the program
To run the program, simply run:
You should see Hello world
printed to the console.
Explanation
The program is divided into two sections: .data
and .text
. The .data
section contains the string Hello world\n
and the length of the string. The .text
section contains the _start
label which is the entry point of the program.
The _start
label is the entry point of the program. and it is defined as a global symbol using the .globl
directive.
In the _start
section, we have the program instructions.