TIP: Click on subject to list as thread! ANSI
echo: public_domain
to: Frank Malcolm
from: Paul Edwards
date: 1996-01-01 14:23:22
subject: movsb

Thanks for the info.  So, ignoring the setup stuff, we have:

SCASB/MOVSD = 5+3/4n = 5.75n
SCASB/MOVSB = 8n
assembler loop = 14n
C loop = 8n?

FM> Basically, yes; there's no combination MOVSB/SCASB instruction. I was
FM> about to write that "anyway, it'd be much faster doing it with the
FM> single instructions", but it looks like it would be close. REPE SCASB is
FM> 7 + 5n clocks on a 486, REP MOVSB is 12 + 3n. (I think - the timings

It is interesting that SCASB only needs to do a memory read, whilst
MOVSB is a read + write, yet the former is faster!

FM> Then for a loop, say

FM> L1: LODSB
FM>     STOSB
FM>     CMP AH ;where you've put $0a
FM>     JNE L1

 002c  8a 01             L2              mov     al,[ecx]
 002e  88 02                             mov     [edx],al
 0030  41                                inc     ecx
 0031  42                                inc     edx
 0032  3c 0a                             cmp     al,0aH
 0034  75 f6                             jne     L2
 
FM> it's 5+5+1+3 = 14n for the loop, once again ignoring setting up the
FM> registers.

Did I add up the numbers wrong or something?  The C loop looks
like 8n to me.  Timings on a 486, since I determined that that
was what figures you were using.  BFN.  Paul.
@EOT:

---
* Origin: X (3:711/934.9)

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™.