[ Usenet FAQs | Web FAQs | Documents | RFC Index ]
    Search the FAQ Archives

Part1 - Part2 - Part3 - Part4 - Part5 - Single Page

Top Document: comp.os.msdos.programmer FAQ part 4/5
Previous Document: - How can I find the Microsoft mouse position and button status?
Next Document: - How can I read or write my PC's CMOS memory?


- How can I access a specific address in the PC's memory?


Date: 7 Feb 2002 14:50:10 -0400

 First check the library that came with your compiler. Many vendors have
 some variant of peek and poke functions. For example:

 * In Turbo Pascal, use the pseudo-arrays Mem, MemW, and MemL. Be sure
   you use the correct array for the size of data you want to access:
   byte, word, or double word. Alternatively, use pointers.

 * In Turbo C/Borland C, and in recent versions of Microsoft C, use
   MK_FP; in older versions of Microsoft C, use FP_OFF and FP_SEG.
   (Caution: Turbo C and Turbo C++ also have FP_OFF and FP_SEG macros,
   but they can't be used to construct a pointer.) Be sure to pick the
   right data type: probably "unsigned char far *" if you're planning to
   access bytes and "unsigned short far *" for words. (The "far" isn't
   needed if your memory model uses 32-bit data pointers, but including
   it does no harm.)

 By the way, it's not useful to talk about "portable" ways to do this.
 Any operation that is tied to a specific memory address is not likely to
 work on another kind of machine.



Top Document: comp.os.msdos.programmer FAQ part 4/5
Previous Document: - How can I find the Microsoft mouse position and button status?
Next Document: - How can I read or write my PC's CMOS memory?

Part1 - Part2 - Part3 - Part4 - Part5 - Single Page


[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
jeffrey@carlyle.org (Jeffrey Carlyle)

Last Update October 22 2009 @ 05:28 AM

Some parts © 2009 Advameg, Inc.