Live data from Hacker News

Dirty tricks 6502 programmers use

nurpax.github.io

21–30 of 63 posts

Re: Dirty tricks 6502 programmers use

#21
My first 6502 program was self-modifying; I wrote it just before reading the book chapter on using registers for indexing relative to a base address. That book was Programming the 6502 by Rodney Zaks.

I have some 1986-dated 6502 assembly code of mine in hard copy (on dot matrix paper with the "holes" intact). I'm going to scan it one day and post.

Re: Dirty tricks 6502 programmers use

#22
post #3

What, if any, modern products still use the 6502? EDIT: That’s not a dig against the 6502. I still fondly remember leaning BASIC in my C64 and wish now I had ventured into Assembly with it. By today’s standards it seems to have a simpler and more approachable instruction set so I’m wondering if there aren’t products I could hack on to learn Assembly with it. Or maybe I should just break out my old Commie.

They are still found as embedded cores in computer mouses and keyboards, monitors (OSD processor/scaler), digital picture frames (https://spritesmods.com/?art=picframe&page=1), MP3 players, Furby (https://news.ycombinator.com/item?id=17751599 , actually a 6502-subset) etc.

Re: Dirty tricks 6502 programmers use

#23
post #14

>Entries were posted as Twitter replies and DMs, containing only the PRG byte-length and an MD5 hash of the PRG file. This is clever. So basically rather than getting bogged down reviewing submissions you just pick a winner and then validate post-hoc! (because when you win the hash of your code has to match the one you submitted)

I wonder if you could brute force a particular solution with that information.

Re: Dirty tricks 6502 programmers use

#24
post #4

Not to belittle the article, because it's definitely interesting. But as an ex-BBC 6502 programmer, my nitpick here would be that the title should really be named "Dirty tricks C64 6502 programmers use". On the beeb we had our own set of tricks specific to the memory layout and ROM of our beloved beige and black machines.

title should really be named "Dirty tricks C64 6502 programmers use". In that case, probably Dirty Tricks 6510 Programmers Use would be even better.

While that may be technically correct, the programmer-visibile difference between the MOS 6502 and the MOS 6510 is totally incidental in this case - the 6510 has a a built in 6/8-pin IO port (partially used for bank switching the ROMs in the C64). Unless you touch the IO ports, they should behave identically, down to the cycle timings of instructions and the same behavior of undocumented opcodes.

In this case, the real C64 specific tricks are not 6510 specific, but depending on the specific initialization done by the C64 ROM and calling C64 ROM routines.

Re: Dirty tricks 6502 programmers use

#25

My first 6502 program was self-modifying; I wrote it just before reading the book chapter on using registers for indexing relative to a base address. That book was Programming the 6502 by Rodney Zaks. I have some 1986-dated 6502 assembly code of mine in hard copy (on dot matrix paper with the "holes" intact). I'm going to scan it one day and post.

A lot more 6502 code was self modifying than necessary - I know a lot of people (myself included) did not pick up zero-page indexed indirect/indirect indexed address modes and instead kept using absolute x/y indexed and modified the absolute part for larger loops. A large part of the reason why I didn't learn about it until fairly late was that I mostly saw absolute x/y indexing in the code I looked at to learn. It's interesting how many bad habits you'd see in code like that, given e.g. the C64 ROMs were extensively dissected and documented and published, and they used zero page all over the place.

Re: Dirty tricks 6502 programmers use

#26
post #12
post #9

Earlier quoted context omitted.

Why is it your favorite?

I'm not the OP, but I always liked its simplicity. There's just enough space to do something interesting without getting bogged down in too much complexity.

I think it's because it was my first. And it is simple. Yes there are many addressing modes (like zero-page, and "absolute indirect", and "indexed indirect") but there's only 56 instructions and you can learn it in one afternoon.

And doing something useful with 56 instructions, 8-bits at a time, is like solving a puzzle.

Re: Dirty tricks 6502 programmers use

#28
post #12

Earlier quoted context omitted.

I'm not the OP, but I always liked its simplicity. There's just enough space to do something interesting without getting bogged down in too much complexity.

I think it's because it was my first. And it is simple. Yes there are many addressing modes (like zero-page, and "absolute indirect", and "indexed indirect") but there's only 56 instructions and you can learn it in one afternoon. And doing something useful with 56 instructions, 8-bits at a time, is like solving a puzzle.

8-bits at a time

It's a detail that doesn't always come up in these threads but it's worth remembering how belligerently 8-bit a 6502 is. Not only are there next to no general-purpose registers but they're 8 bit and there are no pretend-two-registers-are-one-16-bit-register instructions at all. You can't put an address in a register. Compared to even other popular 8 bit CPUs of the time, that's a bit metal.

Re: Dirty tricks 6502 programmers use

#29
post #9

Thanks! 6502 is still my favorite architecture, even though I've done assembly language programming (professionally!) on many platforms in the past 35 years.

Why is it your favorite?

I am not the OP either, but 6502 and 6809 are my faves.

6502 was first. It is simple. And that makes it a lot of fun.

6809 is beautiful. I think it is the most powerful and elegant of the 8 bit CPUs. But that spoils a person too.

6502 is like whittling computing down to some useful nubs. There are enough subtleties to make it interesting too.

Re: Dirty tricks 6502 programmers use

#30
post #28

Earlier quoted context omitted.

I think it's because it was my first. And it is simple. Yes there are many addressing modes (like zero-page, and "absolute indirect", and "indexed indirect") but there's only 56 instructions and you can learn it in one afternoon. And doing something useful with 56 instructions, 8-bits at a time, is like solving a puzzle.

8-bits at a time It's a detail that doesn't always come up in these threads but it's worth remembering how belligerently 8-bit a 6502 is. Not only are there next to no general-purpose registers but they're 8 bit and there are no pretend-two-registers-are-one-16-bit-register instructions at all. You can't put an address in a register. Compared to even other popular 8 bit CPUs of the time, that's a bit metal.

It is. There is always 6809 for a bit more civilized fun, IMHO.
Post reply on HN