Canonical, up-to-date documentation of Apple's assembler ?

I'm trying to get hold of a reliable documentation for the Apple assember ('as'), especially for the M1/M2 ARM architecture, but I suspect it's similar for x86 as well.

I found outdated links here:

https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/Assembler/000-Introduction/introduction.html

But the new documentation site for Xcode (I assume this is where I would have to look) does not seem to have assembler documentation.

It's possible that apple uses the clang-llvm assembler, but it would then be nice to have an authoritative pointer to that documentation. Web searches seem futile for this subject :(

Thanks for any pointers.

Replies

My working hypothesis is that the Apple assembler is close to

 https://developer.arm.com/documentation/100067/0611/armclang-Integrated-Assembler.

But: there are some differences: for instance, the arm documentation allows multiple statements in one line separated by semicolons – the apple assembler does not allow it, it seems to treat semicolons as start of comments.

And :'close to' is not really good enough for someone that needs to port a large assembly program to a new architecture, I'd really need accurate documentation.

If that does not exist, can someone point to the actual source code (I believe it's open source, so should be freely available).

Again, thanks for pointers!

can someone point to the actual source code

So there are two assemblers in play here. If you run as from the command-line, you get the Clang integrated assembler [1]. Consider:

% as --help
OVERVIEW: clang LLVM compiler
…

However, there’s an older codebase that’s part of the cctools project. Based on this, it seems to be an ancient import of gas.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] For Intel and Apple silicon. See the discussion of -q and -Q in the as man page.

That's great, thanks for the digging.

However, I don't quite think the cctools 'as' is the one running on MBPs - for instance, this version only recognizes '@' as comment start for arm.

That's not even recognized by Apple's 'as'.

Oh, I see - you are saying the cctools as is a separate compiler. the arm.c file seems to indicate NEON instructions, so maybe it can create arm64 binaries. Do you know if anyone has actually successfully used the cctols/as for the M1 MBPs ?

  • Oh, I see - you're saying the cctools as is a separate assembler that may work on M1 macs ? has this been tried ? The arm.c file at least mentions NEON instructions, so maybe it can assemble arm64 ?

    Do you happen to know if the 'as' running on mac books is in fact open source and/or whether that source code is published anywhere ? That would be far more convenient than trying to build the cctools assembler.

Add a Comment

Do you know if anyone has actually successfully used the cctools/as for the M1 MBPs ?

I don’t know for sure.

The Clang integrated assembler has been the default for so long that I suspect that no one has ever used the (increasingly poorly named) system assembler for Apple silicon.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"