diff options
author | MITSUNARI Shigeo <[email protected]> | 2014-03-16 16:59:31 +0900 |
---|---|---|
committer | MITSUNARI Shigeo <[email protected]> | 2014-03-16 16:59:31 +0900 |
commit | e214d4ba8e2c692e269451d26ac4f838c2d01baa (patch) | |
tree | 129b249c5389445517969d10401ecf005df05e63 | |
parent | b45cfc68d6b92fbc1fe9485415dabf9cca598e16 (diff) | |
download | xbyak-e214d4ba8e2c692e269451d26ac4f838c2d01baa.tar.gz xbyak-e214d4ba8e2c692e269451d26ac4f838c2d01baa.zip |
pass test of assignL
-rw-r--r-- | test/jmp.cpp | 31 | ||||
-rw-r--r-- | xbyak/xbyak.h | 10 |
2 files changed, 22 insertions, 19 deletions
diff --git a/test/jmp.cpp b/test/jmp.cpp index 6cde759..531d05c 100644 --- a/test/jmp.cpp +++ b/test/jmp.cpp @@ -798,26 +798,27 @@ void testAssign() xor_(eax, eax); Label dst, src; L(src); - inc(eax); - cmp(eax, 1); - je(dst); - inc(eax); // 2, 3, 5 + inc(eax); + cmp(eax, 1); + je(dst); + inc(eax); // 2, 3, 5 cmp(eax, 5); - jne(dst); + putNop(this, 128); + jne(dst, T_NEAR); ret(); assignL(dst, src); } }; - for (int i = 0; i < 2; i++) { - const bool grow = i == 0; - printf("testAssign grow=%d\n", grow); - Code code(grow); - if (grow) code.ready(); - int (*f)() = code.getCode<int (*)()>(); - int ret = f(); - if (ret != 5) { - printf("err %d\n", ret); - } + for (int i = 0; i < 2; i++) { + const bool grow = i == 0; + printf("testAssign grow=%d\n", grow); + Code code(grow); + if (grow) code.ready(); + int (*f)() = code.getCode<int (*)()>(); + int ret = f(); + if (ret != 5) { + printf("err %d\n", ret); + } } } diff --git a/xbyak/xbyak.h b/xbyak/xbyak.h index f11819d..1d1ca1c 100644 --- a/xbyak/xbyak.h +++ b/xbyak/xbyak.h @@ -970,8 +970,10 @@ class LabelManager { disp = size_t(base_->getCurr()); } else { disp = addrOffset - jmp->endOfJmp; - if (jmp->jmpSize <= 4) disp = inner::VerifyInInt32(disp); - if (jmp->jmpSize == 1 && !inner::IsInDisp8((uint32)disp)) throw Error(ERR_LABEL_IS_TOO_FAR); +#ifdef XBYAK64 + if (jmp->jmpSize <= 4 && !inner::IsInInt32(disp)) throw Error(ERR_OFFSET_IS_TOO_BIG); +#endif + if (jmp->jmpSize == 1 && !inner::IsInDisp8((uint32)disp)) throw Error(ERR_LABEL_IS_TOO_FAR); } if (base_->isAutoGrow()) { base_->save(offset, disp, jmp->jmpSize, jmp->mode); @@ -1676,12 +1678,12 @@ private: /* mov(r, imm) = db(imm, mov_imm(r, imm)) */ - int mov_imm(const Reg& reg, uint64 imm) + int mov_imm(const Reg& reg, size_t imm) { int bit = reg.getBit(); const int idx = reg.getIdx(); int code = B10110000 | ((bit == 8 ? 0 : 1) << 3); - if (bit == 64 && (imm >> 32) == 0) { + if (bit == 64 && (imm & ~size_t(0xffffffffu)) == 0) { rex(Reg32(idx)); bit = 32; } else { |