BBC BASIC on the Raspberry Pi Pico

New releases of BB4W and BBCSDL, and other updates, will be announced here
Posts: 12
Joined: Wed 28 Jul 2021, 13:29

BBC BASIC on the Raspberry Pi Pico

Post by MrHiggins »

Noticed that Richard posted this over at the Stardot forums. wrote: Over at the Raspberry Pi forum Eric Olsen is working on a port of my BBC BASIC interpreter (with all the 'modern' extensions, like structures and 64-bit integers) to the Raspberry Pi Pico, a $5 computer! This would be, at least initially, a 'console mode' implementation, requiring an external terminal for user I/O.

He has already had considerable success, but is encountering some problems working within the constraints of having only about 256K of RAM in total. Although that sounds generous for BBC BASIC, I have not had to worry about limited memory availability on modern platforms so my code is not optimised for that (for example the string accumulator is currently 64K just because that's a convenient amount).

So he and I are working on ways to reduce the memory footprint, one of which is to reduce the size of the string accumulator. I have also proposed the following approach to memory management, maximising the flexibility of how the limited RAM is divided between the various competing demands, largely by the BASIC programmer tuning the value of HIMEM to suit the particular program:


This is very much in keeping with the BBC BASIC 'philosophy' of giving the programmer low-level control of memory allocation. It's not yet clear whether it will be possible to cajole the Pico's kernel to allow this arrangement (which involves the CPU stack being within our malloc'ed block). wrote:BBC BASIC for the Raspberry Pi Pico is now at a stage where it can be experimented with. It's very much a work-in-progress (for example there isn't yet a Thumb2 assembler) but it can run programs and control the GPIO. Installation instructions can be found here.

There are a number of demo programs supplied, including one ( to blink the LED:

Code: Select all

 `gpio_put` = SYS("gpio_put")
 led_pin = 25
 SYS "gpio_init", led_pin
 SYS "gpio_set_dir", led_pin, 1
   SYS `gpio_put`, led_pin, 1
   WAIT 25
   SYS `gpio_put`, led_pin, 0
   WAIT 25