Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
553 serge 1
/****************************************************************************
2
*
3
*                            Open Watcom Project
4
*
5
*    Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
6
*
7
*  ========================================================================
8
*
9
*    This file contains Original Code and/or Modifications of Original
10
*    Code as defined in and that are subject to the Sybase Open Watcom
11
*    Public License version 1.0 (the 'License'). You may not use this file
12
*    except in compliance with the License. BY USING THIS FILE YOU AGREE TO
13
*    ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
14
*    provided with the Original Code and Modifications, and is also
15
*    available at www.sybase.com/developer/opensource.
16
*
17
*    The Original Code and all software distributed under the License are
18
*    distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
19
*    EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
20
*    ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
21
*    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
22
*    NON-INFRINGEMENT. Please see the License for the specific language
23
*    governing rights and limitations under the License.
24
*
25
*  ========================================================================
26
*
27
* Description:  WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
28
*               DESCRIBE IT HERE!
29
*
30
****************************************************************************/
31
 
32
 
33
#include "variety.h"
34
#include 
35
#include 
36
 
37
#if defined(__386__)
38
 
39
#if defined(__FLAT__)
40
extern  void    movefwd( char _WCFAR *dst, const char _WCFAR *src, unsigned len);
41
#pragma aux     movefwd =  \
42
        0x06            /* push es */\
43
        0x8e 0xc2       /* mov es,dx */\
44
        0x1e            /* push ds */\
45
        0x96            /* xchg esi,eax */\
46
        0x8e 0xd8       /* mov ds,ax */\
47
        0xd1 0xe9       /* shr cx,1 */\
48
        0x66 0xf3 0xa5  /* rep movsw */\
49
        0x11 0xc9       /* adc cx,cx */\
50
        0xf3 0xa4       /* rep movsb */\
51
        0x1f            /* pop ds */\
52
        0x07            /* pop es */\
53
        parm [dx edi] [si eax] [ecx] \
54
        modify exact [edi esi ecx eax];
55
#else
56
extern  void    movefwd( char _WCFAR *dst, const char _WCFAR *src, unsigned len);
57
#pragma aux     movefwd =  \
58
        0x1e            /* push ds */\
59
        0x96            /* xchg esi,eax */\
60
        0x8e 0xd8       /* mov ds,ax */\
61
        0xd1 0xe9       /* shr cx,1 */\
62
        0x66 0xf3 0xa5  /* rep movsw */\
63
        0x11 0xc9       /* adc cx,cx */\
64
        0xf3 0xa4       /* rep movsb */\
65
        0x1f            /* pop ds */\
66
        parm [es edi] [si eax] [ecx] \
67
        modify exact [edi esi ecx eax];
68
#endif
69
 
70
#elif defined(M_I86)
71
#if defined(__SMALL_DATA__)
72
extern  void    movebwd( char _WCFAR *dst, const char _WCFAR *src, unsigned len);
73
#pragma aux     movebwd =  \
74
        0xfd            /* std */\
75
        0x1e            /* push ds */\
76
        0x96            /* xchg si,ax */\
77
        0x8e 0xd8       /* mov ds,ax */\
78
        0x4e            /* dec si */\
79
        0x4f            /* dec di */\
80
        0xd1 0xe9       /* shr cx,1 */\
81
        0xf3 0xa5       /* rep movsw */\
82
        0x11 0xc9       /* adc cx,cx */\
83
        0x46            /* inc si */\
84
        0x47            /* inc di */\
85
        0xf3 0xa4       /* rep movsb */\
86
        0xfc            /* cld */\
87
        0x1f            /* pop ds */\
88
        parm [es di] [si ax] [cx] \
89
        modify exact [di si cx ax];
90
 
91
extern  void    movefwd( char _WCFAR *dst, const char _WCFAR *src, unsigned len);
92
#pragma aux     movefwd =  \
93
        0x1e            /* push ds */\
94
        0x96            /* xchg si,ax */\
95
        0x8e 0xd8       /* mov ds,ax */\
96
        0xd1 0xe9       /* shr cx,1 */\
97
        0xf3 0xa5       /* rep movsw */\
98
        0x11 0xc9       /* adc cx,cx */\
99
        0xf3 0xa4       /* rep movsb */\
100
        0x1f            /* pop ds */\
101
        parm [es di] [si ax] [cx] \
102
        modify exact [di si cx ax];
103
#else
104
extern  void    movebwd( char _WCFAR *dst, const char _WCFAR *src, unsigned len);
105
#pragma aux     movebwd =  \
106
        0xfd            /* std */\
107
        0x1e            /* push ds */\
108
        0x96            /* xchg si,ax */\
109
        0x8e 0xd8       /* mov ds,ax */\
110
        0x4e            /* dec si */\
111
        0x4f            /* dec di */\
112
        0xd1 0xe9       /* shr cx,1 */\
113
        0xf3 0xa5       /* rep movsw */\
114
        0x11 0xc9       /* adc cx,cx */\
115
        0x46            /* inc si */\
116
        0x47            /* inc di */\
117
        0xf3 0xa4       /* rep movsb */\
118
        0xfc            /* cld */\
119
        0x1f            /* pop ds */\
120
        parm [es di] [si ax] [cx] \
121
        modify exact [di si cx ax];
122
 
123
extern  void    movefwd( char _WCFAR *dst, const char _WCFAR *src, unsigned len);
124
#pragma aux     movefwd =  \
125
        0x1e            /* push ds */\
126
        0x96            /* xchg si,ax */\
127
        0x8e 0xd8       /* mov ds,ax */\
128
        0xd1 0xe9       /* shr cx,1 */\
129
        0xf3 0xa5       /* rep movsw */\
130
        0x11 0xc9       /* adc cx,cx */\
131
        0xf3 0xa4       /* rep movsb */\
132
        0x1f            /* pop ds */\
133
        parm [es di] [si ax] [cx] \
134
        modify exact [di si cx ax];
135
#endif
136
#else
137
#error platform not supported
138
#endif
139
 
140
 
141
_WCRTLINK void _WCFAR *_fmemmove( void _WCFAR *t, const void _WCFAR *f, size_t len )
142
    {
143
        char _WCFAR *to = t;
144
        const char _WCFAR *from = f;
145
        if( from == to ) {
146
            return( to );
147
        }
148
        if( from < to  &&  from + len > to ) {  /* if buffers are overlapped*/
149
#if defined(__HUGE__) || defined(__386__)
150
            to += len;
151
            from += len;
152
            while( len != 0 ) {
153
                to--;
154
                from--;
155
                *to = *from;
156
                len--;
157
            }
158
#else
159
            movebwd(( to + len ) - 1, ( from + len ) - 1, len );
160
#endif
161
        } else {
162
            movefwd( to, from, len );
163
        }
164
        return( to );
165
    }
166