dynarmic/externals/xbyak/sample/zero_upper.cpp
Merry 213fe7a452 externals: Update xbyak to v7.05
Merge commit 'fdf626b74f35deedce0e6196c36b8c9f846c038a'
2024-01-30 00:39:19 +00:00

48 lines
797 B
C++

/*
An example of T_zu (zero upper) flag
> g++ zero_upper.cpp -I ../xbyak
> sde -future -- ./a.out
*/
#include <stdio.h>
#include <xbyak/xbyak.h>
using namespace Xbyak;
struct Code : Xbyak::CodeGenerator {
Code(int mode)
{
mov(eax, 0x12345678);
cmp(eax, eax); // ZF=1
switch (mode) {
case 0: // imul
puts("imul");
imul(ax,ax, 0x1234);
break;
case 1: // imul+zu
puts("imul+zu");
imul(ax|T_zu, ax, 0x1234);
break;
case 2: // setz
puts("setz");
setz(al);
break;
case 3: // setz+zu
puts("setz+zu");
setz(al|T_zu);
break;
}
ret();
}
};
int main()
try
{
for (int mode = 0; mode < 4; mode++) {
Code c(mode);
auto f = c.getCode<int (*)()>();
printf("ret=%08x\n", f());
}
} catch (std::exception& e) {
printf("ERR %s\n", e.what());
}