1 | ; $Id: bs3-cmn-MemZero.asm 106061 2024-09-16 14:03:52Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; BS3Kit - Bs3MemZero.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2007-2024 Oracle and/or its affiliates.
|
---|
8 | ;
|
---|
9 | ; This file is part of VirtualBox base platform packages, as
|
---|
10 | ; available from https://www.virtualbox.org.
|
---|
11 | ;
|
---|
12 | ; This program is free software; you can redistribute it and/or
|
---|
13 | ; modify it under the terms of the GNU General Public License
|
---|
14 | ; as published by the Free Software Foundation, in version 3 of the
|
---|
15 | ; License.
|
---|
16 | ;
|
---|
17 | ; This program is distributed in the hope that it will be useful, but
|
---|
18 | ; WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | ; General Public License for more details.
|
---|
21 | ;
|
---|
22 | ; You should have received a copy of the GNU General Public License
|
---|
23 | ; along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | ;
|
---|
25 | ; The contents of this file may alternatively be used under the terms
|
---|
26 | ; of the Common Development and Distribution License Version 1.0
|
---|
27 | ; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
28 | ; in the VirtualBox distribution, in which case the provisions of the
|
---|
29 | ; CDDL are applicable instead of those of the GPL.
|
---|
30 | ;
|
---|
31 | ; You may elect to license modified versions of this file under the
|
---|
32 | ; terms and conditions of either the GPL or the CDDL or both.
|
---|
33 | ;
|
---|
34 | ; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
35 | ;
|
---|
36 |
|
---|
37 | %include "bs3kit-template-header.mac"
|
---|
38 |
|
---|
39 | ;;
|
---|
40 | ; @cproto BS3_DECL(void) Bs3MemZero_c16(void BS3_FAR *pvDst, size_t cbDst);
|
---|
41 | ;
|
---|
42 | BS3_PROC_BEGIN_CMN Bs3MemZero, BS3_PBC_HYBRID
|
---|
43 | %ifdef RT_ARCH_AMD64
|
---|
44 | push rdi
|
---|
45 |
|
---|
46 | mov rdi, rcx ; rdi = pvDst
|
---|
47 | mov rcx, rdx ; rcx = cbDst
|
---|
48 | shr rcx, 3 ; calc qword count.
|
---|
49 | xor eax, eax ; rax = 0 (filler qword)
|
---|
50 | cld
|
---|
51 | rep stosq
|
---|
52 |
|
---|
53 | mov rcx, rdx ; cbDst
|
---|
54 | and rcx, 7 ; calc trailing byte count.
|
---|
55 | rep stosb
|
---|
56 |
|
---|
57 | pop rdi
|
---|
58 | BS3_HYBRID_RET
|
---|
59 |
|
---|
60 | %elif ARCH_BITS == 16
|
---|
61 | push bp
|
---|
62 | mov bp, sp
|
---|
63 | push di
|
---|
64 | push es
|
---|
65 |
|
---|
66 | mov di, [bp + 2 + cbCurRetAddr] ; pvDst.off
|
---|
67 | mov dx, [bp + 2 + cbCurRetAddr + 2] ; pvDst.sel
|
---|
68 | mov es, dx
|
---|
69 | mov cx, [bp + 2 + cbCurRetAddr + 4] ; cbDst
|
---|
70 | shr cx, 1 ; calc dword count.
|
---|
71 | xor ax, ax
|
---|
72 | rep stosw
|
---|
73 |
|
---|
74 | mov cx, [bp + 2 + cbCurRetAddr + 4] ; cbDst
|
---|
75 | and cx, 1 ; calc tailing byte count.
|
---|
76 | rep stosb
|
---|
77 |
|
---|
78 | pop es
|
---|
79 | pop di
|
---|
80 | pop bp
|
---|
81 | BS3_HYBRID_RET
|
---|
82 |
|
---|
83 | %elif ARCH_BITS == 32
|
---|
84 | push edi
|
---|
85 |
|
---|
86 | mov edi, [esp + 8] ; pvDst
|
---|
87 | mov ecx, [esp + 8 + 4] ; cbDst
|
---|
88 | shr cx, 2 ; calc dword count.
|
---|
89 | xor eax, eax
|
---|
90 | rep stosd
|
---|
91 |
|
---|
92 | mov ecx, [esp + 8 + 4] ; cbDst
|
---|
93 | and ecx, 3 ; calc tailing byte count.
|
---|
94 | rep stosb
|
---|
95 |
|
---|
96 | pop edi
|
---|
97 | BS3_HYBRID_RET
|
---|
98 |
|
---|
99 | %else
|
---|
100 | %error "Unknown bitness."
|
---|
101 | %endif
|
---|
102 | BS3_PROC_END_CMN Bs3MemZero
|
---|
103 |
|
---|