<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Thu, 17 Jun 1993 08:28:51 +1200
From   : David Andrew Sainty <David.Sainty@...>
Subject: Fast routine required

   From: Mik Davis <davism@...>
   Date: Wed, 16 Jun 93 14:24:23 +0100

     I need a *fast* routine to move 1024 bytes of RAM across the memoru of my
   machine. Must be compatible with all the 6502 based machine (B, B+, master
etc)

Fastest method is using an index on self modifying absolute address
instructions. eg.

lda#start DIV256:sta adr+2
lda#end DIV256:sta adr2+2
ldy#3:ldx#0
.adr lda &FF00,X
.adr2 sta &FF00,X
inx:bne adr
inc adr+2
inc adr2+2
dey:bpl adr

This works fine if the blocks you want to move are on page boundaries.
If they are not, it still works but you have to program both bytes of the
address fields. You will also loose some speed as the lda instruction takes
an extra cycle if the address +X crosses a page boundary (I don't think
the sta takes an extra cycle though). In this case, you should move the
first few bytes seperately to bring the load address up to a page
boundary, then use this type of routine for the rest.

If my memory serves correct, this routine takes 4+5+2+3=14 cycles for
each byte on the inner loop, which is what really counts. total cost
is 2+4+2+4+2+2+4*(256*(4+5+2+3)-1+6+6+2+3)-1=14415 I think.

Which is 7.2 milliseconds. Hmm, not too bad....

This is if the sta takes a consistant 5 cycles, which may be wrong, so
adjust accordingly.... (If it's not 5 cycles, it's 4).

Dave.
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>