Hi Bob. XOR function is really good for that. Here is different example with decfsz function (or incfsz). Ok. If value in WREG is 0,1,2,3,4,... i.e. it's monotonously incrementing by some event.. we can do calculated jump (addwf pcl,F for example) or simply following. (it's taking more space but faster to develop and also we will not end up somewhere unexpected in case of wrong switch value as for addwf pcl,F scheme. test_0: movwf temp skpz goto test_1 ;here is WREG=0 ;... goto _somewhere test_1: decfsz temp,F goto test_2 ;here is WREG=1 ;... goto _somewhere test_2: decfsz temp,F goto test_3 ;here is WREG=1 ;... test_3: ;and so on... Bob Ammerman wrote: > > Here is a neat trick to check for several possible values: > > xorlw value_a > skpnz > goto it_is_a > xorlw value_a^value_b > skpnz > goto it_is_b > xorlw value_b^value_c > skpnz > goto it_is_c > > --- optional to restore original value of W: > > xorlw value_c > > Bob Ammerman > RAm Systems > > ----- Original Message ----- > From: "Byron A Jeff" > To: > Sent: Monday, March 17, 2003 1:03 PM > Subject: Re: [PIC] 16F628 ASM Language question > > > 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 > > > > -- > http://www.piclist.com hint: To leave the PICList > mailto:piclist-unsubscribe-request@mitvma.mit.edu -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads