mirror of
https://github.com/TrudeEH/web.git
synced 2025-12-06 08:23:37 +00:00
921 B
921 B
tags, author, draft, showToc, title
| tags | author | draft | showToc | title | ||
|---|---|---|---|---|---|---|
|
TrudeEH | true | true | Assembly |
#todo
Assembler/Compiler
gccGNU C Compiler (The package includesas(assembler) andld(linker))
as <file.asm> -o <output.o> # Assemble
gcc -o <output_file> <output.o> -nostdlib -static # Link using gcc
ld <output.o> # Link using ld
Hello World
.global _start
.intel_syntax noprefix
_start:
// sys_write (Print to stdout)
mov rax, 1
mov rdi, 1
lea rsi, [hello_world]
// Buffer length
mov rdx, 14
syscall
// sys_exit (safely end the program with a re turn code)
mov rax, 60
// Exit with code 0
mov rdi, 0
syscall
hello_world:
// ASCII, zero delimited
.asciz "Hello, World!\n"
To know which system calls we can execute and which values needed for the registers, refer to this table.