1#if defined(_MSC_VER) && (_MSC_VER <= 1200)
2 #pragma warning(disable:4514)
3 #pragma warning(disable:4786)
5#if defined(_MSC_VER) && (_MSC_VER >= 1900)
6 #pragma warning(disable:4456)
10#define XBYAK_NO_OP_NAMES
14 void operator=(
const Sample&);
21#elif defined(XBYAK64_GCC)
50#elif defined(XBYAK64_WIN)
69 mov(rax, (
size_t)atoi);
77#ifdef XBYAK_VARIADIC_TEMPLATE
96 mov(rax, (
size_t)atoi);
114 for (
int i = 0; i < 10 - n; i++) {
127 int (*
f)(int) = code.
getCode<
int(*)(int)>();
128 for (
int i = 0; i < 10; i++) {
131 printf(
"%d %d\n", i, v);
140 printf(
"Xbyak version=%s\n",
s.getVersionString());
142 puts(
"64bit mode(gcc)");
143#elif defined(XBYAK64_WIN)
144 puts(
"64bit mode(win)");
148 int (*func)(int) =
s.getCode<int (*)(int)>();
149 for (
int i = 0; i <= 10; i++) {
150 printf(
"0 + ... + %d = %d\n", i, func(i));
152 for (
int i = 0; i < 10; i++) {
154 int (*
add)(int) =
a.get();
156 printf(
"%d + %d = %d\n", i, i, y);
159 printf(
"call atoi(\"123\") = %d\n", c.
get()(
"123"));
161 printf(
"jmp atoi(\"456\") = %d\n",
j.get()(
"456"));
164 using namespace Xbyak;
165 const size_t codeSize = 1024;
167 uint8 *
p = CodeArray::getAlignedAddress(
buf);
168 CodeArray::protect(
p, codeSize,
true);
170 int (*func)(int) =
s.getCode<int (*)(int)>();
175 printf(
"0 + ... + %d = %d\n", 100, func(100));
176 CodeArray::protect(
p, codeSize,
false);
180 }
catch (std::exception& e) {
181 printf(
"ERR:%s\n", e.what());
183 printf(
"unknown error\n");
int(*)(const char *) get() const
int(*)(const char *) get() const
Sample(void *userPtr=0, size_t size=Xbyak::DEFAULT_MAX_CODE_SIZE)
const uint8 * getCode() const
void call(const Operand &op)
void xor_(const Operand &op, uint32 imm)
void cmp(const Operand &op, uint32 imm)
void jbe(const Label &label, LabelType type=T_AUTO)
void jmp(const Operand &op)
void inc(const Operand &op)
void test(const Operand &op, const Reg ®)
void add(const Operand &op, uint32 imm)
void sub(const Operand &op, uint32 imm)
void jz(const Label &label, LabelType type=T_AUTO)
void mov(const Operand ®1, const Operand ®2)
void lea(const Reg ®, const Address &addr)
void jnz(const Label &label, LabelType type=T_AUTO)
void L(const std::string &label)
void push(const Operand &op)
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Xbyak ; JIT assembler for x86(IA32)/x64 by C++.