Hacker News new | ask | show | jobs
by PinkMilkshake 2786 days ago
I've only had a passing interest in learning assembly. It's always been in the "maybe one day" category.

But after learning about how small the RISC-V instruction set is (less than 50 apparently, but I can't find a citation for that anywhere), I'm far more motivated to get into it.

7 comments

I recommend the 6502[1] if you're just starting. What you learn applies almost everywhere, and it's very much a what-you-write-is-what-happens sort of processor. No branch prediction, no caches, no fancy features. Its op-set is very small and highly expressive. They still make them, in fact.

That said, whether you choose to start with it or RISC-V, from personal experience SiFive's implementations are phenomenal. I used one of their free-implementations, and I was blown away by how easy it was to use their automated tools to build a core exactly the way I wanted. Not as easy as generating a NIOS core, but much more capable. With an Artix-7, I had a very capable low-range processor in about an hour.

[1]: https://skilldrick.github.io/easy6502/

If you just want to dip your hand in, chip8 is also a good starting point (if even less useful than 6502): where 6502 has about 80 actual opcodes acrosss ~50 mnemonics (https://en.wikipedia.org/wiki/MOS_Technology_6502#Assembly_l...) chip8 has 35 opcodes across 19 mnemonics (ADD, AND, CALL, CLS, DRW, JP, LD, OR, RET, RND, SE, SHL, SHR, SKNP, SKP, SNE, SUB, SUBN, XOR).
Having taught asm to people as their first language, I'd go with something like an MSP430. Since a 6502's registers are only half the pointer width, it really makes pointer manipulation more of a pain in the ass than it needs to be. That really obfuscates quite a.few.of the concepts that you're trying to learn by writing asm for a simple core.
The base instruction set is small enough to fit on a card. Of course adding the floating point, vector extensions, etc. would make it a bit harder to squeeze into a single page, but I think it would still end up smaller than the x64 spec.

https://www.cl.cam.ac.uk/teaching/1617/ECAD+Arch/files/docs/...

I'm not sure that's a useful metric; in almost all architectures there's a "core" set which gets used the vast majority of the time in most programs, plus an increasing number of extensions for very specific purposes. You could start today on ARM with the top 20 instructions and get quite a long way.
If you use a Cortex-M0 (v6M) then there are only 60 or so instructions total...
>But after learning about how small the RISC-V instruction set is (less than 50 apparently, but I can't find a citation for that anywhere), I'm far more motivated to get into it.

from the times when x86 wasn't that big: http://pastraiser.com/cpu/i8080/i8080_opcodes.html

30 years ago we were typing the hex codes of those commands straight into the Forth words bodies using the mental copy of that table (as you see it has very logical easy to remember organization)

The 6809 doesn’t get enough love. It was quite good for the era, easy to learn, and could support things like OS/9.

https://en.wikipedia.org/wiki/OS-9

MIPS isn't bad either. Both are pretty small and well-designed, and not particularly complicated.
Check out MSP430 is you want small instruction sets, also fits on one page if needed.