did your mom last night
This commit is contained in:
parent
f5654816e8
commit
bfffbf587d
7 changed files with 81 additions and 10 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
printf/build/
|
BIN
helloworld/hello
BIN
helloworld/hello
Binary file not shown.
|
@ -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
|
||||
|
||||
|
||||
|
|
Binary file not shown.
17
printf/CMakeLists.txt
Normal file
17
printf/CMakeLists.txt
Normal 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
41
printf/hello.asm
Normal 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
BIN
printf/hello.o
Normal file
Binary file not shown.
Loading…
Reference in a new issue