like added everything

libs exist now
This commit is contained in:
zombie maniac 2021-09-26 17:30:13 -04:00
parent 4239ceeb1c
commit 8f228059c0
7 changed files with 189 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
build/

23
CMakeLists.txt Normal file
View file

@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 3.14)
project (yes)
#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 symbols
add_compile_options(-g)
add_link_options(-fno-pie -m64 -no-pie -pedantic-errors)
#Make a EXE with cpp and asm files
add_library(z case.asm diff.asm length.asm)
add_executable(example example.asm)
target_link_libraries(example z)

View file

@ -1,2 +1,4 @@
# zombie-lib # zombie-lib
libs that i ahve made

39
case.asm Normal file
View file

@ -0,0 +1,39 @@
extern length_func
section .text
global tolower
tolower:
sub rsp, 8 ;enter
mov r11, rdi
call length_func
mov r10, rax
xor rcx, rcx ;we do this to clear rcx incase it had garbage in it before
_loop:
;do loop things
mov r9, r11
add r9, rcx
mov r8b, [r9] ;this block here makes sure that our character is a capital letter and if its not a capital letter do nothing and return
cmp r8b, 90
ja _endloop
cmp r8b, 65
jb _endloop
add r8b, 32 ;make the letter capital
mov [r9], r8b
_endloop:
;end loop
inc rcx
cmp rcx, r10
jle _loop
add rsp, 8 ;exit
ret

43
diff.asm Normal file
View file

@ -0,0 +1,43 @@
section .text
global diff_func
diff_func:
sub rsp, 8 ;enter
xor rcx, rcx ;we do this to clear garbage in rcx (i have had garbage in it before)
_loopwasp12bsharknado:
;loop tings
add rdi, rcx
add rsi, rcx
mov r10b, [rdi]
mov r11b, [rsi]
cmp r10b, r11b
jne _differiwikeassembwy
cmp r10b, 0
je _notdifferiwikeassembwy
cmp r11b, 0
je _notdifferiwikeassembwy
inc rcx
jmp _loopwasp12bsharknado
_differiwikeassembwy:
mov rax, 1
jmp _end123432345
_notdifferiwikeassembwy:
mov rax, 0
_end123432345:
add rsp, 8 ;exit
ret

56
example.asm Normal file
View file

@ -0,0 +1,56 @@
extern puts
extern length_func
extern tolower
extern diff_func
section .data
text db "rEEEeee!EEeeeEeEEeE!EEEEEeEEE$eeeEE)EEeEeEEeeeEeEEEEEeeeEeeEeeEeeeeeEeEeEeeE",0
text2 db "reee",0
stoer db "0",0
differ db "they differ",0
notdiffer db "they dont differ",0
section .text
global main
main:
sub rsp, 8 ;enter
mov rdi, text
call tolower
mov rdi, text
cld
call puts ;this is the puts way of printing a string
mov rdi, text2
call length_func
add [stoer], rax
mov rdi, stoer
cld
call puts
mov rdi, text
mov rsi, text2
call diff_func
cmp rax, 1
je _differ
jmp _notdiffer
_differ:
mov rdi, differ
cld
call puts
jmp _end
_notdiffer:
mov rdi, notdiffer
cld
call puts
_end:
add rsp, 8 ;exit
ret

25
length.asm Normal file
View file

@ -0,0 +1,25 @@
section .data
testasd dq 0
section .text
global length_func
length_func:
sub rsp, 8 ;enter
mov r10, rdi
_loop67865432:
mov r9b, [rdi]
cmp r9b, 0
jz _exitloop4323567
inc rdi
jmp _loop67865432
_exitloop4323567:
sub rdi, r10
mov rax, rdi
add rsp, 8 ;exit
ret