On Mon, Mar 17, 2003 at 12:46:46PM -0500, CaptMasterX@CS.COM wrote: > The instruction set for the 16F628 looks kinda skimpy. Simplicity by design. > Is there any way to > test wreg against a certain byte and jump if it's equal. Absolutely. > They have > instructions to test each bit, but to test against a byte, Which by the way doesn't work for the Wreg. > i'd have to write > a function to go through and test every bit before i got the answer. is > there an easier way? Yes. There are two standard ways to do comparitons: 1) Subtraction. If you subtract two equal values, the result is zero. So the SUBLW instruction would be helpful. 2) Exclusive Or (XOR). A useful logic function that produces a zero result when the values are equal. So the "skimpy" instruction set actually has two different instructions (SUBLW and XORLW) that will accomplish what you need. Just be aware of two things: 1) You'll lose the value in W. Each is destructive. If you need the retain the value, store it in a register, load the compare value into Wreg, then perform the operation between Wreg and the saved register. 2) After you perform the operation you'll need to check the (Z)ero flag in the STATUS register. This is where you use the BTFSS or BTFSC instruction. BAJ -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu