5 ms·
Learning assembly was probably the biggest thing that made computers click in my head. Since then, I've always thought that learning assembly as your first prog
by TheAceOfHearts 10y ago
Learning assembly was probably the biggest thing that made computers click in my head. Since then, I've always thought that learning assembly as your first programming language would be a great place to start. Of course, I'm sure this doesn't apply to everyone.
In CS you're usually started off with something like C, Java, or Python. But those languages are so HUGE (in comparison) that it can be really overwhelming. Meanwhile, with assembly, you have far fewer items in your toolbox and you have no abstractions between what you write and what's being executed.
After googling, I found emu8086 [0], which I think is what I used to debug the tiny apps I was writing. It was great! You could step back and forward in time, and you could inspect every detail.
[0] http://www.emu8086.com/ http://www.emu8086.com/
- sanderjd 10y agoI think this is tricky. I was exposed to 8086 assembly having only previously seen a couple flavors of BASIC, and I have to say that it mostly went over my head. It was hard for me to see the bigger picture, the useful functionality that we were painstakingly working toward with our little instructions moving bytes around and taking different paths based on flags. I remember system calls (which are covered early on in the OP) seeming especially confusing and magical. On the other hand, when I dove deeper into (m68k) assembly a few years later, after getting some C and C++ under my belt, it was an amazing eureka moment that made both the earlier assembly exposure and what I had learned of higher level languages click into place. So I do think learning assembly early on is great, but I'm not sure it's such a panacea to learn it first.
- spc476 10y agoAssembly was my second language (BASIC being my first), but it was not the x86 line I learned first (it was my second assembly language). I can name half a dozen architectures that are probably better for learning than the x86, some of them relevant today. Probably in order: 6502---not my favorite, but tons of material and emulators exist. The most popular 8 bit CPU and one of the most simple ones. 6809---my favorite 8-bit and it lends itself fairly well towards higher level languages. A nice register set (2 8bit general purpose registers, four 16bit index registers) and a regular instruction set makes it easy to program. 8080 (or Z80)---if you are going to start down the dark side of x86 line, it's probably best to start at the beginning. A mess of registers, most of which are somewhat general purpose but each has a specific use. 68000---a very nice 32-bit architecture with enough regularity to make it easy to write compilers for, with enough instructions to make it fun to write assembly code. 8 32bit data registers, 8 32bit index registers. VAX---another nice 32-bit architecture with a very regular instruction set. 16 32bit general purpose registers. MIPS---one of the original RISC architectures that's still in use. Perhaps a bit too spare on instructions. 32 32bit registers. ARM---Kind of reminds me of a RISCish 68000 with unique features that make it, again, fun to program at the assembly level. The x86 line is ... baroque due to its history (you can think of it as an overglorified 8080 that gained power over time, much like the MCP in TRON if you think about it) of ossified layers. It's hard to learn because it's almost all exceptions to a non-regular instruction format.
- mikekchar 10y ago6809 is vastly underrated I think. It is super simple, but also has everything you need to program efficiently. I think if I were to introduce people to assembly langue programming first, I would pick that one. Especially being 8 bit with 16 bit addressing gives you a good segue into byte ordering. 6502 was my first (and only really significant) experience with assembly. It is so minimal as to be awkward at times, but as you say with the huge numbers of emulators and instructional materials around, it's hard to discount it. Personally, I would skip x86 altogether unless you actually want to do x86 programming ;-). I've never looked at ARM, but your description makes me want to play with it. The added bonus is that it is still relevant today.
- clishem 10y agoI've been looking to buy "Introduction to 64 Bit Assembly Programming for Linux and OS X: Third Edition - for Linux and OS X". It's an introduction to x84-64 assembly, which I thought makes sense for me to learn, because it is the architecture all my computers use. You say x86 is not a good choice to learn, but this book purports to make assembly for this architecture accessible. If you stand by your opinion, are there even CPUs readily available that support the alternative architectures you mention? Also, can anyone recommend this or any other book or learning resource?
- e12e 10y agoSource code etc on the book homepage for those interested: http://rayseyfarth.com/asm/index.html http://rayseyfarth.com/asm/index.html
- spc476 10y agoAs a first language, or even as a first assembly language. Once can certainly learn it, and it may even come across as half decent if you skip some of the less used instructions (like LOOP, REP, LODS, STOS, AAD, AAS---basically, the really archaic instructions that aren't really used or optimized). But with nearly 40 years of backwards compatibility, it's a monster of an architecture.
- e12e 10y ago
- GolDDranks 10y agoI had the same epiphany. For the long time, I regarded computers deeply magical, and didn't understand why some programming languages had the features they had, and some don't. (At the time, I only knew Python and some superficial C.) Then I read a book that explained how assembly works and how a compiler would implement C's features with assembly. It all clicked since then. Too bad I've forgotten the name of the book.
- llamaz 10y agoAt my university the sequence over two years is python --> boolean algebra + logic gates --> assembly --> c + java It used to be scheme + boolean algebra + logic gates --> assembly + unix programming in c (threads, pipes) but that was a bit too hardcore for freshman in first semester