(added PIC tag) Hi, You can use btfsc/btfss for testing bits (easiest for this I think), or you can use andlw/andwf to leave the bit you need and clear others and then test if the result is zero, or rlf/rrf to shift bits etc. There are too many ways to do that, probably would be easier if you learn pic assembly and try to write it your own and if you have problems you can ask questions here. I found this book very useful (and also free to read online!) http://www.mikroe.com/en/books/picbook/picbook.htm Regards, Tamas ---------- Forwarded message ---------- From: Date: Jan 11, 2008 8:53 PM Subject: Assembly and PIC16F870: how to scann 17 bytes , bit after bit ? To: piclist@mit.edu Hello everyone!!! I need your help! I'm receiving (USART) and saving 17 bytes (128 bits) in 17 differents registers (Byte1, Byte2,.......,Byte17). After receiving the data, I'd like to check all 17 bytes bit after bit for "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 byte bit by bit. When the first "1" is encountered, I should stop scanning and send the following to USART: my first byte to be sent is 00010000 and all other 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=3D022220*= [ 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