diff --git a/sample/Makefile b/sample/Makefile index 2010f69..ff94b3a 100644 --- a/sample/Makefile +++ b/sample/Makefile @@ -30,7 +30,7 @@ else endif 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) TARGET += calc64 #calc2_64 endif @@ -111,6 +111,10 @@ ccmp: ccmp.cpp $(XBYAK_INC) $(CXX) $(CFLAGS) ccmp.cpp -o $@ test_ccmp: 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: rm -rf $(TARGET) profiler profiler-vtune diff --git a/sample/no_flags.cpp b/sample/no_flags.cpp new file mode 100644 index 0000000..8ab08df --- /dev/null +++ b/sample/no_flags.cpp @@ -0,0 +1,28 @@ +#include +#include + +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()()); + } +}