Assembly syntax

57 views
Skip to first unread message

fctorial

unread,
Dec 22, 2020, 9:49:03 AM12/22/20
to zircon-dev
What is the assembler and assembly dialect used in fuchsia project? The assembly files use constructs like `DATA`, `END_DATA`, `FUNCTION`, `END_FUNCTION` which aren't documented in gnu assembler reference. The argument order of instructions is also different.

Sam Hansen

unread,
Dec 22, 2020, 12:47:19 PM12/22/20
to fctorial, zircon-dev
Those are simply macros defined in zircon/kernel/include/asm.h

Unless you configure otherwise (by way of --variant), clang is used as
the compiler (and associated toolchain).

See: docs/development/build/toolchain.md for more info.

Also, note that the tree contains assembly listings for different
architectures (namely, aarch64 and x86), which source were you looking
at?

On Tue, Dec 22, 2020 at 6:49 AM fctorial <fcto...@gmail.com> wrote:
>
> What is the assembler and assembly dialect used in fuchsia project? The assembly files use constructs like `DATA`, `END_DATA`, `FUNCTION`, `END_FUNCTION` which aren't documented in gnu assembler reference. The argument order of instructions is also different.
>
> --
> All posts must follow the Fuchsia Code of Conduct https://fuchsia.dev/fuchsia-src/CODE_OF_CONDUCT or may be removed.
> ---
> To unsubscribe from this group and stop receiving emails from it, send an email to zircon-dev+...@fuchsia.dev.

fctorial

unread,
Dec 22, 2020, 9:39:57 PM12/22/20
to zircon-dev, Sam Hansen, zircon-dev, fctorial

I was reading 'zircon/kernel/arch/x86/asm.S'. The argument order is same as gas.

Roland McGrath

unread,
Dec 23, 2020, 4:36:47 PM12/23/20
to fctorial, zircon-dev
Fuchsia's code can be built by the Clang compiler using --target=*-fuchsia.  On x86-64 (--target=x86_64-fuchsia), this uses so-called AT&T assembly syntax, the same syntax most commonly used on Linux and other ELF-based systems (I believe this syntax is also used on macOS/x86).  We do not use so-called Intel assembly syntax, which is what is used on Windows and what appears in Intel's processor manuals.  On AArch64, there is a single common assembly syntax specified by ARM and that's what Clang supports for --target=aarch64-fuchsia.

Note that .S files are assembler-with-cpp, so they can use C-style macros and `#include` and such.  In the Fuchsia code base all assembly files we write are .S files that can use the C preprocessor.  We also use GNU-style assembler macros (defined with `.macro`) in some places, and have some header files defining some of those as well as header files that define C-style macros used in assembly code.
Reply all
Reply to author
Forward
0 new messages