Files
rc64/sample/no_flags.cpp
Simone Coco 0a097849af Squashed 'external/xbyak/' content from commit 9d8ff37
git-subtree-dir: external/xbyak
git-subtree-split: 9d8ff37306f39c6a71cf998078cbe880ce5dc224
2025-12-23 16:51:03 +01:00

26 lines
490 B
C++

#include <stdio.h>
#include <xbyak/xbyak.h>
struct Code : Xbyak::CodeGenerator {
Code(bool nf) {
xor_(eax, eax); // CF = 0
mov(eax, -1);
if (nf) {
puts("no flags (with T_nf)");
add(eax|T_nf, eax, 1); // does not change CF
} else {
puts("change flags (without T_nf)");
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(*)()>()());
}
}