blippy
Posts: 68
Joined: Fri Nov 03, 2017 3:07 pm

CircleOS + BASIC

Tue Feb 25, 2020 5:43 pm

I implemented a very rough-and-ready version of BASIC for rst's excellent Circle OS.

I did this via a fork, as I haven't yet figured out how to create a build environment that's separate from rst's work. The git repo is available at https://github.com/blippy/circle. Go to subdirectory sample/40-tinybasic.

Build the project in the "usual way". You'll probably need to set your keyboard up if you aren't using a German one. Here's my top-level Config.mk file:

Code: Select all

# For QEMU
# https://www.raspberrypi.org/forums/viewtopic.php?f=72&t=90130&start=250
DEFINE += -DNO_PHYSICAL_COUNTER -DUSE_QEMU_USB_FIX
RASPPI=2
DEFINE += -DDEFAULT_KEYMAP=\"UK\"
Let's write a simple program:

Code: Select all

10 for i = 1 to 10
20 print i
30 next i
Run it:

Code: Select all

run
It should work exactly as expected. Pretty cool, I think.

It has been built for QEMU. I haven't yet tested it out on an SD card.

File IO has not yet been implemented.

The project was conceived as a kind of retro programming environment with a simple programming language. Now you can party like it's 1979.

It's a jumping-off point for adding file io, framebuffer stuff, maybe tones, and all that good stuff.

The version of Basic I used was TinyBasic Plus. It has a long pedigree, going back to the May 1976 issue of Dr. Dobb's Journal. Other people were involved, like a port to the 68000, and the Arduino.

I really love the idea of very old projects being revitalised.

Enjoy!

bzt
Posts: 588
Joined: Sat Oct 14, 2017 9:57 pm

Re: CircleOS + BASIC

Tue Feb 25, 2020 6:04 pm

This is just so cool :-) BASIC was the first language I've learned.

blippy
Posts: 68
Joined: Fri Nov 03, 2017 3:07 pm

Re: CircleOS + BASIC

Tue Feb 25, 2020 6:28 pm

bzt wrote:
Tue Feb 25, 2020 6:04 pm
This is just so cool :-) BASIC was the first language I've learned.
Thanks! Most of the kudos goes to memberlist.php?mode=viewprofile&u=66812 who has basically done all of the heavy lifting by putting an OS in place that can be built upon.

I had in mind a kind-of ZX81 on steroids.

I now confirm it working with a Pi3. It should also work with a Pi2. My config.mk file now looks like:

Code: Select all

RASPPI=2
DEFINE += -DDEFAULT_KEYMAP=\"UK\"
I have taken out the QEMU stuff. If you don't, then you'll get an assertion error when you try to boot the Pi. You should also set your keymap appropriately. I'll write instructions on that later.

But yeah, I like the idea of a nice simple, high-level programming environment. Now that the whole thing actually works, it should be reasonably easy to extend it with file support, graphics, GPIO, and maybe simple audio.

I read that CircleOS supports cooperative multitasking. I haven't investigated how that works yet. It would be interesting to get going, though. Then you could create projects with some nice real-time behaviour. Imagine a BASIC where you could run (psuedo) concurrent tasks.

I found the version of TinyBasicPlus for the Arduino. So you can get BASIC to work on them. I added SD card support on it, but unfortunately right on the edge of the Uno/Nano's memory capacity. I bought a Nano Every recently, although it hasn't yet been delivered. It should give me more room to play with.

I do have my own version of Forth, which is highly portable to just about anything. I thought a BASIC environment might be a preferred system, though.

The current kernel image is 148k, although for an Arduino it would be much smaller.

TinyBasic might make a great environment for something like a Pi0. I don't actually own a Pi 0, but from what I've seen, Linux is way too bulky for it.. So BASIC be a breathe of fresh air.

rst
Posts: 482
Joined: Sat Apr 20, 2013 6:42 pm
Location: Germany

Re: CircleOS + BASIC

Wed Feb 26, 2020 7:02 am

That's a cool project. I started with BASIC too and went over to Z80 assembler then to understand, what is really going on. I think, BASIC is easy understandable for beginners and still of professional importance with Visual Basic .NET.

You could use Git submodules for integrating other projects into your own project:

Code: Select all

git submodule add https://github.com/someuser/someproject.git subdirectory
cd subdirectory
git checkout sometag
cd ..
git add .gitmodules subdirectory
git commit -m "Submodule added"

This adds someproject to your own project in subdirectory, selects the sometag commit of someproject and commits this change to the repo.

blippy
Posts: 68
Joined: Fri Nov 03, 2017 3:07 pm

Re: CircleOS + BASIC

Fri Feb 28, 2020 2:58 pm

The version of BASIC I've adopted is very very ... basic! It was originally written in 1976, way before Basic.Net.

TinyBasic now supports loading and saving files! I've test it under QEMU using a premade image. There are utilities in the project for doing this, but I need to document them.

PS I did read somewhere that it might actually be possible to write an OS in FreeBASIC, although I haven't investigated this.

bzt
Posts: 588
Joined: Sat Oct 14, 2017 9:57 pm

Re: CircleOS + BASIC

Fri Feb 28, 2020 6:51 pm

blippy wrote:
Fri Feb 28, 2020 2:58 pm
The version of BASIC I've adopted is very very ... basic! It was originally written in 1976, way before Basic.Net.
:-) No worries, I like it this way!
blippy wrote:PS I did read somewhere that it might actually be possible to write an OS in FreeBASIC, although I haven't investigated this.
Most definitely. Here's a tutorial. It's for x86 but I think it should be trivial to crosscompile FreeBasic RT for ARM (if it isn't already) and modify the linker script a bit to suit Raspberry Pi's load address.

I'm not familiar with this code, but it looks promising, you should definitely check out (looks like it has C++ parts too).

Cheers,
bzt

blippy
Posts: 68
Joined: Fri Nov 03, 2017 3:07 pm

Re: CircleOS + BASIC

Fri Feb 28, 2020 7:52 pm

Interesting links. Thanks for that.

Return to “Bare metal, Assembly language”