Reputation: 155
I wrote a small random digit program that makes use of RDTSC to give me the randomness. I wrote it on Linux Mint 17 using FASM.
The problem is, it works perfectly on AMD FX 64bit PC but the exact piece of code fail (or hangs) on Intel Celeron netbook (64-bit), both under Windows 8 and Linux Mint (I dual-boot, so I adapted the code for Win 8)
What could be the problem here? This is basically the code;
again:
rdtsc
and eax,1111b
cmp eax,10
jae again
;things to do with the random digit
I debug it and found that the culprit hides in this part of the code. But I don't see any problem either. It works perfectly on my AMD PC. Is RDTSC disabled by default on Intel CPUs?
Upvotes: 0
Views: 398
Reputation: 9278
You're essentially reading the number of clock cycles (which is billions per second) and then not exiting the loop unless the last 4 bits of it are < 10. It could be that it just takes a long time for this situation to occur.
If the instruction was disabled your program would have been killed by the OS with an "illegal instruction" error.
Upvotes: 2