xbyak/test/nm_frame.cpp

54 lines
1.1 KiB
C++
Raw Normal View History

2010-04-16 01:33:04 +00:00
#include <stdio.h>
2018-02-07 07:42:22 +00:00
#define XBYAK_NO_OP_NAMES
2016-08-03 04:19:02 +00:00
#define XBYAK_ENABLE_OMITTED_OPERAND
2010-04-16 01:33:04 +00:00
#include "xbyak/xbyak.h"
using namespace Xbyak;
2015-08-18 02:55:10 +00:00
#ifdef _MSC_VER
#pragma warning(disable : 4245)
2017-08-22 06:53:34 +00:00
#pragma warning(disable : 4312)
2015-08-18 02:55:10 +00:00
#endif
2010-04-16 01:33:04 +00:00
class Sample : public CodeGenerator {
void operator=(const Sample&);
public:
#include "nm.cpp"
};
#define _STR(x) #x
#define TEST(syntax) err = true; try { syntax; err = false; } catch (Xbyak::Error) { } catch (...) { } if (!err) printf("should be err:%s;\n", _STR(syntax))
class ErrorSample : public CodeGenerator {
void operator=(const ErrorSample&);
public:
void gen()
{
bool err;
TEST(mov(ptr[eax],1));
TEST(test(ptr[eax],1));
TEST(adc(ptr[eax],1));
TEST(setz(eax));
}
};
int main()
2016-06-14 07:14:43 +00:00
try
2010-04-16 01:33:04 +00:00
{
2017-08-08 10:08:41 +00:00
size_t size = sizeof(Xbyak::Operand);
if (size != 4) {
printf("sizeof Operand %d\n", (int)size);
}
try {
Sample s;
s.gen();
} catch (std::exception& e) {
printf("ERR:%s\n", e.what());
} catch (...) {
printf("unknown error\n");
}
2010-04-16 01:33:04 +00:00
ErrorSample es;
es.gen();
2016-06-14 07:14:43 +00:00
} catch (std::exception& e) {
printf("err %s\n", e.what());
return 1;
2010-04-16 01:33:04 +00:00
}