From 28f631e02bbf7e4cbd763fc74c4941d3f55a030f Mon Sep 17 00:00:00 2001 From: johannst Date: Sat, 19 Sep 2020 13:57:06 +0000 Subject: deploy: 4a5cd61b7c536ecf1bdb288cb6d584c190b1f6c7 --- arch/x86_64.html | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'arch/x86_64.html') diff --git a/arch/x86_64.html b/arch/x86_64.html index 492927f..26679a1 100644 --- a/arch/x86_64.html +++ b/arch/x86_64.html @@ -287,6 +287,44 @@ LO ADDR +

ASM skeleton

+

Small assembler skeleton, ready to use with following properties:

+ +
# file: greet.s
+
+    .intel_syntax noprefix
+
+    .section .text, "ax", @progbits
+    .global _start
+_start:
+    mov rdi, 1                      # fd
+    lea rsi, [rip + greeting]       # buf
+    mov rdx, [rip + greeting_len]   # count
+    mov rax, 1                      # write(2) syscall nr
+    syscall
+
+    mov rdi, 0                      # exit code
+    mov rax, 1                      # exit(2) syscall nr
+    syscall
+
+    .section .rdonly, "a", @progbits
+greeting:
+    .asciz "Hi ASM-World!\n"
+greeting_len:
+    .int .-greeting
+
+
+

Syscall numbers are defined in /usr/include/asm/unistd.h.

+
+

To compile and run:

+
> gcc -o greet greet.s -nostartfiles -nostdlib && ./greet
+Hi ASM-World!
+

References