examples/complex: and bugfixes

This commit is contained in:
Michael McLoughlin
2018-12-12 00:02:22 -08:00
parent 2189d38d1e
commit b89d211ff4
12 changed files with 179 additions and 34 deletions

View File

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

View File

@@ -8,5 +8,8 @@ import (
//go:generate go run asm.go -out add.s -stubs stub.go
func TestAdd(t *testing.T) {
quick.CheckEqual(Add, func(x, y uint64) uint64 { return x + y }, nil)
expect := func(x, y uint64) uint64 { return x + y }
if err := quick.CheckEqual(Add, expect, nil); err != nil {
t.Fatal(err)
}
}

View File

@@ -11,7 +11,7 @@ func main() {
x := Load(Param("x"), GP64v())
y := Load(Param("y"), GP64v())
ADDQ(x, y)
Store(x, ReturnIndex(0))
Store(y, ReturnIndex(0))
RET()
Generate()
}