Paul wrote: >Hi group, > >In the code below, I want to set a bit in the [INDF] => 0x30 register during >each loop. The label "loop" will be executed >eight times, each time I wish to do the following, using temp1 as a bit index >variable. > >loop 1: BSF INDF,7 ;0x30 = 10000000 >loop 2: BSF INDF,6 ;0x30 = 11000000 >loop 3: BSF INDF,5 ;0x30 = 11100000 >loop 4: BSF INDF,4 ;0x30 = 11110000 >loop 5: BSF INDF,3 ;0x30 = 11111000 >loop 6: BSF INDF,2 ;0x30 = 11111100 >loop 7: BSF INDF,1 ;0x30 = 11111110 >loop 8: BSF INDF,0 ;0x30 = 11111111 > > >However, only BSF INDF,7 appears to work during simulation. So, is it >possible? > >Thanks, > >Paul > >BEGIN: > > > MOVLW 0x07 > MOVWF TEMP1 >LOOP > MOVLW 0x30 > MOVWF FSR > > BSF INDF,TEMP1 > DECFSZ TEMP1,F > GOTO NEXT_LBL2 >; Hi Paul, You can't use a file register as the bit number in the BCF instruction. One way to do it would be shifting (RRF) in a 1 from the carry position each time during the loop. Something like this should do: movlw 0x08 ; movwf temp1 ;set up loop counter movlw 0x30 ; movwf fsr ;point fsr to ram clrf indf ;start with result 00000000 loop: bsf indf,7 ;set bit 7 (1xxxxxxx) ;do something with result here? rrf indf,f ;rotate it towards lsb decfsz temp1,f ;last loop? goto loop ;no Regards... -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu