Hi, Gabor Manic!
On 06 Jul 97 21:01:12 you wrote to Christopher Butler
CB> char i;
CB> if (inp(0x64) & 1) // same as kbhit()
GM> ^^^^^^^^^^^^^^^
GM> The problem is here
GM> Here you set the first bit if it is already set, and erase the others.
HEre he leaves the last bit and clears all the others.
GM> This port can't be changed, and that is the reason why your computer
GM> crashes.
I don't see a reason why the computer crashes but the above code do not
modify the port. It just reads the value from the port then tests its last
bit in a register. To modify a port you should use outp.
GM> If you want a chack the state of N-th bit you can do that like this:
GM> ... (inp(0x64) && 1)
That is truly pointless. That is true if you read any value other than zero
from the port, not the last bit, and && with a constant is mere vaste of
space in the source (but the compiler will optimize it away anyway.)
GM> & - binary AND operator
GM> && - logical AND operator
That last part is true. :)
Paul
... If you drink, don't park. Accidents cause people.
--- OS/2 Warp
---------------
* Origin: The FlintStones' Cave in BedRock (2:371/20)
|