13 comments

[ 3.4 ms ] story [ 44.9 ms ] thread
I'd encourage every programmer to learn some basic assembly. Arguably ARM assembly is slightly easier to learn but either one will give you a better understanding of the API that your programming languages are abstracting over.

And in my experience it makes teaching about C pointers so much easier.

I'm going through this at the moment.

I've come to the point in my life where I've realised I don't understand modern computers, so tasking myself with trying to learn about this stuff.

My mental model of computing is stuck at around the Z80, I wrote a gameboy emulator a few years ago, but that's far away from what modern machines are doing!

Micros generally are great. You gey a good (high level) understanding of registers because you're interacting with them all the time in normal code. Pretty much everything you do with a microcontroller involves setting a bit in some register, and as you say, that register is really an address (this is usually eaiser to grok when reading values from an attached sensor that requires sending a memory offset).

Also the instruction set tends to be quite small. I'd recommend starting with something like AVR though, a bit easier to get going than ARM.

I'm learning about compilers and operating systems. And I don't know how much assembly should I learn. Ofc, I can't read whole x86 manual.
Enough so that you're comfortable that you have a solid mental model of what the CPU is actually doing when a given program is running. (i.e. at least get to the point where the CPU is no longer a black box to you.)
I did take a computer architecture class but all there was addressing modes and few basic instruction classes. Things got difficult when I started studying OS. Then I came to know that sopport for things like page table, higher privilege level instructions etc are all in Architecture itself (Though I still have to read about them from manual). I don't know what else am I missing.
Learn Assembly, as an abstraction, then learn the instruction (Sets) as you need them. Don't bother targeting X86 if you value your sanity
WTF? This has no instructions at all for assembling a PC!
I got a printed copy of this book. It's a great introduction to x86.
imo it really increases you understanding of security issues, stack, heap, over- and under-runs, debugging without source-code, low level caches etc. people often dismiss it because it not being a useful language to implement applications, but it's kind of essential when optimizing C (you might want to play with inline assembly called from C - not always to make things faster but to better understand where your money is spent).

A great place to visit for a break is @x86instructions Twitter[1] feed. Absolutely hilarious (and you will need some humor to keep your sanity with Assembly on Intel), e.g.:

MOV - Literally Copy Something Instead Of Moving It

or

VLTAYTMPNL - I’d Like To Add Your Scalar Vector Lane To My Professional Network On LinkedIn

...

[1] https://twitter.com/x86instructions

Author here. Surprised to see this here.

I wrote most of the book for the class I was teaching in the 90's. All the textbooks I could find were for 16-bit DOS assembly. I wanted to do 32-bit and use free software. I picked NASM and djgpp because most of my students used Windows. There was no free express version of MS Visual Studio back then. I also wanted to cover interfacing with C since that's how one typically uses assembly, plus it shows how C operates under the hood.

I went into industry in 2000, so never had the time to update it to 64-bit.

> I grew frustrated at teaching 16-bit real mode programming and decided to change to 32-bit protected mode. However, I soon ran into a problem. I could not find a textbook that covered 32-bit protected mode assembly programming!

I skimmed through the book a bit and there is an explanation of what protected mode is in chapter 1, but the actual teaching assembly part of the book seems to be all 32 bit real mode. Is that correct?

No, it's all in 32-bit protected mode.