tiny basic interpreter

Go To Last Post
61 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In the good old days (around 1978) I had
the "Palo Alto Tiny Basic" by "Li Chen Wang"
on my 8080. Has anyone ported that or a similar
Tiny-Basic-Interpreter to the AVR ?

It is clear for me, that the limited RAM inside
many AVRs will not let you enter big programs, but
I just want the feeling back !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

With the ability to write blocks of flash memory in almost all AVRs, why would SRAM size be any major consideration?

Was that a true interpreter, or more of a P-code system?

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As far as I remember it was a real interpreter.
Only some tokens (kewords etc) were stored in
compressed form.

Ok, with eeprom or flash there is no real
length limit. Good point !

With a certain AVR-program-flash size it should be
possible to rewrite the interpreter in C.
The orignal was a quite dense assmbly style
( fitted into 2k).
I have found a source in the www, so availability
is not the problem.

But if some other already did something similar, it
would not hurt so much !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hope this can be of help to you

http://cappels.org/dproj/Home.htm

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ossi wrote:
In the good old days (around 1978) I had
the "Palo Alto Tiny Basic" by "Li Chen Wang"
on my 8080. Has anyone ported that or a similar
Tiny-Basic-Interpreter to the AVR ?

It is clear for me, that the limited RAM inside
many AVRs will not let you enter big programs, but
I just want the feeling back !


well, check out Zbasic.net - amazing, given the cost of the AVRs that it runs on.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the hints !
I will see, what I can make out of it......

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ossi wrote:
In the good old days (around 1978) I had
the "Palo Alto Tiny Basic" by "Li Chen Wang"
on my 8080. Has anyone ported that or a similar
Tiny-Basic-Interpreter to the AVR ?

It is clear for me, that the limited RAM inside
many AVRs will not let you enter big programs, but
I just want the feeling back !

For an authentic experience you would need to enter your programs using toggle switches or a KSR33 teletype! LOL

DFR

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry, living in Germany I had no access to either
ASR33 or KSR33 !
But at my parents there is still my good old LO15

(so probably I should create a BAUDOT operated BASIC !)

http://www.teleprinter.net/germa...

LOL, Ossi

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ossi wrote:
In the good old days (around 1978) I had
the "Palo Alto Tiny Basic" by "Li Chen Wang"
on my 8080. Has anyone ported that or a similar
Tiny-Basic-Interpreter to the AVR ?

It is clear for me, that the limited RAM inside
many AVRs will not let you enter big programs, but
I just want the feeling back !

Well here is something you might like. There is nothing "tiny" about it. It is a very well rounded BASIC compiler (P-code). Extremely well supported by the company. Full featured. Available in a pre-assembled 24 pin Dual Inline Platform which fits a breadboard, or as a plain 40 pin AVR pre-programmed with the VM. Also as a 44 pin TQFP.

This is available at ZBASIC.NET

They licensed the code to another company which makes a DIP platform in a 40 pin configuration. This allows independent access to all the AVR pins, where some are combined on the 24 pin device.

It is a great thing.

