mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 23:12:56 +00:00
[CRT]
Fix x86 asm implementation of strlen / wcslen. svn path=/trunk/; revision=70430
This commit is contained in:
parent
2866514570
commit
654e3f7743
1 changed files with 20 additions and 9 deletions
|
@ -7,23 +7,34 @@ PUBLIC _tcslen
|
||||||
|
|
||||||
FUNC _tcslen
|
FUNC _tcslen
|
||||||
FPO 0, 1, 1, 1, 0, FRAME_FPO
|
FPO 0, 1, 1, 1, 0, FRAME_FPO
|
||||||
push edi
|
|
||||||
mov edi, [esp + 8]
|
|
||||||
xor eax, eax
|
|
||||||
test edi, edi
|
|
||||||
jz _tcslen_end
|
|
||||||
|
|
||||||
|
/* Save edi and eflags (according to the x86 ABI, we don't need to do that
|
||||||
|
but since the native function doesn't change the direction flag, we don't
|
||||||
|
either */
|
||||||
|
push edi
|
||||||
|
pushfd
|
||||||
|
|
||||||
|
/* Load the string pointer into edi */
|
||||||
|
mov edi, [esp + 12]
|
||||||
|
|
||||||
|
/* Set eax to 0, since we want to compare with 0 */
|
||||||
|
xor eax, eax
|
||||||
|
|
||||||
|
/* Set ecx to -1 (i.e. 0xFFFFFFFF) */
|
||||||
mov ecx, -1
|
mov ecx, -1
|
||||||
|
|
||||||
|
/* Clear direction flag */
|
||||||
cld
|
cld
|
||||||
|
|
||||||
|
/* Now compare the characters until a 0 is found */
|
||||||
repne _tscas
|
repne _tscas
|
||||||
|
|
||||||
|
/* Calculate the count (eax = -ecx - 1) */
|
||||||
not ecx
|
not ecx
|
||||||
dec ecx
|
lea eax, [ecx-1]
|
||||||
|
|
||||||
mov eax, ecx
|
/* Restore eflags/edi and return the result */
|
||||||
|
popfd
|
||||||
_tcslen_end:
|
|
||||||
pop edi
|
pop edi
|
||||||
ret
|
ret
|
||||||
ENDFUNC
|
ENDFUNC
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue