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
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.
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
.
VPCMPEQB Y8/*(DI)*/, Y0, Y1 // comment...
/*
part.To set up a custom File Watcher in Goland,
<custom>
template.asmfmt
x86 Plan 9 Assembly file
(it will apply to all platforms)Project Files
$FilePath$
.$FilePath$
$ProjectFileDir$
Advanced options, Enable:
Disable the rest.
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)
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.
;
at end of line.//
, except if comment starts with +
.TEXT
, DATA
and GLOBL
, FUNCDATA
, PCDATA
and labels are level 0 indentation.\
in multiline macros.;
is removed. Space is inserted after, if followed by another instruction.