WB4WTN
Posts: 27
Joined: Thu Jan 17, 2013 9:27 pm

Does BBC Basic Run On Raspberry Pi OC 64 Bit?

Fri Jun 04, 2021 8:44 pm

I'm trying to install BBC Basic on a Lite version of Raspberry Pi OS 64 bit, but I get an error loading libSDL2-2.0.so.0. I tried installing libSDL2-2.0.so.0, no such package. Can anyone help? Thanks.

User avatar
scruss
Posts: 4190
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Does BBC Basic Run On Raspberry Pi OC 64 Bit?

Fri Jun 04, 2021 11:13 pm

The package from BBC BASIC is 32-bit only. So it probably won't work. In theory, it can be built from source, in practice, it's likely harder than it looks.

The library installation instructions are:

Code: Select all

 sudo apt-get install libsdl2-2.0-0
 sudo apt-get install libsdl2-ttf-2.0-0
 sudo apt-get install libsdl2-net-2.0-0
I would have thought that the 64-bit os would have libsdl2 packages: what does apt-cache search libsdl2 return?

If you don't need the gui editor, stardot/MatrixBrandy: Matrix Brandy BASIC VI for Linux, Windows, MacOSX should work. It has similar SDL dependencies, though.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

WB4WTN
Posts: 27
Joined: Thu Jan 17, 2013 9:27 pm

Re: Does BBC Basic Run On Raspberry Pi OC 64 Bit?

Fri Jun 04, 2021 11:25 pm

I should have mentioned that I followed the install instructions and I did the above and confirmed they did install. So, I guess the 32 bit won't run. Thanks for the reply.

User avatar
scruss
Posts: 4190
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Does BBC Basic Run On Raspberry Pi OC 64 Bit?

Sat Jun 05, 2021 12:28 am

didn't think it would. I've never bothered with 64 bit on a Raspberry Pi because of the weak software support.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

User avatar
jahboater
Posts: 7198
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Does BBC Basic Run On Raspberry Pi OC 64 Bit?

Sat Jun 05, 2021 1:25 am

sdl2 is installed by default on Raspberry Pi OS 64-bit

WB4WTN
Posts: 27
Joined: Thu Jan 17, 2013 9:27 pm

Re: Does BBC Basic Run On Raspberry Pi OC 64 Bit?

Sat Jun 05, 2021 1:44 am

jahboater wrote:
Sat Jun 05, 2021 1:25 am
sdl2 is installed by default on Raspberry Pi OS 64-bit
It may be, but the error is for libSDL2-2.0.so.0.

User avatar
rpdom
Posts: 18878
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Does BBC Basic Run On Raspberry Pi OC 64 Bit?

Sat Jun 05, 2021 6:43 am

WB4WTN wrote:
Sat Jun 05, 2021 1:44 am
jahboater wrote:
Sat Jun 05, 2021 1:25 am
sdl2 is installed by default on Raspberry Pi OS 64-bit
It may be, but the error is for libSDL2-2.0.so.0.
The libsdl2-2.0-0 package includes that file

Code: Select all

pi@raspi3:~ $ find /usr/lib -name '*SDL2*'
/usr/lib/aarch64-linux-gnu/libSDL2-2.0.so.0.9.0
/usr/lib/aarch64-linux-gnu/libSDL2-2.0.so.0
Unreadable squiggle

User avatar
B.Goode
Posts: 12300
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Does BBC Basic Run On Raspberry Pi OC 64 Bit?

Sat Jun 05, 2021 6:55 am

WB4WTN wrote:
Fri Jun 04, 2021 8:44 pm
I'm trying to install BBC Basic on a Lite version of Raspberry Pi OS 64 bit, but I get an error loading libSDL2-2.0.so.0. I tried installing libSDL2-2.0.so.0, no such package. Can anyone help? Thanks.


A few weeks ago you were in communication with Richard Russell, the developer/maintainer of BBC Basic. Perhaps he would know?

