piclist 2001\01\10\171621a >
Thread: yet another algorithm challange
www.piclist.com/techref/microchip/devices.htm?key=pic
flavicon
face BY : Dave Bell email (remove spam text)



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

Dave Bell

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email KILLspamlistservSTOPspamspam@spam@mitvma.mit.edu with SET PICList DIGEST in the body


<Pine.NEB.4.21.0101101411590.29475-100000@shell2.bayarea.net>

In reply to: <200101090510.VAA88796@postman.bayarea.net>
See also: www.piclist.com/techref/microchip/devices.htm?key=pic
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) yet another algorithm challange

month overview.

new search...