> Andrew Warren has given an optimal implementation of a > switch statement. However, for its interest, here is > a modestly tidied-up version of the original loop. [table-driven switch statement deleted] Cute, but your approach uses 13 cycles per case, at a savings of at most one byte per. On that basis I would have to regard Andy's as being better all around. That does not mean it cannot be improved upon, though. :-) On a non-5x/non-508 part, you may use the addlw instruction to improve things a bit. For example, [hopefully I'm doing this right]... suppose you need to distinguish Y or y, N or n, and 0-9. Switcher: addlw 256-':' ; One character past '9' btfss C goto DigCheck addlw 256+':'-'Y' btfsc Z goto Yep addlw 256+'Y'-'y' btfsc Z goto Yep addlw 'y'-'N' btfsc Z goto Nope addlw 256+'N'-'n' btfsc Z goto Nope goto Reject DigCheck: addlw ':'-'0' btfss C goto Reject goto GotDigit ; W is digit value 0..9 The use of 'addlw' rather than 'xorlw' allows the program to check for ranges, and to perform a binary search. The only downside is that the code can get more complicated (even if it's faster/shorter) than with the 'xorlw' approach.