Last change
on this file since 3261 was 2988, checked in by vboxsync, 17 years ago |
InnoTek -> innotek part 4: more miscellaneous files.
|
-
Property svn:eol-style
set to
native
-
Property svn:keywords
set to
Id
|
File size:
2.7 KB
|
Line | |
---|
1 | ; $Id: strchr.asm 2988 2007-06-01 17:36:09Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; innotek Portable Runtime - No-CRT strchr - AMD64 & X86.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2006-2007 innotek GmbH
|
---|
8 | ;
|
---|
9 | ; This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | ; available from http://www.virtualbox.org. This file is free software;
|
---|
11 | ; you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | ; General Public License as published by the Free Software Foundation,
|
---|
13 | ; in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | ; distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | ; be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | ;
|
---|
17 | ; If you received this file as part of a commercial VirtualBox
|
---|
18 | ; distribution, then only the terms of your commercial VirtualBox
|
---|
19 | ; license agreement apply instead of the previous paragraph.
|
---|
20 | ;
|
---|
21 |
|
---|
22 | %include "iprt/asmdefs.mac"
|
---|
23 |
|
---|
24 | BEGINCODE
|
---|
25 |
|
---|
26 | ;;
|
---|
27 | ; @param psz gcc: rdi msc: rcx x86:[esp+4]
|
---|
28 | ; @param ch gcc: esi msc: edx x86:[esp+8]
|
---|
29 | BEGINPROC RT_NOCRT(strchr)
|
---|
30 | cld
|
---|
31 |
|
---|
32 | ; check for ch == 0 and setup normal strchr.
|
---|
33 | %ifdef __AMD64__
|
---|
34 | %ifdef ASM_CALL64_MSC
|
---|
35 | or dl, dl
|
---|
36 | jz near .strlen
|
---|
37 | mov r9, rsi ; save rsi
|
---|
38 | mov rsi, rcx
|
---|
39 | %else
|
---|
40 | or sil, sil
|
---|
41 | jz near .strlen
|
---|
42 | mov edx, esi
|
---|
43 | mov rsi, rdi
|
---|
44 | %endif
|
---|
45 | %else
|
---|
46 | mov edx, [esp + 8]
|
---|
47 | or dl, dl
|
---|
48 | jz near .strlen
|
---|
49 | mov ecx, esi ; save esi
|
---|
50 | mov esi, [esp + 4]
|
---|
51 | %endif
|
---|
52 |
|
---|
53 | ; do the search
|
---|
54 | .next:
|
---|
55 | lodsb
|
---|
56 | cmp al, dl
|
---|
57 | je .found
|
---|
58 | test al, al
|
---|
59 | jz .not_found
|
---|
60 |
|
---|
61 | lodsb
|
---|
62 | cmp al, dl
|
---|
63 | je .found
|
---|
64 | test al, al
|
---|
65 | jz .not_found
|
---|
66 |
|
---|
67 | lodsb
|
---|
68 | cmp al, dl
|
---|
69 | je .found
|
---|
70 | test al, al
|
---|
71 | jz .not_found
|
---|
72 |
|
---|
73 | lodsb
|
---|
74 | cmp al, dl
|
---|
75 | je .found
|
---|
76 | test al, al
|
---|
77 | jz .not_found
|
---|
78 | jmp .next
|
---|
79 |
|
---|
80 | .found:
|
---|
81 | lea xAX, [xSI - 1]
|
---|
82 | %ifdef ASM_CALL64_MSC
|
---|
83 | mov rsi, r9
|
---|
84 | %endif
|
---|
85 | %ifdef __X86__
|
---|
86 | mov esi, ecx
|
---|
87 | %endif
|
---|
88 | ret
|
---|
89 |
|
---|
90 | .not_found:
|
---|
91 | %ifdef ASM_CALL64_MSC
|
---|
92 | mov rsi, r9
|
---|
93 | %endif
|
---|
94 | %ifdef __X86__
|
---|
95 | mov esi, ecx
|
---|
96 | %endif
|
---|
97 | xor eax, eax
|
---|
98 | ret
|
---|
99 |
|
---|
100 | ;
|
---|
101 | ; Special case: strchr(str, '\0');
|
---|
102 | ;
|
---|
103 | align 16
|
---|
104 | .strlen:
|
---|
105 | %ifdef __AMD64__
|
---|
106 | %ifdef ASM_CALL64_MSC
|
---|
107 | mov r9, rdi ; save rdi
|
---|
108 | mov rdi, rcx
|
---|
109 | %endif
|
---|
110 | %else
|
---|
111 | mov edx, edi ; save edi
|
---|
112 | mov edi, [esp + 4]
|
---|
113 | %endif
|
---|
114 | mov xCX, -1
|
---|
115 | xor eax, eax
|
---|
116 | repne scasb
|
---|
117 |
|
---|
118 | lea xAX, [xDI - 1]
|
---|
119 | %ifdef ASM_CALL64_MSC
|
---|
120 | mov rdi, r9
|
---|
121 | %endif
|
---|
122 | %ifdef __X86__
|
---|
123 | mov edi, edx
|
---|
124 | %endif
|
---|
125 | ret
|
---|
126 | ENDPROC RT_NOCRT(strchr)
|
---|
127 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.