2013-04-15 23:57:11 -07:00
|
|
|
#include <xbyak/xbyak_util.h>
|
|
|
|
|
|
|
|
#ifdef XBYAK32
|
|
|
|
#error "this sample is for only 64-bit mode"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct Code : public Xbyak::CodeGenerator {
|
|
|
|
Code()
|
|
|
|
{
|
2013-04-16 13:52:04 -07:00
|
|
|
// see xbyak/sample/sf_test.cpp for how to use other parameter
|
2013-04-16 13:21:50 -07:00
|
|
|
Xbyak::util::StackFrame sf(this, 3);
|
2013-07-04 07:59:12 -07:00
|
|
|
mov(rax, sf.p[0]);
|
|
|
|
add(rax, sf.p[1]);
|
|
|
|
add(rax, sf.p[2]);
|
2013-04-15 23:57:11 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
Code c;
|
2013-04-16 13:21:50 -07:00
|
|
|
int (*f)(int, int, int) = c.getCode<int(*) (int, int, int)>();
|
|
|
|
int ret = f(3, 5, 2);
|
|
|
|
if (ret == 3 + 5 + 2) {
|
|
|
|
puts("ok");
|
|
|
|
} else {
|
|
|
|
puts("ng");
|
|
|
|
}
|
2013-04-15 23:57:11 -07:00
|
|
|
}
|