An Emacs minor mode for viewing Go compiler assembly output. Generates Plan 9 pseudo-assembly scoped to the current function, with source-line-to-assembly navigation and syntax highlighting.
- Per-function assembly - Generates assembly output for the Go function at point using
go build -gcflags '-S' - Source-to-assembly navigation - Jump the assembly view to the instructions corresponding to the current source line
- Assembly-to-source navigation - Jump from an assembly line back to the corresponding source line
- Jump-to-address navigation - Follow branch/jump instructions to their target offset, or jump to any byte offset manually
- Instruction documentation - Inline eldoc hints for assembly instructions, plus
dto open full documentation in a browser (x86/ARM/Go pseudo-instructions) - Assembly highlighting - Matching assembly lines are highlighted when navigating from source
- Syntax highlighting - Assembly instructions, registers, hex addresses, and source references are font-locked in the output buffer
- Auto-recompilation - Moving to a different function and navigating automatically re-generates assembly
- Emacs 27.1+
- Go compiler (
goon PATH) - A Go project with a
go.modfile
Clone the repository and add it to your load path:
(add-to-list 'load-path "/path/to/goasm-mode")
(require 'goasm-mode)(use-package goasm-mode
:load-path "/path/to/goasm-mode"
:hook (go-mode . goasm-minor-mode))Enable the minor mode in a Go buffer:
M-x goasm-minor-mode
Or add it to your go-mode hook:
(add-hook 'go-mode-hook #'goasm-minor-mode)In a Go source buffer (goasm-minor-mode):
| Key | Command | Description |
|---|---|---|
C-c ! |
goasm-show |
Generate assembly for the function at point |
C-c . |
goasm-goto-line |
Show assembly for the current source line (compiles automatically if needed) |
In the *goasm* assembly buffer:
| Key | Command | Description |
|---|---|---|
l |
goasm-goto-source |
Jump to the source line referenced by the current assembly line |
d |
goasm-describe-instruction |
Open documentation for the instruction on the current line |
f |
goasm-follow-jump |
Follow the branch/jump instruction on the current line to its target |
j |
goasm-jump-to-address |
Jump to an assembly line by byte offset (decimal or 0x hex) |
- Open a Go source file and enable
goasm-minor-mode - Place your cursor inside a function
- Press
C-c .to see the assembly for the current line — assembly is compiled automatically on first use and when you move to a different function - Move to other source lines and press
C-c .again to jump the assembly view and highlight the matching instructions - In the
*goasm*buffer, presslon any assembly line to jump back to the corresponding source line - Hover on any instruction to see a short description via eldoc, or press
dto open full documentation in your browser - On a branch/jump instruction (e.g.
JMP 16,BGT 8), pressfto follow it to its target offset — useC-u C-SPCto jump back - Press
jto jump to any byte offset by typing it (decimal or0xhex)
You can also use C-c ! to explicitly generate assembly without navigating to a specific line.
| Variable | Default | Description |
|---|---|---|
goasm-go-command |
"go" |
Path to the Go executable |
goasm-build-flags |
nil |
Additional flags passed to go build |
make test # Run the ERT test suite
make lint # Byte-compile and check for warnings
make clean # Remove compiled filesGPL-3.0. See LICENSE for details.
Roman Nestertsov