assembly - Compare two strings case-insensitive -
i have code:
section .data msg1 db "equal" msg1len equ $ -msg1 msg2 db "not equal" msg2len equ $ -msg2 str1 db "abcde" str1len equ $-str1 str2 db "abcde" str2len equ $ -str2 section .text global _start _start: mov esi,str1 mov edi,str2 mov ecx,str2len+1 cld repe cmpsb jecxz equal ;jumps if equal ;if not equal mov eax,4 mov ebx,1 mov ecx,msg2 mov edx,msg2len int 80h jmp exit equal: mov eax,4 mov ebx,1 mov ecx,msg1 mov edx,msg1len int 80h exit: mov eax,1 mov ebx,0 int 80h
what i'm trying make case-insensitive "abcde" still equal "abcde". however, case-sensitive. how make case-insensitive? appreciated.
one common approach convert 2 strings common case, example uppercase, , compare those. if don't want manipulate strings beforehand, can on fly, converting current checked characters common case , comparing. take @ ascii chart figure out difference between 2 cases of characters can convert 1 other.
Comments
Post a Comment