RISC OS Open
A fast and easily customised operating system for ARM devices
ROOL
Home | News | Software | Bugs | Bounties | Forum | Documents | Photos | Contact us
Account
Forums → Code review →

Adding BBFW functionality to ARM BASIC

Subscribe to Adding BBFW functionality to ARM BASIC 16 posts, 8 voices

 
Jan 29, 2009 11:53am
Avatar jgharston (196) 7 posts

Prompted by a discussion on comp.sys.acorn.programmer I decided to see if I could add BBC BASIC for Windows functionality to ARM BBC BASIC. I have detailed the work so far at http://mdfs.net/bbcbasic/RISCOS/BasPlus.htm

So far I’ve got working:
  • $$<num>=<str> null-terminated string indirection
  • <str>=$$<num> null-terminated string indirection
  • <num>=^<variable> Address of identifier
  • AND= Compound Bitwise AND.
  • DIV= Compound Integer division.
  • EOR= Compound Bitwise EOR.
  • MOD= Compound Modulus.
  • OR= Compound Bitwise OR.
 
Jan 29, 2009 6:31pm
Avatar Steve Revill (20) 898 posts

Nice one!

I appreciate that most of the implementation details (i.e. syntax decisions) are being discussed on csap, but it’d be worth adding the proposed syntax extensions to this thread, too; for the benefit of people who may be reading here but not csap.

Certainly, the new syntax should be documented in the same style as the BBC BASIC Reference Manual at some point. Ideally on our wiki.

Oh, and the HELP messages (are they in BASICTrans?) would also need updating.

Interested parties should test your changes if possible to help build a bit of confidence – then we can check it into the source repository. To help with this, could you build the BASIC module and pop that on your page (technically, you’ll need to include a copy of the licence – which is found in all our zipfiles).

Great work, keep it up! :)

 
Jan 29, 2009 6:36pm
Avatar Steve Revill (20) 898 posts

Oh, I also have a question about some of the proposed syntax (examples) on your page… you say:

name.name=  Assign structure member

and:

name.name  Read structure member value

would these actually be more like

name{}.name

?

 
Jan 30, 2009 1:18pm
Avatar jgharston (196) 7 posts

It’s not proposed syntax, it’s existing syntax, see http://www.rtrussell.co.uk/bbcwin/manual/bbcwin2.html#structures

eg:

 DIM objpos{roll,pitch,yaw}
 objpos.roll = X
 objpos.pitch = Y
 objpos.yaw = Z

Full list of other BBC BASIC syntax not in ARM BASIC:
Commands
---------
$$<num>=<str>                 DONE: null-terminated string indirection
DIM struct{<members>}               Define a structure
DIM struct{}=struct{}               Define with a prototype
EXIT FOR                            Exit current FOR loop
EXIT FOR <var>                      Exit specified FOR loop
EXIT REPEAT                         Exit current REPEAT loop
EXIT WHILE                          Exit current WHILE loop
PRIVATE struct[,struct...]          Declare structures private to function or procedure.
PRIVATE var[,var...]                Declare variables private to function or procedure.
PROC(<num>)[(parameter list)] DONE: Call a procedure indirectly.
WAIT <num>                    DONE: Wait for multiple horizontal syncs
\                                   Skip to next line
name.name=                          Assign structure member

Functions
---------
$$<num>                       DONE: null-terminated string indirection
DIM(struct{})                       Return size of structure
FN(<num>)[(parameter list)]   DONE: Call a function indirectly.
GET$(<num>,<num>)                   Read a character from the specified character position.
GET(<num>,<num>)                    Read a character from the specified character position.
^<identifier>                 DONE: Address of identifier
name.name                           Read structure member value
The following are from PDP-11 BBC BASIC:
&o                                  octal number  
GET(<num>)                          Read a value from the specified I/O port.  
STR$#<num>                          Return string representation in octal  
STR$/<num>                          Return string representation in binary  

Compound Operators
------------------
*=           Multiplication.
/=           Division.
AND=   DONE: Bitwise AND.
DIV=   DONE: Integer division.
EOR=   DONE: Bitwise exclusive-OR.
MOD=   DONE: Modulus.
OR=    DONE: Bitwise OR.

Array Operations
----------------
array() [AND|DIV|EOR|MOD|OR] array()
array() [AND|DIV|EOR|MOD|OR]= <expr>
(I’ve tried to get the above as a table, but it doesn’t work)
 
Jan 31, 2009 7:07pm
Avatar Mohsen Alshayef (220) 3 posts

What are the plans for the next Version Number of ARM-BASIC following the completion of these new additions. Mind you, once all planned updates get completed, this would be a major change/release to the language since the days of the Arthur OS 23 years ago :-) Looks like we are “finally” going to see ARM BASIC 7 :-)

Excellent work.

Keep it up.

Please keep posting new updates of the test module on your site as I am doing some test for my StrongBS :-)

regards

Mohsen

 
Jan 31, 2009 8:51pm
Avatar Mohsen Alshayef (220) 3 posts

