这个例程有什么问题?它不适用于下面给出的值。我在shell中使用它来创建一个简单的内核,但我不知道为什么它不起作用。
mov si, buffer ; buffer value from user input: 'help'
mov di, shell_command_help ; shell_command_help db 'help',0
call os_compare_string
; ----------------------------------------------------------
; Routine: Compare equality of two strings
; Waits for a complete string of user input and puts it in buffer.
; Sensitive for backspace and Enter buttons
; Input 1. String1 in SI 2. String2 in DI
; Output 1. result in carry flag
; ----------------------------------------------------------
os_compare_string:
.compare_next_character: ; a loop that goes character by character
mov al, [si] ; focus on next byte in si
mov bl, [di] ; focus on next byte in di
cmp al, bl
jne .conclude_not_equal ; if not equal, conclude and exit
; at this point we know the two bytes are equal
cmp bl, 0 ; did we just compare two zeros?
je .conclude_equal ; if yes, we've reached the end of the strings. They are equal.
; increment counters for next loop
inc di
inc si
jmp .compare_next_character
.conclude_equal:
stc ; sets the carry flag (meaning that they ARE equal)
jmp .done
.conclude_not_equal:
clc ; clears the carry flag (meaning that they ARE NOT equal)
jmp .done
.done:
xor cl, cl
ret
答案 0 :(得分:0)
设置进位标志后你是cl。这是一个坏主意。