The Psion 3 FAQ

The Psion FAQ at netogram.com

8. PROGRAMMING

8.1 Overview of development possibilities

There are a number of ways in which you can program the Psion. Choose the one which fits your abilities, requirements, and budget.

8.2 OPL programming directly on the Psion

This is the most straightforward. If you can live with the cramped keyboard and screen, you can pursue this option with no further outlay, anywhere you can take your Psion.

Some alleviators:

  1. A database of the OPL commands is available from the IC archive (see section 5) which you can load into the built-in DATA application.
  2. Switching off the clock in the OPL editor will give you more active screen width. CONTROL/menu toggles this.
  3. CONTROL/Word takes you straight to the OPL editor from the system screen.
  4. Get OPP from Andy Clarkson. This is really *the* programmer's tool for programming directly on the Psion. It allows you to have exactly the same functionnalities as with Psion's S3ATRAN and even more directly on your Psion!

You can also make use of some of the data which follows in this section, so read on.

8.3 OPL programming from a PC

You can compose your OPL text files on your PC and send them down to the Psion with the link for translation, or you can obtain S3ATRAN from the IC archive (Section 5). S3ATRAN will translate your OPL source into .OPO format which you can then use the link to move to the Psion. In addition to translating simple OPL, S3ATRAN understyands a number of C-like pre-processor commands, which make source preparation easier. As well as this advantage, source preparation on a PC allows use of the full-sized keyboard and screen, use of whatever text editor you favour, convenient storage and archival of important source code, and access to printers.

For those using windows, you can use Psion's Opl Development Environment (ODE) which is a *very* nice programmer's tool for developing OPL in windows. ODE is commercial.

There is a Psion 3 emulator for the Series 3 and another one for the Series 3a, both available in the IC archive, which allows you to run OPL programs on the PC. For more details, see elsewhere in this FAQ.

The "Psionics files" are a collection of information for the OPL programmer who wants to know more than is in the programming manual, but who doesn't want the expense and effort of getting the SDK. They include general explanations of system concepts, descriptions of all the system calls usable from OPL, information about some useful device drivers, and random other useful items. Much of the information is taken from the official Psion SDK manuals, with permission. Clive D.W. Feather is widely appreciated for having taken the time to bring this information to the Psion community. You can get the latest set of files (which change quite frequently), from the WWW site. See that section in the FAQ for the address.

Psion offer Software Development Kits - "SDKs". The lowest level is the documentation-only level. This currently includes three large ring-binders which document vast amounts of detail about the Psion. Though much is of prime relevance to C programmers, a lot of essential information can be gleened by the astute OPL programmer. System calls, file formats, transmission protocols, OS structure etc. are all to be had. The SDK costs 75 UKP. See the contacts section if you want to order it.

8.4 C Development on PC

The second level of SDK (see above) is called the "Standard SDK". It includes the documentation mentioned above, and some software on floppies. The software comprises the TopSpeed C language system, an interactive Psion debugger, some customisation files, and some examples. This costs 155 UKP.

"TopSpeed C" is a general purpose development environment and C compiler. You can use it to write C programs for your PC, and the development environment allows you to add other language compilers.

Psion's customisation files taylor TopSpeed C so that it can generate image files which will run on the Psion.

The Psion debugger allows C programs to be debugged. Debugging can be done at the C source code level, or at assembly language level, or in a mixture of the two. The debugger also allows programs to be run locally on the PC in a form of Psion emulator, or run on the Psion itself through the serial link. A slew of very useful features are included in the debugger.

Psion also provide some example programs which are referenced in the manuals. Going through these with the manual is a good way to learn about the Psion and the best way to program on it. The SPY application is amoung the examples included.

It is theoretically possible to write C programs for the Psion using other compilers, but extensive expertise would be needed to avoid the pitfalls. For example, Topspeed C implements parameter passing in a way which is compatible with the Epoch operating system.

