BBC BASIC with VFP/SIMD assembler 0.01
Pages: 1 2
Alan Peters (515) 51 posts |
Today we have released an Alpha test version of BBC BASIC with the VFP/SIMD assembler. Further information is available in the post on the TBA website. We will continue testing the assembler as part of the ongoing TAG development and will submit the code for potential inclusion into CVS in due course. Other plans for BBC BASIC are on hold as the legacy source code does not make it at all easy to enhance the BASIC language. We are considering other options. |
Jeffrey Lee (213) 6048 posts |
Nice work! Now if only I had the time to write something that makes use of this ;-) |
Trevor Johnson (329) 1645 posts |
Wahay!
Is Brandy BASIC worth looking at?[1] [2] (Note that the built-in assembler is not included.) Has anyone tried this on the BeagleBoard? The code doesn’t seem to have been touched for a few years and it would perhaps be too slow for your purposes anyway, Alan. |
Alan Buckley (167) 232 posts |
It’s probably a dumb idea, but have you thought of looking at what it would take to port Mono to RISC OS. If it was possible it would allow you to write program in Visual Basic for RISC OS. |
Andrew Rawnsley (492) 1445 posts |
Given that an ARM port of Mono exists, it certainly looks like something that might be worth pursuing, although reading between the lines, it may be pretty slow/cumbersome (but that seems par for the course with non-RISC OS/Phone stuff on ARM cpus). The lack of cross-platform development options in the 90s ended up being a major problem for Acorn (their lack of Java/Macromedia Director development progress). However, the problem (as always) is finding people to work on the project :( |
nemo (145) 2546 posts |
Brandy Basic? Nah. Mono is a good idea, though not specifically for Visual Basic.
You should try working with no source at all mate. ;-) I was pretty horrified when I finally saw the Basic source though. Yeah, look at that, the insides of Replay and ChangeFSI and your faith can waver slightly. :-p |
Alan Peters (515) 51 posts |
Sure, well in my 20 years of working as a developer I’ve pretty much tried it all when it comes to reverse engineering and hacking around old code. Sometimes it’s easier just to read the dis-assembly as the source can be horribly confusing when very badly constructed! More important than all that is a big dose of realism in what can be achieved when we all work on this thing part time, which is perhaps where Andrew was leaning as there are very few people actually working on anything major. On that very note, while I admire the optimism that we could just “port” something like Mono, there are a lot of missing pieces of the underlying operating system that make this kind of port a very large challenge…
Nice! |
Andrew Rawnsley (492) 1445 posts |
IIRC didn’t Martin make some progress on the pthreads front in years gone by, Alan? |
Steffen Huber (91) 1953 posts |
IIRC, Martin Piper’s work on pthreads was initially used as a base for the UnixLib implementation. Not sure how much of it survived in the end, I remember discussions about a whole bunch of problems. Anyway, I think pthreads support is now mature in UnixLib. |
Alan Peters (515) 51 posts |
An update to the VFP assembler (0.02) has been released that fixes a few bugs. I’ve been discussing threading with Martin and a few other people after reviewing all the previous forum posts here on the subject. When we have something to report I’ll start a new thread as it’s too large a subject for this thread on the VFP assembler. |
Alan Peters (515) 51 posts |
Version 0.03 released today with a few more bug fixes and minor enhancements |
Kuemmel (439) 384 posts |
Great work. Finally I could port my VFP Mandelbrot version from ExtASM to your enhanced Basic Assembler. It can be found here: FracVFP_Basic |
W P Blatchley (147) 247 posts |
Something that’s just occurred to me that perhaps someone here can answer: When you extend the BASIC assembler, is each new mnemonic given a unique token number? Indeed, is assembler tokenised in the same way as normal keywords? And if so, who, if anyone, is in charge of allocating the token numbers? |
Alan Peters (515) 51 posts |
The short answer is no, tokens are not added or used. Problems only occur when a keyword starts with an existing token. Tokens are not used part way through a keyword as it might well be a variable name. For example VMOVEQ would not contain V followed by the token for “MOVE”, where as the ARM instruction MOVEQ would contain the token for MOVE followed by a Q. With VFP there was only VDUP that caused problems as it started with the token for VDU. It was made worse as VDUP.16 ended up being changed to VDUPRINT16 so in this case I changed it to VDPL to work around the problem. The VFP assembler code uses some simple string matching to look for mnemonics, and for VFP they all start with at least 4 chars making it a very simple task. As has been stated in another thread, adding tokens is generally a bad idea as it tends to break lots of things, particularly code editors. I’m certainly not aware of any “authority” on tokens, my guess is they just exist in various large tables in the BASIC source code and the tokenise / detokenise code. |
W P Blatchley (147) 247 posts |
Thanks, Alan. So, no assembler commands are tokenised at all? “MOV” is just “M”, “O”, “V”? I’d naively assumed that they would be… |
Ben Avison (25) 445 posts |
I’m sure the assembler can currently cope with MOVEQ though (the original ARM opcode, not the VFP one) without mistaking it for MOVE + Q. Can you not copy the way it handles that for VDUP? |
nemo (145) 2546 posts |
It’s much worse than that. Individual token numbers are woven throughout the code and used for state representation in various memory and stack structures. Specific tokens are checked for in many places (ELSE is particularly ubiquitous). However, the simplest argument against adding ANY new keywords is backwards compatibility – you may think that “RESUME” might make a good keyword, but if so, any program containing a “RESUMES” variable can never be edited again. (Anyone using all-capital variables in BBC BASIC ought to be shot).
It certainly does cope, but only once it has been tokenised to MOVE,“Q”. EOR,anything and OR,“R” are similar. |
Alan Peters (515) 51 posts |
The problem is the P. not the VDU. It makes VDUP.16 expand to VDUPRINT16 when you save it from a text editor. VDU is a token and P. is short for PRINT which is also a token, so you end up with two tokens in the BASIC file. |
Kuemmel (439) 384 posts |
I managed to port the NEON code from my Mandelbrot application from ExtASM to your Basic Assembler. No more problems occurred with your Version 0.03 :-) You can find the applications here: Frac_NEON_VFP_Basic It includes also the enhanced VFP version. I included the CPU clock detection in my code done by Jeffrey (hope it’s okay…) and some results display stuff. Any comments welcome. Time to start more NEON coding :-) |
Alan Peters (515) 51 posts |
That’s fantastic, it’s great to hear it’s being used. It seems we might be edging towards a release 1.0 that gets checked in to CVS (not that I have access yet!) although I expect there must be a few more bugs lurking. I’m also considering adding all the other missing ARM instructions from the ARMv7 manual. Also the help text needs updating and that’s all a bit messy. Within TBA we’ve not actually used the new instructions much. Our NEON based 3D calculation engine is currently only a design, with some BASIC prototyping to test concepts. Hopefully it will get some time allocated in the not too distant future. I’m currently reading through some of the RISC OS Kernel code trying to get my head around some of the concepts and challenges relating to threading in particular. My knowledge of the ARM architecture is lacking as I’ve never looked at things at such a low level. |
Jan Rinze (235) 368 posts |
Since all upper case key words are tokenised in BASIC perhaps switching to lower case for assembler is a reasonable option? |
Jan Rinze (235) 368 posts |
To emphasize the difference between the use of tokenisation and assembler, tokens are used to optimize speed where as assembler is used only once during the conversion of assembler to code. In that respect the move to lower case assembler statement seems more logical too. |
Kuemmel (439) 384 posts |
Regarding that, do you use fixed point or floating point math for the 3D stuff ? You may have noticed that there’s no real native SQRT or SIN/COS for NEON. At the moment I’m testing different routines found on the web dealing with that. For SQRT there are useful instructions that minimize the work (VRECPE/S and VRSQRTE/S), but for SIN/COS there’s a need for a decent approximation. |
Kuemmel (439) 384 posts |
To show the different approaches for SQRT and results I coded a small example comparing NEON, VFP and FPA/FPEmu. You can find it here: SQRT_variants You can see that the approximation for NEON produces a small slight difference at one digit, but still may be good enough…I’m not really a mathematician to judge that in total…for sure there are other approaches for approximation, and I guess at least in the latest ARM GCC there must be some in the math libraries. |
Alan Peters (515) 51 posts |
The 26bit version of TAG used integer maths and was all limited to 32bits. So there was around 22bits of accuracy for most operations. For TAG32 we’ve been looking at both 32:32 fixed precision and double float, depending on the performance we see when we get it up and running. Currently I am leaning towards using double floats for accuracy, and because the NEON/VFP in the Cortex A15 will (according to ARM at least) be faster than what we have today. This is one reason why we’re also looking at threads as it’s handy to use the multiple cores as rendering pipelines (sub-setting the screen and aspects of the scene). |
Pages: 1 2