Reversing : The Hacker's Guide to Reverse Engineering

(ff) #1

Expressions and Expression Trees


One of the primary differences between assembly language (regardless of the
specific platform) and high-level languages is the ability of high-level lan-
guages to describe complex expressions. Consider the following C statement
for instance.


a = x * 2 + y / (z + 4);

In C this is considered a single statement, but when the compiler translates
the program to assembly language it is forced to break it down into quite a few
assembly language instructions. One of the most important aspects of the
decompilation process is the reconstruction of meaningful expressions from
these individual instructions. For this the decompiler’s intermediate represen-
tation needs to be able to represent complex expressions that have a varying
degree of complexity. This is implemented using expressions trees similar to
the ones used by compilers. Figure 13.1 illustrates an expression tree that
describes the above expression.


Figure 13.1 An expression tree representing the above C high-level expression. The
operators are expressed using their IA-32 instruction names to illustrate how such an
expression is translated from a machine code representation to an expression tree.


add

2

mul

x

div

y

add

z 4

mov

a


Decompilation 461
Free download pdf