added diff but currently it only compares length
This commit is contained in:
parent
a55d2bd12c
commit
7fecbb5170
2 changed files with 55 additions and 0 deletions
|
@ -20,3 +20,4 @@ add_link_options(-fno-pie -m64 -no-pie -pedantic-errors)
|
||||||
add_executable(length length.asm)
|
add_executable(length length.asm)
|
||||||
add_executable(yes yes.asm)
|
add_executable(yes yes.asm)
|
||||||
add_executable(case case.asm)
|
add_executable(case case.asm)
|
||||||
|
add_executable(diff diff.asm)
|
||||||
|
|
54
diff.asm
Normal file
54
diff.asm
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
extern puts
|
||||||
|
%include "../inc/length_func.inc"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
section .data
|
||||||
|
text db "rEE",0
|
||||||
|
text2 db "REEE",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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
_differ:
|
||||||
|
mov rdi, differ
|
||||||
|
cld
|
||||||
|
call puts
|
||||||
|
jmp _end
|
||||||
|
|
||||||
|
_notdiffer:
|
||||||
|
mov rdi, notdiffer
|
||||||
|
cld
|
||||||
|
call puts
|
||||||
|
|
||||||
|
_end:
|
||||||
|
add rsp, 8 ;exit
|
||||||
|
ret
|
Loading…
Reference in a new issue