CPU register test
hI ALL
can any one sugest how to verify that CPU registers are working properly in C under linux.. like i need to check and make sure the the registers of my CPU are working fine?? Thanks in advance.. Arun |
Under C? No. You would need to write assembly code for that. C does provide a "register" storage class for variables. However, it does not allow the programmer to specify which register, and it does not guarantee the register request will be granted. Even if C allowed that, it would only be able to test general purpose registers. There would be no direct tests for the program counter, error status, or other special purpose registers.
If you're just worried that something might be wrong, don't. If a register in the processor was broken or misbehaving, I seriously doubt your computer would boot at all. I mean, we're talking near-impossible to have a functional computer with a bad register. |
If you had a bad register, you would not be able to get anywhere at all. If you still feel the need to test them, the best way (simplest) is to write some assembly code for real mode, boot into DOS and do it that way. You won't be able to test all of them.
|
Quote:
And to reiterate the other point, if you have a broken register, you will not have a functional computer, which implies you wouldn't be able to compile the program in the first place. Trust me, you would have serious problems with a broken register. Lastly, according to the reference book I have (Programmer's Reference: C/C++ Second Edition), the asm keyword is supported only by C++. The book includes the C99 standard, so that leads me to believe it's still current. If gcc supports the asm keyword in standard C, and you are absolutely intent on doing this, then you'll need to find some documentation on what format gcc requires for assembly instructions. |
If I was going to do it in C, I'd just create an executable string which would have the machine code in it. Pretty silly though. C is just the wrong tool, like using a screwdriver to drill a hole in the wall (yeah, I've done that) :)
|
Here's some code I wrote in 1999. You may do anything with it.
I still don't know what you're trying to do. It would be easy to make a function that returns the value of any register. It wouldn't be portable though. The asm keyword may be used too. Just browse some crypto code, ie openssl, gnupg, libgcrypt, mcrypt, libmcrypt, et cetera compile with "gcc showreg.s" Code:
# |
All times are GMT -5. The time now is 05:29 AM. |