Reminds me a lot to a video in the "Low Level Learning" youtube channel. It went through the same path of getting the ref from the chromiumOS site and coding up to a "hello world".
That will make you learn how to write Asm like a compiler, which is useful if all you want to do is read (compiler generated) Asm, but otherwise it only strengthens the notion of "why write Asm if the compiler can do it anyway".
Good handwritten Asm has a very different texture to it than compiler output, and (at least for x86 - perhaps less so for RISCs like ARM) can be substantially more efficient. Many years ago, I remember having to grade students' assignments on writing (x86) Asm in an introductory course, and it was very obvious to see who cheated by using a compiler (probably at O0 too.)
Would love to see some real life examples as even the professor in my Computer Architecture class wasn't able to provide any.
I think the notion of compsci students still having to learn ASM is the relic of an older generation that needs to feel like their outdated skills are still relevant.
If you want to see more examples of handwritten Asm then look at the 512b and below categories in the demoscene. Some of those have appeared on HN too:
The second example only proves my point further: It's a demo from the demoscene. Impressive, but pointless outside enthusiast circles. I'm not going to comment on it.
Regarding the first example: Cool! Really interesting and I wish the contractor / employee all the best. Not many people who can do something like this. That said, are we really forcing compsci students to learn ASM for an entire semester, on the off-chance that they'll end up in a leading security role managing major software products? I feel a different curriculum would be more effective (maybe one that teaches how to avoid these bugs in the first place?).
The only real life application of handwritten ASM that I'm aware of, are the initialization routines for most programming language runtimes (GoLang and C++ come to mind) and microcode optimized shaders in game engines.
You could probably cross-compile on the computer you already own and run the code in an emulator. Or buy a developer board and run on the actual hardware. Raspberry Pi RP2040 boards are pretty inexpensive.
Mac is a lot of money to spend if you care about good Linux support, and Raspberry Pi makes for a very weak workstation (if you can even get one for a reasonable price).
The demand for a developer-oriented ARM workstation is there, but the market still hates us.
I disagree. I think this isn’t a good text. Some examples:
- The text claims to be geared towards beginners, but doesn’t explain what a register is.
- “you are left with an Executable and Linkable Format file (Elf) which is the Linux equivalent of a .exe file” indicates the text is geared towards people who know about execution formats, possibly even Windows users who are.
- “.section .text is where our code will live”, for beginners, needs to explain what sections are and needs a remark that it’s weird that the section named “text” doesn’t contain text, but code. At a very minimum, it should say the reader will have to accept that that magic incantation is needed for now, and that more info will follow.
- the text doesn’t say why you need both ”global _start” and ”_start:”. It does introduce labels, but that’s many lines after using the first one.
Hi author here,
I appreciate the feedback. My goal for this blog is to produce one written article every week, and this one was down to the wire. My view of a beginner is someone that has learned the basics of Python. I struggled a lot with how detailed I wanted the exposition to be and did end up cutting somethings like you mentioned. This won't be the last article I write so I'll keep this in mind in the future
https://azeria-labs.com/writing-arm-assembly-part-1/