Half Way Through Jim Butterfield's Book, What Next?

Building your first 6502-based project? We'll help you get started here.
load81
Posts: 71
Joined: 16 Nov 2018

Half Way Through Jim Butterfield's Book, What Next?

Post by load81 »

Hey folks!

I'm half way though Jim Butterfield's book on Machine Language for the Commodore 64 and Other Computers. Someone here recommended the book and I'm grateful they did. It's typically very easy to follow. I'm going back over the chapter on addressing modes for a 3rd time just to make sure I really get it. The book is about 50% instructional, the rest of it is an extensive series of apendicies.

Once I'm done with this book, what book should I pick up next? I'm just trying to plan ahead.

My goal is to be able to disassemble C64 programs and work backwards until I have a fully functional code base that I can use to reassemble the original binary byte-for-byte accurately. Maybe that's pie in the sky, but help me out here. Once I'm done with Butterfield's book, what should I be reading next to further that goal? I understand this is going to take time and effort and none of this is magic.
User avatar
Dr Jefyll
Posts: 3526
Joined: 11 Dec 2009
Location: Ontario, Canada
Contact:

Re: Half Way Through Jim Butterfield's Book, What Next?

Post by Dr Jefyll »

Are you doing any assembly language coding of your own? I'd say it's very important to put what you're learning into practice! There's a world of difference between being in the driver's seat and simply being an observer. If you aren't able to play with a real, flesh and blood 65xx :) you can use any of several simulators available.

My own learning experience was very "hands on" and for me that proved very successful. But one book I can heartily recommend is the mcs6500 family programming manual.

-- Jeff
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
load81
Posts: 71
Joined: 16 Nov 2018

Re: Half Way Through Jim Butterfield's Book, What Next?

Post by load81 »

