Live data from Hacker News

I believe 6502 instruction set is a good first assembly language

nemanjatrifunovic.substack.com

191–200 of 297 posts

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

#191

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…

Modern CPUs are more difficult to program in assembly. The simplicity of RISC-V is illusory. Because it lacks many features of normal ISAs, like ARM or Intel/AMD x86-64, writing programs that are both efficient and robust, i.e. which handle safely any errors, is quite difficult in assembly language. For a simpler programming in assembly language it is hard to beat DEC PDP-11 and Motorola 68000 derivatives. However th…

> Probably some development board with a microcontroller using Cortex-M33 would be the easiest to find and it should cost no more than $20 to $30.

The Pi Pico 2 RP2350 has dual Cortex-M33 cores (and RISC-V), and costs US$5.

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

#192
post #177
post #118

I would argue that 6502 is a bad first ISA to learn if you want learn assembly. You‘ll spend most of your time fighting the quirks of this clever, but deeply flawed architecture. The idioms you learn to work around them don‘t translate to any better designed architecture that wasn‘t constrained by the tools and budget available to MOS at the time. If you want to learn a small, yet powerful instruction set with a few…

I wrote a lot of 6502 assembly once, and you spend a lot of time dealing with the 8-bittedness of the architecture. Multiplying two 16 bit numbers is a whole blob of code. That doesn't seem useful for new programmers to struggle with. The early ARM ISAs are good, as you say.

I believe you should be able to sort~of simulate higher level languages on the editor level. Writing c = a * b could just be a representation for the large blob of code or subroutine.*

What is particularly funny about your example is that 40 years later you still cant do multiplication or addition in js. You have to install packages (that are multiple computers in size!) after you make up your mind which of the 20+ different modules (read: "dependencies") has the right kind of multiplication for you! I'm not bitter, it's objectively ridiculous :)

* it should actually be c = a × b Without the asterix, we did actually have arithmetic reasonably standardized before IT de-standardized it.

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

#193
i have to agree with a lot of sibling comments: i don't think 6502 is a good pick. first, it's highly atypical and limited. second, it's borderline RISC and i'd start with a simpler to use CISC ISA. CISC makes sense and was designed exactly for hand-written assembler.

VAX or 68K would be cleaner CISC ISA to learn first.

8086 (16 bit) x86 has the advantage of being ubiquitous and you can run on "hardware" everywhere. but the disadvantage of being a little weird wrt. segment registers. x86 32-bit is complicated, but at least flat memory space and you can mostly ignore the segments.

MIPS or one of the RISC-V variants is a second one to learn to contrast RISC load/store with CSIC.

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

#194

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…

My school started with a 6502 lab and then followed it with a 68k lab. That still seems like the right order to me all these years later. Starting with the smaller, more cramped chip and learning its limitations makes it all the more interesting when you can "spread your wings" into the larger, more capable one.

You scale up the complexity of the programs you need to build with the complexity of the chips. In the 6502 lab it was a lot about learning the basics of how things like an MMU works and building basic ones out of TTL logic gates. In the 68k lab you take an MMU for granted and do more ambitious things with that. There's useful skills both from knowing what the low level hardware is like as intimately as a 6502 can get versus the skills from where it is easier to program because you have more modern advantages and fewer limitations.

The other thing about that order was that breadboarding the 6502 hardware was a lot more complex, but it made up for it in that writing and debugging 6502 assembly was a lot easier. There are a ton of useful software emulators for the 6502 and you can debug your code easily before ever testing it on lab hardware. At one point in that lab I even just wrote my own mini-6502 emulator specific to our (intended) breadboard hardware design. On the other side, there a lot fewer software emulators for the 68k and the debug cycle was a lot rougher. The 68k breadboard hardware was a bit more "off the shelf" so it was easier to find an existing emulator that matched our (intended) hardware design, but emulator itself was buggier and more painful to use and ultimately testing on the real hardware was the only trustworthy way to deal with it. I also wasn't going to try to write my own 68k emulator. (Though some of the complexity there was the realities of hardware labs in that the hardware itself starts to pick up its own localized quirks from being run only on breadboards for years.)

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

#195
This is like making a big deal of the flaws of the first automobile. OF COURSE, there are more appropriate ways to teach ASM today .... its been 50 years. As designer of the first sets of computer cards (yes, way before Apple) ... the Jolt, Super Jolt, SYM-1 we sold over 75K units mostly used to teach early college students to program. Ray Holt FirstMicroprocessor. com

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

#196
What about the modern 68K subset still manufactured as Coldfire? Much more orthogonal, modern (as of the 1980s) architecture.

On the other hand, the cleaner, more modern architectures are easily targeted by compilers. If you really want to live the "assembly language required for performance" era, the 6502 is fine. Equally quirky is MCS-51. I've written nontrivial assembly language projects for both "back in the day".

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

#198
post #177
post #118

I would argue that 6502 is a bad first ISA to learn if you want learn assembly. You‘ll spend most of your time fighting the quirks of this clever, but deeply flawed architecture. The idioms you learn to work around them don‘t translate to any better designed architecture that wasn‘t constrained by the tools and budget available to MOS at the time. If you want to learn a small, yet powerful instruction set with a few…

I wrote a lot of 6502 assembly once, and you spend a lot of time dealing with the 8-bittedness of the architecture. Multiplying two 16 bit numbers is a whole blob of code. That doesn't seem useful for new programmers to struggle with. The early ARM ISAs are good, as you say.

Multiplying (or even adding) two 16bit numbers is a good learning experience for assembler. I think it really depends on your goal. I learned x86 assembly way back when it was relevant but now I do 6502 assembly for fun. The simplicity and the limitations are what make it interesting.

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

#199

Earlier quoted context omitted.

6502 really has 262 registers: 256 zero page plus those standard ones mentioned. Or 260 for 6510, as zero page addresses 0 and 1 are for I/O. Practically anything non-trivial uses those zero page addresses as extra registers.

I get what you're saying but I wouldn't personally call zeropage bytes _registers_, even though they are physically connected to internal ones. I treat them as a special zone of memory that has special properties. There are many of these things and just like you would start with any of the old machines you'd first take a look at the memory map to see where's what and how to use it. Registers in a traditional sense wo…

> even though they are physically connected to internal ones

They're not physically connected, other than through the bus. I mean, zero page is part of DRAM.

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

#200
post #130

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…

While I learned programming with 6510, I agree that 68000 instruction set was much nicer and easier to read and learn. I would also chose 68000. This said, 65XX on an early Commodore computers was extremely rewarding to use because there was no memory protection and you could write code altering video memory, mess with sprites, fonts, borders, interrupts, write self modifying code etc etc. 68000 assembly on Amiga was…

68000 assembly on Macintosh was the wild west, nothing protected at all, and it was so much fun.
Post reply on HN