Suggestion for an assembly language tutorial?

Sometimes discussions here ends up at the assembly level… do you have a super entry level tutorial on assembly to recommend ? Where I can find the main concepts but also a bit of stuff to try in practice (Linux x64) ?

3 Likes

What do you mean by assembly? I know of political assemblies and school assemblies, but I have never heard this term used in the context of programming. OK, I think you mean assembly programming. But then, that is CPU-specific, for which CPU?

First hit on Google: Assembly Programming Tutorial

Fun fact: My first assembly language was the 6502 Assembly Language. I used it to write a Basic interpreter and an OS. But it doesn’t work with Julia. :frowning:

Throw in LLVM too, I still don’t really know what @code_llvm is saying most of the time.

I think you are thinking of machine code. Assembly language is an abstraction layer over that again, so should work for many different CPUs, but perhaps not across different architectures.

1 Like

As “entry level” you may have a look at some computer architecture textbook (e.g. Harris and Harris).
Yes machine language is CPU-specific, but some professors tend to say “if you now one (RISC) assembly, you know all”.

But machines like x64 are far more complex than textbook RISC and have evolved over decades. this is why compilers are really needed, build by expert compiler engineers.

Takeaway: Only get to assembly level as very last resort of micro-optimization. Before that, think of restructuring your algorithm / datastructures and build very good benchmarks. Performance bottleneck is memory, >99%.

you both mean ISA - Instruction Set Architecture

(However, exact timing and energy consumption depends on the specific implementation in silicon, not just the ISA. So any performance must be tested on the very target machine.)

https://uops.info/ is an excellent reference

2 Likes

I recommend the book by Igor Zhirkov Low-Level Programming: C, Assembly, and Program Execution on Intel(r) 64 Architecture.

1 Like