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) }
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) }
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) }
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) }
func (opcode insnAddr8) op(code gen.OpCoder, addr int32) (ok bool) { insnSize := int32(len(opcode)) + 1 siteAddr := code.Len() + insnSize offset := addr - siteAddr if offset >= -0x80 && offset < 0x80 { code.Write(opcode) code.WriteByte(uint8(offset)) ok = true } return }
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) }
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) }
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) }
func (opcode insnConst) op(code gen.OpCoder) { code.Write(opcode) }
func (i insnSuffixRMI) opReg(code gen.OpCoder, t types.T, target, source regs.R, value int8) { code.Write(i.opcode) i.suffix.writeTo(code, t, byte(target), 0, byte(source)) writeModTo(code, ModReg, byte(target), byte(source)) code.WriteByte(uint8(value)) }
func (i insnPrefixRexRM) opReg(code gen.OpCoder, floatType, intType types.T, target, source regs.R) { i.prefix.writeTo(code, floatType, 0, 0, 0) writeRexSizeTo(code, intType, byte(target), 0, byte(source)) code.Write(i.opcode) writeModTo(code, ModReg, byte(target), byte(source)) }
func (bytes constPrefix) writeTo(code gen.OpCoder, t types.T, ro, index, rmOrBase byte) { code.Write(bytes) }
func (opcode insnAddr32) writeTo(code gen.OpCoder, offset int32) { code.Write(opcode) writeInt32To(code, int32(offset)) }
func (opcode insnRex) op(code gen.OpCoder, t types.T) { writeRexSizeTo(code, t, 0, 0, 0) code.Write(opcode) }
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)) }
func (opcode insnI) op(code gen.OpCoder, imm imm) { code.Write(opcode) imm.writeTo(code) }
func (i insnRexM) opReg(code gen.OpCoder, t types.T, reg regs.R) { writeRexSizeTo(code, t, 0, 0, byte(reg)) code.Write(i.opcode) writeModTo(code, ModReg, i.ro, byte(reg)) }