Added more functions (memchr, memcmp, strcmp) to asmsupt.asm. Removed strncpy

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@398 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2002-08-03 01:48:49 +00:00
parent cbad615e0b
commit 93bc26d0d5
4 changed files with 109 additions and 24 deletions

View File

@ -47,20 +47,25 @@ segment HMA_TEXT
;
; currently done:
;
; fmemcpyBack(void FAR *dest, void FAR *src, int count)
; memcpy(void *dest, void *src, int count)
; fmemcpy(void FAR *dest, void FAR *src, int count)
; _fmemcpy(void FAR *dest, void FAR *src, int count)
; memset(void *dest, int ch, int count);
; fmemset(void FAR *dest, int ch, int count);
; fstrncpy(void FAR*dest, void FAR *src, int count);
; strcpy (void *dest, void *src);
; fstrcpy (void FAR*dest, void FAR *src, int count);
; strlen (void *dest);
; fstrlen (void FAR*dest);
; strchr (BYTE *src , BYTE ch);
; fmemchr (BYTE FAR *src , int ch);
; fstrchr (BYTE FAR *src , int ch);
; strchr (BYTE *src , int ch);
; fstrcmp (BYTE FAR *s1 , BYTE FAR *s2);
; strcmp (BYTE *s1 , BYTE *s2);
; fstrncmp(BYTE FAR *s1 , BYTE FAR *s2, int count);
; strncmp(BYTE *s1 , BYTE *s2, int count);
; fmemcmp(BYTE FAR *s1 , BYTE FAR *s2, int count);
; memcmp(BYTE *s1 , BYTE *s2, int count);
;***********************************************
; common_setup - set up the standard calling frame for C-functions
@ -116,15 +121,17 @@ domemcpy:
; whenever possible.
shr cx,1
rep movsw
jnc common_return
jnc memcpy_return
movsb
memcpy_return:
cld
;
; common_return - pop saved registers and do return
;
common_return:
pop ds
pop ds
pop es
pop di
pop si
@ -136,11 +143,15 @@ common_return:
;************************************************************
;
; VOID fmemcpy(REG BYTE FAR *d, REG BYTE FAR *s,REG COUNT n);
; VOID fmemcpyBack(REG BYTE FAR *d, REG BYTE FAR *s,REG COUNT n);
;
global __fmemcpy
global _fmemcpy
%if 0
global _fmemcpyBack
_fmemcpyBack:
std ; force to copy the string in reverse order
%endif
_fmemcpy:
__fmemcpy:
call common_setup
; Get the far source pointer, s
@ -205,7 +216,7 @@ _memset:
;***************************************************************
%if 0
global _fstrncpy
_fstrncpy:
call common_setup
@ -233,7 +244,7 @@ store_one_byte: xor al,al
stosb
jmp short common_return
%endif
;*****************************************************************
@ -270,7 +281,7 @@ strcpy_loop:
test al,al
jne strcpy_loop
jmp short common_return
jmp short common_return
;******************************************************************
@ -319,14 +330,56 @@ strchr_loop:
test al,al
jne strchr_loop
mov si,1 ; return NULL if not found
strchr_retzero:
xor ax, ax ; return NULL if not found
mov dx, ax ; for fstrchr()
jmp common_return
strchr_found:
mov ax,si
mov ax, si
mov dx, ds ; for fstrchr()
strchr_found1:
dec ax
jmp common_return
;******
%if 0
global _fmemchr
_fmemchr:
call common_setup
; Get the source pointer, ss
les di, [bp+4]
; and the search value
mov al, [bp+8]
; and the length
mov cx, [bp+10]
repne scasb
jne strchr_retzero
mov dx, es
mov ax, di
dec ax
jmp short strchr_found1
%endif
global _fstrchr
_fstrchr:
call common_setup
; Get the source pointer, ss
lds si, [bp+4]
; and the destination pointer, d
mov bx, [bp+8]
jmp short strchr_loop
;**********************************************************************
%if 0
global _fstrcmp
_fstrcmp:
call common_setup
@ -337,7 +390,7 @@ _fstrcmp:
; and the destination pointer, d
les di,[bp+8]
jmp dostrcmp
jmp short dostrcmp
;******
global _strcmp
@ -395,14 +448,51 @@ strncmp_loop:
jne strncmp_done
test al,al
loopne strncmp_loop
%endif
strncmp_retzero:
xor ax, ax
jmp short strncmp_done2
strncmp_done:
sbb ax,ax
or al,1
lahf
ror ah,1
strncmp_done2: jmp common_return
;**********************************************************************
global _fmemcmp
_fmemcmp:
call common_setup
; Get the source pointer, ss
lds si,[bp+4]
; and the destination pointer, d
les di,[bp+8]
; the length
mov cx, [bp+12]
jmp short domemcmp
;******
global _memcmp
_memcmp:
call common_setup
; Get the source pointer, ss
;mov si,[bp+6]
; and the destination pointer, d
;mov di,[bp+4]
;mov cx,[bp+8]
xchg si,di
domemcmp:
jcxz strncmp_retzero
repe cmpsb
jne strncmp_done
jmp short strncmp_retzero
; Log: asmsupt.asm,v
;
; Revision 1.3 1999/08/10 17:57:12 jprice

View File

@ -1178,6 +1178,8 @@ COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s)
}
current_ldt = &CDSp->cds_table[drive];
/* ensure termination of fstrcpy */
cp[MAX_CDSPATH - 1] = '\0';
if ((current_ldt->cdsFlags & CDSNETWDRV) == 0)
{
@ -1192,7 +1194,7 @@ COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s)
if (*cp == '\0')
s[0] = '\0';
else
fstrncpy(s, cp + 1, 64);
fstrcpy(s, cp + 1, 64);
return SUCCESS;
}

View File

@ -229,13 +229,6 @@ f_node_ptr split_path(BYTE * path, BYTE * fname, BYTE * fext)
}
cdsp = &CDSp->cds_table[nDrive];
/* If the path is null, we to default to the current */
/* directory... */
if (!szDirName[2])
{
fstrncpy(szDirName, cdsp->cdsCurrentPath, PARSE_MAX);
}
/* 11/29/99 jt
* Networking and Cdroms. You can put in here a return.
* Maybe a return of 0xDEADBEEF or something for Split or Dir_open.

View File

@ -249,7 +249,7 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t)
current_ldt = &CDSp->cds_table[i];
/* Always give the redirector a chance to rewrite the filename */
fstrncpy(bufp - 1, src, sizeof(buf) - (bufp - buf));
fmemcpy(bufp - 1, src, sizeof(buf) - (bufp - buf));
if ((t == FALSE) && (QRemote_Fn(buf, dest) == SUCCESS)
&& (dest[0] != '\0'))
{
@ -261,7 +261,7 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t)
}
if (t == FALSE)
{
fstrncpy(buf, current_ldt->cdsCurrentPath, current_ldt->cdsJoinOffset);
fmemcpy(buf, current_ldt->cdsCurrentPath, current_ldt->cdsJoinOffset);
bufp = buf + current_ldt->cdsJoinOffset;
rootEndPos = current_ldt->cdsJoinOffset; /* renamed x to rootEndPos - Ron Cemer */
*bufp++ = '\\';