did your mom last night

This commit is contained in:
zombie maniac 2021-09-07 19:58:21 -04:00
parent f5654816e8
commit bfffbf587d
7 changed files with 81 additions and 10 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
printf/build/

Binary file not shown.

View file

@ -1,14 +1,13 @@
section .data section .data
text db 65,10 text db 65,10
fuckvalue db 255 fuckvalue db 255
sleeplength db 255 texthello db "hello world",10
sleepcounter db 0
section .text section .text
global _start global _start
_start: _start:
mov r8, [fuckvalue] ; put the shit in the register for later mov r8b, [fuckvalue] ; put the shit in the register for later
mov r9, [text] mov r9b, [text]
mov rax, 1 ;syscall 1 mov rax, 1 ;syscall 1
@ -18,18 +17,31 @@ _start:
syscall ;invoke syscall ;invoke
cmp r8, r9
cmp r8b, r9b
je _end je _end
;inc text ;inc text
mov r9, [text] mov r9b, [text]
inc r9 inc r9b
mov [text], r9 mov [text], r9b
jmp _start jmp _start
_end: _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 syscall

Binary file not shown.

17
printf/CMakeLists.txt Normal file
View file

@ -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 <CMAKE_ASM_NASM_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
add_link_options(-fno-pie -m64 -no-pie -pedantic-errors)
#Make a EXE with cpp and asm files
add_executable(hello hello.asm)

41
printf/hello.asm Normal file
View file

@ -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

BIN
printf/hello.o Normal file

Binary file not shown.