VirtualBox

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

Last change on this file since 3840 was 3672, checked in by vboxsync, 17 years ago

RT_OS_* and RT_ARCH_* for Runtime/ and Support/

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