Dr Jefyll wrote:
Are you doing any assembly language coding of your own?
Yes, albeit simple stuff like changing boarder colors to simulate a phosopor display. Right now I'm writing a faux BSoD program for the C64. It's just a gag: a two byte memory address generated at random and a fake processor error. This is requiring me to figure out how to get a random number. (I haven't figured that out, yet.) The errors will be humorous. "Zero page has been eaten by a grue," that sort of thing.
JimBoyd
Posts: 931
Joined: 05 May 2017

Re: Half Way Through Jim Butterfield's Book, What Next?

Post by JimBoyd »

8 bit random number generators were discussed here.

Cheers,
Jim
JimBoyd
Posts: 931
Joined: 05 May 2017

Re: Half Way Through Jim Butterfield's Book, What Next?

Post by JimBoyd »

load81 wrote:
I'm half way though Jim Butterfield's book on Machine Language for the Commodore 64 and Other Computers.
I haven't gotten around to reading that one. I'll give it a look.
I learned with Programming the 6502 by Rodnay Zaks and the C64 Programmers Reference Guide.
whartung
Posts: 1004
Joined: 13 Dec 2003

Re: Half Way Through Jim Butterfield's Book, What Next?

Post by whartung »

load81 wrote:
My goal is to be able to disassemble C64 programs and work backwards until I have a fully functional code base that I can use to reassemble the original binary byte-for-byte accurately.
This isn't necessarily hard with a decent start using a tracing disassembler.

But on complicated systems, using overlays and such, these can be much more difficult.

It's also potentially difficult to get the data organized in to anything remotely human, rather than as an opaque data blob that still assembles properly. Because, in the end, the assembler doesn't really care.

But even if you get that far doesn't mean that you understand the code, as there are several idioms that manifest in different ways within the program. Grasping these larger concepts can require more than what most of the assembly books will teach you, as they're more about data encoding, data structures, and other things not necessarily specific to assembly language programming.

Arguably, the best thing to look at next is any documented assembly code and try to suss that out -- which can be difficult even when it's documented -- so that you can try to apply what you see in those programs to the blob of bytes and pages of instructions that a disassembly will start you with.
User avatar
barrym95838
Posts: 2056
Joined: 30 Jun 2013
Location: Sacramento, CA, USA

Re: Half Way Through Jim Butterfield's Book, What Next?

Post by barrym95838 »

I learned with Scanlon's "6502 Software Design" ISBN 0672216566 and the Apple ][+ built-in machine language monitor "CALL-151". My ][+ is gone (whereabouts unknown), but I still very much enjoy using the emulators. My book is still with me, but I no longer grab it first to look something up, because it's precariously held together by a vintage Apple black paper textbook cover, since the binding disintegrated many years ago from many hundreds of uses.
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some VTL02C on it and see how it grows on you!

Mike B. (about me) (learning how to github)
User avatar
BigDumbDinosaur
Posts: 9426
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Half Way Through Jim Butterfield's Book, What Next?

Post by BigDumbDinosaur »

Dr Jefyll wrote:
Are you doing any assembly language coding of your own? I'd say it's very important to put what you're learning into practice!
I completely agree with Jeff.

The best way to learn 6502 assembly language—any programming language, in fact—is by writing programs, running them and when they blow up (which they will do until you get the hang of it), figuring out where you went wrong. I fail to see how disassembling and reassembling the Commodore 64 firmware is going to teach you how to program. That's akin to attempting to learn how to play music by disassembling and reassembling a pipe organ.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
GARTHWILSON
Forum Moderator
Posts: 8773
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: Half Way Through Jim Butterfield's Book, What Next?

Post by GARTHWILSON »

Yep. This is definitely a contact sport. :lol:
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?
User avatar
barrym95838
Posts: 2056
Joined: 30 Jun 2013
Location: Sacramento, CA, USA

Re: Half Way Through Jim Butterfield's Book, What Next?

Post by barrym95838 »

BigDumbDinosaur wrote:
... The best way to learn 6502 assembly language—any programming language, in fact—is by writing programs, running them and when they blow up (which they will do until you get the hang of it), figuring out where you went wrong ...
I thought I got "the hang of it" many years ago, but my initial attempts still have a strong tendency to "blow up". I think I know why too ... premature optimization. Hugh Aguilar recently brought my attention to a quote that I hadn't seen before, but that seems to ring true, at least for me ... unfortunately, I haven't yet been able to rid myself of this ailment:
Quote:
“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”
― Brian Kernighan
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some VTL02C on it and see how it grows on you!

Mike B. (about me) (learning how to github)
User avatar
cbmeeks
Posts: 1254
Joined: 17 Aug 2005
Location: Soddy-Daisy, TN USA
Contact:

Re: Half Way Through Jim Butterfield's Book, What Next?

Post by cbmeeks »

load81 wrote:
"Zero page has been eaten by a grue," that sort of thing.
I hate when that happens.
Cat; the other white meat.
User avatar
Dr Jefyll
Posts: 3526
Joined: 11 Dec 2009
Location: Ontario, Canada
Contact:

Re: Half Way Through Jim Butterfield's Book, What Next?

Post by Dr Jefyll »

barrym95838 wrote:
my initial attempts still have a strong tendency to "blow up". ... unfortunately, I haven't yet been able to rid myself of this ailment.
Yeah, same with me. Do you think maybe we're subconsciously just thrill seekers ? After all, premature optimization is fun -- and it's kinda exciting when things blow up. The alternative is so boring. The stuff just works. Unless some darn grue comes along and eats zero page, I mean. :wink:
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
White Flame
Posts: 704
Joined: 24 Jul 2012

Re: Half Way Through Jim Butterfield's Book, What Next?

Post by White Flame »

I tend to describe programming as a craft. It involves lots of creative solutions, and exploring what can be done with the tools; in addition to the engineering skills one needs in order to understand and effectively use the tools in the first place.

There's a lot to be learned form others' creative solutions, but as expressed above, you need to hone your own creative application of them as well. This is exercised even in simply figuring out how to reimplement or integrate others' solutions into your own code.
User avatar
BigDumbDinosaur
Posts: 9426
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Half Way Through Jim Butterfield's Book, What Next?

Post by BigDumbDinosaur »

Dr Jefyll wrote:
barrym95838 wrote:
my initial attempts still have a strong tendency to "blow up". ... unfortunately, I haven't yet been able to rid myself of this ailment.
Yeah, same with me. Do you think maybe we're subconsciously just thrill seekers ? After all, premature optimization is fun -- and it's kinda exciting when things blow up. The alternative is so boring. The stuff just works. Unless some darn grue comes along and eats zero page, I mean. :wink:
With the 65C816, those grues can really wreak havoc when you have pointed DP at the stack and your stack pointer arithmetic has "issues." :D
White Flame wrote:
I tend to describe programming as a craft.
I see writing software, especially at the bare metal level, to be more like composing music.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
drogon
Posts: 1671
Joined: 14 Feb 2018
Location: Scotland
Contact:

Re: Half Way Through Jim Butterfield's Book, What Next?

Post by drogon »

BigDumbDinosaur wrote:
Dr Jefyll wrote:
barrym95838 wrote:
my initial attempts still have a strong tendency to "blow up". ... unfortunately, I haven't yet been able to rid myself of this ailment.
Yeah, same with me. Do you think maybe we're subconsciously just thrill seekers ? After all, premature optimization is fun -- and it's kinda exciting when things blow up. The alternative is so boring. The stuff just works. Unless some darn grue comes along and eats zero page, I mean. :wink:
With the 65C816, those grues can really wreak havoc when you have pointed DP at the stack and your stack pointer arithmetic has "issues." :D
White Flame wrote:
I tend to describe programming as a craft.
I see writing software, especially at the bare metal level, to be more like composing music.
All I see is blonde, brunette, red-head ...

:wink:

-Gordon
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/
Post Reply