RISC World

32bit Conversions

A programmers tale by Michelle Kate

There is nothing new in one software company buying the rights to a product from a defunct company or a company that no longer wants to support a specific platform. It happened frequently throughout the 1980s when one ZX Spectrum software company would go under, only for the rights to be bought by another (for instance, Ocean bought Imagine, but sold the software right to Melbourne House who later sold these rights onto Mastertronic and so it goes on).

This sort of thing also happened in the 1990s, but mainly on the PC platform. In the early 2000s, with the our own platform in danger of disappearing, APDL/ProAction began to buy up the rights to the titles from former RISC OS companies and selling them through APDL. While it was not exactly earth shattering, it did enable people to get hold of software which had previously vanished. With a few modifications it was possible to get most products to work on the StrongARM RiscPCs and OS 4 machines.

Then came the Iyonix and the push to a new 32 bit RISC OS and this has caused a bit of a problem.

The problem is simple, a lot of the applications purchased did not come with the source code, making 32bit conversions rather expensive. Additionally some of the applications had already undergone a number of modifications that did not require the source code (such as the changes made to the EasyC++ package), to make these products 32 bit would require a large amount of work.

Fortunately, this was not the case when APDL bought up the sources and packages from Clares Micro Supplies.

First things first

I had been supplied by APDL with the sources to the Clares version of RISC_OSLib, Schema2, Schemex and WimpBasic2. Rather than try to do everything at once I needed to know if the sources would compile without too many problems. RISC_OSLib did. However that's where the good luck stopped.

WimpBasic2 had a couple of problems. The main one being that the dependencies could not be fully met. I had not been supplied with one of the libraries required to compile the application. Eventually, the original author told me that he had never supplied the original sources to Clares and that they had only ever had the linkable object.

Eventually, I was sent the old linkable object, but with a number of functions not prototyped from within the main sources. Once these were resolved, the application, linker and module compiled. Next came compiling Schema and its bits. What a disaster!

I spent an entire working day just getting the source code to compile. The reason was quite simple, some functions being used had not been prototyped or had been prototyped, but the header they were prototyped in was not included. This was further complicated by the source code not being in the typical c and h directories, but branched off into further subdirectories.

After many hours sorting out the prototypes, headers and a few small bugs along the way, Schema2, Schemex and Macroedit finally compiled.

Going 32bit

The first thing to do was ensure that any assembler used was 32 bit clean. That meant removing all MOVS lr,pc lines (this would become MOV) as well as returning out of a function with the ^ set at the end of the LDM line or any other 32 bit no-nos. Here I found the advice on invaluable. Luckily not too much had to be changed, which is good as my assembler skills are not that amazing.

Recompilation was through the makefiles.

To get the code to compile as 32 bit, the following flags were added to the CCFLAGS line

     -apcs 3/32bit/fpe3

And to the objasm lines:

     -apcs 3/32

And finally, for the module:


Although this was not really required as the 32 bit version of cmhg defaults to that flag.

I also had to do this with RISC_OSLib as the stubsg version has missing headers and the Castle one required a bit of patching for the Clares software to work fully.

One final obstacle remained, the object file sent from the original WimpBasic author. This was definitely 26 bit only and 32 bit unsafe. I went through the AOF file by hand removing all of the unsafe code and replacing it with the 32 bit clean code. Finally everything was go! Schema2, Schemex, Macroedit and WimpBasic2 were now all 32 bit clean.

However a sting in the tail awaited...

There is always a problem when you're using a version of a library which has been played with so much. RISC_OSLib has to be one such beast. While most who have the Acorn C package (irrespective of which version) or EasyC++ will have a precompiled version, registered developers and a few others had a full source code release.

In theory, they could add their own parts, create minimal library versions and fix the bugs which had been in there. This is nice in theory but in fact is a recipe for disaster.

While I'm not saying that every developer made a muck of it (which is obvious from the number of commercial developers who have released software linked to their own versions of RISC_OSLib) there were a couple of good muck ups in the version supplied to me.

The first was that the iconbar menu did not have the program name on it. That was quite a fun one to find. It didn't take too long as I had a different version of the source code to compare it to.

The second was a problem which had shown up in that the maximum available wimpslot would be taken. That could mean a simple 28k wimpslot program would take the full 28Mb. Again it was a problem in RISC_OSLib, where it had been altered so that the wimpslot was not using the parameters passed in. As soon as this was fixed, the code used the correct size wimpslot.

The very final thing prior to testing was to add the following lines to load the 32 bit modules into the !Run file.

That done, the apps were sent back with new version numbers, bug fixes ready for testing.

The Moral of the story

Next time you hear the line "it's very simple to 32 bit an application" think again. Yes, it is simple to do if the source is your own and you know that there is nothing in there which is assembler (or if there is assembler, that it is already 32 bit clean). It is not simple to do if you inherit the source code with no documentation, without all of the source code and any of the other problems I've detailed here.

The 32 bit versions of Schema2 and WimpBasic2 should be available at the South East show.

Michelle Kate