本文整理汇总了Golang中github.com/tsavola/wag/internal/gen.OpCoder类的典型用法代码示例。如果您正苦于以下问题:Golang OpCoder类的具体用法?Golang OpCoder怎么用?Golang OpCoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OpCoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: op
func (i insnO) op(code gen.OpCoder, reg regs.R) {
if reg >= 8 {
panic("register not supported by instruction")
}
code.WriteByte(i.opbase + byte(reg))
}
示例2: writeSibTo
func writeSibTo(code gen.OpCoder, scale byte, index, base regs.R) {
if scale >= 4 {
panic("scale factor out of bounds")
}
code.WriteByte((scale << 6) | (byte(index&7) << 3) | byte(base&7))
}
示例3: opImm
func (i insnPrefixMI) opImm(code gen.OpCoder, t types.T, reg regs.R, value int32) {
opcode, imm := i.immOpcode(value)
i.prefix.writeTo(code, t, 0, 0, byte(reg))
code.WriteByte(opcode)
writeModTo(code, ModReg, i.ro, byte(reg))
imm.writeTo(code)
}
示例4: writePrefixRegInsnTo
func writePrefixRegInsnTo(code gen.OpCoder, p prefix, t types.T, opcode []byte, ro, rm byte) {
if opcode == nil {
panic("instruction not supported")
}
p.writeTo(code, t, ro, 0, rm)
code.Write(opcode)
writeModTo(code, ModReg, ro, rm)
}
示例5: writePrefixStackInsnTo
func writePrefixStackInsnTo(code gen.OpCoder, p prefix, t types.T, opcode []byte, reg regs.R, disp int32) {
mod, imm := dispMod(t, regStackPtr, disp)
p.writeTo(code, t, byte(reg), 0, 0)
code.Write(opcode)
writeModTo(code, mod, byte(reg), MemSIB)
writeSibTo(code, 0, regStackPtr, regStackPtr)
imm.writeTo(code)
}
示例6: opStack
func (i insnRexM) opStack(code gen.OpCoder, t types.T, disp int32) {
mod, imm := dispMod(t, regStackPtr, disp)
writeRexSizeTo(code, t, 0, 0, 0)
code.Write(i.opcode)
writeModTo(code, mod, i.ro, MemSIB)
writeSibTo(code, 0, regStackPtr, regStackPtr)
imm.writeTo(code)
}
示例7: writePrefixAddrInsnTo
func writePrefixAddrInsnTo(code gen.OpCoder, p prefix, t types.T, opcode []byte, reg regs.R, scale uint8, index regs.R, addr int32) {
if opcode == nil {
panic("instruction not supported")
}
p.writeTo(code, t, byte(reg), 0, 0)
code.Write(opcode)
writeModTo(code, ModMem, byte(reg), MemSIB)
writeSibTo(code, scale, index, NoBase)
writeInt32To(code, addr)
}
示例8: opImmToStack
func (i insnPrefixMI) opImmToStack(code gen.OpCoder, t types.T, disp, value int32) {
mod, immDisp := dispMod(t, regStackPtr, disp)
opcode, immValue := i.immOpcode(value)
i.prefix.writeTo(code, t, 0, 0, 0)
code.WriteByte(opcode)
writeModTo(code, mod, i.ro, MemSIB)
writeSibTo(code, 0, regStackPtr, regStackPtr)
immDisp.writeTo(code)
immValue.writeTo(code)
}
示例9: writeTo
func (p *floatSizePrefix) writeTo(code gen.OpCoder, t types.T, ro, index, rmOrBase byte) {
switch t.Size() {
case types.Size32:
code.Write(p.size32)
case types.Size64:
code.Write(p.size64)
default:
panic(t)
}
writeRexTo(code, 0, ro, index, rmOrBase)
}
示例10: opIndirect
func (i insnRexM) opIndirect(code gen.OpCoder, t types.T, reg regs.R, disp int32) {
mod, imm := dispMod(t, reg, disp)
writeRexSizeTo(code, t, 0, 0, byte(reg))
code.Write(i.opcode)
if reg != 12 {
writeModTo(code, mod, i.ro, byte(reg))
} else {
writeModTo(code, mod, i.ro, MemSIB)
writeSibTo(code, 0, NoIndex, reg)
}
imm.writeTo(code)
}
示例11: writeRexTo
func writeRexTo(code gen.OpCoder, rex, ro, index, rmOrBase byte) {
if ro >= 8 {
rex |= rexR
}
if index >= 8 {
rex |= rexX
}
if rmOrBase >= 8 {
rex |= rexB
}
if rex != 0 {
code.WriteByte(rex)
}
}
示例12: opImmToIndirect
func (i insnPrefixMI) opImmToIndirect(code gen.OpCoder, t types.T, scale uint8, index, base regs.R, disp, value int32) {
mod, immDisp := dispMod(t, base, disp)
opcode, immValue := i.immOpcode(value)
i.prefix.writeTo(code, t, 0, byte(index), byte(base))
code.WriteByte(opcode)
if scale == 0 && index == NoIndex && base != 12 {
writeModTo(code, mod, i.ro, byte(base))
} else {
writeModTo(code, mod, i.ro, MemSIB)
writeSibTo(code, scale, index, base)
}
immDisp.writeTo(code)
immValue.writeTo(code)
}
示例13: writePrefixIndirectInsnTo
func writePrefixIndirectInsnTo(code gen.OpCoder, p prefix, t types.T, opcode []byte, reg regs.R, scale uint8, index, base regs.R, disp int32) {
if opcode == nil {
panic("instruction not supported")
}
mod, imm := dispMod(t, base, disp)
p.writeTo(code, t, byte(reg), byte(index), byte(base))
code.Write(opcode)
if scale == 0 && index == NoIndex && base != 12 {
writeModTo(code, mod, byte(reg), byte(base))
} else {
writeModTo(code, mod, byte(reg), MemSIB)
writeSibTo(code, scale, index, base)
}
imm.writeTo(code)
}
示例14: UpdateCalls
// UpdateCalls modifies CallRel instructions, possibly while they are being
// executed.
func (mach X86) UpdateCalls(code gen.OpCoder, l *links.L) {
funcAddr := l.FinalAddr()
for _, retAddr := range l.Sites {
mach.PutUint32(code.Bytes()[retAddr-4:retAddr], uint32(funcAddr-retAddr))
}
}
示例15: opReg
func (i insnRexOM) opReg(code gen.OpCoder, reg regs.R) {
writeRexTo(code, 0, 0, 0, byte(reg))
code.Write(i.opcode)
writeModTo(code, ModReg, i.ro, byte(reg))
}