#include <stdio.h>
#include <stdlib.h>
#include "xbyak/xbyak.h"
Go to the source code of this file.
◆ XBYAK_NO_OP_NAMES
#define XBYAK_NO_OP_NAMES |
◆ main()
Definition at line 136 of file test0.cpp.
137{
138 try {
140 printf(
"Xbyak version=%s\n",
s.getVersionString());
141#ifdef XBYAK64_GCC
142 puts("64bit mode(gcc)");
143#elif defined(XBYAK64_WIN)
144 puts("64bit mode(win)");
145#else
146 puts("32bit");
147#endif
148 int (*func)(int) =
s.getCode<int (*)(int)>();
149 for (int i = 0; i <= 10; i++) {
151 }
152 for (int i = 0; i < 10; i++) {
154 int (*
add)(int) =
a.get();
156 printf(
"%d + %d = %d\n", i, i, y);
157 }
159 printf(
"call atoi(\"123\") = %d\n", c.
get()(
"123"));
161 printf(
"jmp atoi(\"456\") = %d\n",
j.get()(
"456"));
162 {
163
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)>();
173 return 1;
174 }
175 printf(
"0 + ... + %d = %d\n", 100,
func(100));
176 CodeArray::protect(
p, codeSize,
false);
177 }
178 puts("OK");
180 } catch (std::exception& e) {
181 printf(
"ERR:%s\n", e.what());
182 } catch (...) {
183 printf(
"unknown error\n");
184 }
185}
int(*)(const char *) get() const
LOGGING_API void printf(Category category, const char *format,...)
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
◆ testReset()
Definition at line 123 of file test0.cpp.
124{
125 puts("testReset");
127 int (*
f)(int) = code.
getCode<
int(*)(int)>();
128 for (int i = 0; i < 10; i++) {
129 code.init(i);
132 code.reset();
133 }
134}
const uint8 * getCode() const