Live data from Hacker News

Elite on the 6502: The original 6502 assembly source, heavily commented

elite.bbcelite.com

31–40 of 61 posts

Re: Elite on the 6502: The original 6502 assembly source, heavily commented

#31

I think Computer Architecture can be designed around legacy but fun hardwares. So instead of using some fantasy machines such as LC-3, students can directly get into the world of 6502. First semester: mostly concentrated on 6502 with a full 6502 CPU emulator as the final project. Second semester: concentrate on a real machine such as the NES. Students need to learn to improve their emulators to program in it (so, do…

> First semester: mostly concentrated on 6502 with a full 6502 CPU emulator as the final project.

I like the principle, and the 6502 holds a special place in my heart as my introduction to machine code programming on an Apple ][ in late 1980 after I got bored with BASIC after two days .. self-taught from the ROM listing and 6502 reference in the back of the manual.

But it's absolutely the wrong ISA today.

RISC-V RV32I (or RV32E, with only 16 registers) is the right ISA today, for many reasons. It is every bit as easy to understand as 6502, if not easier. It is certainly much easier to write an emulator for than 6502 -- and I've done both. And it is at least 10x easier to write real useful programs using, especially if you're going to deal with values bigger than 8 bits, or pointers, or recursive/reentrant subroutines.

You can also cheaply buy a large and growing range of RISC-V hardware, starting from the $0.10 CH32V003 (48 MHz, 2k RAM, 16k of flash for your program) or boards with that chip for about $1, up to ESP32-C3 or RP2350 boards for a couple of bucks with a few hundred KB of RAM. Or the full Linux $5 Milk-V Duo with 1 GHz 64 bit CPU, 64 MB RAM, and SD card for the OS/programs, which you can power from the USB port on any PC and also ssh into it from the PC.

The only advantage the 6502 has now is it is one of the few chips you can still buy with exposed and non-multiplexed 16 bit address bus and 8 bit data bus, which allows you to do tricks such as hard-wiring the data bus to a NOP instruction (0xEA), and feed it a slow clock and watch the PC increment the address bus through all the NOPs.

Nice, but you can do that with an emulator too, or for that matter with a debugger talking to your microcontroller chip.

Re: Elite on the 6502: The original 6502 assembly source, heavily commented

#32

I think Computer Architecture can be designed around legacy but fun hardwares. So instead of using some fantasy machines such as LC-3, students can directly get into the world of 6502. First semester: mostly concentrated on 6502 with a full 6502 CPU emulator as the final project. Second semester: concentrate on a real machine such as the NES. Students need to learn to improve their emulators to program in it (so, do…

I love the 6502, but if we're considering teaching architecture using a legacy machine my preferred choice would be the PDP-11. The ISA is quite nice, and the machine has many of the "modern" features one would expect from a computer, like address translation. On top of that, there's loads of good, historic code to be looked at. Hell, bring back the Lions commentary book!

Re: Elite on the 6502: The original 6502 assembly source, heavily commented

#34
post #18

Earlier quoted context omitted.

I don't actually care one way or another about that particular subject, but if you start making judgements about academic fields of study are worthwhile to pay for on the basis of value to society, you allow other people -- more ignorant people, let's say -- with different concepts of societal value to make somewhat unfortunate decisions. You might end up without any new literature at all.

Very little literature is written by academics. People who want to write new literature can just go ahead and do it. In a world of limited time and resources we always make judgements about which academic fields of study are worthwhile. At some level it's a zero-sum game: time spent on comparative literature is time not spent on philosophy or history or creative writing. So, given that we have to prioritize which peo…

All knowledge is worthwhile. Its that easy. If you want to distinguish “useful” knowledge everything will eventually get thrown out. Why should people spend time and money investigating distant galaxies for example? Its completely useless for 99.999999 of all people. At best it results in “huh, neat” when reading about some new discovery about some star.

Re: Elite on the 6502: The original 6502 assembly source, heavily commented

#35

I think Computer Architecture can be designed around legacy but fun hardwares. So instead of using some fantasy machines such as LC-3, students can directly get into the world of 6502. First semester: mostly concentrated on 6502 with a full 6502 CPU emulator as the final project. Second semester: concentrate on a real machine such as the NES. Students need to learn to improve their emulators to program in it (so, do…

I like this idea.

My fantasy course would start with a BBC Micro - 6502 BBC Basic with its inline assembler.

Then move on to an Acorn Archimedes - 32 bit ARM which was designed as a direct replacement for 6502.

Finally move to Raspberry Pi - 64 bit ARM with multiple cores.

Re: Elite on the 6502: The original 6502 assembly source, heavily commented

#36

The map overview is so well done. The comments are so nice and thoroughly explaining what is stored in which register and what's being manipulated. I wish all codebases were like this. This must have taken months to document it. [1] https://elite.bbcelite.com/c64/articles/map_of_the_source_co... [2] https://elite.bbcelite.com/c64/main/subroutine/tactics_part_...

Glad you like it! I’ve been working on this for nearly five years, along with my other software archaeology projects - I started in May 2020, back in lockdown. It’s a true labour of love.

Here’s a timeline of the project so far:

https://elite.bbcelite.com/about_site/site_history.html

I’m sure it will keep growing, there’s always something more to write about…

Re: Elite on the 6502: The original 6502 assembly source, heavily commented

#37

I think Computer Architecture can be designed around legacy but fun hardwares. So instead of using some fantasy machines such as LC-3, students can directly get into the world of 6502. First semester: mostly concentrated on 6502 with a full 6502 CPU emulator as the final project. Second semester: concentrate on a real machine such as the NES. Students need to learn to improve their emulators to program in it (so, do…

> First semester: mostly concentrated on 6502 with a full 6502 CPU emulator as the final project. I like the principle, and the 6502 holds a special place in my heart as my introduction to machine code programming on an Apple ][ in late 1980 after I got bored with BASIC after two days .. self-taught from the ROM listing and 6502 reference in the back of the manual. But it's absolutely the wrong ISA today. RISC-V RV32…

I don't disagree with you. I picked 6502 has the advantage of having so many real legacy products built on top of it.

But again, I agree it's not a great ISA (and only having 3 registers always bug me anyway), so as long as it's a real machine I think it's good. Maybe the one you talked about, or a Z80 machine, would all do the job.

Re: Elite on the 6502: The original 6502 assembly source, heavily commented

#38
post #32

I think Computer Architecture can be designed around legacy but fun hardwares. So instead of using some fantasy machines such as LC-3, students can directly get into the world of 6502. First semester: mostly concentrated on 6502 with a full 6502 CPU emulator as the final project. Second semester: concentrate on a real machine such as the NES. Students need to learn to improve their emulators to program in it (so, do…

I love the 6502, but if we're considering teaching architecture using a legacy machine my preferred choice would be the PDP-11. The ISA is quite nice, and the machine has many of the "modern" features one would expect from a computer, like address translation. On top of that, there's loads of good, historic code to be looked at. Hell, bring back the Lions commentary book!

I don't disagree with you. Any real computer would work I think. But maybe teaching a not-so-good but popular ISA has educational values too. After all we don't know why good things are good if we haven't seen the bad ones...hah!

Re: Elite on the 6502: The original 6502 assembly source, heavily commented

#39
post #35

I think Computer Architecture can be designed around legacy but fun hardwares. So instead of using some fantasy machines such as LC-3, students can directly get into the world of 6502. First semester: mostly concentrated on 6502 with a full 6502 CPU emulator as the final project. Second semester: concentrate on a real machine such as the NES. Students need to learn to improve their emulators to program in it (so, do…

I like this idea. My fantasy course would start with a BBC Micro - 6502 BBC Basic with its inline assembler. Then move on to an Acorn Archimedes - 32 bit ARM which was designed as a direct replacement for 6502. Finally move to Raspberry Pi - 64 bit ARM with multiple cores.

Ah, just need some years for me to learn all these stuffs and produce a few courses...maybe 10 years given I have a family and not rich enough to fire my boss?

Re: Elite on the 6502: The original 6502 assembly source, heavily commented

#40
post #13

The "Advanced User Guide" referred to several times in the comments is The Advanced User Guide for the BBC Micro by Bray, Dickens and Holmes, 1983, ISBN 0 946827 00 1 . https://stardot.org.uk/forums/viewtopic.php?f=42&t=17242 https://archive.org/details/bbc-micro-advanced-user-guide/ I can't find a source for this now, but IIRC Bell and Braben themselves used this when writing Elite . (I am not an expert.)

Thank you, that's a good point. The site started off with just the BBC Micro version, and I never expanded the book references to be clearer.

Anyway, I have reworded every reference to books in the commentary so they now contain the full title and author list, so hopefully people will be able to find the relevant tomes. I've also linked to the books from my "useful links" page in a more prominent manner:

https://elite.bbcelite.com/about_site/useful_links.html

I hope that helps!

Post reply on HN