EttinOS/src/CMPSTR.INC

42 lines
579 B
Plaintext

;Compares strings from SI and DI until a null and either sets the carry flag if they are equal or clears it if not.
cmpstr:
;Store the initial registers in the stack
push ax
push bx
;Compare the strings
.loop:
;Load the current characters
mov al, [si]
mov bl, [di]
;Compare the characters
cmp al, bl
;Check for difference
jne .neq
;Check for the string end
cmp al, 0x0
je .eq
;Repeat for the next characters
inc si
inc di
jmp .loop
;Set the carry flag
.eq:
stc
jmp .done
;Clear the carry flag
.neq:
clc
.done:
;Load the initial registers from the stack
pop bx
pop ax
ret