mirror of https://github.com/FDOS/kernel.git
* minor size optimizations in chario.c, dosfns.c;
asmsupt.asm: correct fmemchr (all n's) and *memset/*memcpy (n==0) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@590 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
parent
439cc495e4
commit
5210965831
|
@ -119,6 +119,7 @@ domemcpy:
|
||||||
; And do the built-in byte copy, but do a 16-bit transfer
|
; And do the built-in byte copy, but do a 16-bit transfer
|
||||||
; whenever possible.
|
; whenever possible.
|
||||||
shr cx,1
|
shr cx,1
|
||||||
|
jcxz memcpy_return
|
||||||
rep movsw
|
rep movsw
|
||||||
jnc memcpy_return
|
jnc memcpy_return
|
||||||
movsb
|
movsb
|
||||||
|
@ -180,9 +181,10 @@ FMEMSET:
|
||||||
mov bl,8
|
mov bl,8
|
||||||
|
|
||||||
domemset:
|
domemset:
|
||||||
mov ah, al
|
mov ah, al
|
||||||
|
|
||||||
shr cx,1
|
shr cx,1
|
||||||
|
jcxz pascal_return
|
||||||
rep stosw
|
rep stosw
|
||||||
jnc pascal_return
|
jnc pascal_return
|
||||||
stosb
|
stosb
|
||||||
|
@ -391,11 +393,11 @@ FMEMCHR:
|
||||||
|
|
||||||
mov bl, 8
|
mov bl, 8
|
||||||
|
|
||||||
|
jcxz strchr_retzero
|
||||||
repne scasb
|
repne scasb
|
||||||
jne strchr_retzero
|
jne strchr_retzero
|
||||||
mov dx, es
|
mov dx, es
|
||||||
mov ax, di
|
mov ax, di
|
||||||
dec ax
|
|
||||||
jmp short strchr_found1
|
jmp short strchr_found1
|
||||||
|
|
||||||
;**********************************************************************
|
;**********************************************************************
|
||||||
|
|
|
@ -218,6 +218,7 @@ STATIC int raw_put_char(int sft_idx, int c)
|
||||||
STATIC int cooked_put_char(int sft_idx, int c)
|
STATIC int cooked_put_char(int sft_idx, int c)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
unsigned char scrpos = scr_pos;
|
||||||
|
|
||||||
/* Test for hold char */
|
/* Test for hold char */
|
||||||
con_hold(sft_idx);
|
con_hold(sft_idx);
|
||||||
|
@ -225,23 +226,24 @@ STATIC int cooked_put_char(int sft_idx, int c)
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case CR:
|
case CR:
|
||||||
scr_pos = 0;
|
scrpos = 0;
|
||||||
break;
|
break;
|
||||||
case LF:
|
case LF:
|
||||||
case BELL:
|
case BELL:
|
||||||
break;
|
break;
|
||||||
case BS:
|
case BS:
|
||||||
if (scr_pos > 0)
|
if (scrpos > 0)
|
||||||
scr_pos--;
|
scrpos--;
|
||||||
break;
|
break;
|
||||||
case HT:
|
case HT:
|
||||||
do
|
do
|
||||||
err = raw_put_char(sft_idx, ' ');
|
err = raw_put_char(sft_idx, ' ');
|
||||||
while (err >= 0 && ((++scr_pos) & 7));
|
while (err >= 0 && ((++scrpos) & 7));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
scr_pos++;
|
scrpos++;
|
||||||
}
|
}
|
||||||
|
scr_pos = scrpos;
|
||||||
if (c != HT)
|
if (c != HT)
|
||||||
err = raw_put_char(sft_idx, c);
|
err = raw_put_char(sft_idx, c);
|
||||||
return err;
|
return err;
|
||||||
|
|
|
@ -239,23 +239,25 @@ long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode)
|
||||||
{
|
{
|
||||||
size_t cnt = (size_t)rc;
|
size_t cnt = (size_t)rc;
|
||||||
const char FAR *p = bp;
|
const char FAR *p = bp;
|
||||||
|
unsigned char scrpos = scr_pos;
|
||||||
while (cnt--)
|
while (cnt--)
|
||||||
{
|
{
|
||||||
switch (*p++)
|
switch (*p++)
|
||||||
{
|
{
|
||||||
case CR:
|
case CR:
|
||||||
scr_pos = 0;
|
scrpos = 0;
|
||||||
break;
|
break;
|
||||||
case LF:
|
case LF:
|
||||||
case BELL:
|
case BELL:
|
||||||
break;
|
break;
|
||||||
case BS:
|
case BS:
|
||||||
--scr_pos;
|
--scrpos;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
++scr_pos;
|
++scrpos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
scr_pos = scrpos;
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -398,14 +400,9 @@ ULONG DosSeek(unsigned hndl, LONG new_pos, COUNT mode)
|
||||||
STATIC long get_free_hndl(void)
|
STATIC long get_free_hndl(void)
|
||||||
{
|
{
|
||||||
psp FAR *p = MK_FP(cu_psp, 0);
|
psp FAR *p = MK_FP(cu_psp, 0);
|
||||||
unsigned hndl;
|
UBYTE FAR *q = p->ps_filetab;
|
||||||
|
UBYTE FAR *r = fmemchr(q, 0xff, p->ps_maxfiles);
|
||||||
for (hndl = 0; hndl < p->ps_maxfiles; hndl++)
|
return FP_OFF(r) == 0 ? DE_TOOMANY : r - q;
|
||||||
{
|
|
||||||
if (p->ps_filetab[hndl] == 0xff)
|
|
||||||
return hndl;
|
|
||||||
}
|
|
||||||
return DE_TOOMANY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC sft FAR *get_free_sft(COUNT * sft_idx)
|
STATIC sft FAR *get_free_sft(COUNT * sft_idx)
|
||||||
|
@ -442,18 +439,19 @@ STATIC sft FAR *get_free_sft(COUNT * sft_idx)
|
||||||
const char FAR *get_root(const char FAR * fname)
|
const char FAR *get_root(const char FAR * fname)
|
||||||
{
|
{
|
||||||
/* find the end */
|
/* find the end */
|
||||||
register unsigned length = fstrlen(fname) - 1;
|
register unsigned length = fstrlen(fname);
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
/* now back up to first path seperator or start */
|
/* now back up to first path seperator or start */
|
||||||
while (length != (unsigned)-1)
|
fname += length;
|
||||||
|
while (length)
|
||||||
{
|
{
|
||||||
c = fname[length];
|
length--;
|
||||||
|
c = *--fname;
|
||||||
if (c == '/' || c == '\\' || c == ':')
|
if (c == '/' || c == '\\' || c == ':')
|
||||||
break;
|
break;
|
||||||
--length;
|
|
||||||
}
|
}
|
||||||
return fname + length + 1;
|
return fname;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize SFT fields (for open/creat) for character devices */
|
/* initialize SFT fields (for open/creat) for character devices */
|
||||||
|
|
Loading…
Reference in New Issue