Amiga.org

Amiga computer related discussion => General chat about Amiga topics => Topic started by: ricco32097 on October 23, 2006, 02:53:00 AM

Title: Pascal decoder?
Post by: ricco32097 on October 23, 2006, 02:53:00 AM
Is such a thing available? I made a program and compiled it. I would like to get my source code back, or at least some of it.

Could anyone convert this little program back to code for me? 43KB
Title: Re: Pascal decoder?
Post by: Minuous on October 23, 2006, 05:08:59 AM
There are no decompilers available for Amiga.

This is one of the more glaring holes in the Amiga software range.
Title: Re: Pascal decoder?
Post by: Methanoid on October 23, 2006, 08:28:34 AM
Makes me think.. For a time I ran a BBS on /X and then on a PC using PC Express. I wonder if I could decompile PCE and update it?
Title: Re: Pascal decoder?
Post by: Piru on October 23, 2006, 10:39:14 AM
Quote
I wonder if I could decompile PCE and update it?

If you need to ask, no.
Title: Re: Pascal decoder?
Post by: ricco32097 on October 23, 2006, 11:42:14 PM
@Piru Could you decode a 43KB .exe file, or find the password for me? It was a program I made long time ago. It asks for a password, but I can't remember it. When correct password is entered, a menu comes up with some stuff, like jokes, system info and such.
Title: Re: Pascal decoder?
Post by: Minuous on October 24, 2006, 04:16:53 AM
Better would be to ask if he could write and release a decompiler. Rather than to ask him to decompile 43K of code by hand :-)
Title: Re: Pascal decoder?
Post by: Methanoid on October 24, 2006, 08:47:30 AM
Got many friends Piru (real ones not imaginary ones) ??

No, didn't think so and can understand why. There was no need to be so rude.
Title: Re: Pascal decoder?
Post by: Piru on October 24, 2006, 09:12:27 AM
@ricco32097
Quote
Could you decode a 43KB .exe file, or find the password for me?

Possibly. I have never decoded a pascal program before, but I doubt it makes any difference really. It won't give you the src though, but I could either figure out the password or bypass it.
Title: Re: Pascal decoder?
Post by: Karlos on October 24, 2006, 11:18:38 AM
Isn't Pascal compiled? If so, I assume you'd only be able to get as far as dissassembling it? Or is it converted to some sort of bytecode representation that's executed by an interpreter?
Title: Re: Pascal decoder?
Post by: Piru on October 24, 2006, 11:27:54 AM
Pascal is compiled, so yes it's m68k asm disassembly. Shouldn't be too hard.
Title: Re: Pascal decoder?
Post by: Karlos on October 24, 2006, 11:40:51 AM
Quote

Piru wrote:
Pascal is compiled, so yes it's m68k asm disassembly. Shouldn't be too hard.


Aye, not for you but the guy who wanted his source back might balk at the sight of 40 pages of 68K mnemonics :-D
Title: Re: Pascal decoder?
Post by: Piru on October 24, 2006, 11:52:59 AM
Quote
Aye, not for you but the guy who wanted his source back might balk at the sight of 40 pages of 68K mnemonics

That's why I opted for the "or find the password for me" part.
Title: Re: Pascal decoder?
Post by: Karlos on October 24, 2006, 12:02:12 PM
Quote

Piru wrote:
Quote
Aye, not for you but the guy who wanted his source back might balk at the sight of 40 pages of 68K mnemonics

That's why I opted for the "or find the password for me" part.


:lol: I must have missed that bit...
Title: Re: Pascal decoder?
Post by: ricco32097 on October 24, 2006, 01:38:00 PM
@Piru
File send
Title: Re: Pascal decoder?
Post by: Piru on October 24, 2006, 02:52:15 PM
Excuse me, but this is a MS-DOS program.

As this is amiga.org I thought the program would have been compiled to AmigaOS binary... I'm afraid I can't do much about the DOS app. Sorry.
Title: Re: Pascal decoder?
Post by: Karlos on October 24, 2006, 03:10:51 PM
Just how do you say "D'Oh!" in Finnish?
Title: Re: Pascal decoder?
Post by: ricco32097 on October 24, 2006, 04:18:39 PM
Anyone else want to give it a try?
Title: Re: Pascal decoder?
Post by: Karlos on October 24, 2006, 04:21:17 PM
Quote

