VirtualBox

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

Last change on this file since 75129 was 75129, checked in by vboxsync, 6 years ago

IPRT: Make Watcom C an alterntive for compiling the OS/2 kernel code (GA mainly), governed by VBOX_USE_WATCOM_FOR_OS2.

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