Raspberry BASIC

Author Topic: BBC BASIC Compiler?  (Read 5812 times)

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 234
    • View Profile
    • ScriptBasic
BBC BASIC Compiler?
« on: April 15, 2019, 03:33:17 AM »
Richard,

Quote from: Your Web Site
The Raspberry Pi edition has an ARM assembler.

This was the reason I thought BBC BASIC was a BASIC to ASM compiler.

ScriptBasic Project Manager/Facilitator

Richard Russell

  • Moderator
  • *****
  • Posts: 66
    • View Profile
Re: BBC BASIC Compiler?
« Reply #1 on: April 17, 2019, 05:54:18 PM »
This was the reason I thought BBC BASIC was a BASIC to ASM compiler.

An assembler and a compiler are very different things!

Traditionally BBC BASIC has incorporated an assembler as part of its run-time engine, making it easy to include assembly language subroutines in what is otherwise a BASIC program, typically when interpreted BASIC isn't fast enough or to do things that BBC BASIC doesn't support (such as callbacks).

So the original BBC Micro had an integral 6502 assembler, ARM BBC BASIC had an ARM assembler, BBC BASIC for Windows has a 32-bit x86 assembler etc.  The various editions of BBC BASIC for SDL 2.0 have an assembler appropriate to the platform (32-bit x86, 64-bit 86 or 32-bit ARM).

The exception to this rule is Brandy (and its offspring Napoleon Brandy and Matrix Brandy).  Although 'BBC BASIC' they don't include an assembler, and indeed they are generally less extensible and adaptable than most versions of BBC BASIC are.

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 234
    • View Profile
    • ScriptBasic
Re: BBC BASIC Compiler?
« Reply #2 on: April 18, 2019, 02:30:06 AM »
Thanks Richard for the clarification. That is a sweet feature to have in a BASIC. The best ScriptBasic can do is call C extension modules. On Windows, Charles Pegge (OxygenBasic author) wrote an extension module that provides a dynamic FFI definition and full use of the O2.JIT compiler to create virtual DLLs and code in ASM.

I was fortunate that the Brandy author isoated the BBC BASIC graphic primatives in separate SDL 1.2 module. It made making a generic share object usable in most languages that can call a shared object.
« Last Edit: April 18, 2019, 02:35:12 AM by John Spikowski »
ScriptBasic Project Manager/Facilitator

Richard Russell

  • Moderator
  • *****
  • Posts: 66
    • View Profile
Re: BBC BASIC Compiler?
« Reply #3 on: April 19, 2019, 04:37:25 PM »
On Windows, Charles Pegge (OxygenBasic author) wrote an extension module that provides a dynamic FFI definition and full use of the O2.JIT compiler to create virtual DLLs and code in ASM.
It's a shame it's Windows only.  I want to discourage platform-specific extensions to BBC BASIC for SDL 2.0, especially as one of its great strengths is the cross-platform compatibility.  So although the assembler is invaluable for debugging (notably the profiler, list variables and trace features rely on it) I generally don't use it in application programs.

I've recently been experimenting with shader programming in BBC BASIC, and that opens up the possibility of using the GPU to provide acceleration.  Of course it isn't ideally suited to 'general purpose' programming, but increasingly GPUs are used in applications other than graphics.  It potentially has the advantage of being fully cross-platform because all GPUs will run the same source code (it even gets around Apple's prohibition on running arbitrary code in iOS!).