6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 15, 2024 6:36 am

All times are UTC




Post new topic Reply to topic  [ 45 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: Mon Nov 26, 2018 12:19 am 
Offline

Joined: Fri Nov 16, 2018 8:55 pm
Posts: 71
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.


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 26, 2018 1:54 am 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
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


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 26, 2018 2:01 am 
Offline

Joined: Fri Nov 16, 2018 8:55 pm
Posts: 71
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.


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 26, 2018 2:19 am 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 895
8 bit random number generators were discussed here.

Cheers,
Jim


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 26, 2018 2:28 am 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 895
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.


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 26, 2018 4:34 am 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
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.


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 26, 2018 5:42 am 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
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)


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 26, 2018 6:29 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8487
Location: Midwestern USA
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!


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 26, 2018 6:33 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8541
Location: Southern California
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?


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 26, 2018 7:46 am 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
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)


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 26, 2018 3:49 pm 
Offline
User avatar

Joined: Wed Aug 17, 2005 12:07 am
Posts: 1250
Location: Soddy-Daisy, TN USA
load81 wrote:
"Zero page has been eaten by a grue," that sort of thing.


I hate when that happens.

_________________
Cat; the other white meat.


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 26, 2018 4:37 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
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


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 26, 2018 4:44 pm 
Offline

Joined: Tue Jul 24, 2012 2:27 am
Posts: 679
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.

_________________
WFDis Interactive 6502 Disassembler
AcheronVM: A Reconfigurable 16-bit Virtual CPU for the 6502 Microprocessor


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 26, 2018 9:33 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8487
Location: Midwestern USA
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!


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 26, 2018 9:40 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1485
Location: Scotland
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/


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 45 posts ]  Go to page 1, 2, 3  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: