> -----Original Message----- > From: Dmitry Kiryashov [SMTP:nzews@MAIL.RU] > Sent: Monday, January 28, 2002 10:29 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: [PIC]:Checking a register for a value > > Well done Scott ;) > > Scott Dattalo wrote: > > > > Or this: > > > > movlw -2 > > addwf Reg1,W ;Set C if Reg1 is greater than 1 > > movlw 0x0a > > btfsc Reg1,0 > > movlw 3 > > skpc > > movwf Reg2 > > > > Scott > > Here is another shot. > > movlw 3 > decfsz Reg1,F ;back > movfw Reg2 > movwf Reg2 > > movlw 0xA > incfsz Reg1,F ;and forth > movfw Reg2 > movwf Reg2 > > > WBR Dmitry. > > It's early in the morning, have only had half a cup of coffee and it's the first time I've been able to mail the Piclist in about 5 months so forgive me if this is rubbish. This is a bit dangerous in that it assumes Reg1 can only either be 1 or zero. movlw 0x0A ; assume Reg1 is zero, so load w with 0x0A btfsc Reg1,0 ; check if bit zero is set movlw 0x03 ; bit zero is set, so load w with 0x03 movwf Reg2 ; move w to destination Regards Mike Rigby-Jones -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.