github.com/chenzhuoyu/iasm@v0.9.1/x86_64/instructions_test.go (about) 1 package x86_64 2 3 import ( 4 `testing` 5 6 `github.com/davecgh/go-spew/spew` 7 ) 8 9 func TestInstr_Encode(t *testing.T) { 10 m := []byte(nil) 11 a := CreateArch() 12 p := a.CreateProgram() 13 p.VPERMIL2PD(7, Sib(R8, R9, 1, 12345), YMM1, YMM2, YMM3).encode(&m) 14 spew.Dump(m) 15 } 16 17 func TestInstr_EncodeSegment(t *testing.T) { 18 m := []byte(nil) 19 a := CreateArch() 20 p := a.CreateProgram() 21 p.MOVQ(Abs(0x30), RCX).GS().encode(&m) 22 spew.Dump(m) 23 } 24 25 func BenchmarkInstr_Encode(b *testing.B) { 26 a := CreateArch() 27 m := make([]byte, 0, 16) 28 p := a.CreateProgram() 29 p.VPERMIL2PD(7, Sib(R8, R9, 1, 12345), YMM1, YMM2, YMM3).encode(&m) 30 p.Free() 31 b.SetBytes(int64(len(m))) 32 b.ResetTimer() 33 for i := 0; i < b.N; i++ { 34 m = m[:0] 35 p = a.CreateProgram() 36 p.VPERMIL2PD(7, Sib(R8, R9, 1, 12345), YMM1, YMM2, YMM3).encode(&m) 37 p.Free() 38 } 39 }