Helpfile for !PCR13 v.1.00

!PCR13 is for use by owners of the StrongArm-110, to
patch some applications that do not work with this processor. 

Acknowledgements:
The squeeze ,unsqueeze and CallASWI modules are copyright Acorn Computers.
The basics for the !65Host extra adaptation are from 65HostPatch, copyright 
Tim Gladding, (source: FAQlist P.R.Banks)
The idea central to !PCR13 is from J.R. Peterzon. He discovered that if
there is dynamic code on the stack, the PC jumps there with an instruction 
'MOV PC,R13'.What is constructed there often is an SWI;so change the 'MOV PC,R13'
into SWI OS_CallASWI. After this patch and to our amazement, some programs
(!Cadmust suite) now fully worked on a SA110 processor.
!PCR13 more or less automates this, ie. if it recognises the context of the
'MOV PC,R13' instruction. It recognoses 8 variations, but you can add more
(add them to the DATA lines in !pcem13.!Runimage).

Disclaimer: 
Use of this program,!PCR13 is at your own risk completely. I cannot be
held responsible for damage to or loss of your software or hardware,time etc.
Please make a backup copy of your untreated application and of the
data it uses, before trying !PCR13.

Some 'technical' background:
The SA110 has two separate caches, so if the program changes the content of a
location and then wants to execute it (code constructed on the stack,
self-modifying code), the write buffer might not have enough time to alter the 
code location. Or the code cache might not be aware  of the alteration 
at all, if this code happens to be in the code cache already.
Now there is some software written in a distant past that could not foresee the
existence of the SA with its two separate caches, and is not maintained anymore.
!PCEm,!65Host and !Cadmust are some examples. If it is still maintained you
certainly are better off with an update from the vendor, as he will have
recompiled it so it's faster and all SA-incompatibilities are removed.
!PCR13 alters some code-sequences  so that the application gets a little more 
compatible. But, do not expect miracles. There are many reasons that preclude 
success. Some problems are listed in Acorn's application note 295). Others are:
-The program might be copy-protected, as many games are. You would to have to 
extract the program from the program disk to get any further.
-The program might use its own compression system,- try the methods published 
by Chris Poole,11 october 1996,comp.sys.acorn.apps
-The program might assume the hardware of the Archimedes-series. Use !GameOn! 
before trying to get it SA-compliant.
-The program might use more complicated self-modifying code than !PCR13 is able 
to fix. 
-The program might use old modules that cause problems. Music modules are an
example of this.  Also, the application might need a (system) module, does not 
find it, loads the (old) module that comes with the application and your 
system crashes. So, look inside the application directory, update all 
modules that are too old, and alter the !Run 
file to update the version numbers to the version numbers of your updated
modules. Music modules can be found in some new tracker programs.
-The 'absolute' filetypes might be squeezed with an old version of squeeze.
Unsqueeze the file, and squeeze it again.Sometimes the author has squeezed 
his program but altered its header a little , to the effect that unsqueeze does
not recognize it anymore.
If the aplication is still supported the vendor often will send you a new version
for no or a little money. This is, of course, a lot better.

!PCR13 recognizes absolute filetypes and modules. It first unsqueezes absolute 
files, if necessary, and then searches for the code sequence 'MOV PC,R13'.
You can find these sequences yourself by loading the file into !Zap, in CODE mode,
pressing F7 and searching for 'PC,R13'. Ignore very strange pc-r13 
relationships as chances are that they are data, not code.
This (mov PC,R13) is a sign that there is code on the stack. In many cases it 
is a SWI instruction that is constructed on the stack: if the contents of 
some register is added or orred with &EF000000 it is. !PCR13 changes these 
locations to a construction with SWI "CallASWI". This is all !pcr13  does and 
surprisingly it seems to suffice for some old applications, though I did 
not test to exhaustion. For !PCEm it can also will fill in floating-point 
instructions where they are expected, instead of  EQUD 0(ANDEQ R0,R0,R0); 
(for !65Host it applies the patch needed for the RiscPC ('!65Hostpatch'))
You are right to suspect that the fix is not complete. For instance,!PCEm still 
needs to be run with *cache wi; -->! do not use Ctrl-Alt-Del  or Alt-Break !<-- 
but leave with middle mouse button. But now you can use DOS-software with 
floating-point code (I tried ECA-2, a spice-like circuit emulator, and  
TurboPascal3  TURBO87, and TP6).!Cadmust vs.1.00 and InterdictorII seem to work with cache on.

