VirtualBox

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

Last change on this file since 331 was 194, checked in by vboxsync, 18 years ago

memchr.

  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1; $Id: memchr.asm 194 2007-01-19 21:56:57Z vboxsync $
2;; @file
3; InnoTek Portable Runtime - No-CRT memchr - AMD64 & X86.
4;
5
6;
7; Copyright (C) 2006 InnoTek Systemberatung 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;;
25; @param pv gcc: rdi msc: ecx x86:[esp+4]
26; @param ch gcc: esi msc: edx x86:[esp+8]
27; @param cb gcc: rdx msc: r8 x86:[esp+0ch]
28BEGINPROC RT_NOCRT(memchr)
29 cld
30%ifdef __AMD64__
31 %ifdef ASM_CALL64_MSC
32 or r8, r8
33 jz .not_found_early
34
35 mov r9, rdi ; save rdi
36 mov eax, edx
37 mov rdi, rcx
38 mov rcx, r8
39 %else
40 mov rcx, rdx
41 jrcxz .not_found_early
42
43 mov eax, esi
44 %endif
45
46%else
47 mov ecx, [esp + 0ch]
48 jecxz .not_found_early
49 mov edx, edi ; save edi
50 mov eax, [esp + 8]
51 mov edi, [esp + 4]
52%endif
53
54 ; do the search
55 repne scasb
56 jne .not_found
57
58 ; found it
59 lea xAX, [xDI - 1]
60%ifdef ASM_CALL64_MSC
61 mov rdi, r9
62%endif
63%ifdef __X86__
64 mov edi, edx
65%endif
66 ret
67
68.not_found:
69%ifdef ASM_CALL64_MSC
70 mov rdi, r9
71%endif
72%ifdef __X86__
73 mov edi, edx
74%endif
75.not_found_early:
76 xor eax, eax
77 ret
78ENDPROC RT_NOCRT(memchr)
79
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