2014-08-10 03:57:11 +00:00
|
|
|
; size_t __cdecl strlen(const char *s)
|
|
|
|
public _strlen
|
2014-11-05 17:20:02 +00:00
|
|
|
_strlen proc
|
2014-10-20 15:20:04 +00:00
|
|
|
@@s = DPTR_ (2 + cPtrSize)
|
2014-08-10 03:57:11 +00:00
|
|
|
|
|
|
|
push bp
|
|
|
|
mov bp, sp
|
|
|
|
push si
|
|
|
|
push di
|
2014-10-20 15:20:04 +00:00
|
|
|
ife LDATA
|
|
|
|
mov ax, ds
|
|
|
|
mov es, ax
|
|
|
|
mov di, [bp+@@s]
|
|
|
|
xor ax, ax
|
|
|
|
else
|
2014-08-10 03:57:11 +00:00
|
|
|
les di, [bp+@@s]
|
|
|
|
xor ax, ax
|
|
|
|
cmp ax, word ptr [bp+@@s+2]
|
|
|
|
jnz short @@start
|
|
|
|
cmp ax, di
|
2014-10-20 15:20:04 +00:00
|
|
|
je short @@out
|
|
|
|
endif
|
2014-08-10 03:57:11 +00:00
|
|
|
|
|
|
|
@@start:
|
|
|
|
cld
|
2014-10-20 15:20:04 +00:00
|
|
|
mov cx, -1
|
2014-08-10 03:57:11 +00:00
|
|
|
repne scasb
|
|
|
|
xchg ax, cx
|
|
|
|
not ax
|
|
|
|
dec ax
|
|
|
|
|
2014-10-20 15:20:04 +00:00
|
|
|
@@out:
|
2014-08-10 03:57:11 +00:00
|
|
|
pop di
|
|
|
|
pop si
|
|
|
|
pop bp
|
2014-10-20 15:20:04 +00:00
|
|
|
ret
|
2014-08-10 03:57:11 +00:00
|
|
|
_strlen endp
|