Comment by pseudohadamard
4 days ago
I was going to suggest exactly that, if you're got an RNG, or pretty much anything else for that matter, you need the ability to return some sort of things-went-wrong-somewhere indicator value, and presumably AMD is using 0 to do this. Yes, there's also the CF, but the caller may not be checking that, particularly if it's being done from a HLL.
Has anyone checked whether it can return ~0, (signed) -1, the traditional error-return value?
> Yes, there's also the CF, but the caller may not be checking that, particularly if it's being done from a HLL.
You can’t call a CPU instruction from a high-level language. You would either use inline assembly or call a library function.
Either way, not handling CF=0 would be a bug (in your code or in the library function)