Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
static_buf.cpp
Go to the documentation of this file.
1/*
2 sample to use static memory
3*/
4#include <stdio.h>
5#define XBYAK_NO_OP_NAMES
6#include "xbyak/xbyak.h"
7
8MIE_ALIGN(4096) char buf[4096];
9
10struct Code : Xbyak::CodeGenerator {
12 : Xbyak::CodeGenerator(sizeof(buf), buf)
13 {
14 puts("generate");
15 printf("ptr=%p, %p\n", getCode(), buf);
16 Xbyak::CodeArray::protect(buf, sizeof(buf), true);
17#ifdef XBYAK32
18 mov(eax, ptr [esp + 4]);
19 add(eax, ptr [esp + 8]);
20#elif defined(XBYAK64_WIN)
21 lea(rax, ptr [rcx + rdx]);
22#else
23 lea(rax, ptr [rdi + rsi]);
24#endif
25 ret();
26 }
28
29inline int add(int a, int b)
30{
32}
33
34int main()
35{
36 int sum = 0;
37 for (int i = 0; i < 10; i++) {
38 sum += add(i, 5);
39 }
40 printf("sum=%d\n", sum);
41}
static bool protect(const void *addr, size_t size, bool canExec)
Definition xbyak.h:966
static const Reg32 esp(Operand::ESP)
Definition xbyak.h:104
const To CastTo(From p)
Definition xbyak.h:279
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
Code s_code
int add(int a, int b)
int main()
Definition bench.cpp:18
Xbyak ; JIT assembler for x86(IA32)/x64 by C++.
void lea(const Reg &reg, const Address &addr)
CK_RV ret
uint8_t buf[2048]
c_gkp_out sizeof(template))
#define MIE_ALIGN(x)
Definition zm.h:50