[net.micro.apple] Memory Clearing Routines

josh@unm-cvax.UUCP (06/15/84)

< another bug bytes the bus (Is this bug still around?)>


I spent the last few days creating what I think has  to be the
 fastest memory clearing routine found.  The way it's run
 is that you put the starting page in the accumulator and the
 ending page into the x-register. Then you put what you want all the
 locations changed to in location $30. When this is done you JSR to the
 routine.

ROUTINE ( I added the hex codes for those of you who don't have a assembler):

1  ; A<=page<X
2               ORG $800
3  CLRMEM:
4               STA POSIT+$2    800 : 8D 09 08
5               LDA COLOR       803 : A5 30
6               LDY #$00        805 : A0 00
7  CLRLOOP:
8  POSIT        STA $2000,Y     807 : 99 00 20
9               INY             80A : C8
10              BNE CLRLOOP     80B : D0 FA
11              CPX POSIT+$2    80D : EC 09 08
12              BNE CLRLOOP     810 : D0 F2
13              RTS             812 : 60
14 COLOR        EPZ $30  ; Note : if you wish to use this for low resolution
15                       ; just put the color you what the back ground
16                       ; to be in the accumulator and JSR $F864 to set color.
17              END

SAMPLE runner (a faster GR routine):

1               ORG $4000
2               LDA $C050 ; set low res screen
3               LDA $C053
4               LDA $C054
5               LDA $C056
6               LDA #$14
7               STA $22   ; set screen boundary so that you can only
8                         ; print on the bottom 4 lines
9               LDA #$07
10              JSR $F864 ; set color to light blue
11              LDA #$04  ; starting page
12              LDX #$08  ; ending page
13              JSR $800  ; mem-clear routine
14              RTS
15              END

The above would set the low - res screen, make it light blue, and return
 control to the calling program. This is so fast that it can be run 
 6 times in the time that the basic GR command runs( We clocked it).

I would like to see if anybody can make a shorter and/or  faster routine
 then this (no, you don't win anything except my respect). Also,
 does anybody have any routines that I might want to look at?


          Josh Siegel

 {convex,ucbvax,gatech,csu-cs,anl-mcs,lanl-a}!unmvax!unm-cvax!josh

hanson@aerospace.ARPA (06/19/84)

From:            Paul Hanson <hanson@aerospace.ARPA>

   "I spent the last few days creating what I think has to be the 
    fastest memory clearing routine found."


  .
  .
  .
     Well, this may be the fastest routine but it cannot be used for lores
   clearing because the peripheral card scratch pad RAM resides in these
   pages of memory. If you try and run this routine and are using any cards
   important card parameters will be destroyed.

                                   Paul Hanson
                                   (hanson@aerospace)