|
Introduction
Porting tools
Relogix
PortAsm
Mimic
Services
Downloads
|
|
There are four main ways in which code written
for one architecture (such as the 80x86 or 680x0) can be ported to run on
a different architecture (such as a POWER Architecture processor).
|
|
Software written in a high-level language such as C or
Pascal should of course be re-compiled to produce a new executable
for the target architecture, taking advantage of the latest advances
in high-performance compiler design. This may be very
straightforward, but any non-portable or system-dependent parts of
the program may need to be changed (in complex systems this can be a
non-trivial task, especially if the runtime architecture is also
different).
Of course, this assumes that a suitable compiler is available for the target architecture. If the original code was written in a non-mainstream language, or if it made heavy use of proprietary language extensions, other approaches will have to be explored. Sometimes the source code of the original compiler is available and can be modified to generate code for a different target (this approach was successfully used by MicroAPL to allow the porting of a large base of Pascal code with proprietary real-time extensions). Alternative approaches include emulation, using PortAsm to convert the output from the compiler, and using a high-level code converter to translate the original source into a different high-level language.
It used be thought that software written in assembly
language had to be re-written by hand. However, advances in automatic
assembly-language translation mean that an almost entirely
automatic translation, producing good-quality, optimized code for the target processor,
is possible. MicroAPL's PortAsm is the
leading commercial assembly-language translation tool, converting
assembly-language software so that it becomes a full `native' program
for the target architecture. Because PortAsm can analyze the original
program in detail, it is able to eliminate irrelevant side-effects of
instructions during the translation process, and can also apply block
level optimizations. In addition, it can automatically generate any
`glue' code needed to interface translated code to re-compiled
high-level code, or to the operating system/kernel.
This approach has the advantage that the translated program follows the original very closely (in particular, the code flow is virtually the same), making translation very automatic in most cases. It is also straightforward to continue to maintain the code for the original target processor, which you may need to support for some time. In this mode you keep the same source-code base, and use PortAsm rather like a compiler to generate code for the new target architecture, whilst using the original assembler to continue targetting the original processor.
Alternatively, software written in assembly language can be converted to C, using MicroAPL's advanced Relogix assembler-to-C translator. Because Relogix produces good-quality, readable, commented code in a natural C style, this approach has the advantage that the translated code can be easily maintained and developed further, and it becomes processor-independent. On the other hand, because of the fundamental architectural differences between assembler and C, more manual intervention may be required than for assembler-to-assembler translation. This is because the translation process very substantially alters the code-flow of the program (replacing internal branches with structured control constructs, and external branches with function calls). In addition, you may want to supplement the data-type and variable-naming information which Relogix automatically determines, for example by specifying your own C header files.
The software can be left in its original form (as object
code), and run under an emulator program which simulates the
instruction set of the original processor family. This option
requires no changes to the software itself, although it does incur a significant
performance penalty compared with a native (re-compiled or
translated) program. In this solution, every original machine
instruction is read, decoded, and emulated on the target
architecture; the emulator is effectively a language interpreter,
where the `language' is the instruction set of the CPU for which the
program was originally written. MicroAPL's
Mimic/68K is an example of such an
emulator program, designed specifically for the embedded market. It
allows software written for the 68000 or 68020 family to run
unchanged on POWER Architecture, MCore and MIPS processors. It does this by
reading the 680x0 code, interpreting the meaning of each instruction,
and carrying out an equivalent series of instructions in the target architecture.
Sometimes it makes sense to combine these different approaches, and therefore MicroAPL's tools are designed to work together. MicroAPL's Porting Consultancy Sevices
can help in all four areas, as well as in providing custom tools and
solutions for more difficult porting problems.
|