Raspberry BASIC

Author Topic: New: Console Mode editions of BBC BASIC  (Read 13710 times)

Richard Russell

  • Moderator
  • *****
  • Posts: 66
    • View Profile
New: Console Mode editions of BBC BASIC
« on: June 28, 2020, 09:11:49 PM »
By popular request (well, three people!) I have created Console Mode editions of BBC BASIC for MacOS, Linux (64-bit), Windows (64-bit) and Raspbian (32-bit).  These have no graphics and no sound (nor do they support a mouse, joystick etc.) but their text-mode features are reasonably complete, so far as the capabilities of the native console/terminal allow (notably, text viewports are not supported).

You can think of them as BBC BASIC for SDL 2.0 with all the SDL stuff removed, and indeed that is effectively how they were created!  Their keyboard input is taken from stdin and their output is sent to stdout so you can use them for CGI applications or effectively as a replacement shell.  Normal shell commands can be issued by preceding them with a * in the usual BBC BASIC way.

These editions consist of compact self-contained executables with no dependencies on any third-party libraries; the BBC BASIC interpreter they contain is identical to that in BBC BASIC for SDL 2.0.  They should be considered as Beta test programs since they have not received extensive testing.  They are, of course, completely free and can be downloaded as follows:


Supplied with the executables are a small number of BBC BASIC demo programs. Here is the output from 8queens.bbc as seen in the Windows 10 console:

Richard Russell

  • Moderator
  • *****
  • Posts: 66
    • View Profile
Re: New: Console Mode editions of BBC BASIC
« Reply #1 on: July 03, 2020, 04:46:06 PM »
I have updated the Console Mode editions of BBC BASIC to version 0.13.  The differences in this version are:

  • LISTIF is accepted (i.e. without a space, as other versions do).
  • RENUMBER now works even if only some lines are numbered.
  • New demo program 'chess.bbc' added (adapted from QBasic).
  • Demo program 'speed.bbc' modified to be more honest!

The updated version may be downloaded from the same place as before:


John Spikowski

  • BASIC Developer
  • ***
  • Posts: 234
    • View Profile
    • ScriptBasic
Re: New: Console Mode editions of BBC BASIC
« Reply #2 on: July 15, 2020, 02:06:26 AM »
Hi Richard.

I'm running Ubuntu 64 bit on my RPI 4B 4GB. Do you have a distribution for ARM 64 bit?

Curious why your 8queens example seems out of sequence. The last results are in the middle rather than the last row.
« Last Edit: July 15, 2020, 02:10:44 AM by John Spikowski »
ScriptBasic Project Manager/Facilitator

Richard Russell

  • Moderator
  • *****
  • Posts: 66
    • View Profile
Re: New: Console Mode editions of BBC BASIC
« Reply #3 on: July 15, 2020, 08:30:14 AM »
I'm running Ubuntu 64 bit on my RPI 4B 4GB. Do you have a distribution for ARM 64 bit?

Sorry, no.  As you may know, 64-bit ARM compilers (e.g. GCC) are really peculiar in one respect: their 'long double' data type (which is what BBC BASIC uses as its default numeric type) doesn't correspond to any of the floating point types supported by the arm64's FPU but is a 128-bit extended-precision type implemented purely in software.  This breaks BBC BASIC in two ways: calculations are really slow, but more fundamentally I assume a 'long double' will fit in 10 bytes (as it does on an x86) rather than needing 16!

What's really annoying and (in my opinion) silly is that there's no GCC compiler switch to force 'long double' to be a synonym for 'double' as it is in all Microsoft's compilers.  That's what Apple's compiler does too, and is why a 64-bit ARM edition of BBC BASIC for iOS was possible whereas it currently isn't on other 64-bit ARM platforms.  Eventually I'll probably need to work around this issue by changing all my 'long double' type declarations to a user-defined type which can be #typedef'd to mean 'double' on ARM64, but I've not done that yet.

Quote
Curious why your 8queens example seems out of sequence. The last results are in the middle rather than the last row.

It's not 'my' example, you'd have to ask its author.  I assume he's displaying the first twelve solutions on the first page, then the next 12 on the next page (without clearing in between) and so on.  As there are 92 solutions in all, the final 8 are shown on the last page, below which the last four from the previous group of 12 can still be seen.

As the program has been used as a sort of benchmark I expect he did not want to scroll the display, or clear it between one group of 12 and the next, because that could skew the execution time depending on the speed of clearing/scrolling.

Richard Russell

  • Moderator
  • *****
  • Posts: 66
    • View Profile
Re: New: Console Mode editions of BBC BASIC
« Reply #4 on: August 04, 2020, 11:36:43 AM »
I have updated the Console Mode editions of BBC BASIC to version 0.25.  The main changes in this version are:

  • Fixed a bug which caused the expected 'Type mismatch' error not to be reported on assigning a string to a numeric variable!
  • Minor changes to the actions of the Esc key and on reporting an untrapped error, to improve consistency with other versions of BBC BASIC.
  • Added some libraries in the lib/ directory (arraylib, classlib, datelib, fnusing, sortlib, stringlib, utf8lib, xmllib).

Version 0.25 may be downloaded from the usual place:


Richard Russell

  • Moderator
  • *****
  • Posts: 66
    • View Profile
Re: New: Console Mode editions of BBC BASIC
« Reply #5 on: September 12, 2020, 02:44:02 PM »
I have updated the Console Mode editions of BBC BASIC to version 0.26, principally to bring them into line with the latest release of BBC BASIC for SDL 2.0.  The main changes in this version are:
  • File pointers and lengths (PTR#, EXT#) are now 64-bits on all platforms.
  • Added the SYS function to return the entry point of an API, e.g. `memcpy` = SYS("memcpy").
  • Added the PTR()= statement to set the pointer of an array or structure.
  • Extended the =PTR() function to return the pointer of an array or structure.
A typical use for the PTR()= statement is to set the pointer of a linked-list node:

Code: [Select]
      DIM node{link, ...}
      ...
      REPEAT
        PTR(node{}) = node.link : REM traverse linked-list
      UNTIL node.link = 0

Version 0.26 may be downloaded as follows:

Richard Russell

  • Moderator
  • *****
  • Posts: 66
    • View Profile
Re: New: Console Mode editions of BBC BASIC
« Reply #6 on: June 11, 2021, 02:57:53 PM »
I have updated the Console Mode editions of BBC BASIC to version 0.34.  The changes in this version are:

  • I've (hopefully) worked around the apparent bug in MinGW's implementation of the _ftelli64() function.
  • Execution speed has been improved by about 10% by optimising the expression evaluator.

Version 0.34 may be downloaded from the usual place:


Richard Russell

  • Moderator
  • *****
  • Posts: 66
    • View Profile
Re: New: Console Mode editions of BBC BASIC
« Reply #7 on: July 18, 2021, 02:13:34 PM »
I have updated the Console Mode editions of BBC BASIC to version 0.35.  The changes in this version are:

  • An edition for the 64-bit Raspberry Pi OS (currently in beta test) has been added.  This typically runs more than twice as fast as the 32-bit Raspberry Pi edition.

  • The Mac M1 ('Apple Silicon') edition now has an AArch64 assembler.  It has limited usefulness because Apple enforce the Hardened Runtime on this platform, but you could still use it to export assembled code to a file.

Version 0.35 may be downloaded from the usual place:


John Spikowski

  • BASIC Developer
  • ***
  • Posts: 234
    • View Profile
    • ScriptBasic
Re: New: Console Mode editions of BBC BASIC
« Reply #8 on: July 20, 2021, 01:02:08 AM »
Hi Richard,

Would this version allow me to run BBC BASIC on my Ubuntu ARM 64 bit OS on a RPi 4B?
ScriptBasic Project Manager/Facilitator

Richard Russell

  • Moderator
  • *****
  • Posts: 66
    • View Profile
Re: New: Console Mode editions of BBC BASIC
« Reply #9 on: July 20, 2021, 08:21:24 AM »
Would this version allow me to run BBC BASIC on my Ubuntu ARM 64 bit OS on a RPi 4B?

I only intend to build binaries for 'official' releases of Raspberry Pi OS (which is Debian, not Ubuntu) so currently that's the 32-bit 'stable' release and the 64-bit beta-test version.  My expectation would be that the Console Mode edition of BBC BASIC is unlikely to care whether it's Debian or Ubuntu, but the GUI version might be more fussy because of its dependence on graphics drivers etc.

If it turns out that the binary is not compatible with Ubuntu you could easily build a custom version (either Console or GUI) from the source, which should have a better chance of running.

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 234
    • View Profile
    • ScriptBasic
Re: New: Console Mode editions of BBC BASIC
« Reply #10 on: July 20, 2021, 09:25:39 AM »
Ubuntu 64 for the RPI is an option of the official RPi installer. Based on the support and updates coming from Ubuntu for the RPi 64 I foresee Ubuntu becoming RPi's default 64 bit offering.

I'm currently running GitLab-ce on my RPi 4b 8GB. (https://basic-sandbox.us)

ScriptBasic 64 bit also runs fine on Ubuntu ARM 64 bit.

Here is a CGI echo example running on the ScriptBasic Application Server running on the same RPi 4B.

http://23.90.90.91:9090/home/echo

http://23.90.90.91:9090/home/web4cast    <-- This is using the cURL extension module to get the current weather from OpenWeather for Anacortes WA.







« Last Edit: July 20, 2021, 09:35:00 AM by John Spikowski »
ScriptBasic Project Manager/Facilitator

Richard Russell

  • Moderator
  • *****
  • Posts: 66
    • View Profile
Re: New: Console Mode editions of BBC BASIC
« Reply #11 on: July 20, 2021, 10:30:46 AM »
Ubuntu 64 for the RPI is an option of the official RPi installer.

I didn't use an "installer", I just downloaded this 64-bit OS image and flashed it into a memory card.  I don't see any 64-bit Ubuntu image at that site.

Quote
Based on the support and updates coming from Ubuntu for the RPi 64 I foresee Ubuntu becoming RPi's default 64 bit offering.

That isn't the impression I've gained from 'official' pronouncements.  The description of the current 64-bit version of Raspberry Pi OS (Debian) as 'beta test' makes me think that is what will become the default 64-bit offering.  For example see this (long) thread at the forum.

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 234
    • View Profile
    • ScriptBasic
Re: New: Console Mode editions of BBC BASIC
« Reply #12 on: July 20, 2021, 08:09:57 PM »
The only thing I use 32 bit Raspian for is my Zero Windows USB dongle OS.

I'm not going down that rabbit hole with 64 bit on the RPi 4B and anything else they offer going forward.

You would think the Raspberry Pi Foundation would have learned their lesson trying to offer your own OS. Microsoft is struggling trying to keep Windows relevant.
ScriptBasic Project Manager/Facilitator

Richard Russell

  • Moderator
  • *****
  • Posts: 66
    • View Profile
Re: New: Console Mode editions of BBC BASIC
« Reply #13 on: July 20, 2021, 09:19:08 PM »
You would think the Raspberry Pi Foundation would have learned their lesson trying to offer your own OS.

I will concentrate on supporting whichever OS is more popular with users.  It's obvious that many more Raspberry Pis will be running the official 64-bit Debian than the unofficial 64-bit Ubuntu.

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 234
    • View Profile
    • ScriptBasic
Re: New: Console Mode editions of BBC BASIC
« Reply #14 on: July 20, 2021, 09:33:23 PM »
I use Ubuntu 64 on all my Linux based systems. I never thought I would go back to a 32 bit OS again but the RPI was cheap enough so I lived through it.

My RPi 4B 8GB has been running 24/7 for over three months running Ubuntu 64. It seems I have to do a Gitlab-ce update at lest once a week. I'm running Ubuntu in full graphic UI mode (not as a server) and still have 4 GB of memory in reserve.
« Last Edit: July 23, 2021, 08:47:15 AM by John Spikowski »
ScriptBasic Project Manager/Facilitator