VirtualBox

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

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

Biggest check-in ever. New source code headers for all (C) innotek files.

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