class Metasm::X86_64::Reg

general purpose registers, all sizes 8 new gprs (r8..r15), set bit R in the REX prefix to reference them (or X/B if in ModRM) aonethusaontehsanothe with 8bit subreg: with no rex prefix, refers to ah ch dh bh (as usual)

but whenever the prefix is present, those become unavailable and encodie spl..dil (low byte of rsp/rdi)

Constants

Sym

Public Instance Methods

share?(other) click to toggle source

checks if two registers have bits in common

# File metasm/cpu/x86_64/main.rb, line 64
def share?(other)
        raise 'TODO'
        # XXX TODO wtf does formula this do ?
        other.val % (other.sz >> 1) == @val % (@sz >> 1) and (other.sz != @sz or @sz != 8 or other.val == @val)
end
symbolic(di=nil) click to toggle source

returns a symbolic representation of the register: cx => :rcx & 0xffff ah => (:rax >> 8) & 0xff XXX in x64, 32bits operations are zero-extended to 64bits (eg mov rax, 0x1234_ffff_ffff ; add eax, 1 => rax == 0

# File metasm/cpu/x86_64/main.rb, line 47
def symbolic(di=nil)
        s = Sym[@val]
        s = di.next_addr if s == :rip and di
        if @sz == 8 and to_s[-1] == h
                Expression[[Sym[@val-16], :>>, 8], :&, 0xff]
        elsif @sz == 8
                Expression[s, :&, 0xff]
        elsif @sz == 16
                Expression[s, :&, 0xffff]
        elsif @sz == 32
                Expression[s, :&, 0xffffffff]
        else
                s
        end
end
val_enc() click to toggle source

returns the part of @val to encode in an instruction field

# File metasm/cpu/x86_64/main.rb, line 71
def val_enc
        if @sz == 8 and @val >= 16; @val-12  # ah, bh, ch, dh
        elsif @val >= 16                     # rip
        else @val & 7                                # others
        end
end
val_rex() click to toggle source

returns the part of @val to encode in an instruction's rex prefix

# File metasm/cpu/x86_64/main.rb, line 79
def val_rex
        if @sz == 8 and @val >= 16           # ah, bh, ch, dh: rex forbidden
        elsif @val >= 16                     # rip
        else @val >> 3                               # others
        end
end