viewtopic.php?f=34&t=311414&p=1862454#p1862454



There is a long-running thread on the topic here viewtopic.php?f=34&t=238187 whose first page contains a link to the author's GitHub repository where you could use the Issues page - https://github.com/rtrussell/BBCSDL/issues/new

User avatar
RichardRussell
Posts: 774
Joined: Thu Jun 21, 2012 10:48 am

Re: Does BBC Basic Run On Raspberry Pi OC 64 Bit?

Sat Jun 05, 2021 8:30 pm

WB4WTN wrote:
Fri Jun 04, 2021 8:44 pm
I'm trying to install BBC Basic on a Lite version of Raspberry Pi OS 64 bit, but I get an error loading libSDL2-2.0.so.0. I tried installing libSDL2-2.0.so.0, no such package. Can anyone help? Thanks.
The main block to building BBC BASIC for 64-bit ARM (AArch64) is the absence of an assembler for that platform. Both the debugger and the profiler rely on running a periodic interrupt, and you can't write an Interrupt Service Routine in BBC BASIC.

So on all the currently-supported desktop platforms (Windows, MacOS, x86 Linux and 32-bit Raspberry Pi) the ISR is written in assembly language.

Fortunately, a solution is in sight. Somebody is making good progress in writing the required assembler. Once that's working it should be possible to port BBC BASIC to the 64-bit Raspberry Pi OS.

Meanwhile you may be able to build it from source by using the 'wrong' assembler, but the debugger and profiler won't then work.

User avatar
jahboater
Posts: 7198
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Does BBC Basic Run On Raspberry Pi OC 64 Bit?

Sun Jun 06, 2021 7:09 pm

RichardRussell wrote:
Sat Jun 05, 2021 8:30 pm
Fortunately, a solution is in sight. Somebody is making good progress in writing the required assembler. Once that's working it should be possible to port BBC BASIC to the 64-bit Raspberry Pi OS. rk.
I suppose using the GNU assembler called "as" is not an option? It supports absolutely everything, all the Intel instruction sets including AVX512, aarch64, SIMD, all the old 32-bit ARM ISA's, thumb1, thumb2, RISCV, etc etc, right up to the latest yet to be released hardware in some cases.

The diagnostics and debugger support are superlative.

The GNU assembler is designed for use by compilers (GCC emits assembler), so it is very very fast and lightweight. This means (I think) that you could perhaps call it for each single assembler statement.

Writing a separate new assembler each time seems 1) a duplication of effort, and 2) unlikely to keep up with the hardware.

User avatar
RichardRussell
Posts: 774
Joined: Thu Jun 21, 2012 10:48 am

Re: Does BBC Basic Run On Raspberry Pi OC 64 Bit?

Sun Jun 06, 2021 7:55 pm

jahboater wrote:
Sun Jun 06, 2021 7:09 pm
I suppose using the GNU assembler called "as" is not an option?
It wouldn't be straightforward. For example BBC BASIC's assembler must be able to accept a standard BASIC expression (string or numeric) as an operand, and it must be able to create a BASIC variable when a label is declared. Also, BBC BASIC's assembler is expected to assemble to memory rather than to a file.

At the very least some pre-processing would be required before being passed to 'as', and this would probably involve knowing the syntax of each instruction (e.g. how many operands of what kinds are expected, so they can be evaluated and substituted). By the time you've got that far you're on the way to implementing an entire assembler!
Writing a separate new assembler each time seems 1) a duplication of effort, and 2) unlikely to keep up with the hardware.
Keeping up with the hardware isn't really an issue. BBC BASIC users don't expect the assembler (necessarily) to support every instruction, and coverage varies across the current versions (the x86-64 assembler is quite good in that respect, the 32-bit ARM assembler is relatively poor).

At least two people are currently working on an AArch64 assembler, with one quite close to completion as I understand it. So I don't see this as being an issue for much longer, and I'm pretty confident an assembler will be available before the 64-bit Raspberry Pi OS is officially supported.

