P. 1
Study of the techniques for emulation programming by Victor Moya del Barrio

Study of the techniques for emulation programming by Victor Moya del Barrio

4.4

|Views: 12,432|Likes:
Published by Moe B. Us
In the time I started to learn about how an emulator is programmed I found that there was a limited amount of documentation. Documentation about how an emulator should be programmed or about the characteristics of the machines to be emulated. Thinking about how to contribute to the emulation I found that the second part would mean the construction of a database with all the information available of a large amount of computers and systems. This wasn’t very suited neither with a university project for
with my own preferences, and there are a few sites in Internet which more or less serve to that purpose. The first part meant to study and learn the various techniques and knowledges related to emulator programming. Since I like a lot learning and also writing I thought that could be my way to contribute. So I thought it would be nice to have a large, ordered and precise documentation about how to program an emulator. That is the purpose of this document and my work in the last months
In the time I started to learn about how an emulator is programmed I found that there was a limited amount of documentation. Documentation about how an emulator should be programmed or about the characteristics of the machines to be emulated. Thinking about how to contribute to the emulation I found that the second part would mean the construction of a database with all the information available of a large amount of computers and systems. This wasn’t very suited neither with a university project for
with my own preferences, and there are a few sites in Internet which more or less serve to that purpose. The first part meant to study and learn the various techniques and knowledges related to emulator programming. Since I like a lot learning and also writing I thought that could be my way to contribute. So I thought it would be nice to have a large, ordered and precise documentation about how to program an emulator. That is the purpose of this document and my work in the last months

More info:

Published by: Moe B. Us on Jun 04, 2007
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

01/04/2016

pdf

text

original

The basic concepts of binary translation come either from the compiler world or from the emulation
(interpreters world). Since the translation, optimization and code generation phase in a binary translator
are equivalent to the same phases is a compiler the same terminology and techniques can be applied. In a
dynamic binary translator, though, the range of those techniques is limited to the amount of time it can be
spent in the translation of a block.

We have already talked about intermediate representations. An IR is a kind of representation of a code
or algorithm. There are many kinds of IRs, some are based in the compiler theory, like tree based IRs,
other are more nearer to machine language. The IR is as an intermediate step between the source code
and the target code, either for portability or for aiding in the process of optimization.

In the compiler theory the basic unit for code optimization is the basic block. A basic block is a
sequence of instructions which only have one entry point (the first instruction) and one exit point (the last
instruction). The idea is that such a piece of code can be modified, while maintaining its algorithmic
meaning, without affecting the rest of the code. Therefore many of the optimizations (local) are basic
block based. Further optimizations (global optimizations) are performed between basic blocks, working
with their interrelations.

The basic algorithm for building the list of basic blocks of a function (or any other piece of code with an
entry point) is based in searching the basic block leaders. A basic block leader is the entry point/first
instruction of the basic block. The algorithm for finding the leaders is:

1) The first instruction of the function (entry point) is a leader.
2) The target instruction of a jump instruction is a leader.
3) The instruction after a jump instruction is a leader.

After the leaders have been found the basic blocks are built between a leader and the next instruction
before the next leader in the list of leaders.

In static binary translation basic blocks will be the basic translation units. In dynamic binary translation
they could be or could not be the translation unit. At run-time is hard to determine if a given block of
code is really a basic block (in the future a jump instruction could jump to middle of the block). With
profiling and multiple passes it could be built an arrangement of blocks which could be trusted to be basic
blocks. We will keep, though, the idea of basic block while translating dynamically. Another question is
that in dynamic translation sometimes is better to perform instruction by instruction translation or
translation of blocks bigger than a basic block, for example for loop optimization. In a static compiler
this last kind optimizations are performed in a second phase of optimization between the basic blocks.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->