ARM programming for Risc OS

RISC OS was the operating system of the Acorn Archimedes... although the machine is long since dead, RISC OS has survived and ported to modern machines like the Raspberry Pi

In these tutorials we'll be testing with Risc OS 3.57 - which is the OS of the successor of the Archimedes, but where possible we'll try and support the classic RiscOS 2... and we'll be using instructions compatible with ARM2 for backwards compatibility!

These tutorials use the VASM assembler


Acorn Archimedes versions


A3000 A5000 RISC PC
CPU 8mhz ARM2 25 mhz ARM3 30mhz ARM 610
Memory 1 MB 1-8 MB ?
OS RISC OS 2 RISC OS 3 Risc OS 3.5 - 4.03

If you want to learn ARM get the Cheatsheet! it has all the ARM7 commands, it covers the commands, and options like Bitshifts and conditions as well as the bytecode structure of the commands!


Resources

RPCEMU - Risc OS emulator
Rom Images - Images for RISC OS


Executable files
The easiest way to create a program is save it as a FF8.... eg 'prog,ff8'... NOTE: this is a COMMA before ff8 not a full stop - this is how RISC OS denotes file type

Our program just needs to start from 0x8000 and it will work fine!... please note, you'll need to create your own stack area and define a stack pointer if you need the Stack, as the OS doesn't create one!

The Example Hello World to the right will compile correctly with VASM
.org  0x08000    
    SWI 01                    ;OS_WriteS
    .ascii "Hello World!"
    .byte 0                   ;End of string
    .align 4
   
     MOV R0,#0                ;0=No Error
     SWI 0x11                 ;OS_Exit
We can also create a !Run,feb to autostart the program with the emulator,  we RMEnsure UtilityModule 3.10 Error This !Boot structure is only suitable for RISC OS 3.1 or later
Set Boot$Dir <Obey$Dir>
Set Boot$Path <Boot$Dir>.
desktop prog

Using Risc OS
When using Risc OS, you will often want the options on a file... to get this use the MIDDLE MOUSE button
You can get a command prompt by pressing CTRL-F12, or selecting Task Window by middle clicking on the Acorn icon

The commands you can use are known as Star Commands... there is a list of them here

VDU Commands
Many screen functions are performed via 'VDU Commands'... to use these, we just write special character codes to the screen with SWI 0
Page Meaning Parameters Example
VDU 0 Does nothing 0
VDU 1 Sends next character to printer only 1,c
VDU 2 Enables printer 2
VDU 3 Disables printer 3
VDU 4 Writes text at text cursor 4
VDU 5 Writes text at graphics cursor 5
VDU 6 Enables VDU driver 6
VDU 7 Generates bell sound 7
VDU 8 Moves cursor back one character 8
VDU 9 Moves cursor on one space 9
VDU 10 Moves cursor down one line 10
VDU 11 Moves cursor up one line 11
VDU 12 Clears text window 12
VDU 13 Moves cursor to start of current line 13
VDU 14 Turns on paged mode 14
VDU 15 Turns off paged mode 15
VDU 16 Clears graphics window 16
VDU 17 Defines text colour 17,color
VDU 18 Defines graphics colour 18,maskmode,color
VDU 19 Defines logical colour 19,color,mode,r,g,b 19,0,16,255,128,0
VDU 20 Restores default logical colours 20
VDU 21 Disables VDU drivers 21
VDU 22 Selects screen mode 22,ScreenMode 22,9
VDU 23 Multi-purpose command: n,n,n,n,n,n,n,n,n
VDU 23 Sets the interlace and controls cursor appearance ?
VDU 23 Controls text cursor appearance ?
VDU 23 Defines ECF pattern and colours ?
VDU 23 Sets dot-dash line style ?
VDU 23 Scrolls text window or screen ?
VDU 23 Clears a block of the text window ?
VDU 23 Sets first flash time ?
VDU 23 Sets second flash time ?
VDU 23 Sets default patterns ?
VDU 23 Defines simple ECF patterns and colours ?
VDU 23 Controls cursor movement after printing ?
VDU 23 Sets the tint for a colour ?
VDU 23 Chooses ECF patterns ?
VDU 23 Exchanges text foreground and background colours ?
VDU 23 Sets ECF origin ?
VDU 23 Sets character size/spacing ?
VDU 23 Reserved for future expansion ?
VDU 23 Private Font Manager calls ?
VDU 23 Private Sprite Manager calls ?
VDU 23 Reserved for use by application programs ?
VDU 23 Redefines printable characters ?
VDU 24 Defines graphics window 24,x1,y1,x2,y2
VDU 25 PLOT command 25,x,y
VDU 26 Restores default windows 26
VDU 27 Does nothing 27
VDU 28 Defines text window 28,x1,y1,x2,y2
VDU 29 Defines graphics origin 29,x,y
VDU 30 Homes text cursor 30
VDU 31 Moves text cursor 31,x,y
VDU 127 Delete 127

