Commit 25eb8e2c authored by Davi Arnaut's avatar Davi Arnaut

Backport: remove ancient and unused strings files.

parent d60a0ce9
Thu May 20 13:45:15 1993 Michael Widenius (monty at bitch)
* changed itoa() and ltoa() to use the same interface as microsoft:s
and zortech:s libraryes.
Sun Mar 24 00:30:34 1991 Michael Widenius (monty at LYNX)
* Changed int2str to return BIG converted chars.
Sun Feb 24 00:22:54 1991 Michael Widenius (monty at LYNX)
* Added new function strcend(string,char). Its eqvialent to
if (!(a=strchr(string,char)))
a=strend(string);
Tue Oct 16 18:53:19 1990 Michael Widenius (monty at LYNX)
* Added define BAD_STRING_COMPILER to set define strmov()
if compiler is very bad at stringoperations.
* Changed to use cc on sun-systems instead of gcc.
Sat Sep 29 18:42:31 1990 Michael Widenius (monty at LYNX)
* Added my_atof for sparc system to get some speed.
Sun Mar 11 16:35:59 1990 Monty (monty at monty)
* strnmov() was changed to not fill to-string with null.
* strmake() changed to point at closing null.
Wed Feb 7 20:15:34 1990 David Axmark (davida at isil)
* Made functon strinrstr that is reverse search.
Fri Dec 2 03:37:59 1988 Monty (monty at monty)
* Fixed bug in strcont; It didn't return first found character in
set.
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#define IFACTOR 4
void
dcopy(char *chardest, char *charsrc, int size)
{
register int *src, *dest, intcount ;
int startcharcpy, intoffset, numints2cpy, i ;
numints2cpy = size >> 2 ;
startcharcpy = numints2cpy << 2 ;
intcount = numints2cpy & ~(IFACTOR-1) ;
intoffset = numints2cpy - intcount ;
src = (int *)(((int) charsrc) + intcount*sizeof(int*)) ;
dest = (int *)(((int) chardest) + intcount*sizeof(int*)) ;
/* copy the ints */
switch(intoffset)
do
{
case 0: dest[3] = src[3] ;
case 3: dest[2] = src[2] ;
case 2: dest[1] = src[1] ;
case 1: dest[0] = src[0] ;
intcount -= IFACTOR ;
dest -= IFACTOR ;
src -= IFACTOR ;
} while (intcount >= 0) ;
/* copy the chars left over by the int copy at the end */
for(i=startcharcpy ; i<size ; i++)
chardest[i] = charsrc[i] ;
}
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* File : bzero.c
Author : Richard A. O'Keefe.
Michael Widenius; ifdef MC68000
Updated: 23 April 1984
Defines: bzero()
bzero(dst, len) moves "len" 0 bytes to "dst".
Thus to clear a disc buffer to 0s do bzero(buffer, BUFSIZ).
Note: the "b" routines are there to exploit certain VAX order codes,
The asm code is presented for your interest and amusement.
*/
#ifndef BSD_FUNCS
#include "strings.h"
#ifdef bzero
#undef bzero /* remove macro */
#endif
#if VaxAsm
static void _bzero64 _A((char *dst,int len));
void bzero(dst, len)
char *dst;
uint len;
{
while ((int) len >= 64*K)
{
_bzero64(dst, 64*K-1);
dst += 64*K-1;
len -= 64*K-1;
}
_bzero64(dst, len);
}
_bzero64(dst, len)
char *dst;
int len;
{
asm("movc5 $0,*4(ap),$0,8(ap),*4(ap)");
}
#else
#if defined(MC68000) && defined(DS90)
void bzero(dst, len)
char *dst;
uint len;
{
bfill(dst,len,0); /* This is very optimized ! */
} /* bzero */
#else
void bzero(dst, len)
register char *dst;
register uint len;
{
while (len-- != 0) *dst++ = 0;
} /* bzero */
#endif
#endif
#endif /* BSD_FUNCS */
; Copyright (C) 2000 MySQL AB
;
; This library is free software; you can redistribute it and/or
; modify it under the terms of the GNU Library General Public
; License as published by the Free Software Foundation; version 2
; of the License.
;
; This library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; Library General Public License for more details.
;
; You should have received a copy of the GNU Library General Public
; License along with this library; if not, write to the Free
; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
; MA 02111-1307, USA
; Some useful macros
.386P
.387
_FLAT equ 0 ;FLAT memory model
_STDCALL equ 0 ;default to _stdcall
I386 equ 1
begcode macro module
if _FLAT
_TEXT segment dword use32 public 'CODE'
assume CS:FLAT,DS:FLAT,SS:FLAT
else
_TEXT segment dword public 'CODE'
assume CS:_TEXT
endif
endm
endcode macro module
_TEXT ENDS
endm
begdata macro
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Set up segments for data
; Regular initialized data goes in _DATA
_DATA segment dword public 'DATA'
_DATA ends
;Function pointers to constructors
XIB segment dword public 'DATA'
XIB ends
XI segment dword public 'DATA'
XI ends
XIE segment dword public 'DATA'
XIE ends
;Function pointers to destructors
XCB segment dword public 'DATA'
XCB ends
XC segment dword public 'DATA'
XC ends
XCE segment dword public 'DATA'
XCE ends
;Constant data, such as switch tables, go here.
CONST segment dword public 'CONST'
CONST ends
;Segment for uninitialized data. This is set to 0 by the startup code/OS,
;so it does not consume room in the executable file.
_BSS segment dword public 'BSS'
_BSS ends
HUGE_BSS segment dword public 'HUGE_BSS'
HUGE_BSS ends
EEND segment dword public 'ENDBSS'
EEND ends
STACK segment para stack 'STACK'
STACK ends
DGROUP group _DATA,XIB,XI,XIE,XCB,XC,XCE,CONST,_BSS,EEND,STACK
_DATA segment
if _FLAT
assume DS:FLAT
else
assume DS:DGROUP
endif
endm
enddata macro
_DATA ends
endm
P equ 8 ; Offset of start of parameters on the stack frame
; From EBP assuming EBP was pushed.
PS equ 4 ; Offset of start of parameters on the stack frame
; From ESP assuming EBP was NOT pushed.
ESeqDS equ 0
FSeqDS equ 0
GSeqDS equ 0
SSeqDS equ 1
SIZEPTR equ 4 ; Size of a pointer
LPTR equ 0
SPTR equ 1
LCODE equ 0
func macro name
_&name proc near
ifndef name
name equ _&name
endif
endm
callm macro name
call _&name
endm
;Macros to replace public, extrn, and endp for C-callable assembly routines,
; and to define labels: c_label defines labels,
; c_public replaces public, c_extrn replaces extrn, and c_endp replaces endp
c_name macro name
name equ _&name
endm
c_label macro name
_&name:
endm
c_endp macro name
_&name ENDP
endm
clr macro list ;clear a register
irp reg,<list>
xor reg,reg
endm
endm
jmps macro lbl
jmp short lbl
endm
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* memcmp(lhs, rhs, len)
compares the two memory areas lhs[0..len-1] ?? rhs[0..len-1]. It
returns an integer less than, equal to, or greater than 0 according
as lhs[-] is lexicographically less than, equal to, or greater than
rhs[-]. Note that this is not at all the same as bcmp, which tells
you *where* the difference is but not what.
Note: suppose we have int x, y; then memcmp(&x, &y, sizeof x) need
not bear any relation to x-y. This is because byte order is machine
dependent, and also, some machines have integer representations that
are shorter than a machine word and two equal integers might have
different values in the spare bits. On a ones complement machine,
-0 == 0, but the bit patterns are different.
*/
#include "strings.h"
#if !defined(HAVE_MEMCPY)
int memcmp(lhs, rhs, len)
register char *lhs, *rhs;
register int len;
{
while (--len >= 0)
if (*lhs++ != *rhs++) return (uchar) lhs[-1] - (uchar) rhs[-1];
return 0;
}
#endif
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
memcpy(dst, src, len)
moves len bytes from src to dst. The result is dst. This is not
the same as strncpy or strnmov, while move a maximum of len bytes
and stop early if they hit a NUL character. This moves len bytes
exactly, no more, no less. See also bcopy() and bmove() which do
not return a value but otherwise do the same job.
*/
#include "strings.h"
char *memcpy(char *dst, register char *src, register int len)
{
register char *d;
for (d = dst; --len >= 0; *d++ = *src++) ;
return dst;
}
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* File : memset.c
Author : Richard A. O'Keefe.
Updated: 25 May 1984
Defines: memset()
memset(dst, chr, len)
fills the memory area dst[0..len-1] with len bytes all equal to chr.
The result is dst. See also bfill(), which has no return value and
puts the last two arguments the other way around.
Note: the VAX assembly code version can only handle 0 <= len < 2^16.
It is presented for your interest and amusement.
*/
#include "strings.h"
#if VaxAsm
char *memset(char *dst,int chr, int len)
{
asm("movc5 $0,*4(ap),8(ap),12(ap),*4(ap)");
return dst;
}
#else ~VaxAsm
char *memset(char *dst, register pchar chr, register int len)
{
register char *d;
for (d = dst; --len >= 0; *d++ = chr) ;
return dst;
}
#endif VaxAsm
; Copyright (C) 2000 MySQL AB
;
; This library is free software; you can redistribute it and/or
; modify it under the terms of the GNU Library General Public
; License as published by the Free Software Foundation; version 2
; of the License.
;
; This library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; Library General Public License for more details.
;
; You should have received a copy of the GNU Library General Public
; License along with this library; if not, write to the Free
; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
; MA 02111-1307, USA
TITLE Optimized cmp of pointer to strings of unsigned chars
ifndef M_I386
.8087
DOSSEG
.MODEL LARGE
.DATA
compare_length dw 0
.CODE STRINGS
PUBLIC _get_ptr_compare
_get_ptr_compare PROC
mov bx,sp
mov cx,ss:[BX+4]
mov compare_length,cx
mov dx,seg strings:_ptr_cmp
mov ax,offset _ptr_cmp_0
jcxz @F
mov ax,offset _ptr_cmp_1
dec cx
jz @F
mov ax,offset _ptr_cmp
@@: ret
_get_ptr_compare ENDP
_ptr_cmp_0 PROC
mov AX,0 ; Emptyt strings are always equal
ret
_ptr_cmp_0 ENDP
_ptr_cmp_1 PROC
mov bx,sp
mov dx,si ; Save si and ds
mov cx,ds
lds si,DWORD PTR ss:[bx+4] ; s1
lds si,DWORD PTR ds:[si]
mov al,ds:[si]
xor ah,ah
lds si,DWORD PTR ss:[bx+8] ; s2
lds si,DWORD PTR ds:[si]
mov bl,ds:[si]
mov bh,ah
sub ax,bx
mov ds,cx ; restore si and ds
mov si,dx
ret
_ptr_cmp_1 ENDP
_ptr_cmp PROC
mov bx,bp ; Save bp
mov dx,di ; Save di
mov bp,sp
push ds
push si
mov cx,compare_length ; Length of memory-area
lds si,DWORD PTR [bp+4] ; s1
lds si,DWORD PTR ds:[si]
les di,DWORD PTR [bp+8] ; s2
les di,DWORD PTR es:[di]
; cld ; Work uppward
xor ax,ax
repe cmpsb ; Compare strings
je @F ; Strings are equal
sbb ax,ax
cmc
adc ax,0
@@: pop si
pop ds
mov di,dx
mov bp,bx
ret
_ptr_cmp ENDP
else
include macros.asm
fix_es MACRO fix_cld ; Load ES if neaded
ife ESeqDS
mov ax,ds
mov es,ax
endif
ifnb <fix_cld>
cld
endif
ENDM
begdata
compare_length dd 0 ; Length of strings
enddata
begcode get_ptr_compare
public _get_ptr_compare
_get_ptr_compare proc near
mov ecx,P-SIZEPTR[esp]
mov compare_length,ecx
mov eax,offset _TEXT:_ptr_cmp_0
jecxz @F
mov eax,offset _TEXT:_ptr_cmp_1
dec ecx
jz @F
mov eax,offset _TEXT:_ptr_cmp
@@: ret
_get_ptr_compare endp
endcode _get_ptr_compare
begcode ptr_cmp_0
_ptr_cmp_0 PROC
mov EAX,0 ; Emptyt strings are always equal
ret
_ptr_cmp_0 ENDP
endcode ptr_cmp_0
begcode ptr_cmp_1
_ptr_cmp_1 proc near
mov edx,esi ; Save esi
mov esi,P-SIZEPTR[esp] ; *s1
mov esi,[esi]
movzx eax,[esi]
mov esi,P[esp] ; *s2
mov esi,[esi]
movzx ecx,[esi]
sub eax,ecx
mov esi,edx ; Restore esi
ret
_ptr_cmp_1 ENDP
endcode ptr_cmp_1
begcode ptr_cmp
_ptr_cmp proc near
fix_es 1
push ebp
mov ebp,esp
mov edx,edi ; Save esi
push esi
mov esi,P[ebp] ; *s1
mov esi,[esi]
mov edi,P+SIZEPTR[ebp] ; *s2
mov edi,[edi]
mov ecx,compare_length ; Length of memory-area
xor eax,eax
repe cmpsb ; Compare strings
je @F ; Strings are equal
sbb eax,eax
cmc
adc eax,0
@@: pop esi
mov edi,edx
pop ebp
ret
_ptr_cmp ENDP
endcode ptr_cmp
endif
END
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* File : strcat.c
Author : Richard A. O'Keefe.
Updated: 10 April 1984
Defines: strcat()
strcat(s, t) concatenates t on the end of s. There had better be
enough room in the space s points to; strcat has no way to tell.
Note that strcat has to search for the end of s, so if you are doing
a lot of concatenating it may be better to use strmov, e.g.
strmov(strmov(strmov(strmov(s,a),b),c),d)
rather than
strcat(strcat(strcat(strcpy(s,a),b),c),d).
strcat returns the old value of s.
*/
#include "strings.h"
char *strcat(register char *s, register const char *t)
{
char *save;
for (save = s; *s++; ) ;
for (--s; *s++ = *t++; ) ;
return save;
}
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* File : strchr.c
Author : Richard A. O'Keefe.
Michael Widenius: ifdef MC68000
Updated: 20 April 1984
Defines: strchr(), index()
strchr(s, c) returns a pointer to the first place in s where c
occurs, or NullS if c does not occur in s. This function is called
index in V7 and 4.?bsd systems; while not ideal the name is clearer
than strchr, so index remains in strings.h as a macro. NB: strchr
looks for single characters, not for sets or strings. To find the
NUL character which closes s, use strchr(s, '\0') or strend(s). The
parameter 'c' is declared 'int' so it will go in a register; if your
C compiler is happy with register _char_ change it to that.
*/
#include "strings.h"
#if defined(MC68000) && defined(DS90)
char* strchr(char *s, pchar c)
{
asm(" movl 4(a7),a0 ");
asm(" movl 8(a7),d1 ");
asm(".L2: movb (a0)+,d0 ");
asm(" cmpb d0,d1 ");
asm(" beq .L1 ");
asm(" tstb d0 ");
asm(" bne .L2 ");
asm(" moveq #0,d0 ");
asm(" rts ");
asm(".L1: movl a0,d0 ");
asm(" subql #1,d0 ");
}
#else
char *strchr(register const char *s, register pchar c)
{
for (;;)
{
if (*s == (char) c) return (char*) s;
if (!*s++) return NullS;
}
}
#endif
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* File : strcmp.c
Author : Richard A. O'Keefe.
Updated: 10 April 1984
Defines: strcmp()
strcmp(s, t) returns > 0, = 0, or < 0 when s > t, s = t, or s < t
according to the ordinary lexicographical order. To test for
equality, the macro streql(s,t) is clearer than !strcmp(s,t). Note
that if the string contains characters outside the range 0..127 the
result is machine-dependent; PDP-11s and VAXen use signed bytes,
some other machines use unsigned bytes.
*/
#include "strings.h"
int strcmp(register const char *s, register const char *t)
{
while (*s == *t++) if (!*s++) return 0;
return s[0]-t[-1];
}
This diff is collapsed.
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* File : strlen.c
Author : Richard A. O'Keefe. / Monty
Michael Widenius; ifdef MC68000
Updated: 1986-11-30
Defines: strlen()
strlen(s) returns the number of characters in s, that is, the number
of non-NUL characters found before the closing NULEosCh. Note: some
non-standard C compilers for 32-bit machines take int to be 16 bits,
either put up with short strings or change int to long throughout
this package. Better yet, BOYCOTT such shoddy compilers.
Beware: the asm version works only if strlen(s) < 65536.
*/
#include "strings.h"
#if VaxAsm
size_t strlen(char *s)
{
asm("locc $0,$65535,*4(ap)");
asm("subl3 r0,$65535,r0");
}
#else
#if defined(MC68000) && defined(DS90)
size_t strlen(char *s)
{
asm(" movl 4(a7),a0 ");
asm(" movl a0,a1 ");
asm(".L4: tstb (a0)+ ");
asm(" jne .L4 ");
asm(" movl a0,d0 ");
asm(" subl a1,d0 ");
asm(" subql #1,d0 ");
}
#else
size_t strlen(register char *s)
{
register char *startpos;
startpos = s;
while (*s++);
return ((size_t) (s-startpos-1));
}
#endif
#endif
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* File : strrchr.c
Author : Richard A. O'Keefe.
Updated: 10 April 1984
Defines: strrchr(), rindex()
strrchr(s, c) returns a pointer to the last place in s where c
occurs, or NullS if c does not occur in s. This function is called
rindex in V7 and 4.?bsd systems; while not ideal the name is clearer
than strrchr, so rindex remains in strings.h as a macro. NB:
strrchr looks for single characters, not for sets or strings. The
parameter 'c' is declared 'int' so it will go in a register; if your
C compiler is happy with register char change it to that.
*/
#include "strings.h"
char *strrchr(register const char *s, register pchar c)
{
reg3 char *t;
t = NullS;
do if (*s == (char) c) t = (char*) s; while (*s++);
return (char*) t;
}
; Copyright (C) 2000 MySQL AB
;
; This library is free software; you can redistribute it and/or
; modify it under the terms of the GNU Library General Public
; License as published by the Free Software Foundation; version 2
; of the License.
;
; This library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; Library General Public License for more details.
;
; You should have received a copy of the GNU Library General Public
; License along with this library; if not, write to the Free
; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
; MA 02111-1307, USA
TITLE Optimized strxmov for MSDOS / Intel 8086
ifndef M_I386
.8087
DOSSEG
.MODEL LARGE
.CODE
PUBLIC _strxmov
_strxmov PROC
mov bx,sp
add bx,4
push si
push di
mov cx,ds ; Save ds
ASSUME DS: NOTHING
ASSUME ES: NOTHING
les di,DWORD PTR ss:[bx] ; dst
jmp next_str
start_str:
mov al,ds:[si]
movsb ; move arg
and al,al
jnz start_str ; Not last
dec di
next_str:
add bx,4
lds si,DWORD PTR ss:[bx]
mov ax,ds
or ax,si
jnz start_str
mov byte ptr es:[di],0 ; Force end null (if no source)
mov ds,cx
mov ax,di ; Return ptr to last 0
mov dx,es
pop di
pop si
ret
_strxmov ENDP
else
include macros.asm
begcode strxmov
public _strxmov
_strxmov PROC near
ASSUME DS: NOTHING
ASSUME ES: NOTHING
push EBP
mov EBP,ESP
mov EDX,EBX ; Save EBX
mov ECX,ESI ; Save ESI
push EDI
mov EDI,8[EBP] ; Get destination
lea EBX,8[EBP] ; Get adress to first source - 4
xor al,al
jmp next_str
start_str: movsb
cmp AL,[EDI-1]
jne start_str
dec EDI ; Don't copy last null
next_str: add EBX,4
mov ESI,[EBX]
or ESI,ESI
jne start_str
mov byte ptr [EDI],0 ; Force last null
mov EAX,EDI ; Return ptr to null
pop EDI
mov ESI,ECX
mov EBX,EDX
pop EBP
ret
_strxmov endp
endcode strxmov
endif
END
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Do udiv and urem if machine dosn't have it */
#include <my_global.h>
#include <math.h>
unsigned long udiv(long unsigned int a, long unsigned int b)
{
if (a < INT_MAX32 && b < INT_MAX32)
return (unsigned long) ((long) a / (long) b);
if (!(b & 1))
return (unsigned long) ((long) (a >> 1) / (long) (b >> 1));
return (unsigned long) floor(((double) a / (double) b));
}
unsigned long urem(long unsigned int a, long unsigned int b)
{
if (a < INT_MAX32 && b < INT_MAX32)
return (unsigned long) ((long) a % (long) b);
return a-udiv(a,b)*b;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment