Raspberry BASIC

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

Richard Russell

  • Moderator
  • *****
  • Posts: 31
    • 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: 31
    • 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: 162
    • 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: 31
    • 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: 31
    • 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: 31
    • 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: