mirror of
https://github.com/herumi/xbyak
synced 2024-11-21 16:09:11 -07:00
first test of new Label
This commit is contained in:
parent
f22576ad4c
commit
95d3b5c8d0
1 changed files with 32 additions and 0 deletions
32
test/jmp.cpp
32
test/jmp.cpp
|
@ -627,6 +627,37 @@ void test6()
|
|||
}
|
||||
}
|
||||
|
||||
void testNewLabel()
|
||||
{
|
||||
struct Code : Xbyak::CodeGenerator {
|
||||
Code(bool grow)
|
||||
: Xbyak::CodeGenerator(grow ? 128 : 4096, grow ? Xbyak::AutoGrow : 0)
|
||||
{
|
||||
xor_(eax, eax);
|
||||
Label label;
|
||||
inLocalLabel();
|
||||
jmp(".start0");
|
||||
L(label);
|
||||
inc(eax);
|
||||
jmp(".exit");
|
||||
L(".start0");
|
||||
inc(eax);
|
||||
jmp(label);
|
||||
L(".exit");
|
||||
ret();
|
||||
outLocalLabel();
|
||||
}
|
||||
};
|
||||
const bool grow = false;
|
||||
printf("testNewLabel grow=%d\n", grow);
|
||||
Code code(grow);
|
||||
int (*f)() = code.getCode<int (*)()>();
|
||||
int r = f();
|
||||
if (r != 2) {
|
||||
printf("err %d\n", r);
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
try {
|
||||
|
@ -642,6 +673,7 @@ int main()
|
|||
testMovLabel(false);
|
||||
testMovLabel(true);
|
||||
testMovLabel2();
|
||||
testNewLabel();
|
||||
} catch (std::exception& e) {
|
||||
printf("ERR:%s\n", e.what());
|
||||
} catch (...) {
|
||||
|
|
Loading…
Reference in a new issue