VirtualBox

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

Last change on this file since 1071 was 3, checked in by vboxsync, 18 years ago

Include asm memcpy/memset.

  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1; $Id: memset.asm 3 2007-01-15 08:17:06Z vboxsync $
2;; @file
3; InnoTek Portable Runtime - No-CRT memset - AMD64 & X86.
4;
5
6;
7; Copyright (C) 2006 InnoTek Systemberatung 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
24;;
25; @param pvDst gcc: rdi msc: ecx x86:[esp+4]
26; @param ch gcc: esi msc: edx x86:[esp+8]
27; @param cb gcc: rdx msc: r8 x86:[esp+0ch]
28BEGINPROC RT_NOCRT(memset)
29 cld
30%ifdef __AMD64__
31 %ifdef ASM_CALL64_MSC
32 int3
33 %error "Port me"
34 %else
35 movzx eax, sil
36 cmp rdx, 32
37 jb .dobytes
38
39 ; eax = (al << 24) | (al << 16) | (al << 8) | al;
40 ; rdx = (eax << 32) | eax
41 movzx esi, sil
42 mov rax, qword 0101010101010101h
43 imul rax, rsi
44
45 ; todo: alignment.
46
47 mov rcx, rdx
48 shr rcx, 3
49 rep stosq
50
51 and rdx, 7
52.dobytes:
53 mov rcx, rdx
54 rep stosb
55 %endif
56
57%else
58 push edi
59
60 mov ecx, [esp + 0ch + 4]
61 movzx eax, byte [esp + 08h + 4]
62 mov edi, [esp + 04h + 4]
63 cmp ecx, 12
64 jb .dobytes
65
66 ; eax = (al << 24) | (al << 16) | (al << 8) | al;
67 mov ah, al
68 mov edx, eax
69 shr edx, 16
70 or eax, edx
71
72 mov edx, ecx
73 shr ecx, 2
74 rep stosd
75
76 and edx, 3
77 mov ecx, edx
78.dobytes:
79 rep stosb
80
81 pop edi
82%endif
83 ret
84ENDPROC RT_NOCRT(memset)
85
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