问题描述
我正在将一些 Arm64 汇编语言移植到 M1.
I'm porting a bit of Arm64 assembly language to an M1.
其中一些是由 C 预处理生成的,其中单个 #define
宏生成多个以分号分隔的语句.
Some of it is generated by C preprocessing, in which a single #define
macro generates multiple statements separated by semicolon.
不幸的是,在 M1 上,汇编程序将分号视为注释字符.
Unfortunately, on the M1, the assembler treats the semicolon as a comment character.
例如:
#define DEFUN(NAME) \
.globl _ ## NAME ; \
.palign 2 ; \
_ ## NAME:
导致 .globl
指令之后的所有内容都被视为注释.
causes everything after the .globl
directive to be treated as a comment.
MacOS as
手册页没有提供任何线索;它没有涵盖语法.
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.
推荐答案
对于面向 Apple 平台的 aarch64 程序集,您可以使用 %%
作为分隔符.不确定它是否/在哪里记录,但它设置在 LLVM 源 此处.即使它可能没有在任何地方明确记录,它也会在许多地方使用,例如在 libunwind 和 compiler-rt,所以它可能不会随心所欲地改变.
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.
这篇关于我们如何在Apple平台的AArch64程序集中在一行中编写多条语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!