Yes, that was a brute-force quick-n-dirty method. I'm sure there are "better" methods with fewer instructions using loops. B.t.w, have you verified your code below ? Should be easy using MPSIM in MPLAB. *I* am not going to verify it... Jan-Erik. Harry H. Arends wrote: > Hello Jam-Erik, > > Following your recomendations i came up with this. There are a lot of bits > moved forward and back :-) > > SetData > movlw b'00001111' ;*set preamble > movwf DATA0 > movlw b'10000001' ;*bit<7:6> alsways 10 > movwf DATA1 ;*set low byte address > movlw b'11111001' ;*set command > movwf DATA2 > xorwf DATA1,0 > movwf DATA3 ;*save controlbyte > > bsf STATUS, C ;*set Carybit to be insert at > SHIFT3<0> > rlf DATA3 ;*create endbit > rlf SHIFT4 ;*SHIFT4<0> holds DATA3<7> > > bcf STATUS, C ;*reset Carybit to be insert at > DATA2<0> > rlf DATA2 ;*and place it in DATA2 > rrf SHIFT5 ;*SHIFT5<0> holds DATA2<7> > rrf SHIFT4 ;*retrieve DATA3<7> > rlf DATA2 ;*move it to DATA2<0> > rrf SHIFT5 ;*SHIFT5<0:1> holds now DATA2<7:6> > > bcf STATUS, C ;*reset Carybit to be insert at > DATA1<0> > rlf DATA1 ;*and place it in DATA1 > rrf SHIFT3 ;*SHIFT3<0> holds DATA1<7> > rlf SHIFT5 ;*get DATA2<6> > rlf SHIFT5 ;*get DATA2<6> > rlf DATA1 ;*move it to DATA1<0> > rrf SHIFT3 ;*SHIFT3<0:1> holds now DATA1<7:6> > rrf SHIFT5 ;*get saved DATA2<6> > rlf DATA1 ;*and insert it > rrf SHIFT3 ;*SHIFT3<0:1:2> holds now DATA1<7:6:5> > > bcf STATUS, C ;*Create Carybit to be inserted at > DATA0<0> > rlf DATA0 ;*and place it in DATA0 > rlf SHIFT3 ;*Create DATA0 using DATA1<7:6:5:4> from > SHIFT3 > rlf SHIFT3 > rlf SHIFT3 > rlf DATA0 > rrf SHIFT3 > rlf DATA0 > rrf SHIFT3 > rlf DATA0 > > bsf NEW_PACKET ;*new packet received > bcf DCC4BYTE ;*if set there is a 4 byte packet > return > > If it can be done easyer i am happy to hear that. > > Harry > > -----Oorspronkelijk bericht----- > Van: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] Namens > Jan-Erik Soderholm > Verzonden: dinsdag 12 augustus 2008 0:12 > Aan: Microcontroller discussion list - Public. > Onderwerp: Re: [PIC] Packets problem to be solved > > Argh ! > Got a few DATA/BYTE's and some > bit numbers mangled. > Corrected version below. > Jan-Erik. > > > > Jan-Erik Soderholm wrote: >> Harry H. Arends wrote: >> >>>> OK by now i am aware to be more specifik. The language is ASM. >>>> The data to be sendout... >> Can you better define what "sendout" is ? >> How will it be sent ? >> Using what interface ? >> >>>> is in four 8 bit variables: >>>> DATA0 contains all ones >>>> DATA1 contains a 8 bit address (AAAAAAAA) >>>> DATA2 contains a 8 bit command (DDDDDDDD) >>>> DATA3 contains a bitwise exclusif OR from the DATA1 and DATA2 >>>> >>>> The result should become >>>> BYTE0 11110AAA >> Let's number the bit positions 0-7. >> Let's also assume that the bits are 76543210. >> >> So BYTE0.2 = DATA1.7, BYTE0.1 = DATA1.6 and BYTE0.0 = DATA1.5, right ? >> >> That could be done with a few bit-test and bit set/clear instructions. >> >>>> BYTE1 AAAAA0DD >> OK, so rotate DATA1 3 positions to the left and move to BYTE1. >> Then set BYTE1.1 = DATA2.7 and BYTE1.0 = DATA2.6. >> >>>> BYTE2 DDDDDD0E >> Rotate DATA2 2 positions left and move to BYTE2. >> Then set BYTE2.0 = DATA3.7. >> >>>> BYTE3 EEEEEEE1 >> Rotate DATA3 1 position to the left and move to BYTE3. Set BYTE3.0 = >> "1". >> >> Then just do that in assembler. >> >> *THEN* send BYTE0 to BYTE3 using whatever method you'd like. >> >> Jan-Erik. >> > -- > http://www.piclist.com PIC/SX FAQ & list archive View/change your membership > options at http://mailman.mit.edu/mailman/listinfo/piclist > > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist