
NASM Tutorial (2018) - AlexeyBrin
http://cs.lmu.edu/~ray/notes/nasmtutorial/
======
jdsully
Assembly is still quite useful in a number of circumstances. The compiler was
generating terrible code for a ticket (spin) lock, and rewriting in assembly
helped considerably [1].

Its also still the best way to get the most out of AVX and SSE. I find the
register allocation to be extremely poor when using intrinsics.

1\.
[https://github.com/JohnSully/KeyDB/blob/unstable/src/fastloc...](https://github.com/JohnSully/KeyDB/blob/unstable/src/fastlock_x64.asm)

~~~
gpapilion
i agree with this, but find the complexity of writing assembly with modern
processors instruction sets requires quite specialized knowledge.

~~~
pjmlp
It is, but someone needs to write compiler backends.

~~~
elcomet
It is quite scary to think that less and less people know how to write good
assembly. So in a few years (decades?) we will have to rely on backends, with
almost no one knowing how they really work, or how to write another one.

~~~
reitanqild
Luckily it seems working on language design and compiler stuff is stuff is
considered cool, almost as cool as game programming so I'm not too worried
yet.

------
interfixus
Hello Nineties. Are you home? I miss you.

I don't believe I've really thought or heard of Nasm for the last two decades,
but boy is it time for me to dig it out again and get assembling. For
absolutely nothing but the sheer fun of it and for reconnecting with my
hardware.

Thanks for posting.

------
4thaccount
Does anyone know the best way to run assembly code on Windows?

As usual, I seem to recall this is one of the many things that is easy in
Linux and almost impossible on Windows.

~~~
animal531
Well, since we're talking about NASM, go to
[https://www.nasm.us/](https://www.nasm.us/) and download the latest stable
build for Windows.

~~~
4thaccount
Does that use MINGW though and require you to build all that junk on Windows?

~~~
jcelerier
nasm is a single .exe

------
vgoh1
Wow, NASM is really a blast from the past for me. 80386 assembly was my second
"language" that I learned, after various forms of BASIC (on TRS-80 and
QuickBASIC). In the mid-90's I was a teenager, and would write most of my code
in QuickBASIC, and make optimized code in NASM. QuickBASIC was a compiled
BASIC, but still pretty slow on a 386, so about half of my code base ended up
being assembly.

At one point, I made my own pseudo-language, which was actually just a few
dozen commands that would be translated into NASM, to make programming in
assembly much easier to deal with. I ran out of room on my 40mb hard drive,
and also ran out of backup floppies that worked (I would 3x backup my
important stuff, because the mid-90's was a terrible time for reliable
magnetic media on a budget), so I would periodically delete source code that I
had spent weeks programming. The interpreter was one of those casualties,
which, thinking back, was a really dumb move (I was 15 or so, cut me some
slack!), because I still kept a lot of programs that needed that interpreter
to compile. I have those codebases to this day, and can run the executable on
my retro DOS machines, view the code, but no compilation :-(

I can't remember what my old assembler was, but I do remember NASM was a dream
compared to whatever other assembler I was running at the time. I'm happy to
see that it is still kicking.

In case anyone is wondering why I would be running a 386 in the mid 90's with
a 40mb hdd (and 1mb RAM!), it's just because my parents had the time had no
money, and to them a computer was a computer - they couldn't see the advantage
of 1mb vs 16mb of RAM, people in general were much less computer savvy. It
wasn't until my 30's that my mother realized that my time programming
computers as a teenager was actually something productive!

~~~
pjmlp
On my CS degree compiler assignment, I got to learn a neat trick from our
teacher that I still use when advising someone trying to write a compiler.

Basically, our IL was just a bunch of NASM macros.

So yeah not good at all for doing register assignments or writing any kind of
performant code, but it was a binary generated by our toolchain anyway, and it
felt good.

