github.com/Rookout/GoSDK@v0.1.48/pkg/services/assembler/args_amd64.go (about) 1 package assembler 2 3 import ( 4 "github.com/Rookout/GoSDK/pkg/services/assembler/internal/obj" 5 "golang.org/x/arch/x86/x86asm" 6 ) 7 8 const NoArg = x86asm.Reg(0) 9 10 type Arg = x86asm.Arg 11 type Reg = x86asm.Reg 12 13 type Imm = x86asm.Imm 14 15 16 const placeholderOp = APUSHFQ 17 const placeholderLen = 1 18 19 func argToAddr(arg Arg) (addr obj.Addr) { 20 if arg == NoArg { 21 return addr 22 } 23 24 switch t := arg.(type) { 25 case Imm: 26 addr.Type = obj.TYPE_CONST 27 addr.Offset = int64(t) 28 case Reg: 29 addr.Type = obj.TYPE_REG 30 addr.Reg = AsmRegToSysReg(t) 31 case Mem: 32 addr.Type = obj.TYPE_MEM 33 addr.Reg = AsmRegToSysReg(t.Base) 34 addr.Offset = t.Disp 35 } 36 return addr 37 }