Compiling ARM BASIC from Source

discuss general risc os software applications and utilities
Related forum: adventures


Post Reply
User avatar
BeebMaster
Posts: 3645
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Compiling ARM BASIC from Source

Post by BeebMaster » Sat Sep 19, 2020 12:48 pm

I'd like to compile my own version of ARM BASIC from the source here:

https://www.riscosopen.org/content/down ... s-tarballs

I want to push up PAGE to &10000 so that it's out of the way of the copying of the host language across the Tube when using ARM BASIC on the Native ARM Pi Tube.

I think all I need to do is alter the value assigned to VARS in the Programmer.BASIC.hdr.Workspace file and then compile it again.

But I need help on how to compile, I don't know how to do it.

If I double click !Mk in the BASIC directory using my RISC PC I get "file amu_machine not found" - so it looks like I need to install something else first, and possibly have to pay.
Image

RobC
Posts: 3002
Joined: Sat Sep 01, 2007 10:41 pm
Contact:

Re: Compiling ARM BASIC from Source

Post by RobC » Sat Sep 19, 2020 1:45 pm

Might be worth asking on the RISC OS Open forums. I think you may need the Desktop Development Environment but haven't looked at the source code.

I asked about building the CDFSSoftSCSI module here (as my CD-ROM drive wouldn't work with my Pandaboard) and the help I received allowed me to build it and sort the problem.

User avatar
BeebMaster
Posts: 3645
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: Compiling ARM BASIC from Source

Post by BeebMaster » Sat Sep 19, 2020 5:04 pm

Well well! Look what I found!
scrn0.png
Looks like we're on!
Image

User avatar
jgharston
Posts: 4134
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: Compiling ARM BASIC from Source

Post by jgharston » Mon Sep 21, 2020 12:24 am

BeebMaster wrote:
Sat Sep 19, 2020 12:48 pm
I'd like to compile my own version of ARM BASIC from the source here:

https://www.riscosopen.org/content/down ... s-tarballs

I want to push up PAGE to &10000 so that it's out of the way of the copying of the host language across the Tube when using ARM BASIC on the Native ARM Pi Tube.

I think all I need to do is alter the value assigned to VARS in the Programmer.BASIC.hdr.Workspace file and then compile it again.

But I need help on how to compile, I don't know how to do it.

If I double click !Mk in the BASIC directory using my RISC PC I get "file amu_machine not found" - so it looks like I need to install something else first, and possibly have to pay.
You can't compile it, it's written in machine code, you assemble it.

Anyway, if the source bundle you're using is the same as the v1.37 source here then you need aasm in the run path, and then running !Mk will assemble everything.

In my source bundle above I had to tweek a few files to assemble correctly, as parts of it depend on the exact environment within Acorn. From memory it was just a case of *DIR'ing to the correct sirectory, and ensuring all the LINK directives use s.filename instead of filename.s

aasm in in the Library directory of the Acorn C package. Mine appears to be version 1.50 from 1990.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.32
(C) Copyright J.G.Harston 1989,2005-2020
>_

User avatar
BeebMaster
Posts: 3645
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: Compiling ARM BASIC from Source

Post by BeebMaster » Mon Sep 21, 2020 12:31 pm

Oh yes, it's written in ARM assembler, isn't it, I had in my head it was in C.

Getting a bit further now...the !Mk in the current source (1.80) is totally different, it calls amu_machine instead of aasm. So I downloaded the BASPlus source to see if I could assemble that, but I got an undefined instruction error, as I had been getting previously. Turns out the version of aasm must be corrupt, I found another copy of the file in a different directory, and double-clicking that starts the ARM Stand Alone Macro Assembler, and clicking !Mk in BASPlus successfully assembles BASIC Plus for me.

Back to my own attempt - now I'm getting the "something.s doesn't exist" errors - so I need to go through and change all these references to s.something.
Image

User avatar
BeebMaster
Posts: 3645
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: Compiling ARM BASIC from Source

Post by BeebMaster » Mon Sep 21, 2020 1:38 pm

I did that, some progress, but I think the ARM assembler doesn't like some of the mnemonics in v 1.80 of BASIC:
scrn0.png
As a proof-of-concept I altered the workspace value in JGH's BASIC Plus to see if would assemble with PAGE at &10000, and it works. Double clicking !Mk went straight through with no problems:
scrn1.png
I'm not sure what happened to the version string, however it's like that in the unmodified version!

Unfortunately BASIC Plus won't work on the Pi Tube Native ARM, it just gets stuck with a flashing cursor after the "Starting with.." message. Native ARM is a bit fussy about which versions of BASIC it will run, so maybe I'll have to track down the source for 1.35 and try again.
Image

User avatar
BeebMaster
Posts: 3645
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: Compiling ARM BASIC from Source

Post by BeebMaster » Mon Sep 21, 2020 2:20 pm

I was extremely worried when I wrote:
Mon Sep 21, 2020 1:38 pm

I'm not sure what happened to the version string, however it's like that in the unmodified version!
But it's deliberate according to this:

http://mdfs.net/Software/BBCBasic/RISCOS/BasPlus.htm
Image

User avatar
BeebMaster
Posts: 3645
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: Compiling ARM BASIC from Source

Post by BeebMaster » Mon Oct 05, 2020 10:29 pm

With help from RobC, we now have a version of ARM BASIC version 1.35 modified to set PAGE to &10000 so it is out of the way when the current language is copied across the Tube when starting the Pi Tube Native ARM co-processor. I've called it version 1.35H, for "high PAGE".

It also works on RISC OS:
BAS135H1.png
It's relocatable of course, and the exec address is load address + &10C:
BAS135H3.png
I've built it into my custom version of the Pi Tube firmware so it can be invoked with *ARMBASIC:
BAS135H5.png
PAGE is at &10000:
BAS135H6.png
And I have 256MB RAM available, (although I've only tested it up to 32MB):
BAS135H7.png
Attachments
BAS135H,ffa.zip
(33.82 KiB) Downloaded 11 times
Image

User avatar
hoglet
Posts: 9464
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: Compiling ARM BASIC from Source

Post by hoglet » Wed Oct 07, 2020 11:37 am

BeebMaster wrote:
Mon Oct 05, 2020 10:29 pm
I've built it into my custom version of the Pi Tube firmware so it can be invoked with *ARMBASIC:
Sorry for the slow response to this, I'm still catching up on stuff due to other distractions.

This looks great, and I'd like to pull this work back into the main code base.

Could you share your PiTubeDirect changes?

(Or just post a complete source zip and I'll figure them out).

The only downside is it'll make the kernel a bit larger, so slow down booting a tad. I think I can live with that, until we have a way of loading "ROMs" from the filesystem on Co Pro start-up.

Dave

User avatar
BeebMaster
Posts: 3645
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: Compiling ARM BASIC from Source

Post by BeebMaster » Wed Oct 07, 2020 11:22 pm

Yes, certainly. Only 6 source files are changed, I've attached a zip of them, just search for "ISW" in comments to see the changes:

Programs.c - contains BAS135"H" which is poked in memory at &12000000
Copro-armnative.c - increases RAM available to Native ARM to 256MB and re-selects ARM BASIC on a reset if it was active before the reset. (This doesn't work correctly - ARMBASIC is always reselected if it has been in use previously, even CTRL-BREAK. It isn't really a problem, but it isn't authentic co-processor behaviour, which should probably either return to the Supervisor prompt on a hard reset, or attempt to copy the default language across the Tube. Possibly the "Sprow method" (if known) would be the correct way to do it, or I should have found a way to clear the ARMBASIC flag on a hard reset.)
Tubecommands.c - adds *ARMBASIC to the Native ARM command set. It uses the method called by *GO to jump to the ARM BASIC exec address, which isn't necessarily the best way to do it.
Tube-defs.h - not really needed, just has an ISW identifier in the version string to distinguish it from official release
Tube-commands.h - add function to do *ARMBASIC
rpi.ld - move kernel to &13000000

Also config.txt has the kernel set to load at &13000000.

The changes to BASIC v1.35 are very minimal, literally just 2 changes to s.ModHead to set OWNERRORS to 1 and set VARS to &F800 which moves PAGE up to &10000, and VersionNum and VersionASM edited with the "H" (Hi-PAGE) suffix. RobC & I haven't been able to get a later version (I tried 1.37 and 1.80) to comp...err...assemble, the source for 1.80 is quite a bit different to 1.35.
Attachments
PiTubeDirect-gecko-dev-ISW-dev.zip
(76.38 KiB) Downloaded 5 times
Image

User avatar
hoglet
Posts: 9464
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: Compiling ARM BASIC from Source

Post by hoglet » Thu Oct 08, 2020 5:29 pm

BeebMaster wrote:
Wed Oct 07, 2020 11:22 pm
Also config.txt has the kernel set to load at &13000000.
Thanks Ian.

I've have a play with this and it's working nicely for me.

I've done some quick performance measurements, and as expected there is an issue with caching.

Before this change, CLOCKSP (Master version) runs at:
- 280 MHz on the Fast 6502
- 8677 MHz on Native ARM

After this change, CLOCKSP (Master version) runs at:
- 56 MHz on the Fast 6502
- 1260 MHz on Native ARM

What's happening is the whole of the kernel is now sitting in un-cached memory. I need to have a play with the memory layout, and ideally try to make everything cached.

So I think before we release this there are a few things to do.

1. Sort out the caching issue (most of this work is already done in another branch)
2. Add a way to exit from ARM basic (even switching Co Processors doesn't do this)
3. Not break support for 256MB Pi Models

also, fix this bug:

4. copy_programs() is only invoked from the 6502 Co Pro (as previously it only contained 6502 programs). We really need an ARM Native version to install ARM BASIC into memory. So I expected if you start directly into the Arm Native Co Pro (copro=15 in cmdline.txt) then *ARMBASIC won't work, because it is never copied into memory.

Dave

dp11
Posts: 1199
Joined: Sun Aug 12, 2012 9:47 pm
Contact:

Re: Compiling ARM BASIC from Source

Post by dp11 » Thu Oct 08, 2020 9:53 pm

Dave , if you want a chat about memory map I'm happy to help. Pi1MHz makes most of the memory cached and uses cache flushes when required. I think I have just thought of a bit more that can be cached in Pi1MHz.

User avatar
BeebMaster
Posts: 3645
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: Compiling ARM BASIC from Source

Post by BeebMaster » Fri Oct 09, 2020 4:48 pm

There's no need to keep 256MB available to the Native ARM, if it will break compatibility with older Pi models, 128MB would be way more than anyone could ever use (but it's nice to have the Native ARM bigger than my RISC PC though!)

I can't see anywhere that tests or distinguishes between a hard or soft reset, if we had that it could clear the "ARMBASIC active" flag after anything other than a soft reset. (I don't know if the Native ARM itself could call OSBYTE 253 to read the last reset type? Doing it from ARMBASIC gives the right result.)

Also it would be nice if it did a couple of VDU11 when selecting ARMBASIC after a reset to overwrite "BASIC".

QUIT just re-invokes ARMBASIC, I don't know any way out of that. Running ARMBASIC from storage QUITs back to the supervisor prompt, so it's as if the ARMBASIC exec address location has been retained and it's jumping back to it after QUIT.
Image

User avatar
hoglet
Posts: 9464
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: Compiling ARM BASIC from Source

Post by hoglet » Fri Oct 09, 2020 5:22 pm

dp11 wrote:
Thu Oct 08, 2020 9:53 pm
Dave , if you want a chat about memory map I'm happy to help.
Thanks Dominic; I've just done a bit of work and come up with something I'm happy with for now.

It's basically just a memory layout that makes more sensible use of 256MB, with everything below 240MB being cached.
BeebMaster wrote:
Fri Oct 09, 2020 4:48 pm
There's no need to keep 256MB available to the Native ARM, if it will break compatibility with older Pi models, 128MB would be way more than anyone could ever use (but it's nice to have the Native ARM bigger than my RISC PC though!)
I agree. I've fiddled with the memory map this afternoon, and ended up with 216MB available to the Native ARM Environment (and ARM Basic).

I've made a few other small fixes and pushed something back to gecko-dev for people to play with.

You can see all of the changes in this commit:
https://github.com/hoglet67/PiTubeDirec ... 0b440a?w=1

Here's it working nicely, back at full speed again.
capture3.png
BeebMaster wrote:
Fri Oct 09, 2020 4:48 pm
I can't see anywhere that tests or distinguishes between a hard or soft reset, if we had that it could clear the "ARMBASIC active" flag after anything other than a soft reset. (I don't know if the Native ARM itself could call OSBYTE 253 to read the last reset type? Doing it from ARMBASIC gives the right result.)
Yes, it is possible to call OSBYTE, so I've done that:
https://github.com/hoglet67/PiTubeDirec ... ive.c#L340
BeebMaster wrote:
Fri Oct 09, 2020 4:48 pm
Also it would be nice if it did a couple of VDU11 when selecting ARMBASIC after a reset to overwrite "BASIC".
I quite often run with BASIC disabled, so this would then overwrite something else.
BeebMaster wrote:
Fri Oct 09, 2020 4:48 pm
QUIT just re-invokes ARMBASIC, I don't know any way out of that. Running ARMBASIC from storage QUITs back to the supervisor prompt, so it's as if the ARMBASIC exec address location has been retained and it's jumping back to it after QUIT.
I've just tried that, and it seems to work now:
capture4.png
You might notice above that it's now possible to pass command line arguments onto ARMBASIC, so it can execute a named program.

I've gone back and fixed this long-standing bug in BAS135 to make this possible:
https://github.com/hoglet67/PiTubeDirect/issues/37

So this is all looking in good shape now.

Thanks for your work on this Ian, it's much appreciated. I will take a look at some of the other issues you filed.

Dave

User avatar
BeebMaster
Posts: 3645
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: Compiling ARM BASIC from Source

Post by BeebMaster » Fri Oct 09, 2020 9:07 pm

That's great! I couldn't easily see a compiled download of the latest version, so I've attached a zip of the build I just did.

Just one thing - QUIT doesn't work correctly after a soft reset, it starts ARMBASIC again.

And one thought - I'm sure this is OK though - as ARMBASIC is now stored immediately above HIMEM is it correct that the second processor memory above HIMEM is never used for screen display, it's always the host memory? And what if some program directly pokes to locations above HIMEM?

(Although I suppose the same possibility exists with a real co-pro where the language exists at &8000 or &B800 in the second processor).
Attachments
PiTubeDirect_20201009_2038_pi.zip
(2.53 MiB) Downloaded 2 times
Image

User avatar
BeebMaster
Posts: 3645
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: Compiling ARM BASIC from Source

Post by BeebMaster » Fri Oct 09, 2020 9:11 pm

BeebMaster wrote:
Fri Oct 09, 2020 9:07 pm
Just one thing - QUIT doesn't work correctly after a soft reset, it starts ARMBASIC again.
Pondering that...perhaps we also need a "there has just been a reset" flag which is set when there has been a reset, and is cleared again after testing for whether to start ARM BASIC, but before actually starting ARM BASIC again.
Image

User avatar
hoglet
Posts: 9464
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: Compiling ARM BASIC from Source

Post by hoglet » Fri Oct 09, 2020 9:29 pm

BeebMaster wrote:
Fri Oct 09, 2020 9:07 pm
Just one thing - QUIT doesn't work correctly after a soft reset, it starts ARMBASIC again.
Ah yes, that is a problem... I'll try to address this over the weekend.

A quick fix would be to clear the ARM Basic flag in the default exit handler:
https://github.com/hoglet67/PiTubeDirec ... ive.c#L117

But it this is rather making a special case of ARM Basic. It might be better to try to introduce the notion of a currently language, which is a bit more general purpose.
BeebMaster wrote:
Fri Oct 09, 2020 9:07 pm
And one thought - I'm sure this is OK though - as ARMBASIC is now stored immediately above HIMEM is it correct that the second processor memory above HIMEM is never used for screen display, it's always the host memory? And what if some program directly pokes to locations above HIMEM?

(Although I suppose the same possibility exists with a real co-pro where the language exists at &8000 or &B800 in the second processor).
There is currently no memory protection in the Native ARM Co Pro. So if an application scribbles above HIMEM and corrupts ARMBASIC or the Pi Kernel, then bad things will happen. The same thing is true of all the Beeb Co Processors - it's possible to accidentally corrupt the RAM copy of the Tube Client ROM.

The Beeb screen memory is always in host memory, never in second processor memory. But, there is some additional PiTubeDirect work (in a branch called beeb_vdu), that enables the HDMI output on the Pi, and it also imlements a VDU code driver. This will use ARM Memory from 240MB to 256MB.

Dave

User avatar
BeebMaster
Posts: 3645
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: Compiling ARM BASIC from Source

Post by BeebMaster » Fri Oct 09, 2020 10:10 pm

It's a lot faster too, I hadn't realised before. My ADFS disc imager clears a 32MB block of memory, which took a couple of minutes previously, but now it takes about 3 seconds!
Image

User avatar
dudleysoft71
Posts: 115
Joined: Tue May 26, 2020 6:56 pm
Contact:

Re: Compiling ARM BASIC from Source

Post by dudleysoft71 » Fri Oct 09, 2020 10:30 pm

I'll have to pull the latest version and test with my smacker player, I've got a 11MByte video file that should be a good test, it doesn't work very well trying to stream from the host harddrive but it should work when loaded directly into memory.

Post Reply

Return to “32-bit acorn software: other”