github.com/Rookout/GoSDK@v0.1.48/pkg/services/assembler/insts.go (about) 1 package assembler 2 3 import "github.com/Rookout/GoSDK/pkg/services/assembler/internal/obj" 4 5 6 const ( 7 ACALL = obj.ACALL 8 AJMP = obj.AJMP 9 ANOP = obj.ANOP 10 ARET = obj.ARET 11 ) 12 13 14 15 func (b *Builder) BranchToLabel(op obj.As, dst string, args ...Arg) *Instruction { 16 inst := b.NewInstruction() 17 inst.As = op 18 inst.To.Type = obj.TYPE_BRANCH 19 inst.jumpDestLabel = dst 20 if args != nil { 21 inst.From = argToAddr(args[0]) 22 } 23 return inst 24 } 25 26 func (b *Builder) Label(label string) *Instruction { 27 inst := b.PsuedoNop() 28 inst.label = label 29 return inst 30 } 31 32 func (b *Builder) Bytes(bytes []byte) *Instruction { 33 if len(bytes) == 0 { 34 return b.PsuedoNop() 35 } 36 37 inst := b.NewInstruction() 38 inst.placeholderFor = bytes 39 inst.As = placeholderOp 40 return inst 41 } 42 43 44 45 func (b *Builder) PsuedoNop() *Instruction { 46 return b.Inst(ANOP, NoArg, NoArg) 47 }