AGESA F15: AMD family15 AGESA code
[coreboot.git] / src / vendorcode / amd / agesa / f15 / Lib / IA32 / msmemcpy.asm
1 ;/**
2 ; * @file
3 ; *
4 ; * Agesa library 32bit
5 ; *
6 ; * Contains AMD AGESA Library
7 ; *
8 ; * @xrefitem bom "File Content Label" "Release Content"
9 ; * @e project:      AGESA
10 ; * @e sub-project:  Lib
11 ; * @e \$Revision: 9201 $   @e \$Date: 2008-10-31 03:36:20 -0500 (Fri, 31 Oct 2008) $
12 ; */
13 ;*****************************************************************************
14 ;
15 ; Copyright (C) 2012 Advanced Micro Devices, Inc.
16 ; All rights reserved.
17 ;
18 ; Redistribution and use in source and binary forms, with or without
19 ; modification, are permitted provided that the following conditions are met:
20 ;     * Redistributions of source code must retain the above copyright
21 ;       notice, this list of conditions and the following disclaimer.
22 ;     * Redistributions in binary form must reproduce the above copyright
23 ;       notice, this list of conditions and the following disclaimer in the
24 ;       documentation and/or other materials provided with the distribution.
25 ;     * Neither the name of Advanced Micro Devices, Inc. nor the names of
26 ;       its contributors may be used to endorse or promote products derived
27 ;       from this software without specific prior written permission.
28 ;
29 ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
30 ; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31 ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
32 ; DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
33 ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34 ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35 ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36 ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38 ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 ;
40 ;*****************************************************************************
41
42 .586p
43 .model  flat
44 ASSUME FS:NOTHING
45 .code
46 ; void *memcpy( void *dest, void *src, size_t count );
47 ;
48 ; Copy count bytes from src to dest, returning dest.
49 ; ("c" is not legal as an assembly parameter name, replaced with value.)
50 ; Assume ES is set appropriately, 32 bit flat.
51 ;
52 public memcpy
53 memcpy  PROC NEAR C PUBLIC USES ECX EDI ESI dest:DWORD, src:DWORD, count:DWORD
54         pushf
55         cld     ; We will increment through *dest
56         mov     edi, dest
57         mov     esi, src
58         mov     ecx, count
59         rep movsb
60         mov eax, dest
61         popf
62         ret
63 memcpy ENDP
64
65 ; void *memset( void *dest, int c, size_t count );
66 ;
67 ; At dest, set count bytes to byte value, returning dest.
68 ; ("c" is not legal as an assembly parameter name, replaced with value.)
69 ; Assume ES is set appropriately, 32 bit flat.
70 ;
71 public memset
72 memset  PROC NEAR C PUBLIC USES ECX EDI dest:DWORD, value:DWORD, count:DWORD
73         pushf
74         cld     ; We will increment through *dest
75         mov     edi, dest
76         mov     eax, value
77         mov     ecx, count
78         rep stosb
79         mov     eax, edi
80         popf
81         ret
82 memset ENDP
83
84 END