I've finally gotten back to PIC programming, after a series of projects using MIPS 4300i and 4600 RISC chips, and H8/300L microcontrollers. The PIC is more fun, IMHO. I was just writing up some 16Cxx routines I find handy, in preparation for adding them to my web page, when it occurred to me that they might make a nice programming challenge. I'll describe them here, and I'll put the code on my web page in about a week. All three routines use only the W and status registers, don't modify any RAM, and don't use subroutines. toupper - equivalent to the toupper() library function in C. Entry: character in W Exit: if the character was in the range 'a'..'z' return the corresponding upper case character 'A'..'Z' else return with W *unchanged* 6 instruction words, 7 instruction cycles (including return) toascii - convert the low four bits of W into the ASCII representation of a hexadecimal digit Entry: W contains a value in the range 00h..0fh Exit: W contains a the character, '0'..'9', 'A'..'F' if the input was out of range, the output is unspecified 6 instruction words, 7 instruction cycles (including return) ishex - convert the ASCII representation of a hex digit to a binary value Entry: W contains a character Exit: if the character was a valid hex digit ('0'..'9','A'..'F','a'..'f') return the corresponding value 00h..0fh, with STATUS.Z set else return with W *unchanged* and STATUS.Z clear 18 instruction words, 8 to 17 cycles (including return) note - could be made shorter and faster if it didn't accept both cases could be made shorter and slower if it called toupper Hint - all three routines use the same "trick". Those of you familiar with the technique may wish to refrain from posting the solutions immediately to give others a chance to work it out. Cheers, Eric http://www.brouhaha.com/~eric/pic/