Adding BBFW functionality to ARM BASIC
jgharston (196) 8 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:
|
Steve Revill (20) 1361 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! :) |
Steve Revill (20) 1361 posts |
Oh, I also have a question about some of the proposed syntax (examples) on your page… you say:
and:
would these actually be more like
? |
jgharston (196) 8 posts |
It’s not proposed syntax, it’s existing syntax, see http://www.rtrussell.co.uk/bbcwin/manual/bbcwin2.html#structures eg:
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) |
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 |
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 |
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 |
jgharston (196) 8 posts |
> 10 WAIT > 20 END > gives the error “Syntax Error at line 20”. Thanks. Fixed. |
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. |
jgharston (196) 8 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? |
jgharston (196) 8 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. |
Theo Markettos (89) 919 posts |
Mohsen, I’m not sure about WAIT 0. Consider the following:
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). |
Steve Revill (20) 1361 posts |
What’s the point of PLOT <num>,<num> ? Isn’t this what the POINT keyword already does? Other stuff looks like good work. |
Trevor Johnson (329) 1645 posts |
Just wondering if there’s there any chance that the BBFW functionality work would stretch to an assembler update too. |
Terje Slettebø (285) 275 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. |
nemo (145) 2546 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). |