|[18 earlier articles]|
|Re: Help on disassembler/decompilers firstname.lastname@example.org (1990-09-14)|
|Re: Help on disassembler/decompilers email@example.com (1990-09-15)|
|Re: Help on disassembler/decompilers firstname.lastname@example.org (1990-09-14)|
|Re: Help on disassembler/decompilers email@example.com (1990-09-15)|
|Re: Help on disassembler/decompilers firstname.lastname@example.org (1990-09-16)|
|Re: Help on disassembler/decompilers email@example.com (1990-09-16)|
|Re: Help on disassembler/decompilers firstname.lastname@example.org (1990-09-18)|
|Re: Help on disassembler/decompilers email@example.com (1990-09-18)|
|Re: Help on disassembler/decompilers firstname.lastname@example.org (1990-09-18)|
|Re: Help on disassembler/decompilers email@example.com (1990-09-19)|
|Re: Help on disassembler/decompilers td@alice.UUCP (1990-09-21)|
|From:||firstname.lastname@example.org (Charles Bryant)|
|Organization:||Datacode Communications Ltd, Dublin, Ireland|
|References:||<HOW.90Sep5173755@sundrops.ucdavis.edu> <email@example.com> <firstname.lastname@example.org> <1990Sep14.email@example.com> <firstname.lastname@example.org>|
|Date:||Tue, 18 Sep 90 10:36:53 GMT|
In article <email@example.com> firstname.lastname@example.org (R. Kym Horsell) writes:
>In article <1990Sep14.email@example.com> firstname.lastname@example.org (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
if head=0 then
head := newelem;
mem[newelem].next := 0;
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;
>... 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
(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
Charles Bryant (email@example.com)
Return to the
Search the comp.compilers archives again.