I tried a very simple program:
-----------------------------
'prova01
#chip 16F84A, 4
#mem 68
DIR PORTA b'11111111' 'PORTA as input
DIR PORTB b'00000000' 'PORTB as output
Main:
let PORTB = 0
for i = 0 to 7
let PORTB = i
next i
goto Main
------------------------
when I got the asm, I found this:
;Start of the main program
movlw B'11111111'
banksel TRISA
movwf TRISA
movlw B'00000000'
movwf TRISB
MAIN
banksel PORTB
clrf PORTB
movlw 1
movwf I
SysForLoop1
incf I,F
movf I,W
movwf PORTB
movlw 7
subwf I,W
btfss STATUS, C
goto SysForLoop1
goto MAIN
BASPROGRAMEND
sleep
goto $
-------------------------
the for loop start from 2 not from 0, in asm the variable i is set to 1 then it is increased of 1.
if I change the "start" of FOR from 0 to 1:
------------------------
'prova01
#chip 16F84A, 4
#mem 68
DIR PORTA b'11111111' 'PORTA as input
DIR PORTB b'00000000' 'PORTB as output
Main:
let PORTB = 0
for i = 1 to 7
let PORTB = i
next i
goto Main
-------------------------
the assembler that I got is correct:
;Start of the main program
movlw B'11111111'
banksel TRISA
movwf TRISA
movlw B'00000000'
movwf TRISB
MAIN
banksel PORTB
clrf PORTB
clrf I
SysForLoop1
incf I,F
movf I,W
movwf PORTB
movlw 7
subwf I,W
btfss STATUS, C
goto SysForLoop1
goto MAIN
BASPROGRAMEND
sleep
goto $
--------------------------
the variable i is set to 0 then it is increased of 1.
if I change the "start" of FOR from 0 to 2, the asm is correct the i variable is set to 1 and the is increased of 1.
I don't know if this is a bug or in gcbasic I cannot start the FOR from 0.
Regards
stefano
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tried a very simple program:
-----------------------------
'prova01
#chip 16F84A, 4
#mem 68
DIR PORTA b'11111111' 'PORTA as input
DIR PORTB b'00000000' 'PORTB as output
Main:
let PORTB = 0
for i = 0 to 7
let PORTB = i
next i
goto Main
------------------------
when I got the asm, I found this:
;Start of the main program
movlw B'11111111'
banksel TRISA
movwf TRISA
movlw B'00000000'
movwf TRISB
MAIN
banksel PORTB
clrf PORTB
movlw 1
movwf I
SysForLoop1
incf I,F
movf I,W
movwf PORTB
movlw 7
subwf I,W
btfss STATUS, C
goto SysForLoop1
goto MAIN
BASPROGRAMEND
sleep
goto $
-------------------------
the for loop start from 2 not from 0, in asm the variable i is set to 1 then it is increased of 1.
if I change the "start" of FOR from 0 to 1:
------------------------
'prova01
#chip 16F84A, 4
#mem 68
DIR PORTA b'11111111' 'PORTA as input
DIR PORTB b'00000000' 'PORTB as output
Main:
let PORTB = 0
for i = 1 to 7
let PORTB = i
next i
goto Main
-------------------------
the assembler that I got is correct:
;Start of the main program
movlw B'11111111'
banksel TRISA
movwf TRISA
movlw B'00000000'
movwf TRISB
MAIN
banksel PORTB
clrf PORTB
clrf I
SysForLoop1
incf I,F
movf I,W
movwf PORTB
movlw 7
subwf I,W
btfss STATUS, C
goto SysForLoop1
goto MAIN
BASPROGRAMEND
sleep
goto $
--------------------------
the variable i is set to 0 then it is increased of 1.
if I change the "start" of FOR from 0 to 2, the asm is correct the i variable is set to 1 and the is increased of 1.
I don't know if this is a bug or in gcbasic I cannot start the FOR from 0.
Regards
stefano
That's a bug. I've just fixed it, so download the newest version of GCBASIC and it should work. Thanks for telling me!
One more thing: "let" is optional in GCBASIC - you can leave it out if you want.
thank you very much, I will download now the new version.
stefano