> ************ > when i change the bsf code to > MOVLW b'00110000' > MOVWF PORTB > it still works > Correct > ************** > when i change the bcf code to > MOVLW b'00000000' > MOVWF PORTB > it still works > ***************** Correct > i wanted to just use 2 registers > " on " to replace the bsf's > " off " to replace the bcf's > but this won't work !! > =======vars===== > on equ b'00110000' ;set portb 4 & 5 to 1 > off equ b'00000000' ;set portb 4 & 5 to 0 > ====prog==== > tog MOVF on,PORTB ( to replace bsf's) > Bzzzt!! Wrong! MOVF can move a file either into W or back into the same file. You say you want to use 2 registers to store the two states of the ports? Well you haven't really defined them properly. At the moment, you have two literals: on and off that the assembler equates to 0x30 and 0x00 respectively. Note that at the moment you are trying to use these as register locations. First you need to define the locations of the registers you want to use: on equ 12 ; for example...have to choose your own off equ 13 Then the contents of those registers need to be set. MOVLW b'00110000' MOVWF on CLRF off ; just use a clrf for off. Then you need to move the register into PORTB as before: MOVF on,W MOVWF PORTB and: MOVF off,W MOVWF PORTB Of course this is assuming that the TRIS register has been set up beforehand. However, this is a bit wastefull, there is no need to use two registers. If you need to do bit set operations on other pins as well you use a shadow register. Call it b_shadow: on equ b'00110000' off equ 0 b_shadow equ 12 To set 'on' MOVLW on MOVWF b_shadow MOVF b_shadow,W ; don't actually need this in this case MOVWF PORTB Of course this is a bit long winded, but the beauty of this is that you can now do bit operations on the shadow register without worries: BCF b_shadow,0 BSF b_shadow,4 MOVF b_shadow,W MOVWF PORTB Hope this dosen't confuse you any more... Regards Mike Rigby-Jones > MOVLW 0x04 > MOVWF togh > delh DECFSZ togh > GOTO delh > > MOVF off,PORTB (to replace bcf's) > MOVLW 0x02 > MOVWF togl > dell DECFSZ togl > GOTO dell > > BTFSC PORTB,3 ;skip next if 0 , checks for 0 ac cycle > GOTO tog > RETURN > > there's no o/p's at all ! > > i also wanted to use 2 registers for the literals too > togh equ 0x04 > togl equ 0x02 > > thanks for your advice > glen