This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: memory location


Hi Zippo,

>I am trying to write a program and i need to be able to view the bios information in memory, "capslock numlock shit etc" how ever i do not know the code to read raw from a specific memory location, any help and i will be greatful.

Do this:

#include <stdio.h>
typedef volatile char byte;
int main() {
  byte* ptr = (byte*)0xC0000000;
  printf("%02x\n", *ptr &0xFF);
}

That's a raw read of the byte at memory location C0000000.

Unless you are running DOS (MS-DOS, PC-DOS, DR-DOS, et al), old Amiga OS, or old Mac OS, this will be utterly useless.  Most personal computer operating systems since, oh, 1983, have operating system application program interface (API) calls that perform the kind of functionality you are looking for.

Intel architecture also supports IO at the instruction level.  The above only works for reading the bytes in memory, or memory mapped registers.  It doesn't work for inp and outp types of data transfer, nor for DMA data transfer.

If you are running DOS, get the "PC Interrupts" (2nd ed) by Brown and Kyle.  Addison-Wesley, ISBN 0-201-62485-0.  If you are running old Amiga OS, get the RKM.  If you are running old Mac OS, get the Mac "rainbow" suite of technical books.

HTH,
--Eljay



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]