; How string comparison works ; DI => scasb compares value stored in DI which is 's' with 's' stored in AX register ; and then increments DI if DF is 0 ; v ; memory address 1: |s|n|a|t|0| ; memory address 2: |s|n|a|k|e|0| ; ^ ; SI => lodsb loads value stored at SI to AX and then increments SI if DF is 0 os_compare_strings: pusha .compare: lodsb scasb ; Compare di to si jne .unequal ; If they are no equal, jump to .unequal cmp al, 0 ; Check if string is finished je .equal ; If it has, return true jmp .compare ; Finally, repeat .unequal: mov cl, 0 ; Change to 0 if unquality is proven popa ret .equal: mov cl, 1 popa ret