fang@dukempd.phy.duke.edu (Fang Zhong) (02/14/90)
I am relatively new to PC-AT and MS C. I am asking helps from the net. We bought a frequency-timer-counter board for our AT. We need to write to and read from several registers. Currently, I am using POKE and PEEK functions from a GPIB board package. For a given address with segment and offset, how do I use far pointer to write to and read from the address? Will the far pointer macro be faster than POKE and PEEK? Here is something I have tried and it did not work. unsigned far *addr; unsigned seg, offset, byte; addr = NULL; addr += seg*16 + offset; *addr = byte; printf("%u\n"), *addr); Any helps are appreciated very much. -- Fang Zhong 1-919-684-8247 Duke University Dept. of Physics fang@phy.duke.edu Durham, N.C. 27706
fredex@cg-atla.UUCP (Fred Smith) (02/19/90)
In article <848@dukempd.phy.duke.edu> fang@dukempd.phy.duke.edu (Fang Zhong) writes: > > I am relatively new to PC-AT and MS C. I am asking helps from the net. > > Here is something I have tried and it did not work. > > unsigned far *addr; > unsigned seg, offset, byte; > > addr = NULL; > addr += seg*16 + offset; > *addr = byte; > printf("%u\n"), *addr); > > Any helps are appreciated very much. > >-- > Fang Zhong 1-919-684-8247 > Duke University Dept. of Physics fang@phy.duke.edu > Durham, N.C. 27706 MIcrosoft C has a pair of macros called FP_SEG and FP_OFF which are designed for manipulating the segment:offset values of a far pointer. You could try something like this: unsigned far *addr; FP_SEG(addr) = (segment value); FP_OFF(addr) = (offset value); to initialize the address of each place you want to read/write. You could also look at the definitions of those two macros (in dos.h, I think) to see what they are doing if you not only want it to work, but also to UNDERSTAND it! good luck!]] Fred
kaleb@mars.jpl.nasa.gov (Kaleb Keithley) (02/21/90)
In article <8389@cg-atla.UUCP> fredex@cg-atla.UUCP (Fred Smith) writes: >In article <848@dukempd.phy.duke.edu> fang@dukempd.phy.duke.edu (Fang Zhong) writes: >> Here is something I have tried and it did not work. >> unsigned far *addr; >> unsigned seg, offset, byte; > >> addr = NULL; >> addr += seg*16 + offset; >> *addr = byte; >MIcrosoft C has a pair of macros called FP_SEG and FP_OFF which are >FP_SEG(addr) = (segment value); >FP_OFF(addr) = (offset value); Another way to set a far * is as follows assuming, say you want to look at VGA screen memory at A000:0000 unsigned far *addr; addr = (unsigned far *)A0000000; I always thought the FP_SEG and FP_OFF macros were to get the segment/offset components from some initialized far pointer. Chewey, get us outta here! kaleb@mars.jpl.nasa.gov Jet Propeller Labs Kaleb Keithley