User avatar
RichardRussell
Posts: 774
Joined: Thu Jun 21, 2012 10:48 am

Re: Does BBC Basic Run On Raspberry Pi OC 64 Bit?

Thu Jun 17, 2021 3:42 pm

RichardRussell wrote:
Sun Jun 06, 2021 7:55 pm
At least two people are currently working on an AArch64 assembler, with one quite close to completion as I understand it. So I don't see this as being an issue for much longer, and I'm pretty confident an assembler will be available before the 64-bit Raspberry Pi OS is officially supported.
The good news is that I've now built an edition of BBC BASIC for SDL 2.0 for 64-bit Pi OS and it's largely working. The bad news is that it's not fully usable because of what seems to be an incompatibility between SDL 2.0.9 (from the repository) and the 64-bit OS, specifically the SDL_ShowMessageBox() and SDL_ShowSimpleMessageBox() functions aren't working: they return immediately without displaying anything. :(

I've reported this at the Pi OS (64 bit) feedback thread but until the problem is resolved I can't make BBC BASIC available. I could, as a last resort, work around the issue by making my own message boxes using BASIC graphics primitives, but it would be a lot of effort and only a partial solution. It's going to have to be fixed properly otherwise no SDL-based applications that use these functions will run correctly.

User avatar
RichardRussell
Posts: 774
Joined: Thu Jun 21, 2012 10:48 am

Re: Does BBC Basic Run On Raspberry Pi OC 64 Bit?

Fri Jun 18, 2021 1:52 pm

RichardRussell wrote:
Thu Jun 17, 2021 3:42 pm
I could, as a last resort, work around the issue by making my own message boxes using BASIC graphics primitives, but it would be a lot of effort and only a partial solution.
I've been mulling this over, and I'm coming around to the idea that (irrespective of the 64-bit Pi OS issue) it might be better to avoid the use of OS-supplied message boxes as far as possible. BBC BASIC is perfectly capable of creating a message box from scratch, and that would be more consistent with the the overall cross-platform philosophy. At the moment dialogue boxes look identical irrespective of the platform, but message boxes don't, and that's not ideal (the ready availability of SDL message boxes, up till now, means I haven't really thought about this before).

So unless anybody has a major objection I will work towards replacing SDL's message boxes (which currently aren't working in 64-bit Pi OS) with BBC BASIC-created ones.

User avatar
RichardRussell
Posts: 774
Joined: Thu Jun 21, 2012 10:48 am

Re: Does BBC Basic Run On Raspberry Pi OC 64 Bit?

Thu Jun 24, 2021 1:09 pm

I'm pleased to report that I now have a fully working edition of BBC BASIC for SDL 2.0 for the 64-bit Raspberry Pi OS (to the extent that I've tested it, anyway). This includes the AArch64 assembler, so the debugging and profiling capabilities are fully functional, and the modification to use BBC BASIC-generated message boxes as discussed previously.

I will hope to include this edition with the next release of BBCSDL, due in about two weeks time. Meanwhile it may be of interest to compare the measured timings of the 32-bit and 64-bit editions, on the same Raspberry Pi 4 hardware:

32-bit:

