@open: add apps sorting; string.inc: add string.cmp for compare strings

git-svn-id: svn://kolibrios.org@5907 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
eAndrew
2015-11-10 19:03:34 +00:00
parent be110571f5
commit 5ed305bfbd
2 changed files with 80 additions and 7 deletions

View File

@@ -55,6 +55,29 @@
ret
endp
proc string.cmp uses ecx esi edi, _str1, _str2, _n
mov ecx, [_n]
test ecx, ecx ; Max length is zero?
je .done
mov esi, [_str1] ; esi = string s1
mov edi, [_str2] ; edi = string s2
cld
.compare:
cmpsb ; Compare two bytes
jne .done
cmp byte [esi-1], 0 ; End of string?
je .done
dec ecx ; Length limit reached?
jne .compare
.done:
seta al ; al = (s1 > s2)
setb ah ; ah = (s1 < s2)
sub al, ah
movsx eax, al ; eax = (s1 > s2) - (s1 < s2), i.e. -1, 0, 1
ret
endp
proc string.to_lower_case uses eax, _str
mov eax, [_str]
@@: