OK, but I think a diagram or two of the architecture would help.
And personally, I think the Z80 is easier to understand (no zero-page, no limited stack size, etc.) but that is probably just me, though I did write professional 6502 and Z80 code way back when.
Well, on the 6510 address $01 is a port register and address $00 the related data direction register. Therefore, C64 folks tend to ignore these addresses.
(So there are just 254 usable zeropage addresses on the 6510, while on a stock 6502 and other variants the full complement of 256 zeropage addresses is usable.)
I tend to think of them as slow registers, since they provide crucial functionality, as in pre-indexed and post-indexed indirect address modes. There is simply no indirect addressing on the 6502 without them. But the notion of "local variables" (as related to the speed advantage) may be useful, as well.
If you're into 6502 and more specifically the Commodore 64, you should give the winning demo from last weekends Fjälldata a look. Quite insane stuff they do nowadays... https://www.youtube.com/watch?v=WtpPPgFSwxE
I feel this was an example of the crazy things you can do with PAL C64 hardware and not necessarily what can be done with a 6502. I feel Apple // demos are more representative of what a 6502 can do (without hardware assisted sprites, character generators, ADSR waveform generators, etc.)
It's kinda amazing that the people who wrote this probably know every single byte of code that's running on that computer, rom included. Without such deep knowledge you can't get this kind of performance.
With a modern computer that is simply unthinkable.
C64 demo coders don't generally care about ROM contents, there's nothing useful in there. ROMs are usually switched off. Although there might be a few exceptions.
Amazing resource, classic at this point, still probably the best place to start a 6502 journey. I became an NES romhacker with released projects thanks to this as a first step!
I think I can start in C and check the -s assembly code too, and gradually be comfortable with writing directly in assembly. After all a lot of the code is just function calls into libraries.
21 comments
[ 3.4 ms ] story [ 58.9 ms ] threadAnd personally, I think the Z80 is easier to understand (no zero-page, no limited stack size, etc.) but that is probably just me, though I did write professional 6502 and Z80 code way back when.
1. A bunch of numbered "local" variables
2. Data cache with numbered entries
3. 255 numbered registers
IIRC it was mentioned here on HN, but sadly I lost the reference.
EDIT: Formatting.
255? Isn’t that 256? There’s nothing special about address zero on 6502.
(So there are just 254 usable zeropage addresses on the 6510, while on a stock 6502 and other variants the full complement of 256 zeropage addresses is usable.)
With a modern computer that is simply unthinkable.
Easy 6502 - https://news.ycombinator.com/item?id=31548311 - May 2022 (28 comments)
Easy 6502 – How to get started writing 6502 assembly language - https://news.ycombinator.com/item?id=13324978 - Jan 2017 (84 comments)
Easy 6502 - https://news.ycombinator.com/item?id=9761213 - June 2015 (9 comments)
Easy 6502 - https://news.ycombinator.com/item?id=6345730 - Sept 2013 (28 comments)
Easy 6502 - https://news.ycombinator.com/item?id=5180937 - Feb 2013 (59 comments)
Easy 6502 - Learn the 6502 Assembly Language - https://news.ycombinator.com/item?id=4213806 - July 2012 (78 comments)
> I believe 6502 instruction set is a good first assembly language
https://news.ycombinator.com/item?id=42957823
Oddly omitting the standard-setting Atari 8-bit computer line...
https://m.youtube.com/watch?v=p60L-TOecik&t=1042s
I think I can start in C and check the -s assembly code too, and gradually be comfortable with writing directly in assembly. After all a lot of the code is just function calls into libraries.