-
text This is a name assigned to the address in memory that this data is located in. Whenever we use "text" later in the code, when the code is compiled, the compiler will determine the actual location in memory of this data and replace all future instances of "text" with that memory address.
-
"db" Stands for "define bytes". It essentially means that we are going to define some raw bytes of data to insert into our code.
-
"Hello, World!", 10 Above are the bytes of data that we are defining. Each character in the string of text is a single byte. The "10" is a newline character.
Registers are part of the process that temporarily holds memory.
In the x86_64 architecture, registers holds 64 bits.
This means each register can hold the below values.
Type | Min | Max |
---|---|---|
Unsigned | 0 | 18,446,744,073,709,551,616 |
Signed | -9,223,372,036,854,775,808 | 9,223,372,036,854,775,808 |
A system call, or a syscall, is hwhen a program requests a sevice from the kernel.
All syscalls have an ID associated with them (a number).
Syscalls also take arguements, meaning a list of inputs.
Argument | Registers |
---|---|
ID | rax |
1 | rdi |
2 | rsi |
3 | rdx |
4 | r10 |
5 | r8 |
6 | r9 |
System Call List: https://syscalls64.paolostivanin.com/
Let's look at sys_write as an example.
syscall | ID | ARG1 | ARG2 | ARG3 |
---|---|---|---|---|
sys_write | 1 | File Descriptor: 0 (Standard Input), 1 (Standard Output), 2 (Standard Error) | Buffer (Location of string to write) | Count: Length of String |
.data - Where all data is defined before compilation
.bss - Where data is allocated for future use
.text - Where the actual code goes
Used to lable a part of code.
Upon compilation, the compiler will calculate the location in which the label will sit in memory.
Any time the name of the label is used afterwards. the name is replaced by the location in memory by compiler.
The "_start" label is essential for all programs.
When your program is compiled and later executed, it is executed first at the location of "_start"
If the linker cannot find "_start", it will throw an error.
The word "global" is used when you want the linker to be able to know the address of some label.
The object file generated will contain a link to every label declared "global."
In this case, we have the declare "_start" as global since it is required for the code to be properly linked.