Re: Taking an AST back into C

Martin Ward <Martin.Ward@durham.ac.uk>
11 Dec 2004 12:30:38 -0500

          From comp.compilers

Related articles
Taking an AST back into C nb_no_spam@synthcom.com (Neil Bradley) (2004-11-28)
Re: Taking an AST back into C Martin.Ward@durham.ac.uk (Martin Ward) (2004-12-01)
Re: Taking an AST back into C torbenm@diku.dk (2004-12-01)
Re: Taking an AST back into C vbdis@aol.com (2004-12-01)
Re: Taking an AST back into C vbdis@aol.com (2004-12-05)
Re: Taking an AST back into C vbdis@aol.com (2004-12-05)
Re: Taking an AST back into C vbdis@aol.com (2004-12-11)
Re: Taking an AST back into C Martin.Ward@durham.ac.uk (Martin Ward) (2004-12-11)
Re: Taking an AST back into C vbdis@aol.com (2004-12-13)
| List of all articles for this month |

From: Martin Ward <Martin.Ward@durham.ac.uk>
Newsgroups: comp.compilers
Date: 11 Dec 2004 12:30:38 -0500
Organization: Compilers Central
References: 04-12-006 04-12-033
Keywords: decompile
Posted-Date: 11 Dec 2004 12:30:38 EST

On Monday 06 Dec 2004 2:34 am, VBDis wrote:
> Martin Ward <Martin.Ward@durham.ac.uk> schreibt:
> >void
> >no_pick()
> >{
> > if ((adtn1->dsaft == 0 && adtn1->hrfft == 0))
> > {
> > htst_irf();
> > }
> > else if (adtn1->dsaft == 0)
> > {
> > oldgs = 0;
> > hwal_zf = hwal();
> > if (hwal_zf != 0)
> > {
> > htst_irf();
> > }
> > }
> > return;
> >}
>
> Another possible representation:
>
> void
> no_pick()
> {
> if (adtn1->dsaft == 0 && adtn1->hrfft != 0 && oldgs = 0, hwal() == 0)
> htst_irf();
> }
> (Please ignore possible errors in the code, I decompiled manually ;-)


This is not equivalent to the original: in the original code
htst_irf() is called whenever both adtn1->dsaft and adtn1->hrfft are
zero. Yours does nothing in that case. Also, your code never executes
the assignment hwal_zf = hwal().


> Provided that your assembler code actually was disassembler output,
> I'd furthermore suspect a typo in the original C source code, which
> probably should have read as:
>
> if (adtn1->dsaft == 0 && adtn1->hrfft != 0 && oldgs == 0 && hwal() == 0)
> htst_irf();
>
> It were not the first bug of that kind that I found while decompiling ;-)


The assembler code was actually human implemented. Human implemented
assembler is easier in some ways because you have a better idea of the
meaning of data structures (eg if a variable is declared as an
integer, or character string: but that doesn't stop the programmer
from *using* the data in any way they choose), but harder in other
ways: you would be amazed at just how many different ways there are to
write a jump table, for example, all of which need to be detected and
accounted for by the translator.


--
Martin


Martin.Ward@durham.ac.uk http://www.cse.dmu.ac.uk/~mward/ Erdos number: 4
G.K.Chesterton web site: http://www.cse.dmu.ac.uk/~mward/gkc/


Post a followup to this message

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