VirtualBox

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

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

RT_OS_* and RT_ARCH_* for Runtime/ and Support/

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.2 KB
Line 
1; $Id: memset.asm 3672 2007-07-17 12:39:30Z vboxsync $
2;; @file
3; innotek Portable Runtime - No-CRT memset - 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; If you received this file as part of a commercial VirtualBox
18; distribution, then only the terms of your commercial VirtualBox
19; license agreement apply instead of the previous paragraph.
20;
21
22%include "iprt/asmdefs.mac"
23
24BEGINCODE
25
26;;
27; @param pvDst gcc: rdi msc: ecx x86:[esp+4]
28; @param ch gcc: esi msc: edx x86:[esp+8]
29; @param cb gcc: rdx msc: r8 x86:[esp+0ch]
30BEGINPROC RT_NOCRT(memset)
31 cld
32%ifdef RT_ARCH_AMD64
33 %ifdef ASM_CALL64_MSC
34 int3
35 %error "Port me"
36 %else
37 mov r10, rdi ; the return value.
38 movzx eax, sil
39 cmp rdx, 32
40 jb .dobytes
41
42 ; eax = (al << 24) | (al << 16) | (al << 8) | al;
43 ; rdx = (eax << 32) | eax
44 movzx esi, sil
45 mov rax, qword 0101010101010101h
46 imul rax, rsi
47
48 ; todo: alignment.
49
50 mov rcx, rdx
51 shr rcx, 3
52 rep stosq
53
54 and rdx, 7
55.dobytes:
56 mov rcx, rdx
57 rep stosb
58
59 mov rax, rdi
60 %endif
61
62%else
63 push edi
64
65 mov ecx, [esp + 0ch + 4]
66 movzx eax, byte [esp + 08h + 4]
67 mov edi, [esp + 04h + 4]
68 cmp ecx, 12
69 jb .dobytes
70
71 ; eax = (al << 24) | (al << 16) | (al << 8) | al;
72 mov ah, al
73 mov edx, eax
74 shr edx, 16
75 or eax, edx
76
77 mov edx, ecx
78 shr ecx, 2
79 rep stosd
80
81 and edx, 3
82 mov ecx, edx
83.dobytes:
84 rep stosb
85
86 pop edi
87 mov eax, [esp + 4]
88%endif
89 ret
90ENDPROC RT_NOCRT(memset)
91
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