----- Original Message ----- From: Dave Bell To: Sent: Wednesday, January 10, 2001 5:16 PM Subject: Re: [PIC]: yet another algorithm challange > Thanks to Andrew Vassallo and Bob Ammerman for some quick and detailed > help on my "bit stretcher" algorithms! > > Here's what I ended up with for the 6X routine: > > // > int OUT[6]; > > #byte Out1 = OUT > #byte Out2 = OUT+1 > #byte Out3 = OUT+2 > #byte Out4 = OUT+3 > #byte Out5 = OUT+4 > #byte Out6 = OUT+5 > > int inval; > > void X6(int v) > { > #asm > movwf inval > > movlw 0 // start output byte 6 > btfsc inval,0 > iorlw 0x3F > > btfsc inval,1 > iorlw 0xC0 > movwf Out6 > > movlw 0 // start output byte 5 > btfsc inval,1 > iorlw 0x0F > > btfsc inval,2 > iorlw 0xF0 > movwf Out5 > > movlw 0 // start output byte 4 > btfsc inval,2 > iorlw 0x03 > > btfsc inval,3 > iorlw 0xFC > movwf Out4 > > // now, repeat for (bit+4) and (byte-3) > movlw 0 // start output byte 3 > btfsc inval,4 > iorlw 0x3F > > btfsc inval,5 > iorlw 0xC0 > movwf Out3 > > movlw 0 // start output byte 2 > btfsc inval,5 > iorlw 0x0F > > btfsc inval,6 > iorlw 0xF0 > movwf Out2 > > movlw 0 // start output byte 1 > btfsc inval,6 > iorlw 0x03 > > btfsc inval,7 > iorlw 0xFC > movwf Out1 > #endasm > } > > > Fast (enough), clean (very), and (I think) isochronous to boot... You're not likely to find faster. It is very simple to follow and 'clean'. It isn't too long. And yes, it is isochronous. Sometimes the obvious is what makes the most sense. Bob Ammerman RAm Systems (contract development of high performance, high function, low-level software) -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body