SWI commands
SWI's are systems calls to the operating system... many SWI's were added in later operating system versions, so ensure you only use SWI's that exist on the version you want to support.
OS Ver Number Name Function
2 &00 OS_WriteC Write Character R0 to Screen
2 &01 OS_WriteS Write 0 termniated string to screen – string follows SWI in code
2 &02 OS_Write0
2 &03 OS_NewLine
2 &04 OS_ReadC
2 &05 OS_CLI
2 &06 OS_Byte
Index of OS_Bytes

2 &07 OS_Word
Index of OS_Words

2 &08 OS_File
2 &09 OS_Args
2 &0A OS_BGet
2 &0B OS_BPut
2 &0C OS_GBPB
2 &0D OS_Find
2 &0E OS_ReadLine
2 &0F OS_Control
2 &100-1FF OS_WriteI
2 &10 OS_GetEnv
2 &11 OS_Exit Return to OS… R0=Errorcode (0=no error)
2 &12 OS_SetEnv
2 &13 OS_IntOn
2 &14 OS_IntOff
2 &15 OS_CallBack
2 &16 OS_EnterOS
2 &17 OS_BreakPt
2 &18 OS_BreakCtrl
2 &19 OS_UnusedSWI
2 &1A OS_UpdateMEMC
2 &1B OS_SetCallBack
2 &1C OS_Mouse
2 &1D OS_Heap
OS_Heap (5a)

2 &1E OS_Module
2 &1F OS_Claim
2 &20 OS_Release
2 &21 OS_ReadUnsigned
2 &22 OS_GenerateEvent
2 &23 OS_ReadVarVal
2 &24 OS_SetVarVal
2 &25 OS_GSInit
2 &26 OS_GSRead
2 &27 OS_GSTrans
2 &28 OS_BinaryToDecimal
2 &29 OS_FSControl
OS_FSControl 55

2 &2A OS_ChangeDynamicArea
OS_ChangeDynamicArea (5a)

2 &2B OS_GenerateError
2 &2C OS_ReadEscapeState
2 &2D OS_EvaluateExpression
2 &2E OS_SpriteOp
Changes to OS_SpriteOp
OS_SpriteOp 17

2 &2F OS_ReadPalette
2 &30 OS_ServiceCall
OS_ServiceCall (5a)

2 &31 OS_ReadVduVariables
2 &32 OS_ReadPoint
2 &33 OS_UpCall
2 &34 OS_CallAVector
2 &35 OS_ReadModeVariable
OS_ReadModeVariable (5a)

2 &36 OS_RemoveCursors
2 &37 OS_RestoreCursors
2 &38 OS_SWINumberToString
2 &39 OS_SWINumberFromString
2 &3A OS_ValidateAddress
2 &3B OS_CallAfter
2 &3C OS_CallEvery
2 &3D OS_RemoveTickerEvent
2 &3E OS_InstallKeyHandler
2 &3F OS_CheckModeValid
OS_CheckModeValid (5a)

2 &40 OS_ChangeEnvironment
2 &41 OS_ClaimScreenMemory
2 &42 OS_ReadMonotonicTime
2 &43 OS_SubstituteArgs
2 &44 OS_PrettyPrint
2 &45 OS_Plot
OS_Plot (5a)

2 &46 OS_WriteN
2 &47 OS_AddToVector
2 &48 OS_WriteEnv
2 &49 OS_ReadArgs
2 &4A OS_ReadRAMFsLimits
2 &4B OS_ClaimDeviceVector
2 &4C OS_ReleaseDeviceVector
2 &4D OS_DelinkApplication
2 &4E OS_RelinkApplication
2 &4F OS_HeapSort
2 &50 OS_ExitAndDie
2 &51 OS_ReadMemMapInfo
2 &52 OS_ReadMemMapEntries
2 &53 OS_SetMemMapEntries
OS_SetMemMapEntries (5a)

