TinyBASIC for microcontrollers.

by Mike Field
(New Zealand)

It lives!

It lives!

I've ported TinyBasic (http://members.shaw.ca/gbrandly/68ktinyb.html) from 68000 assembler into 'C', allowing it to be uploaded onto C programmed microcontrollers such as PIC or AVR.

My main reason for this was to relive the 80s, and program my robot without needing a full development toolset -just a USB port and putty.

It was very interesting to learn what assembler can do that C can't, and then work around it. For example, TinyBasic directly manipulated the return address on the stack to allow testing for characters using a "BSR TSTC", "DB ", effectively creating a new opcode to save code size.

TinyBASIC also used jump tables to direct program flow, which in C requires a less efficient to code "switch(index) { case X: goto x_code; }" construct.

I also had to implement a user-level stack to hold gosub/return for/next frames that we held on the CPU's stack.

The original expression parser is pretty awesomely tight, supporting +,-,*,/,()s, variables and function calls in 110 lines of assembler, but took 180 lines of C.

It works, in around 8k including boot loader. It also compiles with Visual Studio or GCC for debugging and development. If you want a copy email hamster at snap dot net dot nz.

Comments for TinyBASIC for microcontrollers.

Average Rating starstarstarstar

Click here to add your own comments

Jan 21, 2011
Rating
starstarstar
Need the tiny BASIC
by: Mani

Hi,
I would like to get the Tiny BASIC. It will be useful to my students who are interested to do projects.
my email id vu2iti AT gmail.com

Thanks,
Dr. T.K. Mani

[jfm edit - don't put emails as is onto a web page - spammers will find them and you'll be inundated with rubbish so copy the above method which automatic programs cannot detect as a valid email address]

Jan 21, 2011
Rating
starstarstarstarstar
amazed
by: ntp

it wonderful to see that, now it give me the feeling
to do more practices.

Jan 21, 2011
Rating
starstarstar
More info plz...
by: Anonymous

1. is it [your tinybasic for pic] a freeware ?

2. does it work on all PIC chips or only a specific chip or specific family of PIC chips ?

3. what is the minimum amount of program memory & data memory should the PIC chip have, for using your tinybasic ?

Jan 21, 2011
Rating
starstarstarstarstar
Where to get it.
by: Anonymous

Hi, just send me an email to the address in the article and I'll send you a copy of the latest version.

Sadly it is only suitable to a micro-controller where the amount of RAM allows a reasonable amount of BASIC code to be entered, not the very small ones.

Regards

Mike

Jan 21, 2011
Rating
starstarstarstarstar
More Info?
by: Anonymous

Where can we get more info? Downloads etc?

Click here to add your own comments

Join in and write your own page! It's easy to do. How? Simply click here to return to Project Showcase.


Privacy Policy | Contact | About Me

Site Map | Terms of Use