diff --git a/examples/add/add.s b/examples/add/add.s index e2ceb126..0b694ec0 100644 --- a/examples/add/add.s +++ b/examples/add/add.s @@ -7,4 +7,4 @@ TEXT ·Add(SB),0,$0-24 MOVQ y+8(FP), CX ADDQ AX, CX MOVQ CX, ret+16(FP) - RET + RET diff --git a/examples/complex/complex.s b/examples/complex/complex.s index 7296085b..ba668512 100644 --- a/examples/complex/complex.s +++ b/examples/complex/complex.s @@ -5,12 +5,14 @@ TEXT ·Real(SB),0,$0-24 MOVSD x_real(FP), X0 MOVSD X0, ret+16(FP) - RET + RET + // func Imag(x complex128) float64 TEXT ·Imag(SB),0,$0-24 MOVSD x_imag+8(FP), X0 MOVSD X0, ret+16(FP) - RET + RET + // func Norm(x complex128) float64 TEXT ·Norm(SB),0,$0-24 MOVSD x_real(FP), X0 @@ -20,4 +22,4 @@ TEXT ·Norm(SB),0,$0-24 ADDSD X1, X0 SQRTSD X0, X2 MOVSD X2, ret+16(FP) - RET + RET diff --git a/examples/components/components.s b/examples/components/components.s index d7e1ab50..41c73a54 100644 --- a/examples/components/components.s +++ b/examples/components/components.s @@ -5,64 +5,76 @@ TEXT ·FieldByte(SB),0,$0-184 MOVB s_Byte(FP), AL MOVB AL, ret+176(FP) - RET + RET + // func FieldInt8(s Struct) int8 TEXT ·FieldInt8(SB),0,$0-184 MOVB s_Int8+1(FP), AL MOVB AL, ret+176(FP) - RET + RET + // func FieldUint16(s Struct) uint16 TEXT ·FieldUint16(SB),0,$0-184 MOVW s_Uint16+2(FP), AX MOVW AX, ret+176(FP) - RET + RET + // func FieldInt32(s Struct) int32 TEXT ·FieldInt32(SB),0,$0-184 MOVL s_Int32+4(FP), AX MOVL AX, ret+176(FP) - RET + RET + // func FieldUint64(s Struct) uint64 TEXT ·FieldUint64(SB),0,$0-184 MOVQ s_Uint64+8(FP), AX MOVQ AX, ret+176(FP) - RET + RET + // func FieldFloat32(s Struct) float32 TEXT ·FieldFloat32(SB),0,$0-184 MOVSS s_Float32+16(FP), X0 MOVSS X0, ret+176(FP) - RET + RET + // func FieldFloat64(s Struct) float64 TEXT ·FieldFloat64(SB),0,$0-184 MOVSD s_Float64+24(FP), X0 MOVSD X0, ret+176(FP) - RET + RET + // func FieldStringLen(s Struct) int TEXT ·FieldStringLen(SB),0,$0-184 MOVQ s_String_len+40(FP), AX MOVQ AX, ret+176(FP) - RET + RET + // func FieldSliceCap(s Struct) int TEXT ·FieldSliceCap(SB),0,$0-184 MOVQ s_Slice_cap+64(FP), AX MOVQ AX, ret+176(FP) - RET + RET + // func FieldArrayTwoBTwo(s Struct) byte TEXT ·FieldArrayTwoBTwo(SB),0,$0-184 MOVB s_Array_2_B_2+114(FP), AL MOVB AL, ret+176(FP) - RET + RET + // func FieldArrayOneC(s Struct) uint16 TEXT ·FieldArrayOneC(SB),0,$0-184 MOVW s_Array_1_C+100(FP), AX MOVW AX, ret+176(FP) - RET + RET + // func FieldComplex64Imag(s Struct) float32 TEXT ·FieldComplex64Imag(SB),0,$0-184 MOVSS s_Complex64_imag+156(FP), X0 MOVSS X0, ret+176(FP) - RET + RET + // func FieldComplex128Real(s Struct) float64 TEXT ·FieldComplex128Real(SB),0,$0-184 MOVSD s_Complex128_real+160(FP), X0 MOVSD X0, ret+176(FP) - RET + RET diff --git a/examples/fnv1a/fnv1a.s b/examples/fnv1a/fnv1a.s index aea3e76b..c83baa84 100644 --- a/examples/fnv1a/fnv1a.s +++ b/examples/fnv1a/fnv1a.s @@ -18,4 +18,4 @@ loop: JMP loop done: MOVQ AX, ret+24(FP) - RET + RET diff --git a/examples/sum/sum.s b/examples/sum/sum.s index fab47b14..d06f0387 100644 --- a/examples/sum/sum.s +++ b/examples/sum/sum.s @@ -15,4 +15,4 @@ loop: JMP loop done: MOVQ DX, ret+24(FP) - RET + RET diff --git a/printer/goasm.go b/printer/goasm.go index 8c615cbb..e417a489 100644 --- a/printer/goasm.go +++ b/printer/goasm.go @@ -31,7 +31,6 @@ func (p *goasm) Print(f *avo.File) ([]byte, error) { func (p *goasm) header() { p.NL() p.include("textflag.h") - p.NL() } func (p *goasm) include(path string) { @@ -39,13 +38,18 @@ func (p *goasm) include(path string) { } func (p *goasm) function(f *avo.Function) { + p.NL() p.Comment(f.Stub()) p.Printf("TEXT %s%s(SB),0,$%d-%d\n", dot, f.Name, f.FrameBytes(), f.ArgumentBytes()) for _, node := range f.Nodes { switch n := node.(type) { case *avo.Instruction: - p.Printf("\t%s\t%s\n", n.Opcode, joinOperands(n.Operands)) + if len(n.Operands) > 0 { + p.Printf("\t%s\t%s\n", n.Opcode, joinOperands(n.Operands)) + } else { + p.Printf("\t%s\n", n.Opcode) + } case avo.Label: p.Printf("%s:\n", n) default: