2007-02-19 06:35:21 +01:00
|
|
|
/****************************************************************************
|
|
|
|
*
|
|
|
|
* Open Watcom Project
|
|
|
|
*
|
|
|
|
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* ========================================================================
|
|
|
|
*
|
|
|
|
* This file contains Original Code and/or Modifications of Original
|
|
|
|
* Code as defined in and that are subject to the Sybase Open Watcom
|
|
|
|
* Public License version 1.0 (the 'License'). You may not use this file
|
|
|
|
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
|
|
|
|
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
|
|
|
|
* provided with the Original Code and Modifications, and is also
|
|
|
|
* available at www.sybase.com/developer/opensource.
|
|
|
|
*
|
|
|
|
* The Original Code and all software distributed under the License are
|
|
|
|
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
|
|
|
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
|
|
|
|
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
|
|
|
|
* NON-INFRINGEMENT. Please see the License for the specific language
|
|
|
|
* governing rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* ========================================================================
|
|
|
|
*
|
2007-06-26 02:54:22 +02:00
|
|
|
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
|
|
|
|
* DESCRIBE IT HERE!
|
2007-02-19 06:35:21 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#include "variety.h"
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#if defined(__386__)
|
2007-06-26 02:54:22 +02:00
|
|
|
|
|
|
|
#if defined(__FLAT__)
|
|
|
|
extern void movefwd( char _WCFAR *dst, const char _WCFAR *src, unsigned len);
|
2007-02-19 06:35:21 +01:00
|
|
|
#pragma aux movefwd = \
|
|
|
|
0x06 /* push es */\
|
|
|
|
0x8e 0xc2 /* mov es,dx */\
|
2007-06-26 02:54:22 +02:00
|
|
|
0x1e /* push ds */\
|
|
|
|
0x96 /* xchg esi,eax */\
|
|
|
|
0x8e 0xd8 /* mov ds,ax */\
|
|
|
|
0xd1 0xe9 /* shr cx,1 */\
|
2007-02-19 06:35:21 +01:00
|
|
|
0x66 0xf3 0xa5 /* rep movsw */\
|
2007-06-26 02:54:22 +02:00
|
|
|
0x11 0xc9 /* adc cx,cx */\
|
|
|
|
0xf3 0xa4 /* rep movsb */\
|
|
|
|
0x1f /* pop ds */\
|
2007-02-19 06:35:21 +01:00
|
|
|
0x07 /* pop es */\
|
2007-06-26 02:54:22 +02:00
|
|
|
parm [dx edi] [si eax] [ecx] \
|
|
|
|
modify exact [edi esi ecx eax];
|
|
|
|
#else
|
|
|
|
extern void movefwd( char _WCFAR *dst, const char _WCFAR *src, unsigned len);
|
|
|
|
#pragma aux movefwd = \
|
|
|
|
0x1e /* push ds */\
|
|
|
|
0x96 /* xchg esi,eax */\
|
|
|
|
0x8e 0xd8 /* mov ds,ax */\
|
|
|
|
0xd1 0xe9 /* shr cx,1 */\
|
|
|
|
0x66 0xf3 0xa5 /* rep movsw */\
|
|
|
|
0x11 0xc9 /* adc cx,cx */\
|
|
|
|
0xf3 0xa4 /* rep movsb */\
|
|
|
|
0x1f /* pop ds */\
|
|
|
|
parm [es edi] [si eax] [ecx] \
|
|
|
|
modify exact [edi esi ecx eax];
|
|
|
|
#endif
|
2007-02-19 06:35:21 +01:00
|
|
|
|
2007-06-26 02:54:22 +02:00
|
|
|
#elif defined(M_I86)
|
|
|
|
#if defined(__SMALL_DATA__)
|
|
|
|
extern void movebwd( char _WCFAR *dst, const char _WCFAR *src, unsigned len);
|
2007-02-19 06:35:21 +01:00
|
|
|
#pragma aux movebwd = \
|
|
|
|
0xfd /* std */\
|
2007-06-26 02:54:22 +02:00
|
|
|
0x1e /* push ds */\
|
|
|
|
0x96 /* xchg si,ax */\
|
|
|
|
0x8e 0xd8 /* mov ds,ax */\
|
2007-02-19 06:35:21 +01:00
|
|
|
0x4e /* dec si */\
|
|
|
|
0x4f /* dec di */\
|
|
|
|
0xd1 0xe9 /* shr cx,1 */\
|
|
|
|
0xf3 0xa5 /* rep movsw */\
|
|
|
|
0x11 0xc9 /* adc cx,cx */\
|
|
|
|
0x46 /* inc si */\
|
|
|
|
0x47 /* inc di */\
|
|
|
|
0xf3 0xa4 /* rep movsb */\
|
|
|
|
0xfc /* cld */\
|
2007-06-26 02:54:22 +02:00
|
|
|
0x1f /* pop ds */\
|
|
|
|
parm [es di] [si ax] [cx] \
|
|
|
|
modify exact [di si cx ax];
|
2007-02-19 06:35:21 +01:00
|
|
|
|
2007-06-26 02:54:22 +02:00
|
|
|
extern void movefwd( char _WCFAR *dst, const char _WCFAR *src, unsigned len);
|
2007-02-19 06:35:21 +01:00
|
|
|
#pragma aux movefwd = \
|
2007-06-26 02:54:22 +02:00
|
|
|
0x1e /* push ds */\
|
|
|
|
0x96 /* xchg si,ax */\
|
|
|
|
0x8e 0xd8 /* mov ds,ax */\
|
2007-02-19 06:35:21 +01:00
|
|
|
0xd1 0xe9 /* shr cx,1 */\
|
|
|
|
0xf3 0xa5 /* rep movsw */\
|
|
|
|
0x11 0xc9 /* adc cx,cx */\
|
|
|
|
0xf3 0xa4 /* rep movsb */\
|
2007-06-26 02:54:22 +02:00
|
|
|
0x1f /* pop ds */\
|
|
|
|
parm [es di] [si ax] [cx] \
|
|
|
|
modify exact [di si cx ax];
|
|
|
|
#else
|
2007-02-19 06:35:21 +01:00
|
|
|
extern void movebwd( char _WCFAR *dst, const char _WCFAR *src, unsigned len);
|
|
|
|
#pragma aux movebwd = \
|
|
|
|
0xfd /* std */\
|
2007-06-26 02:54:22 +02:00
|
|
|
0x1e /* push ds */\
|
|
|
|
0x96 /* xchg si,ax */\
|
|
|
|
0x8e 0xd8 /* mov ds,ax */\
|
2007-02-19 06:35:21 +01:00
|
|
|
0x4e /* dec si */\
|
|
|
|
0x4f /* dec di */\
|
|
|
|
0xd1 0xe9 /* shr cx,1 */\
|
|
|
|
0xf3 0xa5 /* rep movsw */\
|
|
|
|
0x11 0xc9 /* adc cx,cx */\
|
|
|
|
0x46 /* inc si */\
|
|
|
|
0x47 /* inc di */\
|
|
|
|
0xf3 0xa4 /* rep movsb */\
|
|
|
|
0xfc /* cld */\
|
2007-06-26 02:54:22 +02:00
|
|
|
0x1f /* pop ds */\
|
|
|
|
parm [es di] [si ax] [cx] \
|
|
|
|
modify exact [di si cx ax];
|
2007-02-19 06:35:21 +01:00
|
|
|
|
|
|
|
extern void movefwd( char _WCFAR *dst, const char _WCFAR *src, unsigned len);
|
|
|
|
#pragma aux movefwd = \
|
2007-06-26 02:54:22 +02:00
|
|
|
0x1e /* push ds */\
|
|
|
|
0x96 /* xchg si,ax */\
|
|
|
|
0x8e 0xd8 /* mov ds,ax */\
|
2007-02-19 06:35:21 +01:00
|
|
|
0xd1 0xe9 /* shr cx,1 */\
|
|
|
|
0xf3 0xa5 /* rep movsw */\
|
|
|
|
0x11 0xc9 /* adc cx,cx */\
|
|
|
|
0xf3 0xa4 /* rep movsb */\
|
2007-06-26 02:54:22 +02:00
|
|
|
0x1f /* pop ds */\
|
|
|
|
parm [es di] [si ax] [cx] \
|
|
|
|
modify exact [di si cx ax];
|
|
|
|
#endif
|
2007-02-19 06:35:21 +01:00
|
|
|
#else
|
2007-06-26 02:54:22 +02:00
|
|
|
#error platform not supported
|
2007-02-19 06:35:21 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2007-06-26 02:54:22 +02:00
|
|
|
_WCRTLINK void _WCFAR *_fmemmove( void _WCFAR *t, const void _WCFAR *f, size_t len )
|
|
|
|
{
|
|
|
|
char _WCFAR *to = t;
|
|
|
|
const char _WCFAR *from = f;
|
|
|
|
if( from == to ) {
|
|
|
|
return( to );
|
2007-02-19 06:35:21 +01:00
|
|
|
}
|
2007-06-26 02:54:22 +02:00
|
|
|
if( from < to && from + len > to ) { /* if buffers are overlapped*/
|
|
|
|
#if defined(__HUGE__) || defined(__386__)
|
|
|
|
to += len;
|
|
|
|
from += len;
|
|
|
|
while( len != 0 ) {
|
|
|
|
to--;
|
|
|
|
from--;
|
|
|
|
*to = *from;
|
|
|
|
len--;
|
|
|
|
}
|
2007-02-19 06:35:21 +01:00
|
|
|
#else
|
2007-06-26 02:54:22 +02:00
|
|
|
movebwd(( to + len ) - 1, ( from + len ) - 1, len );
|
2007-02-19 06:35:21 +01:00
|
|
|
#endif
|
2007-06-26 02:54:22 +02:00
|
|
|
} else {
|
|
|
|
movefwd( to, from, len );
|
2007-02-19 06:35:21 +01:00
|
|
|
}
|
2007-06-26 02:54:22 +02:00
|
|
|
return( to );
|
2007-02-19 06:35:21 +01:00
|
|
|
}
|
|
|
|
|