VirtualBox

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

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

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 2.8 KB
RevLine 
[1176]1; $Id: memrchr.asm 98103 2023-01-17 14:15:46Z vboxsync $
2;; @file
[57722]3; IPRT - No-CRT memrchr - AMD64 & X86.
[1176]4;
5
6;
[98103]7; Copyright (C) 2006-2023 Oracle and/or its affiliates.
[5999]8;
[96407]9; This file is part of VirtualBox base platform packages, as
10; available from https://www.virtualbox.org.
[5999]11;
[96407]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;
[5999]25; The contents of this file may alternatively be used under the terms
26; of the Common Development and Distribution License Version 1.0
[96407]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
[5999]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;
[96407]34; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35;
[1176]36
37%include "iprt/asmdefs.mac"
38
39BEGINCODE
40
41;;
[75129]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
[57722]45RT_NOCRT_BEGINPROC memrchr
46 std
[3672]47%ifdef RT_ARCH_AMD64
[1176]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
[57722]54 lea rdi, [rcx + r8 - 1]
[1176]55 mov rcx, r8
56 %else
57 mov rcx, rdx
58 jrcxz .not_found_early
59
60 mov eax, esi
[57722]61 lea rdi, [rdi + rcx - 1]
[1176]62 %endif
63
64%else
[75129]65 %ifdef ASM_CALL32_WATCOM
66 mov ecx, ebx
67 jecxz .not_found_early
68 xchg eax, edx
69 xchg edi, edx ; load + save edi
70 %else
[1176]71 mov ecx, [esp + 0ch]
72 jecxz .not_found_early
73 mov edx, edi ; save edi
74 mov eax, [esp + 8]
75 mov edi, [esp + 4]
[75129]76 %endif
[57722]77 lea edi, [edi + ecx - 1]
[1176]78%endif
79
80 ; do the search
81 repne scasb
82 jne .not_found
83
84 ; found it
[57722]85 lea xAX, [xDI + 1]
[1176]86%ifdef ASM_CALL64_MSC
87 mov rdi, r9
88%endif
[3672]89%ifdef RT_ARCH_X86
[1176]90 mov edi, edx
91%endif
[57722]92 cld
[1176]93 ret
94
95.not_found:
96%ifdef ASM_CALL64_MSC
97 mov rdi, r9
98%endif
[3672]99%ifdef RT_ARCH_X86
[1176]100 mov edi, edx
101%endif
102.not_found_early:
103 xor eax, eax
[57722]104 cld
[1176]105 ret
[57722]106ENDPROC RT_NOCRT(memrchr)
[1176]107
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use