2010-04-16 01:33:04 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "xbyak/xbyak.h"
|
|
|
|
|
|
|
|
using namespace Xbyak;
|
|
|
|
|
2015-08-18 02:55:10 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(disable : 4245)
|
|
|
|
#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()
|
|
|
|
{
|
2010-06-01 07:28:14 +00:00
|
|
|
try {
|
|
|
|
Sample s;
|
|
|
|
s.gen();
|
2013-07-04 14:59:12 +00:00
|
|
|
} catch (std::exception& e) {
|
|
|
|
printf("ERR:%s\n", e.what());
|
2010-06-01 07:28:14 +00:00
|
|
|
} catch (...) {
|
|
|
|
printf("unknown error\n");
|
|
|
|
}
|
2010-04-16 01:33:04 +00:00
|
|
|
ErrorSample es;
|
|
|
|
es.gen();
|
|
|
|
}
|