File: no_flags.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 (25 lines) | stat: -rw-r--r-- 490 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
#include <stdio.h>
#include <xbyak/xbyak.h>

struct Code : Xbyak::CodeGenerator {
	Code(bool nf) {
		xor_(eax, eax); // CF = 0
		mov(eax, -1);
		if (nf) {
			puts("no flags (with T_nf)");
			add(eax|T_nf, eax, 1); // does not change CF
		} else {
			puts("change flags (without T_nf)");
			add(eax, eax, 1); // CF = 1
		}
		adc(eax, 0); // eax = CF ? 1 : 0
		ret();
	}
};

int main() {
	for (int i = 0; i < 2; i++) {
		Code c(i);
		printf("i=%d ret=%d\n", i, c.getCode<int(*)()>()());
	}
}