Path: csiph.com!weretis.net!feeder8.news.weretis.net!newsfeed.xs3.de!nntp-feed.chiark.greenend.org.uk!ewrotcd!.POSTED.chiark.greenend.org.uk!not-for-mail From: Theo Newsgroups: comp.sys.acorn.programmer Subject: Re: File type of machine code? Where does it start? Date: 20 Jun 2025 17:25:20 +0100 (BST) Organization: University of Cambridge, England Message-ID: References: <5c294dfd2cbavariasound@chiemgau-net.de> <5c29d67fbebavariasound@chiemgau-net.de> <5c2f4363e6bavariasound@chiemgau-net.de> Injection-Info: chiark.greenend.org.uk; posting-host="chiark.greenend.org.uk:93.93.131.173"; logging-data="13075"; mail-complaints-to="abuse@chiark.greenend.org.uk" User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (Linux/5.10.0-35-amd64 (x86_64)) Originator: theom@chiark.greenend.org.uk ([93.93.131.173]) Xref: csiph.com comp.sys.acorn.programmer:6525 Alexander Ausserstorfer wrote: > I created a new file in !StrongEd and saved it with file type > "application". You can change the file type while saving the file to > anywhere. Then opened the file again. It may be required to chance the > mode to 'dump'. Clicked on 'byte'. Now you can write the commands like > you wish. The last command should always be E0 F0 A0 E1. Then saved the > file and started it by a double click. You can add the command 00 00 A0 > E1 (what is doing nothing of course) before. And so on. > > I have no idea, why 'word' and 'byte' are reversed. When you click on > word, you have to write RISC OS uses the Arm chip in 'little endian' mode, where the least significant byte of a word comes first. Others have given the wikipedia link. > E1 A0 00 00 > E1 A0 F0 E0 > > of course. This is the format it is descripted in the manual of the ARM > (Arm A32/T32 Instrution Set for A-profile architecture) I have here. > > An application will always be loaded and started by RISC OS on address > &08000. This is a bit strange because RISC OS can hold different > applications at the same time in the RAM. Normally, the programs would > be overwritten when all are loaded at the same location of memory. But > between the ARM and the RAM you have the MEMC (this I grab from the PRMs 3 > - is that still the case today?). The MEMC maps the memory for the > applications and moves it to elsewhere, to a place where is free > memory. MEMC was the original chip used by RISC OS, but more generally this is the role of the 'memory management unit' (MMU) which translates virtual addresses to physical addresses. Nowadays an MMU is integrated into each processor core. Each application appears to start at a 'virtual' &8000 which is translated to some different physical address where the memory actually stores it. By changing the base of the current mapping table ('page table'), we can swap one application for another. This is called 'context switching'. > With the instruction A1 A0 F0 E0 at the end you will give the controll > back to RISC OS. It moves the address which was stored in register &E > before calling the programm, back to register &F, which is the programm > counter of the ARM. Yes, normally written in assembler as 'MOV pc, lr' - move link register to program counter. The LR holds the location where we were previously, the PC is where we are now. Setting the PC to the LR means we now jump back to where we used to be. > For this part I was looking long. It seems to me that there is no direct > introduction to that issue. But it is so fundamental. And it is very > easy to understand. You can examine an application that way, too! > > It may look a bit strange to other people to instruct the computer in > such a - I'll call it - 'hard' way. It is the direct way. It is machine > code. The problem is if you are not learning it this 'hard' way and if > you are using all the helpers (assemblers, compilers) from the beginning > on you won't learn real coding nor create an understanding in this issue. It is helpful to understand the fundamentals, I agree. > They created the Raspberry Pi to give the people cheap computers to > learn. This alone won't work, of course. You have to give the people the > information to learn, too. And I think this isn't happen. There is a lot > of publication around but nothing what may help people to understand > what's going on. It would be so helpful to have such an publication. There's Bruce Smith's book "Raspberry Pi Assembly Language RISC OS Beginners": https://www.amazon.co.uk/Raspberry-Assembly-Language-Beginners-Hands/dp/0992391628 previous version: https://www.amazon.co.uk/Raspberry-Pi-Assembly-Language-Beginners/dp/148112790X I haven't read this one, but I proof read his OS book. It was ok but a bit sloppy in places - I can't comment on this book. There are a number of other resources available, just not for RISC OS. eg Alex Chadwick did a from-scratch tutorial for learning assembler on the original Raspberry Pi: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/ While that applies to the Pi 1 and Pi Zero hardware (but not newer hardware like the 3 or Zero 2), it's running the assembler on Linux not RISC OS. So some adaptation may be needed to run the tutorials, but you can still read them either way. > I'm a bit confused by the huge amount of documentation I found about the > ARM. It seems to me that there are existing much different ARM chips > today. What are the differences? Which ones are relevant for RISC OS > today? I'm have some Raspberry Pi's and an Elesar's Titanium. Never read > about this issue. Avoid anything talking about 'Thumb' (T32) or 'aarch64'/'Arm64'/A64 as those are different instruction sets. The original ARM is now called A32 or possibly ARMv7 (or earlier numbers). ARMv8 usually means 64 bit, although it doesn't always. There are some differences between different ARM CPUs, from ARM2 to the current Cortex A-series. For a beginner under RISC OS they don't really matter. The only thing that's really important is the difference between 26-bit and 32-bit addressing. > I'm also a bit confused about the documentation. I have the Programmer's > Reference Manuals here. But they are for RISC OS 3. What was chanced in > meantime, what is still valid from them today? Never read about that issue. Others have answered the current state. 90% of the old PRM is still applicable, it's just annoying if you don't know what's been updated. The riscosopen.org wiki is quite useful there. I'd read the PRM for understanding the big picture (which mostly hasn't changed), and then consult the wiki to check if the details have changed. Theo