mirror of
https://github.com/herumi/xbyak
synced 2024-11-21 16:09:11 -07:00
add no_flags sample
This commit is contained in:
parent
523cf1ed04
commit
8c44467afb
2 changed files with 33 additions and 1 deletions
|
@ -30,7 +30,7 @@ else
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(BIT),64)
|
ifeq ($(BIT),64)
|
||||||
TARGET += test64 bf64 memfunc64 test_util64 jmp_table64 zero_upper ccmp
|
TARGET += test64 bf64 memfunc64 test_util64 jmp_table64 zero_upper ccmp no_flags
|
||||||
ifeq ($(BOOST_EXIST),1)
|
ifeq ($(BOOST_EXIST),1)
|
||||||
TARGET += calc64 #calc2_64
|
TARGET += calc64 #calc2_64
|
||||||
endif
|
endif
|
||||||
|
@ -111,6 +111,10 @@ ccmp: ccmp.cpp $(XBYAK_INC)
|
||||||
$(CXX) $(CFLAGS) ccmp.cpp -o $@
|
$(CXX) $(CFLAGS) ccmp.cpp -o $@
|
||||||
test_ccmp: ccmp
|
test_ccmp: ccmp
|
||||||
sde -future -- ./ccmp
|
sde -future -- ./ccmp
|
||||||
|
no_flags: no_flags.cpp $(XBYAK_INC)
|
||||||
|
$(CXX) $(CFLAGS) no_flags.cpp -o $@
|
||||||
|
test_no_flags: no_flags
|
||||||
|
sde -future -- ./no_flags
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(TARGET) profiler profiler-vtune
|
rm -rf $(TARGET) profiler profiler-vtune
|
||||||
|
|
28
sample/no_flags.cpp
Normal file
28
sample/no_flags.cpp
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <xbyak/xbyak.h>
|
||||||
|
|
||||||
|
struct Code : Xbyak::CodeGenerator {
|
||||||
|
Code(bool nf) {
|
||||||
|
if (nf) {
|
||||||
|
puts("no flags (with T_nf)");
|
||||||
|
} else {
|
||||||
|
puts("change flags (without T_nf)");
|
||||||
|
}
|
||||||
|
xor_(eax, eax); // CF = 0
|
||||||
|
mov(eax, -1);
|
||||||
|
if (nf) {
|
||||||
|
add(eax|T_nf, eax, 1); // does not change CF
|
||||||
|
} else {
|
||||||
|
add(eax, eax, 1); // CF = 1
|
||||||
|
}
|
||||||
|
adc(eax, 0); // eax = CF ? 1 : 0
|
||||||
|
ret();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
Code c(i);
|
||||||
|
printf("i=%d ret=%d\n", i, c.getCode<int(*)()>()());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue