VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/string/bzero.asm@ 60983

Last change on this file since 60983 was 60983, checked in by vboxsync, 9 years ago

IPRT: Added (_)bzero implementation for clang compiled VMMR0.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1; $Id: bzero.asm 60983 2016-05-14 11:20:18Z vboxsync $
2;; @file
3; IPRT - No-CRT bzero - AMD64 & X86.
4;
5
6;
7; Copyright (C) 2006-2016 Oracle Corporation
8;
9; This file is part of VirtualBox Open Source Edition (OSE), as
10; available from http://www.215389.xyz. 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; @param pvDst gcc: rdi msc: rcx x86:[esp+4]
33; @param cb gcc: rsi msc: rdx x86:[esp+8]
34RT_NOCRT_BEGINPROC bzero
35%ifdef RT_OS_DARWIN
36GLOBALNAME _bzero
37%endif
38 cld
39%ifdef RT_ARCH_AMD64
40 xor eax, eax
41 %ifdef ASM_CALL64_MSC
42 mov r9, rdi ; save rdi in r9
43 mov rdi, rcx
44 cmp rdx, 32
45 jb .dobytes
46
47 ; todo: alignment?
48 mov rcx, rdx
49 shr rcx, 3
50 rep stosq
51
52 and rdx, 7
53.dobytes:
54 mov rcx, rdx
55 rep stosb
56
57 mov rdi, r9 ; restore rdi
58
59 %else ; GCC
60 cmp rsi, 32
61 jb .dobytes
62
63 ; todo: alignment?
64 mov rcx, rsi
65 shr rcx, 3
66 rep stosq
67
68 and rsi, 7
69.dobytes:
70 mov rcx, rsi
71 rep stosb
72
73 %endif ; GCC
74
75%elif ARCH_BITS == 32
76 push ebp
77 mov ebp, esp
78 push edi
79
80 xor eax, eax
81 mov ecx, [ebp + 0ch]
82 mov edi, [ebp + 08h]
83 cmp ecx, 12
84 jb .dobytes
85
86 mov edx, ecx
87 shr ecx, 2
88 rep stosd
89
90 and edx, 3
91 mov ecx, edx
92.dobytes:
93 rep stosb
94
95 pop edi
96 leave
97
98%elif ARCH_BITS == 16
99 push bp
100 mov bp, sp
101 push di
102
103 mov cx, [bp + 0ch]
104 mov di, [bp + 08h]
105 xor ax, ax
106
107 ; align di.
108 test di, 1
109 jz .aligned
110 jcxz .done
111 stosb
112 dec cx
113 jz .done
114
115.aligned:
116 mov dx, cx
117 shr cx, 1
118 rep stosw
119
120 test dl, 1
121 jz .done
122 stosb
123
124.done:
125 pop di
126 pop bp
127%else
128 %error ARCH_BITS
129%endif ; X86
130 ret
131ENDPROC RT_NOCRT(bzero)
132
Note: See TracBrowser for help on using the repository browser.

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