CONVERTING OLDER 68K PROGRAMS This is a section about converting older 68K executables or source-codes to the PowerPC platform. It may look very easy when you read it but we would like to note that it may get more complicated if the input-code uses complex interrupts, low-level commands, self-modifying code or multiple sections... On the other hand, many programs can be converted without any hassle. Please keep in mind that this section is written for systems running Haage & Partners' WarpOS: Although PPC680x0 supports PowerUP, no real testing has been done for this mode. It is time to switch to just one kernel instead of two, and the best of the two is definitely WarpOS. Here we go! First of all, you should get yourself a reassembler that is able to recreate all kind of codes in an efficient way, so that you can make sure everything is reassembled correctly. One of the best reassemblers around on the Amiga is Ingo Molter's 'In_Go', which is available from the Aminet. Another good one is the Maxon Reassembler supplied with Maxon Asm. Older versions may have become freeware on magazine covers so it shouldn't be a problem to get it somewhere. Using multiple reassemblers is sometimes more effective than using just one... Assume you want to convert a program to PPC: For example, you take a utility that needs to be converted. Of course, you first load it into the reassembler and save it as an assembler source-code. Make sure that all the code sections are reassembled correctly, as several reassemblers do not take care of this automatically. Also, data may not be reassembled as code! Read the manual of the reassembler before using it!!! When all this is done, you have a source-code of the program you wish to convert. Now comes the first part of the PPC680x0 conversion: Enhancing the program to make it run on a PPC. First of all, you have to find the first instruction that needs to be executed and put a 'prolog' (with the size of your stack frame) there, followed by a 'head' command. x prolog head or x prolog 16384 (if you fancy a bigger stack frame) head Then search the very last *returning* 'rts' and change it to a 'lastrts' instruction. Finally, scroll to the bottom of the file and put a 'tail' instruction there: x prolog 16384 head jsr routa jsr routb lastrts routa move.l #1,d0 rts routb move.l #2,d0 rts tail Now, go to the top of the source-code and put the incdir (include-path) and 'powerpc.i' include there, followed by a 'warpreq' command. It might be necessary to add the 'forceb' command after the 'warpreq' as well. Also, 'shiftcarry' is recommended for most source-codes. incdir ppcinclude: include powerpc/powerpc.i warpreq shiftcarry forceb x prolog 16384 head jsr routa jsr routb lastrts routa move.l #1,d0 rts routb move.l #2,d0 rts tail It may be useful to remove ALL 'section' commands as multiple sections may cause crashes after assembly with PowerAsm. (Especially when loading or storing from/to an other section occurs...) But beware: New versions of PowerAsm may have this fixed, what makes converting a lot more easier. Also, make sure there are NO double symbols. Especially '_SysBase' must be defined by PPC680x0. A '_SysBase = 4' will cause a big crash so watch out!!! Save your file away now! Okay, the most important things have been done now. The next step in the PPC680x0 conversion: Load your source-code into PPC680x0 and select a destination output-file. The default settings of PPC680x0 should be good for most current PowerPC CPUs and all current 603/604 Amiga implementations. It might be necessary (for some programs) to make a stack if you want to use an other stack pointer than r13: In that case set the stacksize to a value from which you think it should be big enough. The 40000 bytes (10000 long) default should be more than enough. Don't forget to push the 'r13' button (Button 2) for this mode! Remember: This is NOT required for most programs. Using the 'prolog' command does nearly the same but doesn't makes your source-code bigger!!! So remember: User stack-frames are usually useless for porting...! Finally, press the 'Motorola M' convert button and wait until the conversion is finished. You should now assemble your program with Storm PowerAsm or any similar assembler. Select the file you have converted: powerasm TO The output-file should be executed as documented in the WarpUp manuals. Double-clicking should be well enough for normal programs. Normally, the file is not assembled at once. PowerAsm reports some errors while assembling, and it is vital to remove those errors. Take a look at the Trial And Error section when this occurs. IMPORTANT NOTES!!! One pre-caution must be taken when converting: The execbase is detected in most cases, but there are a few exceptions to the rule. One of those exceptions is the following: move.l #$4,a0 move.l (a0),a6 This will not be detected and therefore it has to be modified by hand. It is illegal to use address $4 for this from the PPC side, so those commands should be changed from: move.l #$4,a0 move.l (a0),a6 TO: move.l _SysBase,a6 Direct loading from address $4/%100/@4/4 (with or without leading zeros), '_SysBase' or 'execbase' is always detected and does not need any assistance. Also, take care that there are no multiple symbols with different values: For example, 'label set value' should not be used multiple times using the same label but a different value. Final Note: It is always useful to take a look at the program before you start the conversion job: Interrupts and several other low-level commands are not always converted perfectly and should be modified by the user. These commands are used rarely: Usually, they are only used in very small parts of a code. Please remember that the PPC interrupt model differs a lot from the 68k model, which means that the best way to use interrupts on WarpUp is by using the 68k processor for that.