Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!vsi1!bitbug From: bitbug@vicom.COM (James Buster) Newsgroups: comp.lang.c Subject: Re: How poke in Quick-C to PC memory ? Keywords: Quick-C, MSC, far pointer, memory mapped Message-ID: <1436@vsi1.COM> Date: 31 Jan 89 02:56:22 GMT References: <6416@bmc.uu.se- <193@ndla.UUCP- Reply-To: bitbug@vicom.COM (James Buster) Organization: Vicom Systems, Inc. Lines: 38 In article <193@ndla.UUCP- platt@ndla.UUCP (Daniel E. Platt) writes: -In article <6416@bmc.uu.se-, aring@bmc.uu.se writes: -- How do you poke, in quick-C, to a memory adress on a PC ? -- Equivalently, how do you set a pointer to point to, say, the base of -- a memory mapped I/O board ? -- gratefull for help, Avi Ring. - -If the address is addr (type long) such as - - 0x010023afL - -where the above refers to location 0100:23af -and you want to put a data type 'foo' there, you can refer to -that memory as (foo *)0x010023afL. Another solution is the following: /* * MAKE FAR POINTER: * macro to create a far pointer to a given segment and offset */ #define MK_FP(segment,offset)\ ((void far *) (((unsigned long) (segment) << 16) + (offset))) Add the approriate type cast, i.e.: #define EGA_SEGMENT (0xa000) #define EGA_RAM_OFFSET (0x0000) char *device_ptr = (char *) MK_FP (EGA_SEGMENT, EGA_RAM_OFFSET); and presto, you have a pointer pointing anywhere you want. -------------------------------------------- James Buster Mad Hacker Extraordinaire ...!ames!vsi1!bitbug bitbug@vicom.com --------------------------------------------