' UnitTest_2 ' struve13@verizon.net ' ' testing if conditional on a single bit '
'Odd results for bit test conditional
' Made a mistake in my program and coded:
' if led_ix.1 on then ...
' as
' if led_ix.1 then ...
' the surprise is that it compiled without reported error but code implemented
' if led_ix.1 off then ....
'Chip model #chip 16F819, 8
#config _INTRC_CLKOUT, MCLR_ON
led_ix = 0
MainLoop:
led_ix += 1
Lable_with_on: if led_ix.1 on then set PortA.1 on Lable_with_off: if led_ix.2 off then set PortA.2 off Lable_without_on_off: if led_ix.3 then set PortA.3 on
GoTo MainLoop
' ========== end gcbasic code =========
========== compiler produced the following asm file code ( partial listing ) =========
Great Cow BASIC (0.9 12/1/2007)
Compiling C:\Russ\PER\_XX\PIC\GCBasic\UnitTests\UnitTest.txt .
Program compiled successfully!
;Start of the main program clrf LED_IX MAINLOOP incf LED_IX,F LABLE_WITH_ON btfsc LED_IX,1 bsf PORTA,1 LABLE_WITH_OFF btfss LED_IX,2 bcf PORTA,2 LABLE_WITHOUT_ON_OFF btfss LED_IX,3 bsf PORTA,3 goto MAINLOOP BASPROGRAMEND sleep goto $
Log in to post a comment.
' UnitTest_2
' struve13@verizon.net
'
' testing if conditional on a single bit
'
'Odd results for bit test conditional
' Made a mistake in my program and coded:
' if led_ix.1 on then ...
' as
' if led_ix.1 then ...
' the surprise is that it compiled without reported error but code implemented
' if led_ix.1 off then ....
'Chip model
#chip 16F819, 8
#config _INTRC_CLKOUT, MCLR_ON
led_ix = 0
MainLoop:
led_ix += 1
Lable_with_on:
if led_ix.1 on then set PortA.1 on
Lable_with_off:
if led_ix.2 off then set PortA.2 off
Lable_without_on_off:
if led_ix.3 then set PortA.3 on
GoTo MainLoop
' ========== end gcbasic code =========
========== compiler produced the following asm file code ( partial listing ) =========
Great Cow BASIC (0.9 12/1/2007)
Compiling C:\Russ\PER\_XX\PIC\GCBasic\UnitTests\UnitTest.txt .
Program compiled successfully!
;Start of the main program
clrf LED_IX
MAINLOOP
incf LED_IX,F
LABLE_WITH_ON
btfsc LED_IX,1
bsf PORTA,1
LABLE_WITH_OFF
btfss LED_IX,2
bcf PORTA,2
LABLE_WITHOUT_ON_OFF
btfss LED_IX,3
bsf PORTA,3
goto MAINLOOP
BASPROGRAMEND
sleep
goto $