Module: YTLJit::AssemblerUtilX64

Defined in:
lib/ytljit/instruction_x64.rb

Instance Method Summary collapse

Instance Method Details

#immidiate_call(addr, offset) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/ytljit/instruction_x64.rb', line 42

def immidiate_call(addr, offset)
  if offset.abs > 0x7fff_ffff then
    addrent = @asm.add_value_entry(addr)
    offset = addrent.value - @asm.current_address - 7
    modseq, modfmt = modrm(:call, 2, offset, nil, addr)
    [0x48, 0xff, *modseq, offset].pack("CC#{modfmt}L")
  else
    [0xe8, offset].pack("CL")
  end
end

#rex(dst, src) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ytljit/instruction_x64.rb', line 3

def rex(dst, src)
  rrex = 0
  if dst.is_a?(OpReg64) then
    rrex |= 0b1000
    if dst.reg_no >= 8 then
      rrex |= 0b1
    end
  end
  
  if dst.is_a?(OpIndirect) and dst.reg.is_a?(OpReg64) then
    if dst.reg_no >= 8 then
      rrex |= 0b1
    end
  end
  
  if src.is_a?(OpReg64) then
    rrex |= 0b1000
    if src.reg_no >= 8 then
      rrex |= 0b100
    end
  end

  if src.is_a?(OpIndirect) and src.reg.is_a?(OpReg64) then
    if src.reg_no >= 8 then
      rrex |= 0b1
    end
  end

  if src.is_a?(OpImmidiate64) then
    rrex |= 0b1000
  end

  if rrex != 0 then
    [[0x40 + rrex], "C"]
  else
    [[], ""]
  end
end