2 &54 OS_AddCallBack
2 &55 OS_ReadDefaultHandler
2 &56 OS_SetECFOrigin
2 &57 OS_SerialOp
OS_SerialOp (5a)

2 &58 OS_ReadSysInfo
OS_ReadSysInfo (5a)

2 &59 OS_Confirm
2 &5A OS_ChangedBox
2 &5B OS_CRC
3 &5C OS_ReadDynamicArea
OS_ReadDynamicArea (5a)

3 &5D OS_PrintChar
3 &5E OS_ChangeRedirection
3 &5F OS_RemoveCallBack
3 &60 OS_FindMemMapEntries
3 &61 OS_SetColour
OS_SetColour (5a)

3 &64 OS_Pointer
3.5 &65 OS_ScreenMode
3.5 &66 OS_DynamicArea
2 &68 OS_Memory
2 &69 OS_ClaimProcessorVector
3.5 &6A OS_Reset
3.5 &6B OS_MMUControl
2 &C0 OS_ConvertStandardDateAndTime
2 &C1 OS_ConvertDateAndTime
2 &D0 OS_ConvertHex1
2 &D1 OS_ConvertHex2
2 &D2 OS_ConvertHex3
2 &D3 OS_ConvertHex4
2 &D4 OS_ConvertHex8
2 &D5 OS_ConvertCardinal1
2 &D6 OS_ConvertCardinal2
2 &D7 OS_ConvertCardinal3
2 &D8 OS_ConvertCardinal4
2 &D9 OS_ConvertInteger1
2 &DA OS_ConvertInteger2
2 &DB OS_ConvertInteger3
2 &DC OS_ConvertInteger4
2 &DD OS_ConvertBinary1
2 &DE OS_ConvertBinary2
2 &DF OS_ConvertBinary3
2 &E0 OS_ConvertBinary4
2 &E1 OS_ConvertSpacedCardinal1
2 &E2 OS_ConvertSpacedCardinal2
2 &E3 OS_ConvertSpacedCardinal3
2 &E4 OS_ConvertSpacedCardinal4
2 &E5 OS_ConvertSpacedInteger1
2 &E6 OS_ConvertSpacedInteger2
2 &E7 OS_ConvertSpacedInteger3
2 &E8 OS_ConvertSpacedInteger4
2 &E9 OS_ConvertFixedNetStation
2 &EA OS_ConvertNetStation
2 &EB OS_ConvertFixedFileSize
2 &EC OS_ConvertFileSize

 

View Options
Default Dark
Simple (Hide this menu)
Print Mode (white background)

Top Menu
Youtube channel
ASM Programming Forums
GitHub
Dec/Bin/Hex/Oct/Ascii Table

Z80 Content
Learn Z80 Assembly
Hello World
Advanced Series
Multiplatform Series
Platform Specific Series
ChibiAkumas Series
Grime Z80
Z80 Downloads
Z80 Cheatsheet
Sources.7z
DevTools kit
Z80 Platforms
Amstrad CPC
Elan Enterprise
Gameboy & Gameboy Color
Master System & GameGear
MSX & MSX2
Sam Coupe
TI-83
ZX Spectrum
Camputers Lynx

6502 Content
Learn 6502 Assembly
Advanced Series
Platform Specific Series
Grime 6502
6502 Downloads
6502 Cheatsheet
Sources.7z
DevTools kit
6502 Platforms
Apple IIe
Atari 800 and 5200
Atari Lynx
BBC Micro
Commodore 64
Super Nintendo (SNES)
Nintendo NES / Famicom
PC Engine (Turbografx-16)
Vic 20

68000 Content
Learn 68000 Assembly
Platform Specific Series
Grime 68000
68000 Downloads
68000 Cheatsheet
Sources.7z
DevTools kit
68000 Platforms
Amiga 500
Atari ST
Neo Geo
Sega Genesis / Mega Drive
Sinclair QL (Quantum Leap)
X68000 (Sharp x68k)

My Game projects
Chibi Aliens
Chibi Akumas

Work in Progress
Learn 6809 Assembly
Learn 65816 Assembly
Learn 8086 Assembly (x86)
Wonderswan
MsDos
Learn ARM Assembly
Gameboy Advance
Risc Os

Misc bits
Ruby programming




If you want to support my work, please consider backing me on patreon!


Buy Chibi Akuma(s) from PolyPlay
Buy ChibiAkuma(s) games now!