ArticleslgStudy

computer science

Binary translation

Binary translation is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Binary translation rather than just read about it. In short: In computing, binary translation is a form of binary recompilation in which sequences of instructions (machine code or bytecode) are translated from a source instruction set architecture (ISA) to a target instruction set with respect to the operating system for which the binary was compiled. In some cases, such as instruction set simulation, the target instruction set may be the same as the source instruction set, p…

Key takeaways

  • Binary translation belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Binary translation to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Binary translation from memory before moving on to harder problems.

Reference excerpt

In computing, binary translation is a form of binary recompilation in which sequences of instructions (machine code or bytecode) are translated from a source instruction set architecture (ISA) to a target instruction set with respect to the operating system for which the binary was compiled. In some cases, such as instruction set simulation, the target instruction set may be the same as the source instruction set, providing testing and debugging features such as instruction tracing, conditional breakpoints, and hot spot detection and optimization. The two main types are static and dynamic binary translation. Binary translation is commonly implemented in software using static or dynamic translation techniques.

Motivation Binary translation can allow software compiled for one instruction set architecture to execute on another without recompiling the original source code, and has been used to migrate existing software between incompatible architectures. Statically recompiled binaries can avoid the runtime translation overhead incurred by dynamic translation, although the performance of a translated program depends on the translator, source and target architectures, and opportunities for optimization. This is similar to the difference in performance between interpreted and compiled programs in general.

Static binary translation A translator using static binary translation aims to convert the code of an executable file into code that runs on the target architecture and platform without having to run the code first, as is done in dynamic binary translation. This can be very difficult to do correctly, since not all code can be discovered by the translator. For example, some parts of the executable may be reachable only through indirect branches, whose value is known only at run-time. One such static binary translator uses universal superoptimizer peephole technology (developed by Sorav Bansal and Alex Aiken from Stanford University) to perform efficient translation between possibly many source and target pairs, with considerably low development costs and high performance of the target binary. In experiments of PowerPC-to-x86 translations, some binaries even outperformed native versions, but on average they ran at two-thirds of native speed.

Examples for static binary translations In the 1960s Honeywell provided a program called the Liberator for their Honeywell 200 series of computers; it could translate programs for the IBM 1400 series of computers into programs for the Honeywell 200 series. In 1995 Norman Ramsey at Bell Communications Research and Mary F. Fernandez at Department of Computer Science, Princeton University developed The New Jersey Machine-Code Toolkit that had the basic tools for static assembly translation. In 2004 Scott Elliott and Phillip R. Hutchinson at Nintendo developed a tool to generate "C" code from Game Boy binary that could then be compiled for a new platform and linked against a hardware library for use in airline entertainment systems. In 2014, an ARM architecture version of the 1998 video game StarCraft was generated by static recompilation and additional reverse engineering of the original x86 version. The Pandora handheld community developed the required tools on their own and achieved usable translations several times. Another example is the NES-to-x86 statically recompiled version of the videogame Super Mario Bros. which was generated using LLVM in 2013. For instance, a successful x86-to-x64 static recompilation was generated for the procedural terrain generator of the video game Cube World in 2014. In the 2020s, static binary translation tools such as N64 Recomp were developed to automatically recompile Nintendo 64 executables into native C code, enabling modern PC builds with features such as arbitrary frame rates and widescreen support.

Dynamic binary translation Dynamic binary translation (DBT) translates binary code during program execution. A common implementation translates source code in units such as basic blocks and stores the generated target code in a code cache so that previously translated blocks can be reused. Dynamic binary translation differs from simple emulation because translated target instructions can subsequently execute directly from the code cache. Translation itself imposes a run-time cost, and DBT systems attempt to amortize this overhead by reusing translated code, particularly for frequently executed regions. More advanced dynamic translators employ dynamic recompilation, using execution information to identify frequently executed regions and apply additional optimization. This approach is similar to just-in-time compilation, although binary translators operate on already compiled machine code rather than source code or a language-level intermediate representation.

Examples for dynamic binary translations in software Pioneering works include Shade (the fast instruction set simulator and custom trace generator originally developed by Bob Cmelik (Sun Microsystems) and David Keppel (University of Washington))., open-source DAISY (Dynamically Architected Instruction Set from Yorktown) and its successor BOA (Binary-translation and Optimization Architecture) from IBM Research, and the Code Morphing Software used in Transmeta processors.

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Binary translation

Start with the simplest possible case. Write down what Binary translation claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Binary translation before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Binary translation ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Binary translation

In research
Binary translation appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Binary translation in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Binary translation is common in secondary-school and first-year university syllabi. It links to neighbouring topics Emulation software, Interpreters (computing), Virtualization, so understanding it makes those chapters shorter.
In everyday life
Look for Binary translation outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Binary translation” →

How to study Binary translation in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Binary translation means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Binary translation out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Binary translation in simple terms?

In computing, binary translation is a form of binary recompilation in which sequences of instructions (machine code or bytecode) are translated from a source instruction set architecture (ISA) to a target instruction set with respect to the operating system for which the binary was compiled. In som…

Why does Binary translation matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Binary translation?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Binary translation.

Tags

  • Emulation software
  • Interpreters (computing)
  • Virtualization

Keep exploring