Skip to content

Commit

Permalink
check imm of mov(Operand, imm)
Browse files Browse the repository at this point in the history
  • Loading branch information
herumi committed Aug 15, 2015
1 parent 93aae57 commit f03bbc2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
21 changes: 19 additions & 2 deletions test/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,22 @@ CYBOZU_TEST_AUTO(compOperand)
CYBOZU_TEST_ASSERT(ptr[eax] == ptr[eax]);
CYBOZU_TEST_ASSERT(dword[eax] != ptr[eax]);
CYBOZU_TEST_ASSERT(ptr[eax] != ptr[eax+3]);
CYBOZU_TEST_ASSERT(ptr[eax] != ptr[eax+3]);
}
}

#ifdef XBYAK64
CYBOZU_TEST_AUTO(mov_const)
{
struct Code : Xbyak::CodeGenerator {
Code()
{
CYBOZU_TEST_NO_EXCEPTION(mov(dword[eax], -1));
CYBOZU_TEST_NO_EXCEPTION(mov(dword[eax], 0x7fffffff));
CYBOZU_TEST_NO_EXCEPTION(mov(dword[eax], -0x7fffffff));
CYBOZU_TEST_NO_EXCEPTION(mov(dword[eax], 0xabcd1234));
CYBOZU_TEST_NO_EXCEPTION(mov(dword[eax], 0xffffffff));
CYBOZU_TEST_EXCEPTION(mov(dword[eax], 0x100000000ull), Xbyak::Error);
CYBOZU_TEST_EXCEPTION(mov(dword[eax], -0x80000000ull), Xbyak::Error);
}
} code;
}
#endif
3 changes: 2 additions & 1 deletion xbyak/xbyak.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace Xbyak {

enum {
DEFAULT_MAX_CODE_SIZE = 4096,
VERSION = 0x4850 /* 0xABCD = A.BC(D) */
VERSION = 0x4851 /* 0xABCD = A.BC(D) */
};

#ifndef MIE_INTEGER_TYPE_DEFINED
Expand Down Expand Up @@ -1866,6 +1866,7 @@ class CodeGenerator : public CodeArray {
} else if (op.isMEM()) {
opModM(static_cast<const Address&>(op), Reg(0, Operand::REG, op.getBit()), B11000110);
int size = op.getBit() / 8; if (size > 4) size = 4;
if (0xffffffff < imm && imm <= ~uint64(0x7fffffffu)) throw Error(ERR_OFFSET_IS_TOO_BIG);
db(static_cast<uint32>(imm), size);
} else {
throw Error(ERR_BAD_COMBINATION);
Expand Down
2 changes: 1 addition & 1 deletion xbyak/xbyak_mnemonic.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const char *getVersionString() const { return "4.85"; }
const char *getVersionString() const { return "4.851"; }
void packssdw(const Mmx& mmx, const Operand& op) { opMMX(mmx, op, 0x6B); }
void packsswb(const Mmx& mmx, const Operand& op) { opMMX(mmx, op, 0x63); }
void packuswb(const Mmx& mmx, const Operand& op) { opMMX(mmx, op, 0x67); }
Expand Down

0 comments on commit f03bbc2

Please sign in to comment.