diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea24011 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +printf/build/ diff --git a/helloworld/hello b/helloworld/hello index b55677b..4411c27 100755 Binary files a/helloworld/hello and b/helloworld/hello differ diff --git a/helloworld/hello.asm b/helloworld/hello.asm index 4f468fa..2bbc4af 100644 --- a/helloworld/hello.asm +++ b/helloworld/hello.asm @@ -1,14 +1,13 @@ section .data text db 65,10 fuckvalue db 255 - sleeplength db 255 - sleepcounter db 0 + texthello db "hello world",10 section .text global _start _start: - mov r8, [fuckvalue] ; put the shit in the register for later - mov r9, [text] + mov r8b, [fuckvalue] ; put the shit in the register for later + mov r9b, [text] mov rax, 1 ;syscall 1 @@ -18,18 +17,31 @@ _start: syscall ;invoke - cmp r8, r9 + + + + + cmp r8b, r9b je _end ;inc text - mov r9, [text] - inc r9 - mov [text], r9 + mov r9b, [text] + inc r9b + mov [text], r9b jmp _start _end: - mov rax, 60 - mov edi, 0 + + mov rax, 1 ;syscall 1 + mov rdi, 1 ; arg 1 (stdout) + mov rsi, texthello ; the shit to print + mov rdx, 12 ; the length + syscall ;invoke + + mov rax, 60 ; exit + mov edi, 1 ; error 1 syscall + + diff --git a/helloworld/hello.o b/helloworld/hello.o index 83a2140..6136a64 100644 Binary files a/helloworld/hello.o and b/helloworld/hello.o differ diff --git a/printf/CMakeLists.txt b/printf/CMakeLists.txt new file mode 100644 index 0000000..bca0339 --- /dev/null +++ b/printf/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.14) +project (hello) + +#set(CMAKE_ASM_NASM_LINK_EXECUTABLE ld) + + +#Set C++ language version +set(CMAKE_CXX_STANDARD 17) +#Enable ASM provided by NASM +enable_language(ASM_NASM) + +set(CMAKE_ASM_NASM_LINK_EXECUTABLE "gcc -o ") + +add_link_options(-fno-pie -m64 -no-pie -pedantic-errors) + +#Make a EXE with cpp and asm files +add_executable(hello hello.asm) diff --git a/printf/hello.asm b/printf/hello.asm new file mode 100644 index 0000000..a8f13fa --- /dev/null +++ b/printf/hello.asm @@ -0,0 +1,41 @@ +extern puts + +section .data + text db "Bottom Text",10,0 +section .text + global main + +main: + sub rsp, 8 + mov r9b, [text] + + + mov rax, 1 ;syscall 1 + mov rdi, 1 ; arg 1 (stdout) + mov rsi, text ; the shit to print + mov rdx, 12 ; the length + syscall ;invoke +; ^^^^ is the linux syscall way of printing a string + + mov r8b, [text] + add r8b, 1 + mov [text], r8b + + + + + mov rdi, text + cld + call puts + + add rsp, 8 + ret + + + +_end: + mov rax, 60 ; exit + mov edi, 1 ; error 1 + syscall + + diff --git a/printf/hello.o b/printf/hello.o new file mode 100644 index 0000000..c3f4ec9 Binary files /dev/null and b/printf/hello.o differ