Michael McLoughlin e0c1ed5776 doc: add quick start to README
Updates #13
2019-01-03 20:02:36 -08:00
2019-01-02 00:10:55 -08:00
2018-12-31 11:20:59 -08:00
2018-12-31 11:01:50 -08:00
2018-12-30 18:40:45 -08:00
2019-01-02 20:41:59 -08:00
2018-12-31 11:20:59 -08:00
2019-01-02 20:41:59 -08:00
2018-12-31 11:20:59 -08:00
2019-01-02 20:41:59 -08:00
2018-11-04 09:44:22 -08:00
2019-01-03 00:36:38 -08:00
2019-01-03 20:02:36 -08:00

avo
Build Status GoDoc

High-level Golang x86 assembly generator. Inspired by PeachPy.

Warning: avo is experimental. APIs are subject to change.

Install

Install avo with go get:

$ go get -u github.com/mmcloughlin/avo

Quick Start

avo assembly generators are pure Go programs. Let's get started with a function that adds two uint64 values.

// +build ignore

package main

import (
	. "github.com/mmcloughlin/avo/build"
)

func main() {
	TEXT("Add", "func(x, y uint64) uint64")
	Doc("Add adds x and y.")
	x := Load(Param("x"), GP64v())
	y := Load(Param("y"), GP64v())
	ADDQ(x, y)
	Store(y, ReturnIndex(0))
	RET()
	Generate()
}

You can go run this code to see the assembly output. To integrate this into the rest of your Go package we recommend a go:generate line to produce the assembly and the corresponding Go stub file.

//go:generate go run asm.go -out add.s -stubs stub.go

After running go generate the add.s file will contain the Go assembly.

// Code generated by command: go run asm.go -out add.s -stubs stub.go. DO NOT EDIT.

// func Add(x uint64, y uint64) uint64
TEXT ·Add(SB), $0-24
	MOVQ	x(FP), AX
	MOVQ	y+8(FP), CX
	ADDQ	AX, CX
	MOVQ	CX, ret+16(FP)
	RET

The same call will produce the stub file stub.go which will enable the function to be called from your Go code.

// Code generated by command: go run asm.go -out add.s -stubs stub.go. DO NOT EDIT.

package add

// Add adds x and y.
func Add(x uint64, y uint64) uint64

See the examples/add directory for the complete working example.

License

avo is available under the BSD 3-Clause License.

Description
Avo build
Readme GPL-3.0 3.6 MiB
Languages
Go 96.8%
Assembly 3.1%