Code: Select all

      BBC BASIC for Linux version 1.22a       Average:                   694 ns

      Colon:                      33 ns       A%=B%<<C%:                 780 ns
      Dispatch (ENDCASE):         36 ns       A%=B%>>C%:                 760 ns
      Dispatch (ENDIF):           36 ns       A%=B%>>>C%:                763 ns
      NEXT (integer):            123 ns       A%%=B%%:                   584 ns
      NEXT (default real):       172 ns       A%%=B%%+C%%:               925 ns
      NEXT (64-bit real):        162 ns       A%%=B%%-C%%:               912 ns
      NEXT N%:                   220 ns       A%%=B%%*C%%:               969 ns
      NEXT n%:                   316 ns       A%%=B%%DIVC%%:            1093 ns
      NEXT N:                    325 ns       A%%=B%%/C%%:              1130 ns
      NEXT N#:                   351 ns       A%%=B%%^3:                1602 ns
      REPEATUNTILTRUE:           234 ns       A%%=B%%<<C%%:              983 ns
      WHILEFALSE:ENDWHILE:       230 ns       A%%=B%%>>C%%:              982 ns
      A%=FALSE:                  324 ns       A%%=B%%>>>C%%:             979 ns
      A%=0:                      440 ns       A=B+PI:                    875 ns
      A=PI:                      449 ns       A=B-PI:                    887 ns
      ANTIDISESTABLISHMENT=PI:   549 ns       A=B*PI:                    865 ns
      A=(PI):                    661 ns       A=B/PI:                    859 ns
      A%=1234567890:             624 ns       A=B^3:                    1541 ns
      A%=&499602D2:              451 ns       A=B^PI:                   1216 ns
      A=1.23456789E38:          1005 ns       A=SINB:                    742 ns
      A%=B%:                     425 ns       A=TANB:                    867 ns
      A=B:                       536 ns       A=LOGB:                    925 ns
      ANTI=ANTI:                 568 ns       A=EXPB:                    764 ns
      A%=B%+C%:                  683 ns       A=SQRB:                    693 ns
      A%=B%-C%:                  675 ns       A=ATNB:                    816 ns
      A%=B%*C%:                  742 ns       A=ABSB:                    645 ns
      A%=B%DIVC%:                991 ns       A=INTB:                    729 ns
      A%=B%/C%:                  817 ns       PROC1:                     236 ns
      A%=C%^D%:                 1686 ns       A%=FN1:                   1283 ns
64-bit:

Code: Select all

      BBC BASIC for Linux version 1.22a       Average:                   296 ns

      Colon:                      14 ns       A%=B%<<C%:                 358 ns
      Dispatch (ENDCASE):         26 ns       A%=B%>>C%:                 364 ns
      Dispatch (ENDIF):           24 ns       A%=B%>>>C%:                360 ns
      NEXT (integer):             38 ns       A%%=B%%:                   272 ns
      NEXT (default real):        39 ns       A%%=B%%+C%%:               422 ns
      NEXT (64-bit real):         38 ns       A%%=B%%-C%%:               427 ns
      NEXT N%:                    71 ns       A%%=B%%*C%%:               403 ns
      NEXT n%:                   101 ns       A%%=B%%DIVC%%:             414 ns
      NEXT N:                     97 ns       A%%=B%%/C%%:               492 ns
      NEXT N#:                    98 ns       A%%=B%%^3:                 525 ns
      REPEATUNTILTRUE:           144 ns       A%%=B%%<<C%%:              453 ns
      WHILEFALSE:ENDWHILE:       139 ns       A%%=B%%>>C%%:              460 ns
      A%=FALSE:                  166 ns       A%%=B%%>>>C%%:             450 ns
      A%=0:                      208 ns       A=B+PI:                    354 ns
      A=PI:                      228 ns       A=B-PI:                    355 ns
      ANTIDISESTABLISHMENT=PI:   275 ns       A=B*PI:                    349 ns
      A=(PI):                    340 ns       A=B/PI:                    365 ns
      A%=1234567890:             238 ns       A=B^3:                     534 ns
      A%=&499602D2:              249 ns       A=B^PI:                    499 ns
      A=1.23456789E38:           379 ns       A=SINB:                    372 ns
      A%=B%:                     211 ns       A=TANB:                    396 ns
      A=B:                       265 ns       A=LOGB:                    424 ns
      ANTI=ANTI:                 281 ns       A=EXPB:                    386 ns
      A%=B%+C%:                  329 ns       A=SQRB:                    332 ns
      A%=B%-C%:                  333 ns       A=ATNB:                    387 ns
      A%=B%*C%:                  311 ns       A=ABSB:                    339 ns
      A%=B%DIVC%:                316 ns       A=INTB:                    338 ns
      A%=B%/C%:                  337 ns       PROC1:                      86 ns
      A%=C%^D%:                  475 ns       A%=FN1:                    497 ns
