VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/string/memset.asm@ 17951

Last change on this file since 17951 was 14021, checked in by vboxsync, 16 years ago

The VMMR0 template now uses the IPRT No-CRT stuff, as does RuntimeR0. Added nocrt strcpy and fixed completely busted aliases.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.2 KB
Line 
1; $Id: memset.asm 14021 2008-11-10 16:31:22Z vboxsync $
2;; @file
3; IPRT - No-CRT memset - AMD64 & X86.
4;
5
6;
7; Copyright (C) 2006-2007 Sun Microsystems, Inc.
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; Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27; Clara, CA 95054 USA or visit http://www.sun.com if you need
28; additional information or have any questions.
29;
30
31%include "iprt/asmdefs.mac"
32
33BEGINCODE
34
35;;
36; @param pvDst gcc: rdi msc: ecx x86:[esp+4]
37; @param ch gcc: esi msc: edx x86:[esp+8]
38; @param cb gcc: rdx msc: r8 x86:[esp+0ch]
39RT_NOCRT_BEGINPROC memset
40 cld
41%ifdef RT_ARCH_AMD64
42 %ifdef ASM_CALL64_MSC
43 mov r9, rdi ; save rdi in r9
44 mov rdi, rcx
45 mov r10, rcx ; the return value.
46 movzx eax, dl
47 cmp r8, 32
48 jb .dobytes
49
50 ; eax = (al << 24) | (al << 16) | (al << 8) | al;
51 ; rdx = (eax << 32) | eax
52 movzx edx, dl
53 mov rax, qword 0101010101010101h
54 imul rax, rdx
55
56 ; todo: alignment.
57 mov rcx, r8
58 shr rcx, 3
59 rep stosq
60
61 and r8, 7
62.dobytes:
63 mov rcx, r8
64 rep stosb
65
66 mov rdi, r9 ; restore rdi
67 mov rax, r10
68
69 %else ; GCC
70 mov r10, rdi ; the return value.
71 movzx eax, sil
72 cmp rdx, 32
73 jb .dobytes
74
75 ; eax = (al << 24) | (al << 16) | (al << 8) | al;
76 ; rdx = (eax << 32) | eax
77 movzx esi, sil
78 mov rax, qword 0101010101010101h
79 imul rax, rsi
80
81 ; todo: alignment.
82 mov rcx, rdx
83 shr rcx, 3
84 rep stosq
85
86 and rdx, 7
87.dobytes:
88 mov rcx, rdx
89 rep stosb
90
91 mov rax, r10
92 %endif ; GCC
93
94%else ; X86
95 push edi
96
97 mov ecx, [esp + 0ch + 4]
98 movzx eax, byte [esp + 08h + 4]
99 mov edi, [esp + 04h + 4]
100 cmp ecx, 12
101 jb .dobytes
102
103 ; eax = (al << 24) | (al << 16) | (al << 8) | al;
104 mov ah, al
105 mov edx, eax
106 shl edx, 16
107 or eax, edx
108
109 mov edx, ecx
110 shr ecx, 2
111 rep stosd
112
113 and edx, 3
114 mov ecx, edx
115.dobytes:
116 rep stosb
117
118 pop edi
119 mov eax, [esp + 4]
120%endif ; X86
121 ret
122ENDPROC RT_NOCRT(memset)
123
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