VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/string/memchr.asm

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 2.7 KB
Line 
1; $Id: memchr.asm 98103 2023-01-17 14:15:46Z vboxsync $
2;; @file
3; IPRT - No-CRT memchr - AMD64 & X86.
4;
5
6;
7; Copyright (C) 2006-2023 Oracle and/or its affiliates.
8;
9; This file is part of VirtualBox base platform packages, as
10; available from https://www.virtualbox.org.
11;
12; This program is free software; you can redistribute it and/or
13; modify it under the terms of the GNU General Public License
14; as published by the Free Software Foundation, in version 3 of the
15; License.
16;
17; This program is distributed in the hope that it will be useful, but
18; WITHOUT ANY WARRANTY; without even the implied warranty of
19; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20; General Public License for more details.
21;
22; You should have received a copy of the GNU General Public License
23; along with this program; if not, see <https://www.gnu.org/licenses>.
24;
25; The contents of this file may alternatively be used under the terms
26; of the Common Development and Distribution License Version 1.0
27; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28; in the VirtualBox distribution, in which case the provisions of the
29; CDDL are applicable instead of those of the GPL.
30;
31; You may elect to license modified versions of this file under the
32; terms and conditions of either the GPL or the CDDL or both.
33;
34; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35;
36
37%include "iprt/asmdefs.mac"
38
39BEGINCODE
40
41;;
42; @param pv gcc: rdi msc: ecx x86:[esp+4] wcall: eax
43; @param ch gcc: esi msc: edx x86:[esp+8] wcall: edx
44; @param cb gcc: rdx msc: r8 x86:[esp+0ch] wcall: ebx
45RT_NOCRT_BEGINPROC memchr
46 cld
47%ifdef RT_ARCH_AMD64
48 %ifdef ASM_CALL64_MSC
49 or r8, r8
50 jz .not_found_early
51
52 mov r9, rdi ; save rdi
53 mov eax, edx
54 mov rdi, rcx
55 mov rcx, r8
56 %else
57 mov rcx, rdx
58 jrcxz .not_found_early
59
60 mov eax, esi
61 %endif
62
63%else
64 %ifdef ASM_CALL32_WATCOM
65 mov ecx, ebx
66 jecxz .not_found_early
67 xchg eax, edx
68 xchg edi, edx ; load and save edi.
69 %else
70 mov ecx, [esp + 0ch]
71 jecxz .not_found_early
72 mov edx, edi ; save edi
73 mov eax, [esp + 8]
74 mov edi, [esp + 4]
75 %endif
76%endif
77
78 ; do the search
79 repne scasb
80 jne .not_found
81
82 ; found it
83 lea xAX, [xDI - 1]
84%ifdef ASM_CALL64_MSC
85 mov rdi, r9
86%endif
87%ifdef RT_ARCH_X86
88 mov edi, edx
89%endif
90 ret
91
92.not_found:
93%ifdef ASM_CALL64_MSC
94 mov rdi, r9
95%endif
96%ifdef RT_ARCH_X86
97 mov edi, edx
98%endif
99.not_found_early:
100 xor eax, eax
101 ret
102ENDPROC RT_NOCRT(memchr)
103
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use