simple ARM assembly question
Colin McMurchie (8817) 21 posts |
All this heated debate about ARM assembly has whetted my appetite to play, but where to start? I have seen 2 tutorials. One by Rick Murrey linked to from thr Riscository site https://heyrick.eu/assembler/index.html, and one by Peter Cockerell, published by Alligata http://www.riscos.com/support/developers/armlang/index.htm. However, being new to riscos, and would like to know whether the code in iether or both of these will run on a Pi 4b. There have been so many different machine versions over time. Any advice would be appreciated, before I try and invariably error. |
David Pitt (3386) 1248 posts |
The Cockerell book is from the 26bit era but is still of some value. Not quite so cheap but much more relevant is Raspberry Pi Assembly Language RISC OS Beginners (Hands On Guide) by Bruce Smith |
Paolo Fabio Zaino (28) 1882 posts |
@ Colin McMurchie
If your goal is to learn ARM Assembly, may I ask you for what do you need it? To be clear, if you need to use it on multiple projects and also for a possible use on multiple OSes not just RISC OS (like Linux or BSD) then you may want to consider using an Assembler that works on them all. In this case I would suggest to start from GCC GAS (GNU Assembler, more info here: https://en.wikipedia.org/wiki/GNU_Assembler), it works on RISC OS, GCCSDK, Linux, BSD and other OS running on ARM. GAS syntax is slightly different than the one used on Rick’s tutorials (AFAIR), and on the Aligata book. But, as long as you stick to ARMv8 assembly code, everything should work on your Pi 4b (as long as there are no mistakes of course). If you are not familiar with what I am talking about, please have a look at this: https://www.youtube.com/watch?v=VcMyr2_SObc Here is a quick reference to GNU Assembler syntax: https://www.ic.unicamp.br/~celio/mc404-2014/docs/gnu-arm-directives.pdf This may help translating (if needed) the examples on Rick’s and the Aligata Book. Please note that the Aligata Book uses BBC BASIC Assembler, which has some powerful facilities, for example using BBC BASIC variables and functions in the Assembly code, this makes things much easier, but it’s not something you can use outside of the BBC BASIC Assembler (to be precise certainly not in the same form). There are few differences between older AArch32 and never, nothing that can’t be handled with a quick reference. oldest ARM Architecture was 26bit, there is almost nothing of that era left, except some extremely old RISC OS apps that are more for retro-computing fans and for ARM26 I would look more on the https://stardot.org.uk/forums/ than here. While you’ll be coding on RISC OS you need to understand how its SysCalls work and how to use them in your ASM code, this website has a lot of useful documentation on the matter: https://www.riscosopen.org/wiki/documentation/show/Programmer’s%20Reference%20Manuals and https://www.riscosopen.org/wiki/documentation/show/OS%20SWI%20Calls When you have learned the basics and your code works solidly in single task then you may want to deepen your knowledge and start playing with the WIMP (RISC OS Desktop environment and multi-tasking). There are tons of good books on the specific matter of ARM Assembly, but Rick’s tutorial can be very useful to combine that knowledge with RISC OS. Hope this will help you. Enjoy! |
Colin McMurchie (8817) 21 posts |
Thank you both for your quick and useful replies. David, I will look to obtain a copy of the Bruce Smith book. In the meantime I will follow the Cockerell tutorial and see how far I get. I assume the mnemonics will be similar even if the addressing space is different? Paulo, thanks for the detailed and helpful ideas. I really have no aim in mind, other than my own curiousity, and a little nostalgia. Half a lifetime ago I was a nurse teacher here in Britain and CBT was all the rage (that was Computer Based Training, we had cannabis for the other thing), so I bought my first computer, a C64. I managed to understand some 6502 assembly on that, even to the extent of programmimg the SID chip and playing tunes. That is the level I am aiming for initially. So assembly under riscos is fine for now (perhaps for ever), as is running through a basic program. Eventually who knows. Perhaps I will have a go at a roll-your-own filer %~). |