From 5fbf00fa1171b426374b000e719da82a85af2209 Mon Sep 17 00:00:00 2001 From: Aaron Date: Tue, 5 Dec 2023 21:26:41 -0500 Subject: [PATCH 1/2] more code --- assemblyexample1.asm | 30 ++++++++++++++++++++++++++++++ assemblytutorial.txt | 24 ++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 assemblyexample1.asm create mode 100644 assemblytutorial.txt diff --git a/assemblyexample1.asm b/assemblyexample1.asm new file mode 100644 index 0000000..d2cd502 --- /dev/null +++ b/assemblyexample1.asm @@ -0,0 +1,30 @@ + +.global _start + //exposes a symbol called start to the assembler +.intel_syntax noprefix + +//See: https://www.youtube.com/watch?v=6S5KRJv-7RU +//See: https://blog.rchapman.org/posts/Linux_System_Call_Table_for_x86_64/ + +_start: + //write call (sys_write) + mov rax,1 + //sys_write system call + mov rdi, 1 + //unsigned int fd = 1 (stdout) + lea rsi,[hello_world] + //load effective address (lea) into rsi of hello_world data + mov rdx, 14 + //size_t count excluding null terminator + syscall + + //exit call + mov rax, 60 + mov rdi, 33 + //return result (must be "rdi" not "rdx" - how are these registers named?) + syscall + //apprently int 80h interrupt is also syscall? + +hello_world: + .asciz "Hello, World!\n" + diff --git a/assemblytutorial.txt b/assemblytutorial.txt new file mode 100644 index 0000000..bdf694a --- /dev/null +++ b/assemblytutorial.txt @@ -0,0 +1,24 @@ +https://www.youtube.com/watch?v=6S5KRJv-7RU + +rdi +rsi +r8 +r - 64 bit pointer + +mov rdi,8 +mov rdi,rsi + +memory operations + +mov rdi, qword ptr[rsi] values from memory into register +mov qword ptr[rsi], rdi store into memory operation + +https://blog.rchapman.org/posts/Linux_System_Call_Table_for_x86_64/ + + +Compilation: + as -c assemblyexample1.asm -o assemblyexample1.o + gcc assemblyexample1.o -o assemblyexample1 -nostdlib -static + +Check error code: + echo $? \ No newline at end of file From afd707610614f97fbed93ac77bcc84c9c4aa6768 Mon Sep 17 00:00:00 2001 From: Aaron Date: Tue, 5 Dec 2023 21:34:23 -0500 Subject: [PATCH 2/2] test merge conf --- test.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test.txt b/test.txt index 3f878b4..1bcfd38 100644 --- a/test.txt +++ b/test.txt @@ -1,3 +1,5 @@ I've added this new thing a new addition + +a third line