tmp: rsc.io/tmp/go2asm Files

Command go2asm

Go2asm converts the Go compiler's -S output to equivalent assembler source files.

Usage:

go2asm [-s symregexp] [file]

Go2asm reads the compiler's -S output from file (default standard input), converting it to equivalent assembler input. If the -s option is present, go2asm only converts symbols with names matching the regular expression.

Example

Extract the assembly for a test program:

$ cat /tmp/x.go
package p

func f(x int) (y int) {
	return x / 10
}
$ go tool compile -S /tmp/x.go | go2asm
#include "funcdata.h"

TEXT ·f(SB), $0-16 // /tmp/x.go:3
	NO_LOCAL_POINTERS
	// FUNCDATA $0, gclocals·f207267fbf96a0178e8758c6e3e0ce28(SB) (args)
	// FUNCDATA $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB) (no locals)
	MOVQ       $-3689348814741910323, AX  // x.go:4
	MOVQ       x+0(FP), CX
	IMULQ      CX
	ADDQ       CX, DX
	SARQ       $3, DX
	SARQ       $63, CX
	SUBQ       CX, DX
	MOVQ       DX, y+8(FP)
	RET
$

Extract the assembly for the function math.IsInf:

$ go build -a -v -gcflags -S math 2>&1 | go2asm -s math.IsInf
TEXT math·IsInf(SB), $0-24 // /Users/rsc/go/src/math/bits.go:43
	NO_LOCAL_POINTERS
	// FUNCDATA $0, gclocals·54241e171da8af6ae173d69da0236748(SB) (args)
	// FUNCDATA $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB) (no locals)
	MOVQ       sign+8(FP), AX  // bits.go:48
	TESTQ      AX, AX
	JLT        pc66
	MOVSD      f+0(FP), X0
	MOVSD      $(1.7976931348623157e+308), X1
	UCOMISD    X1, X0
	JLS        pc40
	MOVL       $1, AX
pc35:
	MOVB       AL, _r2+16(FP)
	RET
pc40:
	TESTQ      AX, AX
pc43:
	JGT        pc62
	MOVSD      $(-1.7976931348623157e+308), X1
	UCOMISD    X0, X1
	SETHI      AL
	JMP        pc35
pc62:
	MOVL       $0, AX
	JMP        pc35
pc66:
	MOVSD      f+0(FP), X0
	JMP        pc43
$

Bugs

Go2asm only handles amd64 assembler.

Data symbols are not implemented.

Package Files

main.go

Package main imports 10 packages (graph). Updated 2017-03-11. Refresh now. Tools for package owners.