ricco32097 wrote:
Anyone else want to give it a try?


Perhaps someone over on the AROS sites would be better to ask? There are probably (just guessing) more x86 coders there?
Title: Re: Pascal decoder?
Post by: Minuous on October 24, 2006, 04:23:40 PM
Then just use an MS-DOS decompiler.

Of course you will end up with C source rather than Pascal source, but that is actually an improvement :-)
Title: Re: Pascal decoder?
Post by: Karlos on October 24, 2006, 04:37:28 PM
Arent there fundamental differences in the handling of variables etc in Pascal? I thought strings were represented differently than they are in Cfor example?
Title: Re: Pascal decoder?
Post by: Piru on October 24, 2006, 04:45:31 PM
@Minuous
Quote
Of course you will end up with C source rather than Pascal source

Uh?
Title: Re: Pascal decoder?
Post by: Karlos on October 24, 2006, 04:55:32 PM
Quote

Piru wrote:
@Minuous
Quote
Of course you will end up with C source rather than Pascal source

Uh?


I was thinking it would be an x86 dissassembly, myself ;-)
Title: Re: Pascal decoder?
Post by: Piru on October 24, 2006, 05:00:46 PM
Well, I know there are apps that try to convert binaries to C code, but I doubt they produce any more readable code than x86 disassembly, anyway. :-)
Title: Re: Pascal decoder?
Post by: Karlos on October 24, 2006, 05:04:36 PM
I suppose it depends how stripped the binaries are, I guess. I also expect OS calling mechanisms can be spotted and properly labelled.

As for the rest...

Try decompiling a duffs device loop to see what you get :-D
Title: Re: Pascal decoder?
Post by: Minuous on October 24, 2006, 05:43:02 PM
If you use a disassembler, you'll get x86 source.

But if you use a decompiler you'll get source in a high-level language.

See http://en.wikipedia.org/wiki/Decompiler

Decompiler and disassembler aren't the same. Disassembler stops when it has created assembly code. Decompiler keeps processing and ends up with high-level language source. Of course there are many disassemblers on the Amiga but no decompilers AFAIK.

Most of the decompilers I've heard about produce C output, but in theory you could make one that produced Pascal output.
Title: Re: Pascal decoder?
Post by: Karlos on October 24, 2006, 05:51:16 PM
I doubt a C decompiler would work well with code not written in C to start with.

There are certain programming constructs you can engineer in assembler that have absolutely no equivalent in C.

I wrote a small emulation core which was optimised in assembler, where each operation calculated the jump to the next code block directly and went there. A bit like having a big switch/case where the switch itself is never executed, but the code in each case clause is able to work out which one to jump to next relative to a base address (each block is padded to a certain 2^n size). There's absolutely no way to represent that in C.

So, code produced by pascal, could in theory contain machine level constructs that have no equivalent in C (not likely given their similarities).
Title: Re: Pascal decoder?
Post by: Piru on October 24, 2006, 06:26:07 PM
Oh well, I still believe decompiler output is far from usable (at least the outputs I've seen, though I must admit it was years ago. Technology has gone forward since then I suppose).
Title: Re: Pascal decoder?
Post by: Minuous on October 24, 2006, 06:46:37 PM
Yeah, they are far from perfect, but they automate some of the process: less hand-editing required to convert from assembler to C than if you did the whole thing by hand.

I wrote a program (Aminet:dev/cross/Annotate.lha) that comments Signetics 2650 assembly source with pseudo-C equivalents...a similar principle but not exactly a decompiler in the strictest sense.
Title: Re: Pascal decoder?
Post by: ricco32097 on October 24, 2006, 07:25:23 PM
File send...good luck, and thanks.
Title: Re: Pascal decoder?
Post by: TheMagicM on October 24, 2006, 09:07:41 PM
decompile it with a AmigaBASIC like decompiler.. LOL.. get a couple of BASIC lines of code then a whole bunch of DATA statements... that should keep you busy. LOL