VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/string/RTStrMemFind32.asm@ 82477

Last change on this file since 82477 was 81927, checked in by vboxsync, 5 years ago

IPRT: Added 32-bit memchr variant. Prepared 16 and 64 bit ones too.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 KB
Line 
1; $Id: RTStrMemFind32.asm 81927 2019-11-18 00:30:04Z vboxsync $
2;; @file
3; IPRT - RTStrMemFind32 - AMD64 & X86.
4;
5
6;
7; Copyright (C) 2019 Oracle Corporation
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 (GPL) as published by the Free Software
13; Foundation, in version 2 as it comes in the "COPYING" file of the
14; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16;
17; The contents of this file may alternatively be used under the terms
18; of the Common Development and Distribution License Version 1.0
19; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20; VirtualBox OSE distribution, in which case the provisions of the
21; CDDL are applicable instead of those of the GPL.
22;
23; You may elect to license modified versions of this file under the
24; terms and conditions of either the GPL or the CDDL or both.
25;
26
27%include "iprt/asmdefs.mac"
28
29BEGINCODE
30
31;;
32;
33; This is just a 32-bit memchr.
34;
35; @param pvHaystack gcc: rdi msc: ecx x86:[esp+4] wcall: eax
36; @param uNeedle gcc: esi msc: edx x86:[esp+8] wcall: edx
37; @param cbHaystack gcc: rdx msc: r8 x86:[esp+0ch] wcall: ebx
38BEGINPROC_EXPORTED RTStrMemFind32
39 cld
40%ifdef RT_ARCH_AMD64
41 %ifdef ASM_CALL64_MSC
42 mov r9, rdi ; save rdi
43 mov eax, edx
44 mov rdi, rcx
45 mov rcx, r8
46 %else
47 mov rcx, rdx
48 mov eax, esi
49 %endif
50%else
51 %ifdef ASM_CALL32_WATCOM
52 mov ecx, ebx
53 xchg eax, edx
54 xchg edi, edx ; load and save edi.
55 %else
56 mov ecx, [esp + 0ch]
57 mov edx, edi ; save edi
58 mov eax, [esp + 8]
59 mov edi, [esp + 4]
60 %endif
61%endif
62 cmp xCX, 4
63 jb .not_found
64
65 ; do the search
66 repne scasd
67 jne .not_found
68
69 ; found it
70 lea xAX, [xDI - 4]
71%ifdef ASM_CALL64_MSC
72 mov rdi, r9
73%endif
74%ifdef RT_ARCH_X86
75 mov edi, edx
76%endif
77 ret
78
79.not_found:
80%ifdef ASM_CALL64_MSC
81 mov rdi, r9
82%endif
83%ifdef RT_ARCH_X86
84 mov edi, edx
85%endif
86 xor eax, eax
87 ret
88ENDPROC RTStrMemFind32
89
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette