4

I'm porting a bit of Arm64 assembly language to an M1.

Some of it is generated by C preprocessing, in which a single #define macro generates multiple statements separated by semicolon.

Unfortunately, on the M1, the assembler treats the semicolon as a comment character.

For instance:

#define DEFUN(NAME)  \
  .globl _ ## NAME ; \
  .palign 2 ;        \
  _ ## NAME:

causes everything after the .globl directive to be treated as a comment.

The MacOS as man page provides no clue; it has no coverage of syntax.

Is there an alernative character for separating statements? I tried using @ and !, but both are rejected.

Answers to this question are of no use here.

mstorsjo
  • 12,603
  • 2
  • 37
  • 61
Kaz
  • 51,856
  • 9
  • 92
  • 143

1 Answers1

6

For aarch64 assembly targeting Apple platforms, you can use %% as separator character. Not sure if/where it's documented, but it's set in the LLVM source here. And even if it might not be documented explicitly anywhere, it is used in a number of places, e.g. in libunwind and compiler-rt, so it probably won't change in a whim.

mstorsjo
  • 12,603
  • 2
  • 37
  • 61
  • Thanks a lot; that works perfectly. I can now throw away the annoying special case treatment of this platform. – Kaz Mar 24 '21 at 06:55