The difference (the 64-bit version being more than twice as fast on average) is a great deal more than I was expecting, and I don't know what the explanation is.
Last edited by RichardRussell on Wed Jun 30, 2021 7:21 pm, edited 1 time in total.

User avatar
jahboater
Posts: 7198
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Does BBC Basic Run On Raspberry Pi OC 64 Bit?

Thu Jun 24, 2021 6:00 pm

RichardRussell wrote:
Thu Jun 24, 2021 1:09 pm
The difference (the 64-bit version being more than twice as fast on average) is a great deal more than I was expecting, and I don't know what the explanation is.
The Pi4 has Cortex-A72 CPU cores which are relatively modern "out-of-order" designs.
The old 32-bit instruction set (I think) was designed around 30 years ago? and does not fit well with modern OOO processors.
The 64-bit instruction set is a new design, streamlined for recent and future CPU hardware. All the slow stuff was removed!

Also, the 64-bit ISA has twice the number of registers (more than twice the number of general purpose registers of course).

Well done for completing the 64-bit port!

User avatar
RichardRussell
Posts: 774
Joined: Thu Jun 21, 2012 10:48 am

Re: Does BBC Basic Run On Raspberry Pi OC 64 Bit?

Thu Jun 24, 2021 6:44 pm

jahboater wrote:
Thu Jun 24, 2021 6:00 pm
The old 32-bit instruction set (I think) was designed around 30 years ago? and does not fit well with modern OOO processors.
I'm sure that's true, but I was hoping GCC could mitigate that to some extent by reordering the instructions itself. The original ARM CPU was designed more like 35 years ago, and was famously simulated in BBC BASIC! Here's a snippet from that simulation which Steve Furber sent me (the full program was about 700 lines):

Code: Select all

2950 DEF PROCaregph1
2960 tareg%=areg% AND 3
2970 ENDPROC
2980
2990 DEF PROCaregph2
3000 oareg%=tareg%
3010 achkx%=FALSE
3020 IF aregs%=0 areg%=aregn%*4
3030 IF aregs%=1 areg%=alu% AND &3FFFFFF:achkx%=alu% AND &FC000000
3040 IF aregs%=2 areg%=inc% OR areg% AND 3
3050 IF aregs%=3 areg%=reg%(15)
3060 ENDPROC
Also, the 64-bit ISA has twice the number of registers (more than twice the number of general purpose registers of course).
Indeed, and with so many registers it's rare for a local variable to need to be spilled to the stack. The AArch64 ABI also allows structs to be passed to functions in registers, something that 32-bit ABIs generally don't support.

User avatar
jahboater
Posts: 7198
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Does BBC Basic Run On Raspberry Pi OC 64 Bit?

Thu Jun 24, 2021 7:39 pm

RichardRussell wrote:
Thu Jun 24, 2021 6:44 pm
I'm sure that's true, but I was hoping GCC could mitigate that to some extent by reordering the instructions itself.
Yes, no doubt it does.
But can you imagine the effect of "most" instructions being conditional (with an extra dependency), or the PC be arbitrarily written to like any other register, on a modern CPU? How does all that work with speculative execution? God knows.
Complicated and very slow load and store insns (ldm/stm) don't help.

Anyway, its pleasing the 64-bit port is so fast.
The RPF will no doubt officially release Raspberry Pi SO 64-bit in the not too distant future.

Nice to hear about the simulation of the ARM prototype using BBC Basic!

User avatar
Gavinmc42
Posts: 5882
Joined: Wed Aug 28, 2013 3:31 am

Re: Does BBC Basic Run On Raspberry Pi OC 64 Bit?

Sat Jul 24, 2021 12:10 am

Seem to remember coming across something that said SDL 2.12 would be better for Aarch64.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Return to “Other programming languages”