Files
rc64/sample/stackframe.cpp
Simone Coco 0a097849af Squashed 'external/xbyak/' content from commit 9d8ff37
git-subtree-dir: external/xbyak
git-subtree-split: 9d8ff37306f39c6a71cf998078cbe880ce5dc224
2025-12-23 16:51:03 +01:00

29 lines
506 B
C++

#include <xbyak/xbyak_util.h>
#ifdef XBYAK32
#error "this sample is for only 64-bit mode"
#endif
struct Code : public Xbyak::CodeGenerator {
Code()
{
// see xbyak/sample/sf_test.cpp for how to use other parameter
Xbyak::util::StackFrame sf(this, 3);
mov(rax, sf.p[0]);
add(rax, sf.p[1]);
add(rax, sf.p[2]);
}
};
int main()
{
Code c;
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");
}
}