Compare commits
No commits in common. "fcaf7f98f744d5437c0d8580efbc7a02155fbae7" and "e63923d4a87a934614dfa385c8578b5949c76d3e" have entirely different histories.
fcaf7f98f7
...
e63923d4a8
5 changed files with 19 additions and 99 deletions
|
@ -20,4 +20,4 @@ add_link_options(-fno-pie -m64 -no-pie -pedantic-errors)
|
|||
add_executable(length length.asm)
|
||||
add_executable(yes yes.asm)
|
||||
add_executable(case case.asm)
|
||||
add_executable(diff diff.asm)
|
||||
|
||||
|
|
7
case.asm
7
case.asm
|
@ -1,19 +1,14 @@
|
|||
extern puts
|
||||
|
||||
%include "../inc/length_func.inc"
|
||||
|
||||
section .data
|
||||
text db "rEEEeee!EEeeeEeEEeE!EEEEEeEEE$eeeEE)EEeEeEEeeeEeEEEEEeeeEeeEeeEeeeeeEeEeEeeE",0
|
||||
textlength db 0
|
||||
textlength db 76
|
||||
section .text
|
||||
global main
|
||||
|
||||
main:
|
||||
sub rsp, 8 ;enter
|
||||
|
||||
mov r8, text ;get textlength
|
||||
call length_func
|
||||
mov [textlength], rax
|
||||
|
||||
|
||||
xor rcx, rcx ;we do this to clear rcx incase it had garbage in it before
|
||||
|
|
84
diff.asm
84
diff.asm
|
@ -1,84 +0,0 @@
|
|||
extern puts
|
||||
%include "../inc/length_func.inc"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
section .data
|
||||
text db "REEEEEEEEEE",0
|
||||
text2 db "REEEEEEErEE",0
|
||||
differ db "they differ",0
|
||||
notdiffer db "they do not differ",0
|
||||
textlength dq 0
|
||||
text2length dq 0
|
||||
section .text
|
||||
global main
|
||||
|
||||
main:
|
||||
sub rsp, 8 ;enter
|
||||
|
||||
|
||||
;below we are getting the length of each string
|
||||
;we do this because we dont want to compare with memory that isnt ours
|
||||
|
||||
mov r8, text
|
||||
call length_func
|
||||
mov [textlength], rax
|
||||
|
||||
mov r8, text2
|
||||
call length_func
|
||||
mov [text2length], rax
|
||||
|
||||
mov r8, [textlength]
|
||||
mov r9, [text2length]
|
||||
|
||||
cmp r8, r9
|
||||
jne _differ
|
||||
|
||||
|
||||
|
||||
xor rcx, rcx ;we do this to clear garbage in rcx (i have had garbage in it before)
|
||||
_loop:
|
||||
;loop tings
|
||||
|
||||
mov r8, text
|
||||
add r8, rcx
|
||||
|
||||
mov r9, text2
|
||||
add r9, rcx
|
||||
|
||||
mov r10b, [r8]
|
||||
mov r11b, [r9]
|
||||
|
||||
|
||||
|
||||
cmp r10b, r11b
|
||||
jne _differ
|
||||
cmp r10b, 0
|
||||
je _notdiffer
|
||||
cmp r11b, 0
|
||||
je _notdiffer
|
||||
|
||||
|
||||
|
||||
inc rcx
|
||||
jmp _loop
|
||||
|
||||
|
||||
|
||||
|
||||
_differ:
|
||||
mov rdi, differ
|
||||
cld
|
||||
call puts
|
||||
jmp _end
|
||||
|
||||
_notdiffer:
|
||||
mov rdi, notdiffer
|
||||
cld
|
||||
call puts
|
||||
|
||||
_end:
|
||||
add rsp, 8 ;exit
|
||||
ret
|
17
length.asm
17
length.asm
|
@ -1,17 +1,16 @@
|
|||
extern puts
|
||||
extern printf
|
||||
default rel
|
||||
%include "../inc/length_func.inc"
|
||||
%include "../length_func.inc"
|
||||
|
||||
|
||||
|
||||
|
||||
section .rodata
|
||||
format db "%#d", 10, 0
|
||||
format db "%#x", 10, 0
|
||||
|
||||
section .data
|
||||
text db "rEE",0
|
||||
testasd dq 0
|
||||
text db "rEEEeee!EEeeeEeEEeE!EEEEEeEEE$eeeEE)EEeEeEEeeeEeEEEEEeeeEeeEeeEeeeeeEeEeEeeE",0
|
||||
section .text
|
||||
global main
|
||||
|
||||
|
@ -22,16 +21,22 @@ main:
|
|||
|
||||
mov r8, text
|
||||
call length_func
|
||||
mov [testasd], rax
|
||||
|
||||
|
||||
mov rsi, [testasd]
|
||||
|
||||
mov rdi, text
|
||||
cld
|
||||
call puts ;this is the puts way of printing a string
|
||||
|
||||
|
||||
mov rsi, r8
|
||||
lea rdi, [rel format]
|
||||
xor eax, eax ; AL=0 no FP args in XMM regs
|
||||
call printf
|
||||
|
||||
|
||||
|
||||
|
||||
_end:
|
||||
add rsp, 8 ;exit
|
||||
ret
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
length_func:
|
||||
|
||||
mov r10, r8
|
||||
_loop67865432:
|
||||
|
||||
|
||||
mov r9b, [r8]
|
||||
cmp r9b, 0
|
||||
jz _exitloop4323567
|
||||
|
@ -11,7 +11,11 @@ _loop67865432:
|
|||
|
||||
jmp _loop67865432
|
||||
_exitloop4323567:
|
||||
dec r8 ; idk how to do it properly do im doing this instead
|
||||
|
||||
dec r8
|
||||
dec r8
|
||||
dec r8
|
||||
|
||||
sub r8, r10
|
||||
mov rax, r8
|
||||
ret
|
Loading…
Reference in a new issue