Live data from Hacker News

I believe 6502 instruction set is a good first assembly language

nemanjatrifunovic.substack.com

211–220 of 297 posts

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

#211

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…

6502 and 68000 are both perfectly good assembly languages, but I think the best remains PDP-11 assembly. It scans so nicely in octal. :)

For anyone interested, learn the PDP-11 instruction set from the first model, the PDP-11/20, before DEC added protection modes, memory management hardware, etc. A summary of the instruction set is in Appendix A, and it's worth taking a look at chapters 3 and 4 of the PDP-11(/20) Handbook to get more detail on each instruction and the addressing modes.

https://bitsavers.org/pdf/dec/pdp11/1120/PDP-11_Handbook_Sec...

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

#212

Earlier quoted context omitted.

ARM designers liked and had extensive experience with 6502 - it WAS their bread and butter for a long time - and this might be why the mnemonics are so similar (and carry in subtraction - that might have been for making porting easy, but I won't risk assuming that without a primary source). They obviously also studied foundational papers on RISC and understood the possibility of having a simple design (such as the 65…

Completely agree with all these points and that without the 6502 the ARM1 would not have looked like it did. One might say ARM1 was inspired by the 6502 and it prevented them going down the CISCy 68k route. But I don't think that ARM 'ARM borrowed most of its design from 6502' or (to my mind at least) looks like a refreshed 6502. There are just too many fundamental differences: - ARM1 was a load/store architecture /…

Things like conditional execution being always available, and the barrel shifter being always available feel a lot more like ideas from VLIW architectures. And when you come from 8-bit instructions and suddenly have 32 bits available, your instructions are a very long word.

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

#213

What is a "good" assembly language? The best I've ever seen was the VAX instruction set. The second best, probably m68k. These were big, CISC CPUs that were as nice as possible to program in assembly language. The 6502 wasn't. Everything about the 6502 was "do more with less" and you had to be really clever to eke out performance on it. But that's a good thing! A clean, big CISC architecture like the former ones is a…

Arguably PDP11 is probably the best. Dates back to the assembly language programming era, but nice clean instruction set. But what are you going to run your PDP11 code on? A simulator? Sure. But no real, consumer facing machines with graphics chips.

If you like the PDP11 instruction set, then you'll probably enjoy 68000 as well. It drew a lot of inspiration from the former. You lose the "deferred" addressing modes (though the 68020 adds something similar), but gain access to a few other useful ones. Conveniently it was used in a lot of consumer devices (Mac, Amiga, Sega Genesis, etc.)

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

#214
post #152

Every time I have tried to learn assembly, I've gotten frustrated with an overwhelming urge to try and automate it. I end up having to talk myself down like "no, we're here to learn, not to create another language"

Maybe you can meet yourself halfway and write assembly macros to make your life easier.

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

#215
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 think this is true for any bus/register size. Various high-level language "bignum" libraries generalize to any size.

But it's true that with only 8 bits, the problem happens very soon. However, if one doesn't want to solve basic problems "the hard way", one probably won't be interested in assembly programming anyway.

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

#216
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 kept thinking about the Ben Eater's 65C02 in a bread board series[1], is there any way to replicate what he is doing in his videos with an ARM CPU?

[1] https://youtube.com/playlist?list=PLowKtXNTBypFbtuVMUVXNR0z1...

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

#217
I think that the first question to ask oneself is "why do you want to learn assembly language?"

If you want to learn to write programs in assembly language or to debug disassembly of programs written in higher languages, then learn the language for the platform that you want to target. This also covers the "I want to write/understand retro stuff" case.

If you want to understand how high-level programs are compiled into assembly language, then read Aho[1].

If you want to understand how algorithms are implemented in assembly, read Knuth[2]. Knuth invented a hypothetical computer "MIX" with its own assembly level instruction set and I believe that MIX has actually been implemented in software several times.

If you just want to play a little bit with assembly, "dipping your toes in the water", then I agree with the OP that 6502 is simple and easy to learn, but it is not practical for many modern use cases and has sharp edges.

[1] "Compilers - Principles, Techniques and Tools", by Alfred V. Aho et al. https://en.wikipedia.org/wiki/Compilers:_Principles,_Techniq...

[2] "The Art of Computer Programming", Volume 1, by Donald Knuth, Section 1.3 "MIX" (p. 124 in the 3rd edition) https://en.wikipedia.org/wiki/The_Art_of_Computer_Programmin...

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

#218
This may be an unpopular opinion but I think Knuth's MMIX is ideal as an initial introduction to ASM these days.

It is Purpose built, load-store etc...

https://mmix.cs.hm.edu/

You can use the simplified MMIX-SIM

Then you can move to typical RISC features like full pipeline, cache, etc...

Then you can move to actual hardware etc..

But I am probably bitter, I learned on a Heathkit ET 3400, and I find that a lot of the quirks of the 6800 are something I had to get around to understand modern processors.

MMIX may not be 'useful' for real applications, but being intentionally free of those quirks is very useful for understanding the core concepts, at least for the few people I have had try it.

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

#219
My first exposure assembly language was the PDP-10. All I had was the DEC-10 processor manual. I was completely baffled by it. It had hundreds of instructions, with completely opaque descriptions. What was a register? What was an accumulator? What was an address? What was a stack? I had no idea. David Rolfe wrote some subroutines I needed for my Fortran version of Empire, and that helped a little, but I was lost.

One day, I asked my friend Shal Farley, what was a stack? He said "Imagine a stack of plates. You added a plate (pushed it on the stack), and took off a plate (popped it off the stack). Suddenly, Shal had turned the lights on! I instantly understood it.

Then, I began working with a 6800 microprocessor on a little board. It had something like 40 instructions, that all fit on a card. 40 instructions were simple to learn, and suddenly, I got it.

I want back to the -10 manual, and it all made sense.

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

#220

I prefer RISCV as an starting assembly language because: it has good design, it's more intuitive, it has modern language and tool support (GCC, LLVM, Rust, etc.), and it runs on QEMU and real available hardware.

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

All my old assembly games would be 14x too fast. I'd have to adjust the between loop sleep constant?
Post reply on HN