Native ARM PiCoPro programming

bbc micro/electron/atom/risc os coding queries and routines
Post Reply
User avatar
sydney
Posts: 2582
Joined: Wed May 18, 2005 10:09 am
Location: Newcastle upon Tyne
Contact:

Native ARM PiCoPro programming

Post by sydney » Tue Mar 31, 2020 11:51 am

I'd like to get some more use out of my PiCoPro so thought it would be a good idea to program the fastest cpu available to it - the native ARM.
I've had trouble setting up the gcc cross compiler and even with the help of RobC have come to a bit of a dead end there. This prompted me to consider learning ARM assembler. I've got BAS135 on my hard disk and it seems to work ok. I found the following example in The 'ARM Assembly Language Programming' book by Peter Cockerell .

It works fine with the ARM2 core but seems to get stuck in a loop on the native ARM.
I have literally just started to look at ARM assembly so don't know but I assume the problem is the OS doesn't know what to do with 'SWI 0' and crashes.

Are there any documents on how to get started with this anywhere?
Am I going to have to implement all the SWI calls myself to use the native ARM?
Are there better tools, preferably on the beeb, that I can use?
Am I better off sticking with the ARM2 instead of the native ARM or abandoning the ARM altogether and using the fast 6502?

Code: Select all

10 DIM org 40
20 P% = org
30 [ ;A simple ARM program
40 MOV R0,#32
50.LOOP
60 SWI 0
70 ADD R0,R0,#1
80 CMP R0,#126
90 BNE LOOP
100 MOV R15,R14
110 ]

RUN

00008FA0                 ;A simple ARM program
00008FA0 E3A00020        MOV R0,#32
00008FA4          .LOOP 
00008FA4 EF000000        SWI 0
00008FA8 E2800001        ADD R0,R0,#1
00008FAC E350007E        CMP R0,#126
00008FB0 1AFFFFFB        BNE LOOP
00008FB4 E1A0F00E        MOV R15,R14

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

Re: Native ARM PiCoPro programming

Post by hoglet » Tue Mar 31, 2020 12:02 pm

sydney wrote:
Tue Mar 31, 2020 11:51 am
It works fine with the ARM2 core but seems to get stuck in a loop on the native ARM.
I have literally just started to look at ARM assembly so don't know but I assume the problem is the OS doesn't know what to do with 'SWI 0' and crashes.

Are there any documents on how to get started with this anywhere?
Am I going to have to implement all the SWI calls myself to use the native ARM?
Are there better tools, preferably on the beeb, that I can use?
Am I better off sticking with the ARM2 instead of the native ARM or abandoning the ARM altogether and using the fast 6502?
The API of the Native ARM Co Pro is SWI based, and is based on that implemented on Sprow's ARM7TMDI Co Pro, as documented here:
http://www.sprow.co.uk/bbc/hardware/arm ... scalls.pdf

The Native ARM Co Pro is running an original version of Basic (BAS135) that itself uses many of the SWI calls. So that does I think indicate most work.

Not every SWI call is implemented, but most are. If you want to check the implementation of a particular SWI, look here:
https://github.com/hoglet67/PiTubeDirec ... swi.c#L110

SWI &00 (OS_WriteC) is definitely implemented, so should work.

Are you assembling the program from within BAS135?

How are you then invoking the program?

Dave

User avatar
sydney
Posts: 2582
Joined: Wed May 18, 2005 10:09 am
Location: Newcastle upon Tyne
Contact:

Re: Native ARM PiCoPro programming

Post by sydney » Tue Mar 31, 2020 12:23 pm

hoglet wrote:
Tue Mar 31, 2020 12:02 pm
The API of the Native ARM Co Pro is SWI based, and is based on that implemented on Sprow's ARM7TMDI Co Pro, as documented here:
http://www.sprow.co.uk/bbc/hardware/arm ... scalls.pdf

The Native ARM Co Pro is running an original version of Basic (BAS135) that itself uses many of the SWI calls. So that does I think indicate most work.

Not every SWI call is implemented, but most are. If you want to check the implementation of a particular SWI, look here:
https://github.com/hoglet67/PiTubeDirec ... swi.c#L110

SWI &00 (OS_WriteC) is definitely implemented, so should work.
Thanks for the information Dave, I'll be reading that this afternoon.
Are you assembling the program from within BAS135?

How are you then invoking the program?

Dave
Yes, I am using BAS135 to assemble it and invoking it with 'CALL org' from within BAS135. Should I save it and try running from the command prompt?

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

Re: Native ARM PiCoPro programming

Post by hoglet » Tue Mar 31, 2020 12:55 pm

sydney wrote:
Tue Mar 31, 2020 12:23 pm
Yes, I am using BAS135 to assemble it and invoking it with 'CALL org' from within BAS135. Should I save it and try running from the command prompt?
Yes, do try that.

And also, do a *DUMP of the saved file, to make sure it matches the assembly listing.

Dave

User avatar
sydney
Posts: 2582
Joined: Wed May 18, 2005 10:09 am
Location: Newcastle upon Tyne
Contact:

Re: Native ARM PiCoPro programming

Post by sydney » Tue Mar 31, 2020 2:05 pm

Success!

Code: Select all

SAVE 00008FAO +18
QUIT
*LOAD "CODE"
*GO 00008FA0
Should '*CODE' work? It didn't, nor did '*RUN CODE'.
'*CODE' also failed on the ARM2, '*RUN CODE' and *GO 00008FA0' ran differently in that it looped repeatedly on the ARM2 and ran only once on the native core.

Any idea why 'CALL org' worked from within BAS135 on the ARM2 core but not the native core, just out of curiosity?

Are there any better development tools than BAS135 available? I'm happy using it now with small snippets of code but once things get larger I'm not sure how well it'll work.

Post Reply

Return to “programming”