One way to decide is the number of lines of messy tests versus a 256-entry table. This problem is similar to identifying whether a recieved char is a number, a lowercase letter, or an uppercase letter. Let's say you wanted to output the character to a 7-seg dispaly, and you had a table for the letter shapes. You could do a big table with shapes for everything you wanted, and a ? for anything else, or do the messy test business first. I chose the messy test version, because it was a lot shorter for what I needed. Including overhead, my letter-and-number parser was about 120 lines including character shape tables, half of what a full 256-line ascii shape table would have taken. alice > Hi all, > I currently have an application where in the comms receive > handler, I test the received command byte and branch off > to other places depending on the value. As the values are > not consecutive, is there a better way to test them than just > doing the following time after time? > > ... > movf rx_cmd,w ;get the received command byte > xorlw msg_eg1 ;compare with msg_eg1 (a constant) > btfsc zero ;is it msg_eg1 ? > goto rx_eg1 ;yes, jump to that handler > ... > > Block repeats for as many test cases as I need. > It just seems ugly - is there a better/shorter way? > The msg constants are all over the place value wise. > I can't arrange them to be in continuous blocks. > Regards... > > -- > http://www.piclist.com#nomail Going offline? Don't AutoReply us! > email listserv@mitvma.mit.edu with SET PICList DIGEST in the body > > > -- _______________________________________________ Sign-up for your own FREE Personalized E-mail at Mail.com http://www.mail.com/?sr=signup 1 cent a minute calls anywhere in the U.S.! http://www.net2phone.com/cgi-bin/link.cgi?170 -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu