Latest News
!System updates

Development tools
C/C++ Tools

Writing 32-bit code
32-bit introduction
32-bit overview
32-bit technical
Memory issues
Developer tools
Paul Skirrow's Guide (PDF)
Download area

32-bit APIs
API changes
CallASWI
FileCore

RISC OS 5
Overview
BBC BASIC
CDFS driver
OS_ClaimDeviceVector behaviour
CDFS
Draw clipping
GraphicsV
HAL
Internet
UTF8 & Japanese support
International IME support
MIMEMap
Module PostInit/Final
PCI Manager
PDumper
Podules
Resource allocation
SCSI
Service Calls
UCS fonts
USB
WIMP API Changes
WIMP Flags

IYONIX pc
DDR memory
Help system
Keyboard layout
Miscellaneous
PCI slots

Opportunities

Iyonix Ltd
IYONIX home page
Contact details

   

32-bit introduction

The IYONIX pc

One of the key features of the IYONIX pc is that it uses a fast Intel 80321 processor featuring the Intel XScale microarchitecture. This is the most powerful processor to feature the ARM core and is capable of running software many times faster than older processors such as the ARM 7500 or Intel StrongARM. However, the 80321 XScale processor no longer supports the 26-bit mode that RISC OS has used since the 1980's so software needs to be converted to work in 32-bit mode.

Most developers will be keen to produce new 32-bit compatible versions of their software, but old 26-bit software that has not been converted can still be used thanks to Aemulor, a 26-bit emulator. It will not run as fast as a true 32-bit version but nevertheless most software will be quite useable. See http://www.aemulor.com for more details. If the emulator is not installed, then attempting to run 26-bit applications and modules will generate an error message (RISC OS will issue a service call to allow the emulator to run the code, but if it is unclaimed, an error message will appear).

Converting Software to 32-bit Mode

Most RISC OS applications are written in BASIC, C or assembler.

Anything written in BASIC should generally work without any problem since it is an interpreted high level language which isn't translated into ARM machine code. BASIC programs that include assembler code will need the assembler sections updating as described below.

The vast majority of the commercial RISC OS applications are written in C. The good news is that C programs can easily be converted to run in a 32-bit environment re-compiling them using the new C compiler and linking them with new 32-bit compatible libraries on the latest Acorn C/C++ CD. The new version will work on existing 26-bit versions of RISC OS as well as 32-bit versions of RISC OS.

Programs that use other compiled languages or libraries will also need to be re-compiled and linked against the new libraries. A new 32-bit version of the ABC BASIC compiler is available on the Acorn C/C++ CD and new 32-bit UnixLib libraries are also available now.

Assembler programs are more complicated as they need to be modified by hand. In particular, instructions that manipulate the Processor Status Register (PSR) in 26-bit mode (such as MOVS PC, TEQP, LDM ^ etc) will not work in 32-bit mode. If the code is only intended for ARM6 and later processors (i.e. RISC OS 3.50 onwards) then these instructions may simply be replaced by the new MSR and MRS instructions. If compatibility with ARM2 and ARM3 computers is required than more cunning code sequences are needed to achieve compatibility across the whole range of processors. There is no easy way of automating the conversion process, although the ARM Club‘s free ARMalyser tool is helpful in identifying what needs converting. This may sound difficult but the changes are actually simpler than the changes needed to make software run on the StrongARM when it was launched in 1996. If you are writing much ARM code you should obtain a copy of the latest ARM Architecture Reference Manual - see the list of recommended books.

Where it is difficult writing assembler code which works on 26-bit and 32-bit systems as well as coping with the various bugs which are present in different ARM processors it is quite acceptable to produce two separate versions and use whichever one is appropriate. This could be a run-time decision, for example an interrupt handler could branch to whichever routine is appropriate, or it could be a load-time decision, loading a suitable version of a module.

Note that whatever language software is written in it can be converted to 32-bit mode without losing compatibility with 26-bit mode. Software that is updated to work in 32-bit mode on an IYONIX pc with an Intel 80321 XScale running RISC OS 5 can still work in 26-bit mode on an Acorn Archimedes A310 with an ARM2 running RISC OS 3.10 (memory and other hardware limitations aside).

The SID disassembler on the Acorn C/C++ CD or the ARMalyser software on the ARM Club's Free software page can be useful in identifying code sequences that are invalid for 32-bit processors.

Note that it is essential that every module, whether written in C or assembler, is re-built for 32 bit use even if it is 32 bit clean and doesn't contain any illegal code sequences. This is because the flags word must be added to the module header to mark the module as being 32 bit compatible.

26-bit Mode

RISC OS was originally developed to run on the ARM2 processor which used a 26-bit address bus and combined a 26-bit Program Counter (PC) and 8-bit Process Status Register (PSR) into R15, a single 32-bit register. The same 'ARM version 2' architecture was used in the ARM3 processor and limited the system to a maximum of 64MBytes of addressable memory.

Later processors, such as the ARM6 and ARM7 used 'ARM architecture version 3' which introduced 32-bit mode and a 32-bit address bus allowing up to 4GBytes of addressable memory, but for backwards compatibility RISC OS itself and RISC OS applications continued to use the old 26-bit mode. This was quite reasonable at the time although the 26-bit Program Counter meant that all executable code had to reside in the bottom 64MBytes of memory. Since RISC OS pages applications into memory as they are needed, this restriction is not as bad as it first appears but it does result in the maximum application slot size of 28MBytes.

