digitalmars.D - Re: Reading few CPU flags from D code
- bearophile <bearophileHUGS lycos.com> Mar 20 2010
A simple way to implement it is to define few magic variables inside the std.intrinsic module, and then allow them to be used only inside an if, alone, like this: import std.intrinsic: overflow_flag; if (overflow_flag) {...} else {...} But magic variables are not tidy. So a tidier solution is to turn them into boolean functions that the compiler manages in a special way, as the other intrinsics: bool o = if overflow_flag(); Or: if (overflow_flag()) {...} else {...} But then the compiler has to manage them efficiently (for example here using a single JNO or JO instruction). Bye, bearophile
Mar 20 2010