Page 2 of 2
Re: Crowdfunding pledge for a 6502 decompiler
Posted: Sun Jul 29, 2012 12:56 am
by White Flame
There's been an update posted a few days ago. Unfortunately, I think he's missing the point.
Alright, so the campaign is public now, and I’m slowly recovering from being the nervous wreck I became five minutes after I pressed the “Go Live” button. The whole project has so far been met with a lot of enthusiasm, a couple of amusing anecdotes, and a really large amount of skepticism. Decompilation still seems to have an air of witchcraft to many people.
I’m planning to post a write-up of how the decompiler prototype works on the blog, in the hope that this will convert a few non-believers. For those that need no conversion, I’d like to ask you to go forth and tell a few people about it, because I won’t be able to do all this on Joe Decuir’s contribution alone.

Every technical feature that he's discussed adding is possible to implement to some degree, but doesn't help with the real problems.

Re: Crowdfunding pledge for a 6502 decompiler
Posted: Sun Jul 29, 2012 6:11 am
by BigEd
Hi White Flame (and welcome!)
I saw a rather unseemly mob, but I'm not sure I saw 'real problems' with the project.
The negative posts seem to be attacking a straw man: take a difficult example, suppose it to be necessary, and pronounce the project as hopeless.
In fact, I think the project has a loose goal, of producing C which is accurate and to some degree more useful for study than the machine code. (One might argue that C could never be useful, but again I don't see that as helpful - a decompilation will always have more potential readers than a disassembly.) Six months of full time effort by someone who knows what they are doing has every chance of producing something impressive. Much less time went into any of these forum posts than into that prototype, and yet the prototype actually does something interesting.
(As for my mob comment: I'd much rather see comments pitched as "I don't see how..." instead of "You can't possibly...", and "I wouldn't support this" instead of "This is hopeless and wrong-headed". If a friend comes up to a bunch of friends with a wild idea for building something, is rubbishing the idea the best response? Even if you know them well and have good reason to judge it over-ambitious, that seems unnecessarily hostile to me. In this case, we don't know well.)
Cheers
Ed
Re: Crowdfunding pledge for a 6502 decompiler
Posted: Sun Jul 29, 2012 6:36 am
by GARTHWILSON
The negative posts seem to be attacking a straw man: take a difficult example,
Those are the ones that will hold the unexpected secrets we want. Can we get them? I'm not sure. You can't make a program look for something that's entirely different from what you think it is. I'm not very optimistic, but I will say that I was all the more motivated to develop my
method of servicing interrupts in high-level Forth with zero overhead on 65C02 when people said it couldn't be done but I already knew what I was going to do. It did not discourage me, but instead fired me up. I won't attack him, but I will say he has set the bar awfully high for himself, as I have done sometimes, and recognized that I had bit off a big chuck and I was going to have to come through for my employer. I
had to perform. There was no choice.
Re: Crowdfunding pledge for a 6502 decompiler
Posted: Sun Jul 29, 2012 7:44 am
by White Flame
I will simply say that his list of "Use $TECHNOLOGY to reveal $INFO" features that he plans to include do not close the gap between hand-written assembly and his goal of "Derive readable C that can be ported", even if he implements them completely.
Re: Crowdfunding pledge for a 6502 decompiler
Posted: Sun Jul 29, 2012 10:02 pm
by BigDumbDinosaur
BTW, I wonder what Samuel would have to say about this effort. He's definitely the language guru around here. 
Re: Crowdfunding pledge for a 6502 decompiler
Posted: Sun Jul 29, 2012 10:06 pm
by BigDumbDinosaur
The negative posts seem to be attacking a straw man: take a difficult example,
Those are the ones that will hold the unexpected secrets we want. Can we get them? I'm not sure. You can't make a program look for something that's entirely different from what you think it is. I'm not very optimistic, but I will say that I was all the more motivated to develop my
method of servicing interrupts in high-level Forth with zero overhead on 65C02 when people said it couldn't be done but I already knew what I was going to do. It did not discourage me, but instead fired me up. I won't attack him, but I will say he has set the bar awfully high for himself, as I have done sometimes, and recognized that I had bit off a big chuck and I was going to have to come through for my employer. I
had to perform. There was no choice.
Garth is right. Not only has the bar been set (to turn phrase on current events) to Olympic heights, the activity itself is not well defined. Over which part of the bar do you leap? How do you land? How is your performance scored? What's the ultimate goal? From what I've read on this project to date, it seems much of it is fuzzy and ill-defined.
Re: Crowdfunding pledge for a 6502 decompiler
Posted: Mon Jul 30, 2012 6:04 am
by BigEd
BTW, I wonder what Samuel would have to say about this effort. He's definitely the language guru around here.

No need to wonder! He
said:
"I do like how it can already detect do/while loops. That's really cool.

"
(This was actually my internal prompt for the claim that the prototype can already do interesting things.)
(I'm not suggesting that gplus has become the place for 6502 discussions, but it's where he and I interact most these days)
Cheers
Ed
Re: Crowdfunding pledge for a 6502 decompiler
Posted: Mon Jul 30, 2012 7:06 pm
by BigDumbDinosaur
BTW, I wonder what Samuel would have to say about this effort. He's definitely the language guru around here.

No need to wonder! He
said:
"I do like how it can already detect do/while loops. That's really cool.

"
I don't do Google, so I didn't know that Samuel had seen and commented on this project.
Re: Crowdfunding pledge for a 6502 decompiler
Posted: Mon Jul 30, 2012 7:32 pm
by BigEd
I don't do Google, so I didn't know that Samuel had seen and commented on this project.
Indeed - I was being helpful, for you and anyone else who might be interested.
Cheers
Ed
Re: Crowdfunding pledge for a 6502 decompiler
Posted: Thu Sep 27, 2012 3:53 pm
by White Flame
Well, the fundraiser is over and didn't draw much money. I feel kind of bad for the guy; if he just focused on the technical features he wanted to put in, but didn't frame it with generating "high-level, readable" handwaviness, he might have successfully raised funds.
Re: Crowdfunding pledge for a 6502 decompiler
Posted: Thu Sep 27, 2012 4:51 pm
by BigDumbDinosaur
Well, the fundraiser is over and didn't draw much money. I feel kind of bad for the guy; if he just focused on the technical features he wanted to put in, but didn't frame it with generating "high-level, readable" handwaviness, he might have successfully raised funds.
While I would never discourage anyone from working on whatever it is that floats their boat, I stop at the point where funding is requested for something that will most likely prove to be an exercise in futility.
Case closed.
Re: Crowdfunding pledge for a 6502 decompiler
Posted: Sat Oct 20, 2012 11:30 am
by BigEd
I see Ulrich has released his state-of-play code as open source:
https://github.com/uli/decomp#readme
There are pointers there to a few articles he's written about the techniques he used.
(As the crowdfunding didn't get any significant money, I would suppose future progress, if any, will be at a slow pace.)
Cheers
Ed
Re: Crowdfunding pledge for a 6502 decompiler
Posted: Sat Oct 20, 2012 1:43 pm
by Arlet
I gave it a try with some of my own code. It's pretty impressive what it can do, but on the other hand there's still a lot that it can't. One particularly amusing bit:
Code: Select all
inc second
lda second
sbc #60
bcc @1
sta second
inc minute
lda minute
sbc #60
bcc @1
sta minute
inc hour
lda hour
sbc #24
bcc @1
sta hour
inc day
This is part of my code that keeps track of the time. Apparently, the decompiler doesn't understand that the code after the 'bcc' always has the carry flag set, leading to:
Code: Select all
sec = tmp2 = sec + 1;
if (sec >= (1 - c) + 60) {
sec = sec - c - 61;
minute = tmp3 = minute + 1;
if (minute >= (1 - (sec >= (1 - c) + 60)) + 60) {
minute = minute - (sec >= (1 - c) + 60) - 61;
hour = hour + 1;
a = hour - (minute >= (1 - (sec >= (1 - c) + 60)) + 60) - 25;
c = hour >= (1 - (minute >= (1 - (sec >= (1 - c) + 60)) + 60)) + 24;
if (c) {
hour = a;
}
}
}
I edited the code to fix the numbered variable names back into the original names.
Re: Crowdfunding pledge for a 6502 decompiler
Posted: Sat Oct 20, 2012 1:48 pm
by BigEd
Yes, he mentions the detection of branch-always idioms in his pieces. Doubtless you could never get 100% correct, so the question would be how often you get it wrong, and how your progress is in improving that. Also, what interactive tools you might have to assist.
Cheers
Ed