🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rec.games.programmer
Article #988

Re: Code for loading

#988
From: John A. Slagel
Date: Thu, 05 Nov 1992 01:30
58 lines
2636 bytes
colin.buckley@rose.com (colin buckley) writes:


>Date Entered: 11-04-92 15:38

>  JNC  @@Even
>  MOVSB
>@@Even:
>  REP MOVSW

>  is quicker on my computer, and because the possible odd byte is moved
>first, we get even 16-bit moves.  I assume anyways.  It was faster in large
 
    No, the odd/even for 16-bit moves is determined by where the
    first byte starts in memory, not whether the length is odd or even.
    REP MOVSW will always move an even number of bytes.

>.----------------------------------------------------.
>| Colin Buckley -- 486 Powered (Packing Extra Socks) |
                    ^^^ This is why its faster on yours... On 386 or 286,
			that isn't the case.

    There are three methods of doing fast moves:   
    (1)                (2)              (3) (Assumes top 1/2 of ECX is 0)
    shr cx,1           shr  cx, 1        ror   ecx, 2
    rep movsw          rep  movsw        rep   movsd
    adc cx, cx         jnc  notodd       rol   ecx, 2
    rep movsb          movsb             rep   movsb
                       notodd:

     Speed ordering:   486:  Fastest=3
			     Medium=2
			     Slow=1
                       386:  Fastest=3
			     Medium=1
			     Slow=2
                       286:  Fastest=1
			     Slow=2
			     (3 not possible)

    Explanation:
     3 is obviously the fastest if you have a 32-bit data bus. It
     will move 4 bytes at a time, with a few byte moves at the end to 
     clean up.

     Item 1 is faster than 2 because if the length is even, it doesn't
     branch which saves some cycles and won't blow the prefetch queue.
     (Jumps are BAD!)  If the length is odd, the REP will cause a slowdown,
     but if the lengths are equal odd and even, 1 will tend to be faster.
     However, the 486 will do method #2 faster 'cause its weird.          

     I use item #1 because using jumps in inline assembler tend to be
     a pain in the rear sometimes. Also, I have a 386 so its faster on mine.


-- 
------------------------------------------------------------------------
  John A. Slagel, email: jas37876@uxa.cso.uiuc.edu
Technical Details
Message-ID: <Bx7yus.8CA@news.cso.uiuc.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!decwrl!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!uxa.cso.uiuc.edu!jas37876
References: <1992Nov04.204346.19452@rose.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!decwrl!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!uxa.cso.uiuc.edu!jas37876
From: jas37876@uxa.cso.uiuc.edu (John A. Slagel)
Newsgroups: rec.games.programmer
Subject: Re: Code for loading
Message-ID: <Bx7yus.8CA@news.cso.uiuc.edu>
Date: 5 Nov 92 01:30:26 GMT
Article-I.D.: news.Bx7yus.8CA
References: <1992Nov04.204346.19452@rose.com>
Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
Organization: University of Illinois at Urbana
Lines: 58