oops: i misread the range to clear. I read it as 0..0x7FF it should have been 0..0xF7F also the sense of the btf instructions was reversed below. So, try this at 6 instructions: lfsr 0,0 movlw 0xF8 loop: clrf POSTINC0 cmpseq FSR0H goto loop and for a little faster at 9 instructions: lfsr 0,0 movlw 0xF8 loop: clrf POSTINC0 clrf POSTINC0 clrf POSTINC0 clrf POSTINC0 cmpseq FSR0H goto loop er.... not quite. see corrections below: ----- Original Message ----- From: "Bob Ammerman" To: Sent: Monday, August 19, 2002 3:20 PM Subject: Re: [PIC]: Challenge: 18F Clear RAM > Short: > > clrf FSR0L > clrf FSR0H > > (or LFSR 0,0) > > loop: > clrf POSTINC0 > btfsc FSR0H,3 oops! should be: btfss FSR0,3 > bra loop > > Faster: > > clrf FSR0L > clrf FSR0H > > (or LFSR 0,0) > > loop: > clrf POSTINC0 > clrf POSTINC0 > clrf POSTINC0 > clrf POSTINC0 > clrf POSTINC0 > clrf POSTINC0 > clrf POSTINC0 > clrf POSTINC0 > btfsc FSR0H,3 oops! should be btfss FSR0,3 > bra loop > > > > ----- Original Message ----- > From: "Scott Dattalo" > To: > Sent: Monday, August 19, 2002 2:13 PM > Subject: [PIC]: Challenge: 18F Clear RAM > > > > All this talk about the 18F parts warrants a challenge. A useful snippet > > every programmer should have is a Clear Ram one. > > > > Challenge: > > > > Write a program to clear the RAM in an 18f452 (or any 18X part with RAM > > from 0x000 through 0xf7f). Minimize the # of CPU cycles and limit the > > snippet to 12 instructions. > > > > I've got 2 - a slow, but short routine, and a fast, but long one. > > > > Scott > > > > -- > > http://www.piclist.com hint: To leave the PICList > > mailto:piclist-unsubscribe-request@mitvma.mit.edu > > > > > > -- > http://www.piclist.com hint: To leave the PICList > mailto:piclist-unsubscribe-request@mitvma.mit.edu > > -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu