zombie-core-utils/diff.asm
zombie 015f460d7f removed length code from differ
after galaxy brianing i realize i dont need to check the length of the strings
because if it compares a character with another from another string and one is a zero
we have reached the end of the string and we arnt reading memory that isnt ours
2021-09-19 12:20:15 -04:00

60 lines
692 B
NASM

extern puts
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
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