File: stackframe.cpp

package info (click to toggle)
xbyak 7.24.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,068 kB
  • sloc: cpp: 21,493; ansic: 2,981; python: 372; makefile: 306; sh: 204
file content (28 lines) | stat: -rw-r--r-- 506 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#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");
	}
}