BBC BASIC on the Raspberry Pi Pico
BBC BASIC on the Raspberry Pi Pico
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).
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).
Re: BBC BASIC on the Raspberry Pi Pico
Ooo, looking good.
Code: Select all
$ bbcbasic
PDP11 BBC BASIC IV Version 0.45
(C) Copyright J.G.Harston 1989,2005-2024
>_
Re: BBC BASIC on the Raspberry Pi Pico
I'm afraid I don't understand the term 'string accumulator ', could you explain a bit more?
Re: BBC BASIC on the Raspberry Pi Pico
It's a temporary holding buffer for a string, principally for use during expression evaluation. Consider a simple statement such as:
Code: Select all
a$ = a$ + b$
- Copy the string a$ to the string accumulator.
- Concatenate b$ onto the contents of the string accumulator.
- Replace a$ with the contents of the string accumulator.
The name arises by analogy with the accumulator register which performs a similar function in numeric calculations.
Re: BBC BASIC on the Raspberry Pi Pico
For additional reference, according to MDFS the string accumulator of Sophie's original 6502 BBC BASIC is at &0600 to &06FF. It's also used to contain the parameter block built by the CALL statement.
When it's not at a fixed address there is typically a way to discover where it is. For example in BBC BASIC for Windows and 32-bit editions of BBC BASIC for SDL 2.0 its address can be found as !332 and in 64-bit editions its address can be found as ]332:
which prints:
showing how the string accumulator holds the concatenated string temporarily for its length to be measured, even though it's not actually stored in a variable.
When it's not at a fixed address there is typically a way to discover where it is. For example in BBC BASIC for Windows and 32-bit editions of BBC BASIC for SDL 2.0 its address can be found as !332 and in 64-bit editions its address can be found as ]332:
Code: Select all
a$ = "Hello "
b$ = "world!"
L% = LEN(a$ + b$ + CHR$&D)
PRINT $!332
Code: Select all
Hello world!
Re: BBC BASIC on the Raspberry Pi Pico
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 (gpio.bbc) to blink the LED:
There are a number of demo programs supplied, including one (gpio.bbc) 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
REPEAT
SYS `gpio_put`, led_pin, 1
WAIT 25
SYS `gpio_put`, led_pin, 0
WAIT 25
UNTIL FALSE
Re: BBC BASIC on the Raspberry Pi Pico
An interesting development thread, and a fine milestone!
Re: BBC BASIC on the Raspberry Pi Pico
That's very cool. A chance to use some of the Picos I have lying around with a decent BASIC