Use:
Make sure that you keep an untreated copy of your application in a safe place.
At first, use data that can do no harm if they are damaged.
Open the application directory with the (absolute and module) files to treat.
Double click on the !PCR13 icon. The files to be treated now can be dragged to
the writable text icon in the !pcr13 window. After having done so, an icon 
appears which can be dragged back to the application directory (or to an editor).
Pressing Menu over the window gives you 3 options, 'quit' and a report window.
The latter says how many code locations are patched (in words, not in 
instances, it's mostly two instances and 2-9 locations); whether suspected 
locations are left (mov pc,R13 and mov pc,Rx where x<13);whether the file was 
squeezed; whether there are floatingpoint locations (mostly 0- this is useful 
only for !PCEm, I suppose). 'MOV PC,Rx, x<13' instructions --can-- indicate
dynamic code, which is much harder to treat than !PCR13 is able to do, but it
doesn't have to - it could mean a calculated jump (eg. ADD PC,R9,R4,LSL#7 in PCEm)
The options are: to patch known 'mov pc,R13' sequences yes/no, to keep a
squeezed file squeezed, to apply the floatingpoint fill-in.
If both 'mov pc,R13->CallASWI' and 'keep squeezed' are OFF, !PCR13 can be used 
to quickly unsqueeze and resqueeze a file.
If !PCR13 reports that more than half of the code is strange, it can mean that
it is still compressed,but not with squeeze; in the case of !65Host there is no
squeezed code but the Basic and OS ROMS,ie.6502 code are included in !Runimage;
or the author tried to fool us by slightly altering the header of a squeezed file.
Here you have to make it unsqueezable, unsqueeze it, and undo your alterations.
Quitting is by clicking on the close icon or on the 'quit' menu option.
Do not forget to see if you can replace modules that come with the application,
with newer ones. In the application !Run file, replace the version nrs.
in the 'rmensure..'lines with the versions from updated modules.
If the application crashes with *cache ON, try *cache wi or *cache OFF, add 
this somewhere in the RUN file. (!PCEm still needs *cache wi).
Where needed, activate !GameOn!.
So far I got some success with:
!PCEm 1.86 -add *cache wi in the !Run file; perform floatingpoint patch;don't do
Ctrl-alt-del;quit by pressing Mouse-Menu and quit via the PCEm iconbar icon.
NortonSI: 5.4
!PCEMs - runs with *cache on; perform floatingpoint patch; NortonSI appr. 80;
however there is NO clean way to quit; so Ctrl-Shift-Break to quit;-
*rmfaster fpemulator lets you enjoy greater fp performance.I get the idea that
copying pcemmod from !PCEM 1.86 to PCEmS makes quitting slightly more civilised:
press middle mouse button and then Ctrl-Break.
Instead of these two apps, !FasterPC can be used and is fully SA-compatible, not 
to mention, of course, the various 80x86 hardware upgrades..
!65Host runs with cache on;however you can't control the speed,in the way !6502Em 
does. Most games (except chess..)are unplayably fast.!65Host is e.g.in the Acorn
-->Riscos-->Releases-->RO310--App2-->directory on the Acorn User 3 cdrom. For
games in particular,!6502Em from WSS is a very recommendable alternative!
!cadmust vs.1.00 - do all applications inside the !cadmust directory, also 
libmod 1.40. 
!Interdictor II: treat the 'fly' file. Runs with cache on.
!Warjet treat the !fly file. cache on.
!mig29 seems to run OK. (did not try it myself).cache on.
!pipedream demo on the Arm club cd: nibble off the first 128 bytes from !runimage,
treat, reattach the first 128 bytes.Treat all other modules and apps..cache on
!hearsay: seem to run OK after treating all modules and runimages in the
 package.Note there is an update available from Beebug.
Good luck!
Jan De Boer 
jandboer@worldonline.nl
