'A program to flash LED on PIN 13/PORTB5
'Chip model
#chip 16F1829, 16
'Main routine
Start:
'Turn one LED on, the other off
SET LATB.5 ON
wait 1 sec
'Now toggle the LEDs
SET LATB.5 OFF
wait 1 sec
'Jump back to the start of the program
goto Start
You don't have to tweak anything. The configuration, variables, every command is presented just like you wrote it in Assembly code to start with. The only difference is your Basic commands are now comments.
;Start of the main program
;A program to flash LED on PIN 13/PORTB5
;Chip model
;Main routine
START
; SET LATB.5 ON
banksel LATB
bsf LATB,5
;wait 1 sec
movlw 1
movwf SysWaitTempS
banksel STATUS
call Delay_S
; SET LATB.5 OFF
banksel LATB
bcf LATB,5
;wait 1 sec
movlw 1
movwf SysWaitTempS
banksel STATUS
call Delay_S
;goto Start
goto START
BASPROGRAMEND
sleep
goto BASPROGRAMEND
I've seen many compilers make assembly files; that's what they do. But I've never seen one produce something so crystal clear as Great Cow Basic. It's really easy to see the assembly code produced from these BASIC commands.
And what a great way to teach assembly language. Make a simple Basic language program that flashes an LED and then you can see how to setup the port registers, manipulate the bits and even switch banks of memory if needed. It's all done for you in pure assembly language. No hidden macros or cryptic defines.
It does have some setup routines like the main Initsys subroutine where the registers, that get most beginner's in trouble, are handled for you. It's brilliantly simple and can easily be modified if you are an experienced assembly programmer.I am so impressed with this open source compiler. I plan to do a lot more with it in the future.
INITSYS
;OSCCON = OSCCON OR b'01111000'
movlw 120
banksel OSCCON
iorwf OSCCON,F
;SET ADCON0.ADON OFF
bcf ADCON0,ADON
;SET ADFM OFF
bcf ADCON1,ADFM
;ANSELA = 0
banksel ANSELA
clrf ANSELA
;ANSELB = 0
clrf ANSELB
;C2ON = 0
banksel CM2CON0
bcf CM2CON0,C2ON
;C1ON = 0
bcf CM1CON0,C1ON
;PORTA = 0
banksel PORTA
clrf PORTA
;PORTB = 0
clrf PORTB
;PORTC = 0
clrf PORTC
return