Re:Machine language and assembler translators?

"Robert Thorpe" <Robert.Thorpe@antenova.com>
22 Jul 2005 20:20:31 -0400

          From comp.compilers

Related articles
[3 earlier articles]
Re: Machine language and assembler translators? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2005-06-23)
Re: Machine language and assembler translators? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2005-06-26)
Re: Machine language and assembler translators? vtsikoza@yahoo.com (2005-06-30)
Re: Machine language and assembler translators? jcrens@earthlink.net (Jack Crenshaw) (2005-07-17)
Re: Machine language and assembler translators? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2005-07-22)
Re: Machine language and assembler translators? toby@telegraphics.com.au (toby) (2005-07-22)
Re:Machine language and assembler translators? Robert.Thorpe@antenova.com (Robert Thorpe) (2005-07-22)
Re: Machine language and assembler translators? peter.jinks@manchester.ac.uk (Pete Jinks) (2005-07-22)
Re: Machine language and assembler translators? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2005-07-26)
Re: Machine language and assembler translators? Martin.Ward@durham.ac.uk (Martin Ward) (2005-07-26)
Re: Machine language and assembler translators? haberg@math.su.se (2005-07-28)
Re: Machine language and assembler translators? jjk@acm.org (Jens Kilian) (2005-07-28)
Re: Machine language and assembler translators? pohjalai@cc.helsinki.fi (A Pietu Pohjalainen) (2005-07-28)
[1 later articles]
| List of all articles for this month |

From: "Robert Thorpe" <Robert.Thorpe@antenova.com>
Newsgroups: comp.compilers
Date: 22 Jul 2005 20:20:31 -0400
Organization: Compilers Central
References: 05-06-103 05-07-076
Keywords: translator
Posted-Date: 22 Jul 2005 20:20:31 EDT

Jack Crenshaw wrote:
> I have built translators like this for machine/assembly language, with
> mixed results. Yes, it can be done. But it won't be efficient code.
>
> At the most primitive level, you can look at each instruction of the
> "source" processor, and see how best to make the CPU do _EXACTLY_ the
> same thing in the "target" processor. Once you have a translation of
> each instruction, it's a simple matter to write a text processor that
> will make the necessary substitutions. I've even been known to do it
in
> the macro language of a good editor.


The original 8086 came with a utility to convert 8085 code into 8086
code.
I believe it worked by simple substitution like you describe.


> As both John and Vit point out, your results will depend a lot on the
> similarity between the two processors. Translating, say, the assembly
> language of one RISC machine to another one is a piece of cake, and
> gives good results. Translating between families is a lot harder.


It depends. If the target processor has many more registers than the
source processor then it's not as difficult.


When DEC supported Windows on the Alpha they provided a program called
FX!32 that translated x86 Windows programs statically into Alpha
programs.
The alpha has far more registers than an x86 does which probably helped.


FX!32 achieved reasonable performance by first running the program with
an emulator. It would examine the trace of calls made by the emulator
and in the background the binary translator would translate into Alpha
code the important parts of the code. The translated code is then
stored
for future runs. I think it worked at about half native speed.


As well as registers there are other difficulties such as instructions
that have no equivalent on the target architecure. For example 80-bit
x87
instructions don't exist elsewhere. Also, the target architecture may
have no flags, or different flags to the source architecture.



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.