Hi, it doesn't sound too difficult. I would suggest using indirect addressing to iterate through your bytes, and you can use the following algorithm to check for bits within each byte, using TMP1 and TMP2 as a temporary registers: movlw 0x80 movwf TMP2 ; mask movf INDF, W ; load current byte movwf TMP1 checkbit: movf TMP2, W btfsc STATUS,Z return ;mask is empty, therefore we're done here rrfc TMP2, F ;shift mask right andwf TMP1, W ;mask all but the n'th bit btfsc STATUS, Z goto checkbit ; the n'th bit is not set, so go to the next one ;;; here goes the logic where you send out 'W' on the UART with the appropriate amount of 0's before and after goto checkbit this doesn't cover the advancing through all the bytes, nor the actual UART stuff, but you should be able to fill that in easily. - Marcel On Jan 11, 2008 12:53 PM, wrote: > > > Hello everyone!!! > > I need your help! > I'm receiving (USART) and saving 17 bytes (128 bits) in 17 differents reg= isters (Byte1, Byte2,.......,Byte17). > After receiving the data, I'd like to check all 17 bytes bit after bit fo= r "1". And each time I > encounter an "1" I should send to another applicaton 127 "0" and one "1". > > Here is an example: > > Received 17 bytes: 00010100 00001011 00110011 11111111 10110000 00000010 = 11001100 11111100 00001100 ..........etc the last byte is 11100001 > > The first byte is 00010100. My Assembly code should begin scanning this b= yte bit by bit. When the first "1" is encountered, I should stop scanning a= nd send > the following to USART: my first byte to be sent is 00010000 and all othe= r bytes should be "0": So the 17 bytes I'd send would be: 00010000 00000000= 00000000 00000000 ....etc and > the last byte 00000000. > After sending these bytes I should return and continue scanning the byte = just after the "1" where I stopped. > I hoppe you undestood the description of my probleme so that you can help= me. > I'd like to write the code in Assembly Language. > > Thank you in advance > > > > Jetzt neu! Sch=FCtzen Sie Ihren PC mit McAfee und WEB.DE. 30 Tage > kostenlos testen. *http://www.pc-sicherheit.web.de/startseite/?mc=3D02222= 0* [http://www.pc-sicherheit.web.de/startseite/?mc=3D022220] > -- > 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