Subversion Repositories Kolibri OS

Rev

Rev 1338 | Rev 3244 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1338 IgorA 1
; strlen function
2
;
3
; Copyright (c) 2003 Thomas Mathys
4
; killer@vantage.ch
5
;
6
; This program is free software; you can redistribute it and/or modify
7
; it under the terms of the GNU General Public License as published by
8
; the Free Software Foundation; either version 2 of the License, or
9
; (at your option) any later version.
10
;
11
; This program is distributed in the hope that it will be useful,
12
; but WITHOUT ANY WARRANTY; without even the implied warranty of
13
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
; GNU General Public License for more details.
15
;
16
; You should have received a copy of the GNU General Public License
17
; along with this program; if not, write to the Free Software
18
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
;
20
;%ifndef _STRLEN_INC
21
;%define _STRLEN_INC
22
 
23
 
24
;********************************************************************
25
;       returns the length of an asciiz string
26
;       input           :       esi = pointer to string
27
;       output          :       eax = string length
28
;       destroys        :       nothing
29
;********************************************************************
30
strlen:
1467 IgorA 31
	push	ecx edi
1338 IgorA 32
	pushfd
33
	cld				; !
34
	mov	ecx,-1
35
	mov	edi,esi 		; find terminating zero
36
	xor	al,al
37
	repne	scasb
38
	mov	eax,edi 		; calculate string length
39
	sub	eax,esi
40
	dec	eax
41
	popfd
1467 IgorA 42
	pop	edi ecx
1338 IgorA 43
	ret
44
 
45
 
46
 
47
; linlen function
48
;
49
; Copyright (c) 2009 Igor Afanasiev
50
 
51
linlen:
1467 IgorA 52
	push	ecx edi
1338 IgorA 53
	pushfd
54
	cld				; !
55
	mov	ecx,eax
56
 inc ecx
57
	mov	edi,esi 		; find terminating zero
58
	mov	al,13
59
	repne	scasb
60
	mov	eax,edi 		; calculate string length
61
	sub	eax,esi
62
	dec	eax
63
	popfd
1467 IgorA 64
	pop	edi ecx
1338 IgorA 65
	ret
66
;%endif
67