-Tony

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There was a recent article on the original TinyBasic by Tom Pittmann in DDJ (http://www.ddj.com/dept/lightlang/184406381). Given the small memory and storage of microcontrollers, there are a lot of tricks and techniques that are still useful from the early days of personal computers.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've been thinking that it's well past time for there to be "open embedded basic" that offers essentially the functionality of Basic52 (Basic interpreter in an 8k Intel 8051, complete with floating point), but written in a HLL and designed to be easily portable between multiple architectures. I wouldn't expect it to fit in 8k any more, but since you can get chips like AVRs and ARMs and such with 64k+ flash, it wouldn't need to be that small.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

with GCC's price as it is, and the low cost of several good C compilers, and two or more low cost BASIC_like compilers, plus virtual machine HLL's like ZBasic (VB6-like, w/structures, RTOS), as cheap as they are, I'll take a pass on a BASIC interpreter a la 1980's.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Clearly all compiler-solutions are superior to an
RETRO style Tiny-Basic. But usually you need a
powerful computer as cross platform for development, while tiny-basic (or FORTH) is a real stand-alone
solution. And its just a RETRO project, not something
"REAL".

You may also see it as an entry point to
a tiny script language for AVRs

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
...but since you can get chips like AVRs and ARMs and such with 64k+ flash, it wouldn't need to be that small

But IMHO it does only make sense in a 'small' chip with not too many resources.
If you have a big project with more than 50-100 lines of code, interpreting this code does not make sense. You would better use a compiler which will compile this code within a couple of seconds and then transfer this native code to the chip.
The 8052 AH Basic and similar products gave a completely different feeling. You could just connect a terminal to the chip (or better a board with that chip) and type in lines of code. Press 'Run', look at the output, change one line, run again and so on. This is very nice for small programs (only).

Jörg.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I dunno. There's a lot of power to be had in a dynamically programmable device. Perhaps the "hook" would be a way to integrate interpretted basic with pre-compiled basic code via "chain" type commands; you'd distribute a compiled system with the ability to do customization by re-writing little bits of interpreted code (sorta like EMACS extensibility?)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't get it.

With WinAVR and a Bootloader, I can compile a program and download it to an AVR in seconds and for free.

What does a BASIC interpreter (or compiler) buy me that I don't already have?

Smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Very simple (see original post) :

I just want that feeling back !

( May be , its because I am old,
may be its because I am a NERD !)

And I am just in the process of porting it, and the
"good old days" feeling is coming back !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I get your reason, but I note that Parallax is HUGE and almost exclusively uses BASIC on PICs. So BASIC must have something going for it other than inertia and nostalgia. I'm just wondering what it is.

Is it really that much easier to learn and use than C?

Smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

smileymicros wrote:
I get your reason, but I note that Parallax is HUGE and almost exclusively uses BASIC on PICs.
Smiley

IMO they do well in the education market, but "huge" as in $MMM a public company (they're privately held), with high volumes, not.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

20 Million a year is HUGE (for a microcontroller eductional company) to me and I've been told that's what they do.

Smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

smileymicros wrote:
20 Million a year is HUGE (for a microcontroller eductional company) to me and I've been told that's what they do.

Smiley


that is good revenue for that one vertical, for sure.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ossi wrote:
Very simple (see original post) :

I just want that feeling back !

( May be , its because I am old,
may be its because I am a NERD !)

Ah! You want that "old feeling" back? I have a Teletype if you REALLY want that old feeling back! Bought it for my Altair 8800, which I've since sold.

You'll need to convert RS-232 to current-loop, though. Not hard...

Stu

PS: Yes, I bought the Altair new and put it together myself. Boy, was that a long time ago!

Engineering seems to boil down to: Cheap. Fast. Good. Choose two. Sometimes choose only one.

Newbie? Be sure to read the thread Newbie? Start here!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

what did the Altair sell for, if you don't mind saying?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

smileymicros wrote:
I get your reason, but I note that Parallax is HUGE and almost exclusively uses BASIC on PICs. So BASIC must have something going for it other than inertia and nostalgia. I'm just wondering what it is.

Is it really that much easier to learn and use than C?

Smiley

BASIC is still around on microcontrollers for the same reason as Visual BASIC is for PC's, almost anyone can pick it up quickly (typically much quicker than languages like C, especially if you're just starting out). Although STAMPs are popular in educational circles, they are also popular in hobbiest circles. Many people tend to start out on something like a STAMP, and then evolve to something more powerful. But for many tasks BASIC is still good enough.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

...and it is easier to learn than C... that was by design and still holds true. It doesn't mean it's better or faster. The Success of the stamp is certainly not disputed by me.

I too understand the desire to have an AVR equivalent of a BASIC-52 style device. I say it's worth the trouble.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'll note that micromint is still selling Basic52 CHIPS at $25 a pop, and Parallax has LOTS of competition in the "chip with interpretter on a module." I think the key is extensibility without having to become a full "programmer" (whatever that means.) (yeah, you wonder why basic programs suck so often? It's not the language, it's because they were written by people who didn't bother to learn what programs should look like; they just wanted something that did something.)

You can get nearly to the same place with a compiler, a tiny OS, and a good set of library functions, but those tend to be produced by programmers for programmers...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A worthless personal opionion dating back 20 years...
secondary education and trade schools do a huge disservice to their students and the engineering profession by teaching BASIC as the first introduction to software engineering.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm sure nobody teaches BASIC in a software engineering course. A programming course, yes. SW engineering means object oriented... ada-99 or c++ or c# something modern

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Interesting to see this thread drifting off-topic.
I had not in mind to start any discussion about
programming languages !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The most useful use IMO would be to include an interpeter as part of a system. Imagine for example a car computer (easy target for this discussion), it reads a bunch of variables from the car:- acceleration, velocity, direction, fuel flowrate, light intensity, temperature, moisture sensor ....

The avid user of such a system could then program his own outputs like fuel consumption, power output, warnings when exceeding velocity, turn lights on when dark, turn wipers on when raining, eject passenger when whining exceeds preset level.

A good example is Alberto Ricci Bitti's scriptable thermometer. http://www.riccibitti.com/scriptherm/scriptherm.htm

The measured variables get updated in the background so when you use
LET POWER = ACC * 1100 * SPEED
the current power in kW is calculated from 2 values (ACC and SPEED, the car mass is 1100kg) that are updated in the background and are always current.

The same could be used for a networked system where the varaible gets sent via some network, from a distance away, the user writes his own less sophisticated programme and the heavy lifting gets done in the background. Display driving, network reading, shaft encoder pulse decoding etc are all designed into the system but the fun part is writing the programme to use these variables and drivers.

Of course the language is not necessarily BASIC but FORTH, ladder logic or your own "Script Interpreter" could be used. The design would allow a simple terminal to be used to change the programme, even offline, and then downloaded to the microcontroller.

A background tasks updates the "System Variables" using the interrupt handler on a time or change basis so that it is always current and the lower priority interpreter runs in the forground at a lower priority.

Proprietary algorithms and IP is coded in assembler and resident in the system firmware so that commercial potential is not compromised.

I think a very good case exists for interpreted languages, you buy a bare bones system and adapt it for your motorcyle, car, rocket, fishtank or whatever - imagine all the fun.

GK

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

stevech wrote:
what did the Altair sell for, if you don't mind saying?

Like I said, that was a LONG time ago! $500, I think. Quite a bit for a starving college student, at the time.

It was supposed to come with 256 BYTES of memory, but they upped it to a whole 1024 by the time I got the RAM card! WOW!

Somewhere in my house is a paper tape with Microsoft 8K Basic, along with a bunch of games. I've been looking for it for years now, so I may have thrown it away.

Ahhh, those were the days!

Stu

Engineering seems to boil down to: Cheap. Fast. Good. Choose two. Sometimes choose only one.

Newbie? Be sure to read the thread Newbie? Start here!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And I have my old Lorenz LO15 typewriter at my
parents home, so perhaps I will in deed
give my tiny-basic interpreter a current loop !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When did just mentioning BASIC become evil?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

pwillard wrote:
When did just mentioning BASIC become evil?

June 12th, 1978.

Smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ossi, you're in luck. I just finished an interactive BASIC interpreter for the AVR. It's written entirely in C using avr-gcc, and I plan to release it under the GPL.

My goals were to make a tokenized basic interpreter that was optimized for speed, portability, and written in a high-level language. It supports floating point, strings, arrays, as well as access to most of the AVR peripherals. It allows you to save and load user programs using internal flash. To program it, all you need is a serial connection. It's also easy to extend the basic with your own commands. The syntax is very close to PBasic with inspiration from the old Atari Basic. It's reasonably fast - a small loop runs at about 13000 lines/sec on an 8mhz atmega128.

The current code size is about 23K, so you'll need an Atmega 32 and up to use it. I've been working on getting a version down to below 16K, but this is proving to be harder than I expected.

I expect to officially release it in a week or two. Right now I'm just doing more testing while trying to increase the speed and reduce the code size. If anyone would like a pre-release copy, feel free to email me at gordonrice[at]sbcglobal.net.

Gordon

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
what did the Altair sell for, if you don't mind saying?

Like I said, that was a LONG time ago! $500, I think. Quite a bit for a starving college student, at the time.

My memory is that they were $300, although I get parity errors now and then. It was on the cover of the January issue (1974? 75?) of Popular Electronics - I came home from work, read the article, mailed in an order, and got a serial number in the low 300s. The grounding straps and other "improvements" came later, since the poor things were pretty unreliable. Of course it was all binary input of opcodes entered through switches to start with. Steve Ciarcia came out with Byte Magazine after a while, and Bill Gates used to take out full page rants about software piracy.

Please notice the phrase "good old days" does not appear above.

Chuck Baird

"I wish I were dumber so I could be more certain about my opinions. It looks fun." -- Scott Adams

http://www.cbaird.org

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

$300, in the era when my house cost $27,600 and I was REALLY sweating the payments on a 30 yr. loan.

In that time frame, I built my home-brew "PC" from TTL parts, designed instruction set, wrote assembler, etc. Ah so, Woz was soon on the scene.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Zilog had a Z8 microcontroller with TinyBasic preprogrammed in the ROM. (I used one to teach BASIC years ago). All you had to do was add an SRAM chip and 232 line drivers for your VDU. You could use embedded assembly code in the BASIC.
The SEQUEL family of minicomputers used the PICK operating system (REVELATION on PCs) and the programming language was DATABASIC, BASIC enhanced to include database manipulation instructions.

C.H.

Someone mentioned ADA - isn't that Pascal written in COBOL? (or vice versa?)

C. H.
-------------------------------------------------------------------
It's only waste if you don't use it!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

c_hirst wrote:
Zilog had a Z8 microcontroller with TinyBasic preprogrammed in the ROM.

I used one of those to build a data logger and PC interface for a Heathkit weather station. Also had a speech synthesizer chip (talking weather station). That thing still worked last time I checked - 2-3 years ago.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can't wait... I want to give this puppy a try myself.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gordon918,
I will be lucky if you publish your interpreter !
Simply give us a link at the appropriate time !

I am making progress with a small basic interpreter,
but surely your solution will be probably more
advanced !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I saw tiny basic interpreter for AVR here http://www.cqham.ru/PLC_1.htm

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

... and more advanced project http://www.cqham.ru/tbcgroup/bas... in russian, but clear enough

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

anyone know if the source to the interpreter is available?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As co-author of this project can say that we are going to translate it to english.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

RV3BJ wrote:
As co-author of this project can say that we are going to translate it to english.

Great!

So is it proprietary or, as Steve asked, will the source code be available?

Smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am not sure if we are ready to open source right now. HEX files are ready for testing purpose. You can send your request to tbcgroup@mail.ru

I invite all of you to forum http://www.cqham.ru/tbcgroup/lit...

Best regards,
Evgeny

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you are looking for as basic interpreter to modify and play around with, you can see the AVR Studio assembler source code for AttoBasic.

ATMEGA515/AT90S8515:
http://cappels.org/dproj/ab163/8...

ATMEGA163:
http://cappels.org/dproj/ab163/1...

They are similar.

--
"Why am I so soft in the middle when the rest of my life is so hard?"
-Paul Simon

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can take a look to http://www.cqham.ru/tbcgroup/tbc...
It's in english.

Evgeny

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That's very cool. When will you post the source code?

--
"Why am I so soft in the middle when the rest of my life is so hard?"
-Paul Simon

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There is always dds basic. Just reduce these:
#define SMAX 999
#define CMAX 256
#define BMAX 999
#define LMAX 9999
and add peek and poke for stuff like PORTs, etc

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

http://www.ittybittycomputers.co...

Compiles in gcc just fine with little changes.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The source code of TBC is now published on http://www.cqham.ru/tbcgroup/tbc...
It's in english.
Everyone can use it without any limitaions.

Have a fun.

Evgeny

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That is most impressive, Evgeny.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Another tiny basic implementation you might want to look at for ideas is Adam Dunkels uBasic at http://www.sics.se/~adam/ubasic/

Michael

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I called this basic interpreter I wrote Tiny Basic...it is not very tiny, however...I used Anagram to write the parser...(parser generator that produces C code). Somebody might have fun with it.

-Jim

-Jim
http://www.noniandjim.com
Analog and Digital Electronics
Music Synthesizers

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I called this basic interpreter I wrote Tiny Basic...it is not very tiny, however...I used Anagram to write the parser...(parser generator that produces C code). Somebody might have fun with it.

http://www.noniandjim.com/Jim/up...

-Jim

P.S...hope this didn't show up twice...forgot the url

-Jim
http://www.noniandjim.com
Analog and Digital Electronics
Music Synthesizers

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

RV3BJ wrote:
The source code of TBC is now published on http://www.cqham.ru/tbcgroup/tbc...

Maybe my eyes are playing tricks on me but I can't find the source code. I see the hex file in the firmware zip, but no source code for the interpreter?

Eric

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

HI,

 

Not yet, but I am working on it.

 

I plan to add some other functions to the source. 

 

My (til now) plans are:  PWM, PORT  (i / o) , COM n (n = 0-3) 

 

Will be (re)written in 2560 Assembler .

 

Kris AKA Snestrup2016

 

 

KSH