Home

Awesome

asmfmt

Go Assembler Formatter

This will format your assembler code in a similar way that gofmt formats your Go code.

Read Introduction: asmfmt: Go Assembler Formatter

Go Reference Go

See Example 1, Example 2, Example 3, or compare files in the testdata folder.

Status: STABLE. The format will only change if bugs are found. Please report any feedback in the issue section.

install

Binaries can be downloaded from Releases. Unpack the file into your executable path.

To install the standalone formatter from source using Go framework: go install github.com/klauspost/asmfmt/cmd/asmfmt@latest.

updates

goland

To set up a custom File Watcher in Goland,

Advanced options, Enable:

Disable the rest.

Goland Configuration

emacs

To automatically format assembler, in .emacs add:

(defun asm-mode-setup ()
  (set (make-local-variable 'gofmt-command) "asmfmt")
  (add-hook 'before-save-hook 'gofmt nil t)
)

(add-hook 'asm-mode-hook 'asm-mode-setup)

usage

asmfmt [flags] [path ...]

The flags are similar to gofmt, except it will only process .s files:

	-d
		Do not print reformatted sources to standard output.
		If a file's formatting is different than asmfmt's, print diffs
		to standard output.
	-e
		Print all (including spurious) errors.
	-l
		Do not print reformatted sources to standard output.
		If a file's formatting is different from asmfmt's, print its name
		to standard output.
	-w
		Do not print reformatted sources to standard output.
		If a file's formatting is different from asmfmt's, overwrite it
		with asmfmt's version.

You should only run asmfmt on files that are assembler files. Assembler files cannot be positively identified, so it will mangle non-assembler files.

formatting