Go: cmd/asm Files | Directories

Command asm

Asm, typically invoked as “go tool asm”, assembles the source file into an object file named for the basename of the argument source file with a .o suffix. The object file can then be combined with other objects into a package archive.

Command Line


go tool asm [flags] file

The specified file must be a Go assembly file. The same assembler is used for all target operating systems and architectures. The GOOS and GOARCH environment variables set the desired target.


-D name[=value]
	Predefine symbol name with an optional simple value.
	Can be repeated to define multiple symbols.
-I dir1 -I dir2
	Search for #include files in dir1, dir2, etc,
	after consulting $GOROOT/pkg/$GOOS_$GOARCH.
	Print assembly and machine code.
	Print assembler version and exit.
	Dump instructions as they are parsed.
	Support references to Go symbols defined in other shared libraries.
-o file
	Write output to file. The default is foo.o for /a/b/c/foo.s.
	Generate code that can be linked into a shared library.
-trimpath prefix
	Remove prefix from recorded source file paths.
	Write symbol ABI information to output file. Don't assemble.

Input language:

The assembler uses mostly the same syntax for all architectures, the main variation having to do with addressing modes. Input is run through a simplified C preprocessor that implements #include, #define, #ifdef/endif, but not #if or ##.

For more information, see https://golang.org/doc/asm.

Package Files

doc.go main.go


internal/archPackage arch defines architecture-specific information and support functions.
internal/asmPackage asm implements the parser and instruction generator for the assembler.
internal/flagsPackage flags implements top-level flags and the usage message for the assembler.
internal/lexPackage lex implements lexical analysis for the assembler.

Package main imports 12 packages (graph). Updated 2020-07-22. Refresh now. Tools for package owners.