[comp.sys.amiga.programmer] How to swap chip data??

jay@deepthot.cary.nc.us (Jay Denebeim) (05/07/91)

In article <1991May6.100837.24590@wehi.dn.mu.oz> baxter_a@wehi.dn.mu.oz writes:
>What is the best (quickest and least wasteful of memory) for swapping
>chip data in and out of memory?
>
>I am using Lattice C and am putting the data in an overlay and then 
>allocating chip memory and memcpy ing across (the overlay manager can't
>cope with swapping chip memory), but I'm not sure that the overlay manager
>hasn't stuck the data in memory when the program was started. There doesn't
>seem to be an extra disk access for it.
>
>Any one know if this is a good way, or if there is a better one?

Well, it sounds like you're copying a bunch of stuff.  In this case
(I don't know exactly how many bytes is break even) I would probably
use the CopyMem(?) function in the KickStart.  

SAS's memcpy ALWAYS uses byte copies.  The one in the kickstart is
smart, it figures out alignments and bus size of the processor and
copies it using the biggest chunks of memory it can.

On a 68K the fastest copy I can think of would be something along
the lines of:
  push a bunch of registers
  init looping vars
  movem(ultiple) into cpu
  movem to destination
  dbra until done.
  pop used registers
  
In some code we use at work the size of the copy is constant, in
that case you could:
  push a bunch of registers
  movem to cpu
  movem to mem
  ... bunch 'o these
  pop 'em
  
Using the second technique you can move up to 64 bytes (16*4) with two
instructions.

To sum up, I would probably use the call to the KS function for this.
Its more portable, and should be quite fast.
  
>
>Regards Alan

--

 |_o_o|\\
 |. o.| || The           Jay Denebeim
 | .  | ||  Software
 | o  | ||   Distillery
 |    |//        Address: UUCP:     mcnc.org!deepthot.uucp!jay
 ======                   Internet: jay@deepthot.cary.nc.us
                 BBS:(919)-460-7430      VOICE:(919)-460-6934

dillon@overload.Berkeley.CA.US (Matthew Dillon) (05/09/91)

In article <jay.5697@deepthot.cary.nc.us> jay@deepthot.cary.nc.us (Jay Denebeim) writes:
>In article <1991May6.100837.24590@wehi.dn.mu.oz> baxter_a@wehi.dn.mu.oz writes:
>>What is the best (quickest and least wasteful of memory) for swapping
>>chip data in and out of memory?
>>..
>Well, it sounds like you're copying a bunch of stuff.  In this case
>(I don't know exactly how many bytes is break even) I would probably
>use the CopyMem(?) function in the KickStart.
>
>SAS's memcpy ALWAYS uses byte copies.  The one in the kickstart is
>smart, it figures out alignments and bus size of the processor and
>copies it using the biggest chunks of memory it can.
>
>On a 68K the fastest copy I can think of would be something along
>the lines of:
>  push a bunch of registers
>  init looping vars
>  movem(ultiple) into cpu

    Which is exactly what CopyMem() and CopyMemQuick() do.

    But, BEWARE, CopyMem[Quick]() does NOT handle overlapping source
    and destination.  As long as your source & destination are not
    overlapping, it's the quickest way to copy a block of memory.

    CopyMem() will deal with arbitrary data lengths and alignments,
    by the way.

>To sum up, I would probably use the call to the KS function for this.
>Its more portable, and should be quite fast.
>
>>
>>Regards Alan
>
>--
>
> |_o_o|\\
> |. o.| || The 	  Jay Denebeim
> | .  | ||  Software
> | o  | ||   Distillery
> |    |//	  Address: UUCP:     mcnc.org!deepthot.uucp!jay
> ======		   Internet: jay@deepthot.cary.nc.us
>		  BBS:(919)-460-7430      VOICE:(919)-460-6934

				    -Matt

--

    Matthew Dillon	    dillon@Overload.Berkeley.CA.US
    891 Regal Rd.	    uunet.uu.net!overload!dillon
    Berkeley, Ca. 94708
    USA