movlw 0x08 ;Move 0x08 to Working Register
movwf 0x20 ;Move W to General purpose register
loop:
call delay1ms
movlw 0x0B ;Move .11 to W for subtraction in next command
subwf 0x20,0 ;Subtract 11 from value in 0x20 and store in W
btfsc status,2 ;Test the Z bit of STATUS register to see if the subtraction equaled Zero. Skip the next command if NOT zero.
call subroutine
incf 0x20, 1 ;Increment 0x20 and store in 0x20
goto loop
Note: This assumes you start out in BANK 0 and end in BANK0 after subroutines are called.
EDIT:
If you are looking for (2 < X < 10) then you will use two "bit test file register" statements...one for the ( > 2 ) and one for the ( < 10 ) part.
But let me go back. In general the btf statements (paired with the STATUS register) are going to be your standard if/else commands for Assembly. Default syntax looks something like this.
btfs(s/c) f,b ; 'f' is the file register, and 'b' is the bit you want to test
goto label1 ; Do this 'else'
goto label2 ; Do this 'if'
label1: ;'else'
nop ;your code here
goto label3
label2: ;'if' the test is true,...
nop ;your code here
goto label3
label3: ;break out of the if/else statement and continue
To test for ( > 2 ) you would add these two lines above the btf statement.
movlw .3
subwf x, W
According to the datasheet (pg 111),...
If x < 2 , then the 'C' bit of STATUS is going to be 0.
If x >= 2, then the 'C' bit of STATUS is going to be 1.
So if you want ONLY greater than 2, then you would really want to test on the number 3. Since it will match for greater or equal to 3. (...which is > 2).
To test again on ( < 10 ) you would nest another btf statement inside of either label1 or label2 depending on whether you used btfsc or btfss.
Maybe something like this,...
movlw .3
subwf x, W
btfsc f,b ; 'f' is the file register, and 'b' is the bit you want to test
goto label1 ; Do this 'else'
goto label2 ; Do this 'if'
label1: ; ( > 2 )
movlw .10
subwf x, W
btfsc STATUS, 2
goto label4
goto label5
label4: ;( 2 < X >= 10 )
;yourcode
goto label3
label5: ;(2 < X < 10 )
;yourcode
goto label3
label2: ; ( <= 2 )
;yourcode
goto label3
label3: ;break out of the if/else statement and continue