Developer's Guide Chapter 11 - not significantly revised since 2006

I have been looking for a good, current source of information related to Assembly on FreeBSD. The closest I've come is:

The FreeBSD Developer's Handbook, Chapter 11. x86 Assembly Language Programming, by Adam Stanislav

For general assembly language instruction, I've found:
The Art of 64-bit Assembly: Volume 1, by Randall Hyde
x64 Assembly Language: Step by Step - Programming with Linux 4th ed., by Jeff Duntemann

Stanislav's chapter is FreeBSD specific, but it appears to be quite dated. I did some webarcheology and figured out that the version in the handbook is from 2006, with the only revisions being the Unix copymark, chapter headings, and word here or there.

Hyde's book is good, but it's MASM, so I'm constantly doing all kinds of translations to see the results in FreeBSD. Duntemann's book is for linux, so it's not that big a deal to make the leap to FreeBSD and is likely the text I'm gonna work from...

but, my question is, is there any chance that there'll be a x64 update to the chapter, or am I looking in the right place for this kind of info (the dev handbook)?
 
Coincidentally, I have been looking at that same chapter myself a few days ago and arrived at a similar conclusion.

I'm not sure what the process here is because that seems to be both docs@ related as well as src@ related.
Maybe grahamperrin could shed some light on how such an update effort would look like.

I assume somebody from the technical side of things would need to volunteer to do the bulk of the work and somebody else would probably need to review that thoroughly before passing it to the docs@ team.
I'm inclined to start pointing fingers towards cracauer@ :p
 
There is nothing very specific about FreeBSD when it comes to assembly language. You can learn a lot by looking at the .s files created by "cc -S".
 
There is nothing very specific about FreeBSD when it comes to assembly language. You can learn a lot by looking at the .s files created by "cc -S".
Right, Of course, at a certain level of abstraction, it is the same, but take a linux hello world asm file or worse yet a masm file and try to run it through FreeBSD's toolset (llvm or gnu or nasm, yasm, etc). You'll dump core every time, even if you fix up all the syntax, though it all looks reasonable. That's why the dev handbook is so useful. It explains the different calling conventions in use, the system call differences, the syntax variations and what not. I've hand coded PDP-7 machine code and KIM-1 too (all via emulation or retro-kits of course, I'm old, but not that old) and while moving bits around is nothing new, every system is different and to newbs on a new platform, the orientation to the platform's way of doing things is super helpful.

The cc -S approach is dandy, if you're familiar with a c based language, no complaints there :).
 
take a linux hello world asm file or worse yet a masm file and try to run it through FreeBSD's toolset (llvm or gnu or nasm, yasm, etc). You'll dump core every time, even if you fix up all the syntax, though it all looks reasonable.
How to translate assembly code written in another style or for another OS is not FreeBSD's responsibility. *You* need to understand them both if you want to try such a thing but you can't expect any FreeBSD document to cover this case. Just like how to write a document in English doesn't cover anything about translating documents written in other languages!
The cc -S approach is dandy, if you're familiar with a c based language, no complaints there :).
Pick any language whose compilers produce assembly output. C just happens to be easier.

The calling conventions are written for C as C is the "native" language for Unix systems. So before you dive into assembly you need to understand C. Even 99.9% of kernel code is written in C, not assembly.
 
How to translate assembly code written in another style or for another OS is not FreeBSD's responsibility. *You* need to understand them both if you want to try such a thing but you can't expect any FreeBSD document to cover this case. Just like how to write a document in English doesn't cover anything about translating documents written in other languages!

Nope it's not a responsibility, it's a service. And that's what the handbook does. It would just be nice if it was updated. Sheesh.
 
I don't see too much that needs correcting. These days I would recommend calling system calls through libc, not directly from assembler, but that is a matter of taste.

I didn't write much assembler, I usually looked at compiler output. Normally SBCL's assembler output, which is its own format. These days more in Compiler Explorer (which is really cool, check it out if you haven't). https://godbolt.org/

A bit torn about the utility of assembler. On one hand there is now a second architecture that matters (ARM). On the other hand we can see that compilers doing SIMD on their own has failed, otherwise the Foundation wouldn't have a project to do SIMD for string functions in libc. Somebody is doing a lot of assembler there.
 
… both docs@ related as well as src@ related.
Maybe grahamperrin could shed some light …

An example:
  1. as a subscriber to the freebsd-doc list, I followed 270481 – intro(9) needs an update/rewrite
  2. I don't recall viewing the related review, ⚙ D41104 intro(9): rewrite from scratch
  3. I made a related PR, intro.9: minor changes by grahamperrin · Pull Request #813 · freebsd/freebsd-src.
More generally:
 
Lulu comes to the rescue again and with a bit of artwork from the available stuff, looks about right. Weighing in at just about an inch thick. Way better than pdf :).

IMG_4089.JPG
 
Back
Top