Reference for ARM assembly topics.
Assemble assembly source file into object file
as -o program.o program.s
Assemble assembly source file into object file with debugging info
as -g -o program.o program.s
Link assemble object file into executable
ld -o program program.o
The proper way to finish a program is by calling sys_exit.
System calls are called “Software Interrupt” command
The following code is an example of using exit system call:
.global _start
_start:
MOV R0,#5 ; Set the parameter for sys_exit
MOV R7,#1
SWI 0 ; Call sys_exit
You can observe the exit code of the last exited command by running:
echo $?
.req - Alias for register.
foo .req R0
.equ - Define a constant.
.equ BYTES_TO_ALLOCATE, 16