Find file History
mmcloughlin operand: include '+0' in named symbol references
Intended to address an asmdecl error.

  [amd64] Butterfly: use of unnamed argument 0(FP); offset 0 is x0+0(FP)

Updates #24
Latest commit 475a241 Jan 13, 2019
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
README.md
add.s
add_test.go
asm.go build: add attributes argument to TEXT Jan 7, 2019
doc.go doc: add package-level doc comments (#9) Jan 6, 2019
stub.go examples: add most docstrings Dec 28, 2018

README.md

add

Add two numbers with avo.

The code generator is as follows:

// +build ignore

package main

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

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

We use a go:generate line to produce the assembly and Go stub files together.

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

This produces add.s as follows:

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

#include "textflag.h"

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