Related articles |
---|
[18 earlier articles] |
Re: Help on disassembler/decompilers hankd@dynamo.ecn.purdue.edu (1990-09-14) |
Re: Help on disassembler/decompilers hawley@icot32.icot.or.jp (1990-09-15) |
Re: Help on disassembler/decompilers ch@dce.ie (1990-09-14) |
Re: Help on disassembler/decompilers kym@bingvaxu.cc.binghamton.edu.cc.binghamton.edu (1990-09-15) |
Re: Help on disassembler/decompilers roland@ai.mit.edu (1990-09-16) |
Re: Help on disassembler/decompilers raulmill@usc.edu (1990-09-16) |
Re: Help on disassembler/decompilers ch@dce.ie (1990-09-18) |
Re: Help on disassembler/decompilers ctl8588@rigel.tamu.edu (1990-09-18) |
Re: Help on disassembler/decompilers megatest!djones@decwrl.dec.com (1990-09-18) |
Re: Help on disassembler/decompilers markh@csd4.csd.uwm.edu (1990-09-19) |
Re: Help on disassembler/decompilers td@alice.UUCP (1990-09-21) |
Newsgroups: | comp.compilers |
From: | ch@dce.ie (Charles Bryant) |
Keywords: | disassemble, debug |
Organization: | Datacode Communications Ltd, Dublin, Ireland |
References: | <HOW.90Sep5173755@sundrops.ucdavis.edu> <6839.26ea3b0e@vax1.tcd.ie> <3972@bingvaxu.cc.binghamton.edu> <1990Sep14.181616.26890@dce.ie> <4028@bingvaxu.cc.binghamton.edu> |
Date: | Tue, 18 Sep 90 10:36:53 GMT |
In article <4028@bingvaxu.cc.binghamton.edu> kym@bingvaxu.cc.binghamton.edu.cc.binghamton.edu (R. Kym Horsell) writes:
>In article <1990Sep14.181616.26890@dce.ie> ch@dce.ie (Charles Bryant) writes:
>>Well how would you translate this C function into Pascal.
>>[simple linked list insertion]
>
>I'm not sure at what level to aim this so I'll play it straight.
>
>[pascal version using fixed size array]
>It even duplicates the same bug as the original code! (:-)
That's funny, I can't see any bug in the original. I can see a bug in the
Pascal one though: when the list is empty new elements can't be inserted
because 'head' is never changed.
>Complaints about _efficiency_ can be countered by resorting to arguments re
>code optimization ...
Quite true. But one important property of the original is that it has no
fixed limit. The Pascal version is limited by the space allocated in
the array. If the array is big, space is wasted; and any fixed size may turn
out to be too small.
>[I suspect that the original author expected the Pascal version to use Pascal
>pointers. My Pascal is rusty enough that I don't immediately see what the
>problem is, other than perhaps the static list head.
Any method can be used if the basic properties of the original code are
preserved. One of these is that the list has no predetermined maximum size.
As far as I can see this means pointers are necessary, but it is not possible
to take the address of a variable in Pascal, so the case of an empty list
must be treated specially, I'll use the array method here to make it easy to
compare.
<same declarations>
begin
if head=0 then
begin
head := newelem;
mem[newelem].next := 0;
end
else begin
p := head; break:= false;
while (p<>0) and not break do
if mem[p].item >= mem[newelem].item then break:=true;
else p := mem[p].next;
mem[newelem].next := mem[p].next;
mem[p].next := newelem;
end;
end;
>... This is a long way from decompiling assembler into
>some language. -John]
What I meant was that unless the decompiler produces code in the same
language that the code was originally written in, it may have to produce
things that bear no relation to the original code (nor the assembler). If the
target language is less powerful that the original a decompilation may not be
possible.
(Well obviously you could write a program in the target language that emulated
the machine that the assembly came from, but I wouldn't consider that to be
decompilation).
--
Charles Bryant (ch@dce.ie)
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.