Please note that the new WAIT keyword with WAIT <num> causes current programs to fail with a Syntax Error.

Today the purpose of WAIT keyword is to wait for the end of the current display frame.

In BB4W the WAIT statement has a different function in that it causes the program to pause for the specified number of centiseconds (hundredths of a second), and a WAIT without any parameter in BB4W is equivalent to WAIT 0.

To keep compatibility with the current WAIT keyword in BASIC V, I suggest the following:

WAIT [<numeric>]

Purpose: A statement to wait for the end of the current display frame. Optionally to causes the programme to pause for the specified number of centi-seconds.

Syntax: WAIT [<numeric>]

<numeric> a numeric integer constant, variable or expression.

WAIT without any parameter should continue to provide the function of waiting for the end of the current display frame to be compatible with existing BASIC programmes as in BASIC V.

WAIT 0 should be equivalent to WAIT with no parameters.

Please note that in BB4W, WAIT with a negative number is equivalent to WAIT 0. Maybe this could also be implemented so that WAIT -1 will be the same as WAIT or WAIT 0.

I have noticed a wrong reporting of error line (but this could be for another reason – testing purpose, etc.).

The following program:

10 WAIT

20 END

gives the error “Syntax Error at line 20”. The error seems to be at line 10 because of the missing WAIT parameter.

regards

Mohsen

 
Jan 31, 2009 10:16pm
Avatar Mohsen Alshayef (220) 3 posts

Question: The latest version of BASIC V is 1.39 available for download from the Download section. Why are the updates using the earlier version 1.37? Has there been anything added to version 1.38 and 1.39 that does not appear in the version currently being worked on?

thanks

Mohsen

 
Feb 2, 2009 2:00pm
Avatar jgharston (196) 7 posts
> 10 WAIT
> 20 END
> gives the error “Syntax Error at line 20”.

Thanks. Fixed.

 
Feb 3, 2009 8:19pm
Avatar Alex Farlie (144) 35 posts

Well I seem to recall mentioning something about trying to put BB4W features in BBC Basic back in 2007:

http://www.riscosopen.org/forum/forums/2/topics/71

There’s another thread somewhere on the ROOL forums (not mine) that appeared to ask if COMAL like scoping could be considered in a future version of ARM (BBC) Basic.

 
Feb 9, 2009 4:49pm
Avatar jgharston (196) 7 posts
Current state of play is:
$$<num>=<str>                 DONE:  null-terminated string indirection  
PROC(<num>)[(parameter list)] DONE:  Call a procedure indirectly.  
WAIT <num>                    DONE:  Wait for centisecond delay  
\                             DONE:  Skip to next line  
EXIT FOR|REPEAT|WHILE         Syntax checking done.
^<identifier>                 DONE:  Address of identifier  
FN(<num>)[(parameter list)]   DONE:  Call a function indirectly.  
AND=   DONE:  Bitwise AND.  
DIV=   DONE:  Integer division.  
EOR=   DONE:  Bitwise exclusive-OR.  
MOD=   DONE:  Modulus.  
OR=    DONE:  Bitwise OR.
I’ve done some timing tests as well, and my ClockSp program suggests an average 0.03% speed reduction when thrashing the interpreter.

A query: I’m tempted to put all the modifications in the source inside conditional assembly blocks, so they can all be turned off at the assembly stage. Suggestions?

 
Feb 17, 2009 3:50pm
Avatar jgharston (196) 7 posts
Since last week, the following are now working:
PLOT <num>,<num>  DONE:  Do PLOT 69,<num>,<num>  
EXIT WHILE        DONE:  Exit current WHILE loop  
EXIT REPEAT       DONE:  Exit current REPEAT loop  
EXIT FOR          DONE:  Exit current FOR loop

I’ve also changed the version string to “1.37-Varient” to indicate that it isn’t actually 1.37. I also need to download the sources for 1.39 and continue working from there. The reason I was working on 1.37 is that I downloaded the sources last year before 1.39 was uploaded.

Once I get EXIT FOR var done and finished *= and /= it’s time to roll up my sleeves and start working out how to do structures.

 
Feb 19, 2009 12:34am
Avatar Theo Markettos (89) 443 posts

Mohsen, I’m not sure about WAIT 0. Consider the following:


INPUT "Enter number of seconds to wait:";secs%
WAIT secs%*100

If I enter ‘0’ there it’ll wait one Vsync, not 0 centiseconds. So I think WAIT 0 should be a no-op.

If you want to be really swanky it can call OS_Upcall 6 (sleep taskwindow) which has a similar effect to WAIT 0 on BBFW (but perhaps it’s better for BASIC not to call random extra SWIs).

 
Feb 19, 2009 3:02am
Avatar Steve Revill (20) 898 posts

What’s the point of PLOT <num>,<num> ? Isn’t this what the POINT keyword already does? Other stuff looks like good work.

 
Nov 25, 2010 9:30pm
Avatar Trevor Johnson (329) 1468 posts

