Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!bbn!uwmcsd1!lakesys!gryphon!greg From: greg@gryphon.CTS.COM (Greg Laskin) Newsgroups: comp.sys.ibm.pc,comp.lang.c Subject: Re: Looking for C functions to access PC memory Message-ID: <2292@gryphon.CTS.COM> Date: Fri, 13-Nov-87 23:42:54 EST Article-I.D.: gryphon.2292 Posted: Fri Nov 13 23:42:54 1987 Date-Received: Sun, 15-Nov-87 16:42:46 EST References: <24261F3U@PSUVMB> <2312@emory.uucp> Reply-To: greg@gryphon.CTS.COM (Greg Laskin) Organization: Trailing Edge Technology, Redondo Beach, CA Lines: 48 Xref: mnetor comp.sys.ibm.pc:10152 comp.lang.c:5413 >In article <24261F3U@PSUVMB> F3U@PSUVMB.BITNET writes: >>I am looking for some functions when called from a C program, will: >> 1) read (peek) memory directly when supplied with >> an address. Returns with the value at specified address. >> and >> 2) write (poke) memory directly when supplied with an >> address and a byte value. >> >>I am using Microsoft C 4.0 on an AT&T 6300 PLUS. Routines >>in C or Assembler OK. In Mircrosoft C: foo() { char huge *blat =0; char far *p; char c; int i; /* assume n is the ABSOLUTE address of an object in physical memory -- linear space, not segmented */ long n = 0x0c0000; c = blat[n]; i = ((int huge *)blat)[n]; /* huge pointers are EXPENSIVE so if you're going to do lots of stuff in a 64K segement, like video stuff, resolve the address into a far pointer and use it instead thusly */ p = &blat[0xb8000]; } Note: #ifndef M_LGDATA #define huge #define far #endif to remove the processor dependency of the code. (Yes. I know about the non-portability of the hard addressing) -- Greg Laskin "When everybody's talking and nobody's listening, how can we decide?" INTERNET: Greg.Laskin@gryphon.CTS.COM UUCP: {hplabs!hp-sdd, sdcsvax, ihnp4}!crash!gryphon!greg UUCP: {philabs, scgvaxd}!cadovax!gryphon!greg