Lennie Tofft on 06/24/12 - 16:37:20
Does anyone know ifit is possible to configure ntvdm to always give full CPU power to qbasic, even when it is in a loop? I have discovered that when a QB program is in a loop, ntvdm notices this and cut down CPU power, unless a key is stroked. Perhaps there are older versions of ntvdm or vdm which doesn't analyze the dos program in this way?
Todd on 06/25/12 - 12:10:28
I think it might be possible in DOSBox but I'm not certain. NTVDM is only an emulator for DOS applications in Windows NT-based platforms (like Windows XP and 7).
Just curious, but why would you want it to kill your CPU if it's in a loop? I'm just not sure what you're trying to accomplish if the program isn't doing anything in a loop.
Lennie Tofft on 06/26/12 - 12:50:08
One reason may be to measure the speed of the computer. If you know how far the computer counts in a given time interval, you can use counting, in a loop, to control time delays in a program.
Another reason is to create a true random number generator. I use to do this with the following code:
T = TIMER
WHILE TIMER - T < 1
X = X + TIMER - T
X = X - INT(X / 10) * 10
This generates a random number between 0 and 9.
Todd on 06/26/12 - 16:14:40Reply to this message
Unfortunately for the case of newer Windows platforms, the only way you can measure processor speed through a DOS program is by having your program run something like XOR and then subtracting the XOR time from it (estimated), or you can try making interrupt calls to the BIOS to get a more approximate time or even finding the CPU speed (although NTVDM probably won't let you get away with that easily).
Random number generators are never truly random. You can make one by taking a seed (time or date is a good way to start) and then generating a pseudo-random number by modding the number repeatedly by the limit (10 in your example).