module Rex::Arch::Sparc
Everything here is mostly stolen from vlad’s perl sparc stuff
Public Class Methods
ori(src, constant, dst)
click to toggle source
Encodes an OR instruction with the value ‘constant’ being OR’ed with the ‘src’ register into the ‘dst’ register
# File lib/rex/arch/sparc.rb, line 40 def self.ori(src, constant, dst) [ (2 << 30) | (RegisterNumber[dst] << 25) | (2 << 19) | (RegisterNumber[src] << 14) | (1 << 13) | (constant & 0x1fff) ].pack('N') end
set(constant, dst)
click to toggle source
Puts ‘constant’ into the ‘dst’ register using as few instructions as possible by checking the size of the value. XXX: signedness support
# File lib/rex/arch/sparc.rb, line 55 def self.set(constant, dst) if (constant <= 4095 and constant >= 0) ori('g0', constant, dst) elsif (constant & 0x3ff != 0) set_dword(constant, dst) else sethi(constant, dst) end end
set_dword(constant, dst)
click to toggle source
Puts ‘constant’ into the ‘dst’ register using both sethi and ori (necessary to use both uncessarily in some cases with encoders)
# File lib/rex/arch/sparc.rb, line 68 def self.set_dword(constant, dst) sethi(constant, dst) + ori(dst, constant & 0x3ff, dst) end
sethi(constant, dst)
click to toggle source
Encodes a SETHI instruction with the value ‘constant’ being put into ‘dst’ register
# File lib/rex/arch/sparc.rb, line 29 def self.sethi(constant, dst) [ (RegisterNumber[dst] << 25) | (4 << 22) | (constant >> 10) ].pack('N') end