Tutorial 00 - Getting started
Revision as of 08:32, 2 September 2011
Before we begin, we need to have a level playing field. Now the problem is that there are all sorts of ARM development platforms, but there is no common factor in them, and in some cases playing with ARM code is tedious. For example, I can run
arm-linux-gcc on my x86 computer to compile code to copy to my ARM based PVR to run... but what a load of bother.
Therefore, the tutorials will be based upon RISC OS.
The benefits of RISC OS are as follows:
- Suitable emulators exist for Windows, Mac, and Linux machines. Sources too, if you have some esoteric box and fancy porting.
- RISC OS is an ARM based operating system. Once you are in RISC OS, you are in ARM land.
- Running ARM code is as simple as assembling and running it, right there!
- RISC OS offers many system calls to make programming fun!
- Trust me, I can get you to the point of running your first ARM code program in under five minutes. Just have a Windows PC with at least a 1.6GHz processor handy.
Your RISC OS computer
Now the best way to delve into RISC OS is to pick up a RiscPC from eBay. Or maybe an A7000 or 7000+. You can't beat running ARM on real ARM.
As I write this page, there's a StrongARM RiscPC currently up for 99p though I'm sure that'll go up a fair bit at the end of the auction time.
The next best idea is a commercial emulator. This is Virtual Acorn which offers a good solid emulation platform for Windows and Mac. It comes complete with an operating system ROM image, start-up files, etc. This is plug'n'play stuff.
The final idea is the freebie. A free emulator and a free operating system to run on it. The emulator isn't as polished as VirtualAcorn, and the OS version is "bleeding edge" so may be a bit quirky, however, it'll cost you nothing.
It can't hurt to try this - and if you are interested in what you see, Virtual Acorn is currently selling their RiscPC emulator for £49...
Here we go!
Okay, I promised you five minutes (or less) to get your first ARM program running. You give me a decent spec Windows box with broadband of some form as your workstation, and I'll give you RISC OS.
First, grab yourself a copy of RPCEmuSpoon (yes, seriously, it is called that!). The files are here and I recommend the .msi installer file - just download it and then run it to install the emulator.
Do not run the emulator!
- If you have a Mac or Linux box, there are options here for those machines, however you're on your own in these cases - I'm not particularly familiar with Linux and I know zip about Macs.
Because of copyright issues, while the most useful version of RISC OS is likely to be 3.70 (or 3.71), such ROM images are not lawfully available. You can find them, and, God help us, there's probably even Rule 34 too if you look far enough. You're on your own if you want to run an unlawful copy of somebody's ROMs...
However, there is in existence a bleeding edge port of RISC OS 5 for the older IOMD class machines. What this means in non-gobbledegook is there's a ROM image of the open source RISC OS 5 that will run on the emulator you just installed. Download it now!
Install the ROM image
The ROM image is a zip archive. Open it using the tool of your choice, be it WinZip or 7Zip or even XP's built in effort. You will see a 4MiB file called "
Click XP's Start button, go to All programs and then RPCEmu and click on the option Shortcut to RPCEmu Directory. Explorer will open showing RPCEmu's files and resources.
Open the "roms" subfolder.
Copy the "riscos" file from the archive into this roms folder.
You can now close the Explorer window, but take a moment to ponder that the entirety of RISC OS is a mere 4MiB.
Running the emulator
Click XP's Start button, go to All programs and then RPCEmu and click on the option RPCEmu Interpreter.
- The interpreter is slightly slower then the recompiler, however on my machine the recompiler kept giving DEP faults. DEP can be turned off for the emulator, but for now we'll just go with the one that works - the interpreter version.
The emulator will start up, and immediately throw an error. This is not a surprise, for the machine hasn't been configured yet. Just click the Cancel button.
You'll see a logo appear briefly saying it's an Iyonix (ho ho) and then... well... that's it. RISC OS is pretty quick to boot. Even with the complex boot structure (which you don't have), it wipes the floor with Linux, Windows, even mobile phones take longer to start up than RISC OS.
A few quick tweaks
Don't worry about what is happening, just do exactly what I say.
- Click in the emulator window to give it focus.
- Press the
F12key. This will give you a command line where everything is prefixed with a '
*'. This '
*' is like the DOS '
- Type in the following commands, pressing
Enterat the end of each line:
Configure CDROMDrives 0 Configure FileSystem HostFS Configure NoBoot
- Now go to the top of the emulator window, click the
Filemenu, then click
Reset, and wait nine seconds (eeePC 901) while the emulator resets itself.
A crash course to RISC OS
You will be looking at this:
The lower part of the screen is called the icon bar. Tasks and filesystems live here. Filesystems start on the left, towards the middle, and applications start on the right towards the middle. If the icon bar fills up, it can scroll side to side if you let your mouse pointer linger over the end you wish to scroll.
In a polar opposite to Linux and its single "/" with mount points, RISC OS takes the approach of every filing system and every partition being a separate entity. This is akin to C: and D: and E: being different, only the power and flexibility make this arrangement quite workable.
Provided on the left is "HostFS", a fake filing system that gives access to files on your harddisc (the "hostfs" folder inside RPCEmu).
To the right of that is the "Apps" repository. Long before people associated the word "Apps" with mobile phones, in fact before mobile phones even existed, RISC OS offered a special location for priveliged applications. RISC OS comes with six applications built in - an alarm clock (I wrote my own clone of this for Windows), a Character Map, a vector drawing program, a basic text editor, a help message viewer, and a bitmap painting program.
On the right, the blue egg thing hides the TaskManager to end all task managers. Seriously, Windows users should look at this and weep.
To the left of that is the DisplayManager. As you have not informed RISC OS what sort of display device you have, you are locked to a 256 colour VGA display (a safe 'default').
Your first assembler program!
- Click once on the Apps icon on the iconbar.
- In the window that opens, double-click on !Edit. The "!" prefix tells you that this is an application. It is actually a folder containing a bunch of stuff, then when double-clicked, is executed as an application.
- Notice that no window appeared. Unlike Windows, a loaded application that isn't actually asked to display something will load and sit quietly on the iconbar until required. You'll see the Edit icon has appeared down the bottom to the left of DisplayManager.
- On the Edit icon on the iconbar, press the
Menukey on your keyboard. You probably haven't used this much - it's the one with a weird menu glyph to the right of the
AltGrkey. It's a pain to have to use the keyboard in this way, however RISC OS machines use a three-button mouse, a behaviour that isn't so well supported under Windows (even if your mouse has three buttons!).
- Notice a menu pops up. Unlike pretty much every other operating system, RISC OS doesn't waste screen space with a permanent menu bar along the top of the window. It is all based around context-sensitive pop-up menus.
- The second option down is Create. Put your mouse pointer on that, and move towards the arrow on the right. A submenu will appear.
- Choose BASIC.
- A blank window titled "<untitled>" appears.
- Press the
- A save dialogue saying "BASICfile" will appear. Delete that and in its place write "$.tutorial00" and then click
- Now into the window, type the following:
DIM code% 64 FOR loop% = 0 TO 3 STEP 3 P% = code% [ OPT loop% ADR R0, message SWI "OS_Write0" MOV PC, LR .message EQUS "Awesome! My first assembler program! :-)" EQUB 10 EQUB 0 ALIGN ] NEXT CALL code%
Enterto save the file.
- Click on the HostFS icon. A window will appear listing two objects - Network and tutorial00.
- Double-click on tutorial00. Your code will be assembled, and then executed. It will look like this:
There you go. It might not look like much, but it's an ARM program!
Where to go from here?
I recommend you open Apps and double-click !Help. If you let your mouse linger over stuff, help messages will pop up. Familiarise yourself with what RISC OS looks like. There is a nice tutorial, or you might like to keep your eye on eBay for the RISC OS User Guide. 3.5 better than 3, but... It'll be a little outdated, but the principles are the same.