Added mov reg, DWORD support to set()

git-svn-id: file:///home/svn/incoming/trunk@3280 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
vlad902 2005-12-30 20:26:41 +00:00
parent 61c715ac27
commit 44e0c1e5bc
1 changed files with 16 additions and 1 deletions

View File

@ -109,7 +109,7 @@ module X86
end
#
# This method generates the mod r/m character for a source and destinatino
# This method generates the mod r/m character for a source and destination
# register.
#
def self.encode_modrm(dst, src)
@ -172,6 +172,15 @@ module X86
return "\x66" + (0xb8 | reg).chr + [ val ].pack('v')
end
#
# This method generates the opcodes that set the a register to the
# supplied value.
#
def self.mov_dword(reg, val)
_check_reg(reg)
return (0xb8 | reg).chr + [ val ].pack('V')
end
#
# This method is a general way of setting a register to a value. Depending
# on the value supplied, different sets of instructions may be used.
@ -197,6 +206,12 @@ module X86
rescue ::ArgumentError, RuntimeError, RangeError
end
# try clear dst, mov DWORD dst
begin
return _check_badchars(clear(dst, badchars) + mov_dword(dst, val), badchars)
rescue ::ArgumentError, RuntimeError, RangeError
end
raise RuntimeError, "No valid set instruction could be created!", caller()
end