Just wondering if there’s there any chance that the BBFW functionality work would stretch to an assembler update too.

 
Nov 26, 2010 11:37am
Avatar Terje Slettebø (285) 193 posts

It’s great that someone has been working on adding BBC BASIC for Windows functionality to ARM BBC BASIC (I wasn’t aware of this thread), as I’ve been itching to do that, myself, as I find BBC BASIC a great language for relatively simple applications, or even more elaborate ones.

One of the great advantages over C/C++ is that you don’t have to compile a program to run it, so you may iterate much faster between programming and testing, which is especially useful when exploring and experimenting with something.

I guess this is one of the reasons of the popularity of other “scripting languages”, as well, like Perl and Python, but unlike these, BASIC has actually a quite strong type system (variables are typed).

However, each time I’ve looked at the source code for BBC BASIC, I’ve shied away from it… Mind you, I’m used to reading and writing assembly code from the work on extASM, but when I took over the work on extASM, the system was well-designed in a layered structure, with well-documented subroutines (documenting entry- and exit-conditions), meaningful variable names, etc.

Unfortunately, the same can’t be said for the BBC BASIC source code… If there are subroutines there, I haven’t found a way to tell what is a subroutine, and what is merely a branch target, and the cryptic names doesn’t exactly help, either, so I’ve just had to give it up…

It’s good that someone else has been able to make some sense of it, but unfortunately, it seems the work has stalled before structures were implemented, which is a shame, as that would have been one of the more valuable additions…

Given that I haven’t been able to make sense of the BBC BASIC assembly code, lately I’ve been toying with the idea of reimplementing BBC BASIC using C++... Yes, I know there’s already an open source C version around (Brandy), but I’m not particularly fond of working with C, either, and using C++, you may work at a higher level of abstraction, and use something like Boost.Spirit for the parsing…

Had the work on the BASIC improvements mentioned in this thread been moving forward, I probably wouldn’t bother with such a rewrite, but as it appears to have somewhat stalled, then it might be something to consider, still…

Trevor: Yes, if I were to tackle this, I might be able to use extASM’s assembly engine for the reimplemented BBC BASIC assembler (adapted to work with BASIC variables, etc.), since it already supports the full ARMv7 instruction set. :) (except Thumb) (*)

Thanks for making me aware of this thread: I’ll read up on on, as well as the corresponding c.s.a.p. thread, and unless it’s clear from that, I’ll contact the author, Jonathan Graham Harston, and hear what the status is (unless he replies in this thread, that is :) ).

(*) Anyone wanting to try to incorporate the extASM assembler in the current BBC BASIC, would also be welcome to do this. I don’t think the extASM co-author Eivind Hagen would mind that we switch to a BSD-type of licence.
 
Jul 7, 2011 5:57pm
Avatar nemo (145) 434 posts

Somehow I missed this thread. I’ve done a great deal of BASIC jiggery pokery.

I’m slightly concerned about ^ as its use will be ambiguous in list operators (eg PRINT).

You can add *= and /= trivially. I also added ; as equivalent to REM for some reason.

I don’t think it’s a good idea to add keywords, as that breaks all existing editors and source processors, so I would avoid EXIT and use END instead (or consider rehabilitating GOTO – eg GOTO NEXT, though that looks more like a continue semantic. Hmm. How about STOP FOR? At least implementation is easy.)

I did quite a bit of work on making Basic go faster, including partial compilation operators such as binary format constants, and preresolved WHILE, CASE and multi-line IF constructions (so it doesn’t have to scan). The fast CASE was particularly significant for desktop applications of course.

However, one of the simplest speedups was my Celerity optimiser, which scanned the program and pre-built all the variables and PROC/FN constructions in memory so they were instantly available. Constructing these lists in most-used-first order makes a massive difference especially to large well-structured programs (MRU is a fair compromise though and rather easier).

I also did the OO stuff a long time ago (well it was my idea).

Reply

To post replies, please first log in.

Forums → Code review →

Search forums

Social

Follow us on and

Commercial use

For commercial enquiries, please contact the owners of RISC OS, Castle Technology Ltd.

ROOL Store

Buy RISC OS Open merchandise here, including SD cards for Raspberry Pi and more.

Donate! Why?

Help ROOL make things happen – please consider donating!

Description

Developer peer review of proposed code alterations.

Voices

  • jgharston (196)
  • Steve Revill (20)
  • Mohsen Alshayef (220)
  • Alex Farlie (144)
  • Theo Markettos (89)
  • Trevor Johnson (329)
  • Terje Slettebø (285)
  • nemo (145)

Options

  • Forums
  • Login
Site design © RISC OS Open Limited 2011 except where indicated
The RISC OS Open Beast theme is based on Beast's default layout

Valid XHTML 1.0  |  Valid CSS

Powered by Beast © 2006 Josh Goebel and Rick Olson
This site runs on Rails

Hosted by Arachsys