Compare commits
No commits in common. "0428078991057ebf2be8ef4c84094ee33a548468" and "e40f7dbe2b92ec7dbba7fe0c1cb7a2ca14755586" have entirely different histories.
0428078991
...
e40f7dbe2b
4 changed files with 2 additions and 91 deletions
|
@ -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 tolower.asm strlen.asm strcmp.asm atoi.asm)
|
||||
add_library(z tolower.asm strlen.asm strcmp.asm atoi.asm hextoi.asm)
|
||||
add_executable(example example.asm)
|
||||
target_link_libraries(example z)
|
||||
|
|
24
example.asm
24
example.asm
|
@ -3,7 +3,6 @@ extern libz_strlen
|
|||
extern libz_strcmp
|
||||
extern libz_tolower
|
||||
extern libz_atoi
|
||||
extern malloc
|
||||
|
||||
section .data
|
||||
text2 db "asdasdASDd",0
|
||||
|
@ -61,7 +60,7 @@ _differ:
|
|||
mov rdi, differ
|
||||
cld
|
||||
call puts
|
||||
jmp _afterdiff
|
||||
jmp _end
|
||||
|
||||
|
||||
|
||||
|
@ -70,27 +69,6 @@ _notdiffer:
|
|||
cld
|
||||
call puts
|
||||
|
||||
_afterdiff:
|
||||
|
||||
mov rdi, 20
|
||||
cld
|
||||
call malloc
|
||||
;i think i just malloced (hopefully)
|
||||
|
||||
xor rcx, rcx
|
||||
_malloctestloop:
|
||||
mov [rax], rcx
|
||||
cmp rcx, 20
|
||||
je _end
|
||||
inc rcx
|
||||
inc rax
|
||||
jmp _malloctestloop
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
_end:
|
||||
add rsp, 8 ;exit
|
||||
ret
|
||||
|
|
29
tolower.asm
29
tolower.asm
|
@ -1,5 +1,4 @@
|
|||
extern libz_strlen
|
||||
extern malloc
|
||||
|
||||
global libz_tolower
|
||||
section .text
|
||||
|
@ -12,32 +11,6 @@ libz_tolower:
|
|||
call libz_strlen
|
||||
mov r10, rax
|
||||
|
||||
inc rax ;we do this because we need room for the null terminator
|
||||
|
||||
mov rdi, rax
|
||||
push r11
|
||||
push r10
|
||||
call malloc ;spot to put the new string
|
||||
pop r10
|
||||
pop r11
|
||||
|
||||
;at this point r11 (hopfully) has the original string and rax has the new string home
|
||||
push rax ;save rax for later
|
||||
push rax ;save it twice so we can return the pointer
|
||||
_mcopyloop:
|
||||
mov r8b, [r11]
|
||||
mov [rax], r8b
|
||||
inc r11
|
||||
inc rax
|
||||
|
||||
mov rsi, [r11] ;man i hope i can use rsi for anything and it wont nuke anything
|
||||
cmp sil, 0
|
||||
jnz _mcopyloop
|
||||
|
||||
pop r11 ;the loop below uses r11
|
||||
|
||||
|
||||
|
||||
|
||||
xor rcx, rcx ;we do this to clear rcx incase it had garbage in it before
|
||||
_loop:
|
||||
|
@ -61,7 +34,5 @@ _endloop:
|
|||
cmp rcx, r10
|
||||
jle _loop
|
||||
|
||||
pop rax ;returning rax (the pointer to the new string)
|
||||
|
||||
add rsp, 8 ;exit
|
||||
ret
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
extern libz_strlen
|
||||
|
||||
global libz_tolower
|
||||
section .text
|
||||
|
||||
libz_tolower:
|
||||
sub rsp, 8 ;enter
|
||||
|
||||
mov r11, rdi
|
||||
|
||||
call libz_strlen
|
||||
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
|
Loading…
Reference in a new issue