I agree with peja089, the colon acts as a virtual line break.
If more than a signle statement should execute as a result of the evaluation use IF-THEN-ENDIF.
With that said... In section 5.35 of the manual they actually DO show the following as a valid example:
Code:
IF B0 <> 10 THEN B0 = B0 + 1: B1 = B1 - 1
And in fact, when compiling the followong code for a 16F628 both the Test1 and Test2 routines results in the same assembly code
Code:
A VAR BYTE
B VAR BYTE
C VAR BYTE
D VAR BYTE
Test1:
IF A = 12 THEN B = 2 : C = 3 : D = 4
Test2:
IF A = 12 THEN
B=2
C=3
D=4
ENDIF
Here's the resulting assembly (both versions looks identical to me (wasn't really expecting that to be honest):
Code:
_Test1
clrwdt
movf _A, W
sublw 00Ch
btfss STATUS, Z
goto L00001
movlw low (002h)
movwf _B
movlw low (003h)
movwf _C
movlw low (004h)
movwf _D
L00001
_Test2
clrwdt
movf _A, W
sublw 00Ch
btfss STATUS, Z
goto L00003
movlw low (002h)
movwf _B
movlw low (003h)
movwf _C
movlw low (004h)
movwf _D
L00003
That got me curious so I compiled both version of the original code
Code:
ticker VAR BYTE
ard VAR BYTE
atrig VAR BYTE
Test1:
if ticker>150 and ard<140 and atrig=0 then ticker=1: atrig=1
Test2:
if ticker>150 and ard<140 and atrig=0 then
ticker=1
atrig=1
ENDIF
And the resulting assebly (less library code) looks like this:
Code:
_Test1
movf _ticker, W
movwf R0
movlw low (096h)
call CMPGTB
movwf T1
movf _ard, W
movwf R0
movlw low (08Ch)
call CMPLTB
movwf T2
movf T1, W
movwf FSR
movf T2, W
call LAND
movwf T2
movwf T2 + 1
movf _atrig, W
sublw 000h
btfss STATUS, Z
movlw -1
xorlw 0ffh
movwf T3
movf T2, W
iorwf T2 + 1, W
movwf FSR
movf T3, W
call LAND
movwf T3
movwf T3 + 1
clrwdt
movf T3, W
iorwf (T3) + 1, W
btfsc STATUS, Z
goto L00001
movlw low (001h)
movwf _ticker
movlw low (001h)
movwf _atrig
L00001
_Test2
movf _ticker, W
movwf R0
movlw low (096h)
call CMPGTB
movwf T1
movf _ard, W
movwf R0
movlw low (08Ch)
call CMPLTB
movwf T2
movf T1, W
movwf FSR
movf T2, W
call LAND
movwf T2
movwf T2 + 1
movf _atrig, W
sublw 000h
btfss STATUS, Z
movlw -1
xorlw 0ffh
movwf T3
movf T2, W
iorwf T2 + 1, W
movwf FSR
movf T3, W
call LAND
movwf T3
movwf T3 + 1
clrwdt
movf T3, W
iorwf (T3) + 1, W
btfsc STATUS, Z
goto L00003
movlw low (001h)
movwf _ticker
movlw low (001h)
movwf _atrig
L00003
As far as I can see they are identical, meaning atrig will only get set to 1 if the evaulation is true. So I don't know what might be happening in CuriousOnes case because as far as I can see it IS working as CuriousOne expects - which I did NOT expect.
/Henrik.
Bookmarks