22#if defined(_MSC_VER) && (_MSC_VER <= 1200)
23 #pragma warning(disable:4514)
24 #pragma warning(disable:4786)
30#define XBYAK_NO_OP_NAMES
33#define NUM_OF_ARRAY(x) (sizeof(x) / sizeof(x[0]))
42 typedef std::vector<uint32> Buffer;
67 mark_ = (int)code_.size();
71 return mark_ - (int)code_.size() - 1;
77 const size_t end = code_.size();
82 decode(code,
r, imm, x);
85 printf(
"A %08x B %08x\n", reg[0], reg[1]);
86 printf(
"mem_[] = %08x %08x %08x\n", mem_[0], mem_[1], mem_[2]);
87 printf(
"pc=%4d, code=%02x, r=%d, imm=%04x\n", pc, code,
r, imm);
112 printf(
"%c %8d(0x%08x)\n",
'A' +
r, reg[
r], reg[
r]);
115 if (reg[
r] != 0) pc +=
static_cast<signed short>(imm);
122 if (pc >= end)
break;
127 using namespace Xbyak;
146 for (
size_t i = 0; i < memTblNum; i++)
xor_(memTbl[i], memTbl[i]);
150 mov(mem, (
size_t)mem_);
151 const size_t end = code_.size();
157 decode(code,
r, imm, x);
164 if (imm < memTblNum) {
165 mov(reg[
r], memTbl[imm]);
167 mov(reg[
r],
ptr[mem + imm * 4]);
171 if (imm < memTblNum) {
172 mov(memTbl[imm], reg[
r]);
174 mov(
ptr [mem + imm * 4], reg[
r]);
178 if (imm < memTblNum) {
179 add(reg[
r], memTbl[imm]);
181 add(reg[
r],
ptr [mem + imm * 4]);
188 if (imm < memTblNum) {
189 sub(reg[
r], memTbl[imm]);
191 sub(reg[
r],
ptr [mem + imm * 4]);
199 static const char *str =
"%c %8d(0x%08x)\n";
223 if (pc >= end)
break;
238 r = (x >> 16) & 0xff;
243 uint32 x = (code << 24) | (
r << 16) | imm;
253 fprintf(stderr,
"current version support only imm16\n");
297 printf(
"c=%d(0x%08x)\n", c, c);
313 printf(
"vm %.2fKclk\n", clk.
getClock() * 1e-3);
321 printf(
"jit %.2fKclk\n", clk.
getClock() * 1e-3);
329 printf(
"native C %.2fKclk\n", clk.
getClock() * 1e-3);
331 }
catch (std::exception& e) {
332 printf(
"ERR:%s\n", e.what());
334 printf(
"unknown error\n");
void vsubi(Reg r, uint16 imm)
void vldi(Reg r, uint16 imm)
void vadd(Reg r, uint16 idx)
void vjnz(Reg r, int offset)
void vaddi(Reg r, uint16 imm)
void vst(Reg r, uint16 idx)
void vsub(Reg r, uint16 idx)
void vld(Reg r, uint16 idx)
const uint8 * getCode() const
void call(const Operand &op)
void xor_(const Operand &op, uint32 imm)
void test(const Operand &op, const Reg ®)
void add(const Operand &op, uint32 imm)
void sub(const Operand &op, uint32 imm)
void mov(const Operand ®1, const Operand ®2)
void pop(const Operand &op)
void jnz(const Label &label, LabelType type=T_AUTO)
void L(const std::string &label)
void push(const Operand &op)
static std::string toStr(int num)
Xbyak ; JIT assembler for x86(IA32)/x64 by C++.
memset(pInfo->slotDescription, ' ', 64)