Crowdfunding pledge for a 6502 decompiler

Let's talk about anything related to the 6502 microprocessor.
White Flame
Posts: 704
Joined: 24 Jul 2012

Re: Crowdfunding pledge for a 6502 decompiler

Post by White Flame »

There's been an update posted a few days ago. Unfortunately, I think he's missing the point.
Quote:
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. :?
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Crowdfunding pledge for a 6502 decompiler

Post 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
User avatar
GARTHWILSON
Forum Moderator
Posts: 8773
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: Crowdfunding pledge for a 6502 decompiler

Post by GARTHWILSON »

Quote:
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.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
White Flame
Posts: 704
Joined: 24 Jul 2012

Re: Crowdfunding pledge for a 6502 decompiler

Post 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.
User avatar
BigDumbDinosaur
Posts: 9426
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Crowdfunding pledge for a 6502 decompiler

Post by BigDumbDinosaur »

BTW, I wonder what Samuel would have to say about this effort. He's definitely the language guru around here. :)
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
BigDumbDinosaur
Posts: 9426
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Crowdfunding pledge for a 6502 decompiler

Post by BigDumbDinosaur »

GARTHWILSON wrote:
Quote:
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.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Crowdfunding pledge for a 6502 decompiler

Post by BigEd »

BigDumbDinosaur wrote:
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
User avatar
BigDumbDinosaur
Posts: 9426
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Crowdfunding pledge for a 6502 decompiler

Post by BigDumbDinosaur »

BigEd wrote:
BigDumbDinosaur wrote:
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.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Crowdfunding pledge for a 6502 decompiler

Post by BigEd »

Quote:
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
White Flame
Posts: 704
Joined: 24 Jul 2012

Re: Crowdfunding pledge for a 6502 decompiler

Post 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.
User avatar
BigDumbDinosaur
Posts: 9426
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Crowdfunding pledge for a 6502 decompiler

Post by BigDumbDinosaur »

White Flame wrote:
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.

BigDumbDinosaur wrote:
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.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Crowdfunding pledge for a 6502 decompiler

Post 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
User avatar
Arlet
Posts: 2353
Joined: 16 Nov 2010
Location: Gouda, The Netherlands
Contact:

Re: Crowdfunding pledge for a 6502 decompiler

Post 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.
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Crowdfunding pledge for a 6502 decompiler

Post 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
Post Reply