Object-oriented programming is possible in this C environment.

8.5 Advanced C Development on a PC

The highest level of SDK is the "Professional SDK". This adds the source code of various device drivers to the Standard SDK. It costs £295.

8.6 Available books (by John A Watson)

In order of complexity, the following books are available.

1) First Steps in Programming the Psion Series 3 by Mike Shaw, £14.95
ISBN 0-7457-0145-0
An introduction to the basic principles of programming.
2) Graphic Programming on the Psion Series 3 by Bill Aitken, £14.95
ISBN 0-7457-0156-6
As the title suggests this is for those interested in graphics.
3) Serious Programming on the Psion 3a by Bill Aitken, £16.95
ISBN 0-7457-0035-7 (Series 3)
ISBN 0-7457-0282-1 (Series 3a)
A complete OPL programming tutorial from basics to advanced especially graphics including sprite design.
4) Machine Code Programming on the Psion Series 3a & 3 by John Farrant, £16.95
As the title suggests this book tells you how to program in 8086 machine code and assembly language. The price/package includes a fully functional two-pass assembler with tesxt editor and debugger.
5) Introduction to Using the Psion Series 3 by Ros Lawton & Isaac Davis, £14.95
ISBN 0-7457-0146-9 14.95.
6) The 100 Most Frequently Asked Questions for You and Your Psion Series 3a & 3 by Richard Bloss & Adam Taylor, £9.95
ISBN 0-7457-0300-3

8.7 How to do various things: tips & tricks (Thanks to Andrew Baldwin for material)

1) First - reading the programming manual which came with your Psion more than once is thoroughly recommended !

2) REVTRAN - is a reverse translator available at the archive. It turns OPO modules back into OPL - though variable names may be lost. This program allows developers to see how others have implemented their programs, and this may give valuable insights into useful programming techniques. Please note that you should not use REVTRAN to circumvent protection mechanisms, to avoid paying shareware fees, to steal programs or fragments thereof, or to do anything else illegal or anti-social. Some OPL programs are protected against reverse translation.

3) SPRITES - the manual doesn't make it clear. You can have only one sprite. You must emulate any further sprite functionality in OPL.

4) MULTI-DIMENSIONAL ARRAYS - are not provided in OPL, but they can be emulated. For example, a two dimensional array: ARRAY%(X%,Y%) may be implemented by declaring ARRAY%(Z%) (where Z%=X%*Y%). You can now access element (a%,b%) as ARRAY((b%-1)*X% + a%). Each access requires arithmetic so this will incurr a speed penalty.

5) SPEED - OPL can get slow. Here are some ideas for speeding them up.

a) Where does your program spend the most time ? Find out, and concentrate on those sections. It's pointless speeding up code segments which will not impact overall speed significantly.
b) The use of floating point numbers is very slow; the Series 3 calls code which emulates a floating point processing chip. Major gains can be had if you avoid floating point numbers. Often integers can be used with a mental shift of the decimal point.
c) BUILT-IN FUNCTIONS like SIN can also be very slow. Sometimes it is preferable to build a table of answers and use a look-up strategy.
d) On the Series 3a, make use of the procedure cache, which can keep often-used procedures in memory - thereby avoiding a heavy time penalty for loading them in. On the Series 3 there is no cache to use, but you can place the procedure code inline to avoid the overhead. There will be a readability/complexity overhead to trade off.
e) Use gUPDATE to restrict screen updates, as detailed in the manual.
f) OPL allows the programmer to call machine code routines, which can be highly optimized for speed. These can be built from C programs using the SDK, or with an assembler (available in the archive). Programming at low levels requires extensive knowledge of the Series 3 Operating System. During development crashes are common, and data loss may well occur. Also note that re-implementing a code segment at a lower level will not necessarily give significant speed improvements; it depends on what the code is doing.


[ Previous Section || FAQ Contents ]

Psion Menu

Index