Live data from Hacker News

I believe 6502 instruction set is a good first assembly language

nemanjatrifunovic.substack.com

41–50 of 297 posts

Re: I believe 6502 instruction set is a good first assembly language

#41

6502 was my first assembly, though we didn't have an assembler - we entered raw opcodes into the Epyx FastLoad monitor on the C64. You kids with your symbol tables and your fancy mnemonics. a9 01 8d 20 d0 a9 93 20 d2 ff ... When we got a KIM-1, we were able to write meaningful programs on it in a weekend, since we already had memorized all the hex.

Even on the Apple //e you could “call -151” to get into the assembler and then type “!” to use the mini assembler

Re: I believe 6502 instruction set is a good first assembly language

#42

I cannot agree that the simplicity of the 6502 wins over the 68000. The 68000 has more registers and wider data types: but the registers are all uniformly the same. It's really just two registers A and D, copied a bunch of times in to D0 to D7, and A0 to A7. Whatever you can do with D0 can be done with D3 and so on. Some A's are dedicated, like for a stack pointer. Simplicity of structure has to be balanced with simp…

Yeah. If you want to teach someone to implement a CPU, then the sort of simplicity the 6502 brings to the table is useful, but it's definitely not the most straightforward CPU to write code for.

The 68000 instruction set is very C-like (probably because it draws a lot of inspiration from the PDP-11 which was C's first target). Implementing it sucks (I know from experience) because the ISA is on the large side and all the little pragmatic exceptions add up. But because these exceptions are fairly pragmatic, they're not really a big issue when writing code.

Re: I believe 6502 instruction set is a good first assembly language

#43

Earlier quoted context omitted.

> real available hardware Last I checked the 65C02 was still being manufactured and sold. It can also at a blazing 14 MHz.

It's $8 and can't run without external ROM and RAM and a clock circuit and some glue logic. A RISC-V CH32V003 32 bit processor with 2k RAM and 16k of flash running at 48 MHz costs $0.10 for an 8 pin package (6 available I/O pins) or $0.20 for the 20 pin package. Once programmed, it needs only electricity between 2.8V and 5.5V to be applied to start running. https://www.aliexpress.com/item/1005005036714708.html You ca…

Sounds nice, but the 6502 is certainly real, available hardware that you can buy and set up on a breadboard.

There are tutorials on youtube for it as well, such as Ben Eater's tutorial.

Re: I believe 6502 instruction set is a good first assembly language

#44

Nope. Too many quirks. 68k or if you must do 8-bit 6809.

6809 is a good point. It's like let's split the difference between 6502 and 68000! I started with the 6502 and graduated to 68000 on ST and Amiga and Sega Genesis. Definitely two of my all time favourites. Only recently have I started to try my hand at 6809 and I can see how you reccomend it, it's a very nice in-between from the 6502 to 68000.

It's hard to fathom the 6502 came out in '75, the 6809 in '78 and the 68000 in '79

Re: I believe 6502 instruction set is a good first assembly language

#45
post #31

Can anyone speak on how it is to move from an older assembly, to a modern CPU? I asked to take an assembly class in local/public college, and was told they wouldn't hold the class because not enough students were interested. This was in 1998, and I truly couldn't believe my ears. I feel like learning modern assembly would be more useful, but maybe 6502 assembly is far easier to pick up? The first language I learned w…

I started with BASIC on a Vic 20 in 1979 in a computer class for kids. Then I got my own Atari 400 at home, so I learned BASIC on that. Then around 1984 I got a Commodore 64 and it was amazing. I quickly got past the BASIC part of the C64 manual and in the back of the manual they had a memory map, all the hardware registers for all the chips, and then all the 6502/6510 opcodes. There was even an entire schematic for…

Thank you for this, I was born in 1979, but got introduced to the Atari 8-bit computers VERY early, and connected immediately. I have a Raspberry Pi v4, and it sounds like learning assembly on nearly anything right now will pay off. I don't have a problem learning a new language, but the C-style of languages are easiest for me. I'm sure them being imperative is a huge plus for me learning new things about any imperative language. I actually find JavaScript to be quite satisfying to write code in, mostly because I can test out functional features more easily than adopting an entirely different language to do it in.

I spent my teenage years grabbing cracks and texts from BBS', and enjoyed the whole scene. It's really what sparked my interest into writing software, and I always wished I had learned some lower-level skills beyond running a debugger and poking at memory. I felt like if I knew Assembly, I could get into deeper debugging (cracking was initially my "exciting" topic to cover, but now I feel like it would just be understanding memory better when I run into a strange error).

Re: I believe 6502 instruction set is a good first assembly language

#46

6502 was my first assembly, though we didn't have an assembler - we entered raw opcodes into the Epyx FastLoad monitor on the C64. You kids with your symbol tables and your fancy mnemonics. a9 01 8d 20 d0 a9 93 20 d2 ff ... When we got a KIM-1, we were able to write meaningful programs on it in a weekend, since we already had memorized all the hex.

Even on the Apple //e you could “call -151” to get into the assembler and then type “!” to use the mini assembler

Not on the Microsoft laden Apple ][+ - they removed that... :`(

Only on the OG Integer ROM Apple ][ and then again on the later 1985 enhanced ROM //e

Re: I believe 6502 instruction set is a good first assembly language

#47
6502 is a bit limited, so you'd have to resort to self-modifying code to get things done — and self-modifying code is a big no-no on any processor with cache, and therefore not a good habit to acquire.

For teaching, I would instead go with RISC-V. In particular RISC-V with the bitmanip extensions, which make some things much easier and gives it feature-parity with the base set on x86 and ARM. The Raspberry Pico 2 has two RISC-V CPUs with those. The board is easy to use, widely available and has a lot of support. There are also alternative boards with the same MCU but other form factors and features.

Re: I believe 6502 instruction set is a good first assembly language

#48

Biased here (it was my first language period), but I agree. Simple addressing modes. Getting started with x86 seems like it would warp the thinking a little bit, you can always pick its peculiarities up later. Having worked with the 6809 series as well, it wouldn't be a bad choice either. The Freescale 68HC12 is still in production. Little systems with limited-yet-real I/O give the programmer very useful feedback.

The 6809 seems like a more powerful (16-bit accumulator and index registers, multiply instruction) and orthogonal 6502 (itself a cheaper/simpler 6800) with fewer (possibly charming) quirks? The 6502 won in the marketplace though, apparently due to its lower cost (the 6809 had nearly triple the transistors.) It's nice that it's still in production if you want to build a breadboard system.

The Dragon-P eval board has a keypad, breadboard, and small display. Great for getting close to the metal.

Re: I believe 6502 instruction set is a good first assembly language

#49

It really isn't. Biggest issue is that register width is half of pointer width, so for arbitrary pointers you at least need to make a trip through the zero page. That fact alone really obfuscates a lot of what you're trying to teach as a first stab in assembly. I say this as someone who has a whole lesson plan in 6502 asm.

IDK - I guess you are mentally modelling it wrong. Think of the zero page as a bunch of registers - that's kind of how I modelled it and it was also the hump to get over that helped someone building a 6502 compiler backend. See the slide on imaginary registers. https://llvm.org/devmtg/2022-05/slides/2022EuroLLVM-LLVM-MOS...

But all that being said, 68000 or modern ARM or RISCV are also good targets. I am probably just a little nostalgic for the 6502.

Re: I believe 6502 instruction set is a good first assembly language

#50

Biased here (it was my first language period), but I agree. Simple addressing modes. Getting started with x86 seems like it would warp the thinking a little bit, you can always pick its peculiarities up later. Having worked with the 6809 series as well, it wouldn't be a bad choice either. The Freescale 68HC12 is still in production. Little systems with limited-yet-real I/O give the programmer very useful feedback.

The 6809 seems like a more powerful (16-bit accumulator and index registers, multiply instruction) and orthogonal 6502 (itself a cheaper/simpler 6800) with fewer (possibly charming) quirks? The 6502 won in the marketplace though, apparently due to its lower cost (the 6809 had nearly triple the transistors.) It's nice that it's still in production if you want to build a breadboard system.

Indeed the 6809 has several 16 bit stack registers as well as 16 bit X and Y index registers which mean you can use proper structures and it even has a decent mul instruction.
Post reply on HN