<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Wed, 23 Jun 1993 12:42:17 +0100
From   : Mik Davis <davism@...>
Subject: Re: Unrolling loops & fast routines

>I wrote:
>>  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)
>
>David Andrew Sainty replied:
>>Fastest method is using an index on self modifying absolute address
>>instructions. eg.

  [code deleted]

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

  Someone else replied:  [sorry, I deleted the header]
>
>This can be sped up still further by copying more bytes
>each time through the loop. This takes more program bytes,
>but more time is spent transferring memory, and less
>is spent looping. Also, there is not need to use Y:
>
>ldx#start DIV256:stx adr1+2
>inx:stx adr3+2
>inx:stx adr5+2
>inx:stx adr7+2
>ldx#end DIV256:stx adr2+2
>inx:stx adr4+2
>inx:stx adr6+2
>inx:stx adr8+2
>ldx#0
>.adr1 lda &FF00,X
>.adr2 sta &FF00,X
>.adr3 lda &FF00,X
>.adr4 sta &FF00,X
>.adr5 lda &FF00,X
>.adr6 sta &FF00,X
>.adr7 lda &FF00,X
>.adr8 sta &FF00,X
>inx:bne adr
>
>If daves memory serves him right about timing issues...
>Inner loop: 4+5+4+5+4+5+4+5+2+3=41 cycles for four bytes.
>Total cost is: 2+4+2+4+2+4+2+4+2+4+2+4+2+4+2+4+2+256*41 = 10546

  Great, now I'm no expert in this area, so could someone please send me
the above code set up to work anywhere in memory. (Dave mentioned something
about page boundaries earlier?). The destination will always be the screen
display RAM (yes, I'm shifting MODE 7 screens) so &7C00 to &7FFF. The source
address could potentially be anywhere as it is just DIMed in BASIC.

  Thanks, Mik

        Mik Davis at Aston University. E-Mail davism@...
"There are two ways of disliking poetry; one way is to dislike it, the
other is to read Pope."
               -- Oscar Wilde
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>