Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4327 yogev_ezra 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:
31
	push	ecx
32
	push	edi
33
	pushfd
34
	cld				; !
35
	mov	ecx,-1
36
	mov	edi,esi 		; find terminating zero
37
	xor	al,al
38
	repne	scasb
39
	mov	eax,edi 		; calculate string length
40
	sub	eax,esi
41
	dec	eax
42
	popfd
43
	pop	edi
44
	pop	ecx
45
	ret
46
 
47
 
48
 
49
; linlen function
50
;
51
; Copyright (c) 2009 Igor Afanasiev
52
 
53
linlen:
54
	push	ecx
55
	push	edi
56
	pushfd
57
	cld				; !
58
	mov	ecx,eax
59
 inc ecx
60
	mov	edi,esi 		; find terminating zero
61
	mov	al,13
62
	repne	scasb
63
	mov	eax,edi 		; calculate string length
64
	sub	eax,esi
65
	dec	eax
66
	popfd
67
	pop	edi
68
	pop	ecx
69
	ret
70
;%endif
71