www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Reading few CPU flags from D code

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

bool o = if overflow_flag();
if (overflow_flag()) {...} else {...}

But then the compiler has to manage them efficiently (for example here using a
single JNO or JO instruction).

Mar 20 2010