From 8960a62da9611b26d7f6519e4fa1784778a3b1b6 Mon Sep 17 00:00:00 2001 From: zombie Date: Mon, 27 Sep 2021 16:40:27 -0400 Subject: [PATCH] made the function names for "C" like --- CMakeLists.txt | 2 +- example.asm | 16 ++++++++-------- diff.asm => strcmp.asm | 4 ++-- length.asm => strlen.asm | 6 ++---- case.asm => tolower.asm | 8 ++++---- 5 files changed, 17 insertions(+), 19 deletions(-) rename diff.asm => strcmp.asm (94%) rename length.asm => strlen.asm (78%) rename case.asm => tolower.asm (87%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6aef5f4..4f69d3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,6 @@ 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_library(z tolower.asm strlen.asm strcmp.asm) add_executable(example example.asm) target_link_libraries(example z) diff --git a/example.asm b/example.asm index 1c88a06..73cc0b0 100644 --- a/example.asm +++ b/example.asm @@ -1,11 +1,11 @@ extern puts -extern length_func -extern _case_func -extern diff_func +extern libz_strlen +extern libz_strcmp +extern libz_tolower section .data - text2 db 0,0 - text db 0,0,0 + text2 db "asdasdASDd",0 + text db "asdasdasd",0 stoer db "0",0 @@ -18,7 +18,7 @@ main: sub rsp, 8 ;enter mov rdi, text - call _case_func + call libz_tolower mov rdi, text cld @@ -33,7 +33,7 @@ main: mov rdi, text2 - call length_func + call libz_strlen add [stoer], rax @@ -43,7 +43,7 @@ main: mov rdi, text mov rsi, text2 - call diff_func + call libz_strcmp cmp rax, 1 je _differ jmp _notdiffer diff --git a/diff.asm b/strcmp.asm similarity index 94% rename from diff.asm rename to strcmp.asm index 8f40526..60d00e2 100644 --- a/diff.asm +++ b/strcmp.asm @@ -1,7 +1,7 @@ -global diff_func +global libz_strcmp section .text -diff_func: +libz_strcmp: sub rsp, 8 ;enter xor rcx, rcx ;we do this to clear garbage in rcx (i have had garbage in it before) diff --git a/length.asm b/strlen.asm similarity index 78% rename from length.asm rename to strlen.asm index 10dc52b..64fad05 100644 --- a/length.asm +++ b/strlen.asm @@ -1,9 +1,7 @@ -global length_func -section .data - testasd dq 0 +global libz_strlen section .text -length_func: +libz_strlen: sub rsp, 8 ;enter mov r10, rdi diff --git a/case.asm b/tolower.asm similarity index 87% rename from case.asm rename to tolower.asm index 2a53ee3..add19b3 100644 --- a/case.asm +++ b/tolower.asm @@ -1,14 +1,14 @@ -extern length_func +extern libz_strlen -global _case_func +global libz_tolower section .text -_case_func: +libz_tolower: sub rsp, 8 ;enter mov r11, rdi - call length_func + call libz_strlen mov r10, rax