TIP: Click on subject to list as thread! ANSI
echo: public_domain
to: Paul Edwards
from: Frank Malcolm
date: 1995-12-28 09:57:00
subject: movsb

Hi, Paul.

PE> Hi Matthew.  I have the following code...

PE> #include 

PE> int main(void)
PE> {
PE>     register char *t = NULL;
PE>     register char *u = NULL;

PE>     while ((*t++ = *u++) != '\n') ; /* This is the only line of interest */

PE>     if (*t == 37) printf("hello\n");
PE>     return (0);
PE> }

PE> Which produces various assembler on my various compilers, but it
PE> is fairly similar, along the lines...

PE>  002c  8a 01             L2              mov     al,[ecx]
PE>  002e  88 02                             mov     [edx],al
PE>  0030  41                                inc     ecx
PE>  0031  42                                inc     edx
PE>  0032  3c 0a                             cmp     al,0aH
PE>  0034  75 f6                             jne     L2


PE> This code is what will be the bottleneck in any text processing
PE> applications using fgets() with PDPCLIB, and I was thinking it
PE> might be possible/better to use some assembler here, to use a
PE> MOVSB or something.  If the average length of a text line that is
PE> processed by fgets is say 30 bytes, then this loop will be
PE> executed 30 times.

PE> I was wondering if you had any feel for what would be best
PE> time-wise.  This code is a C runtime library for OS/2 32-bit
PE> 80386 and above.  The C runtime library, being of dire
PE> importance, can be as dirty as you can make it, so long as it's
PE> FAST FAST FAST!  BFN.  Paul.

Yep, you can do that if speed is super important. I assume you're
absolutely sure there's a \n in there somewhere. Stick a big number in
CX (or ECX), say $ffff, and set up ds:si from the pointer to u; es:di
from the pointer to t. REP SCASB for $0a, reset ds:si, subtract CX from
$ffff then REP MOVSB.

Regards, FIM.

 * * Every loose nut eventually rolls out to California
@EOT:

---
* Origin: Pedants Inc. (3:711/934.24)
SEEN-BY: 690/718 711/809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.