Assembly - Variables, instructions and addressing modes
In a previous article I showed how to assemble a program using nasm. In this article I’m going to explore different ways to access data and explore some instructions.
Variables
The simplest way do declare variables is by initializing them in the .data
segment of a program. The format to define initialized data is:
1
[variable-name] define-directive initial-value [,initial-value]...
An example use:
1
2
3
4
5
6
7
8
9
10
11
section .data
exit_code dq 0
sys_call dq 60
section .text
global _start
_start:
mov rax, [sys_call]
mov rdi, [exit_code]
syscall