32-bit Mode

Since modern ARM processors do not support the old 26-bit backwards compatibility mode it was necessary to develop a new 32-bit version of RISC OS.

After Pace Micro Technology bought Acorn they used RISC OS in several of their products and updated the RISC OS kernel and many of the RISC OS modules to work in 32-bit mode. Castle Technology are now using a later version, known as RISC OS 5, on the IYONIX pc. This is based on the work that Pace did, and used under licence, but extended to provide support for additional hardware, as found on the IYONIX pc.

Detecting 32-bit Mode

To detect whether the system is running a 32-bit version of RISC OS you should use OS_PlatformFeatures 0 which returns:
    Bit 6 set    32-bit RISC OS
    Bit 7 set26-bit mode is unavailable on this platform

In assembler you can use this sequence to detect 32-bit mode:

    TEQ R0, R0    ; Set Z flag
    TEQ PC, PC    ; Set Z flag if in 32-bit mode
This works because the second operand to TEQ will include the flags in 26-bit mode, but not in 32-bit mode, whereas the first operand never includes the flags. We are therefore comparing PC with PC+PSR if in 26-bit mode, but comparing PC with PC in 32-bit mode. This will set Z in 32-bit mode but not in 26-bit mode since we know at least one bit (the Z flag) is set in the PSR. Note that the first instruction can be omitted if a flag is known to be set (eg the V flag) or if not in user mode (since one of the mode flag bits will be set).

Software Development Tools

To develop software for 32-bit versions of RISC OS and the IYONIX pc using Acorn C, ARM Assembler or the ABC BASIC compiler it is recommended that you buy the latest Acorn C/C++ Development Environment from Castle. This contains an updated version of Acorn's C compiler, linker, ARM assembler and ABC BASIC compiler which can generate code suitable for 32-bit systems. The tools may be used on existing computers to generate 32-bit code which is suitable for all versions of RISC OS from RISC OS 3.10 to RISC OS 5.00. In fact the tools themselves will all run in a 32-bit version of RISC OS so they may be used on the IYONIX pc.

If you are developing software using interpreted BASIC or the public domain GCC compiler then you should find all of the 32-bit information that you need on this web site.

Technical Documentation

Several technical documents and change logs are available in the 32bitv19a.zip file which complements the updated manuals provided on the Acorn C/C++ CD. All developers should download this file as it contains essential information and advice on converting software to 32-bit:


32bitv19a.zip

Assembler programmers should also download the latest Strong Help Assembler manual which describes all of the new instructions, such as MSR and MRS.

To see all of the files that can be downloaded go to the download area.

More Information

For a more complete introduction to 32-bit mode, the new C/C++ compiler and the issues involved in converting software you should see Paul Skirrow's guide which was originally published in Archive magazine and in a shortened form in Acorn User: This web site contains a lot of useful technical details which should enable you to prepare software for 32-bit versions or RISC OS and the IYONIX pc. In particular you should refer to:

Peter Naulls has also published his own Introduction to 32-bit RISC OS.

If you wish to work more closely with Castle Technology or develop hardware for the IYONIX pc you should apply to Castle to become a registered software developer.

Recommended Books

One or more of these books will be useful if you are writing a lot of ARM assembler.

  • ARM Architecture Reference Manual, Second Edition, edited by David Seal : Addison-Wesley, 2000, 816 pages, ISBN 0-201-73719-1. This book is also known as the 'ARM ARM' and is an essential reference for anyone working at a low level with the ARM processor, but its style makes it unsuitable as an introductory reference. It is available in PDF format free of charge from ARM upon request (ARM Doc No.: DDI-0100). It is also on ARM Technical Publications CD and the ARM Developer Suite Evaluation CD both of which can be ordered via the Documentation page on the ARM Support Site at http://www.arm.com/support/support/.
  • The ARM RISC Chip -A Programmer's Guide / A. van Someren and C. Atack - Wokingham, UK: Addison-Wesley, 1993, 400 pages, ISBN 0201624109.This is a good introduction to the ARM although the book is a little dated and doesn't cover the later architectures.
  • Archimedes Assembly Language: A Dabhand Guide, second edition, M. Ginns - Manchester, UK: Dabs Press, 1988, 368 pages, ISBN 1870336208. Out of print and difficult to obtain, but useful as it specifically refers to using RISC OS and the built-in BBC BASIC assembler.
  • ARM Assembly Language Programming / P.J. Cockerell -Computer Concepts/MTC, 1987, ISBN0951257900. Out of print and difficult to obtain but available in HTML and PDF formats on Peter Cockerell's web site.
  • ADS Assembler Guide, version 1.2 / ARM, 2001. This is also available for download from the ARM web site at: http://www.arm.com/arm/User_Guides and it is included on the ARM Technical Publications CD which is available from ARM upon request.

You will need a PDF reader to view any of the PDF documents. If you are using RISC OS you should download Colin Granville's PDF Reader. If you are using Windows you should use the Adobe Acrobat Reader.

© 2006 IYONIX Ltd 32-bit RISC OS