Electronic Products
Find us here:
  • Books
    • Embedded C Books >
      • cbookfiles
      • cbook2files
      • cbook3files
    • BASIC Books >
      • Programming PICs in BASIC_vol1
      • PICBasic Book Support
      • Basic Atom Book Support
    • Other Books >
      • Arduino Book
      • chipkitbookfiles
  • Chuck's Blog
    • Blog Posts Archive
    • Disclaimer
  • YouTube Channel
  • About Chuck
    • About Chuck
    • Stock Car Racing
  • 3D Printing
    • Fabrikator Mini
  • Getting Started with PICs
    • BASIC Programming
    • C Programming >
      • C Compilers
  • Build Your Own PICKit 2
    • PICkit 2 Starter Kit
  • CHIPINO
    • Shields
  • CHIPAXE Breadboard Modules
  • Understanding Hex Files
  • chipKIT
  • Newsletter Archive
  • Contact
  • Retired Designs
    • BasicBoard
    • Ultimate OEM
    • Maximite BasicBox
    • Maximino
  • Downloads
  • Kickstarter Projects
    • Demo-Shield
  • Great Cow Basic Site
  • Buy Hardware
  • Links I Recommend

Great Cow Basic----or Great Cow Assembly

6/9/2013

0 Comments

 
Great Cow Basic could actually be called Great Cow Assembly. This is because the compiler produces pure assembly code. By that I mean after running the compiler on your Great Cow Basic code you end up with a .asm file of the same name as your Great Cow Basic file. That .asm file can be directly loaded, built and simulated or debugged right in Microchip's MPLAB.

'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

0 Comments



Leave a Reply.


    Categories

    All
    3D Printer
    Chipaxe
    Chipino
    Chipkit
    CNC
    Copper Connection
    Dot Matrix
    Elproductsnews
    Expresspcb
    Graphic Lcd
    Great Cow Basic
    Kickstarter
    Lcd Shield
    Makefaire
    Makercase
    Maximite
    Microchip Pic
    Pickit 2
    Pickit 3
    Videos

    Visit previous blog posts in the archives below.

    Archives

    February 2018
    October 2017
    September 2017
    July 2017
    November 2016
    August 2016
    July 2016
    May 2016
    March 2016
    January 2016
    November 2015
    September 2015
    August 2015
    July 2015
    June 2015
    April 2015
    March 2015
    February 2015
    January 2015
    December 2014
    November 2014
    October 2014
    September 2014
    August 2014
    July 2014
    June 2014
    May 2014
    April 2014
    March 2014
    February 2014
    January 2014
    December 2013
    November 2013
    October 2013
    September 2013
    August 2013
    July 2013
    June 2013
    May 2013
    April 2013
    March 2013
    October 2012
    October 2011

    RSS Feed



    About Chuck

    Chuck has been programming with PIC Microcontrollers since there were only five devices. Now there are over 700 and growing. He also has a lot of fun 3D printing designs using his Davinci 3D printer and TinkerCad software. In this series of blog posts and occasional videos on his YouTube Channel he tries to help you get started with electronics and 3D printing.

    Disclaimer

Powered by Create your own unique website with customizable templates.