Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!rutgers!labrea!aurora!ames!sdcsvax!ucsdhub!hp-sdd!hplabs!hplabsz!dleigh From: dleigh@hplabsz.HPL.HP.COM (Darren Leigh) Newsgroups: comp.sources.wanted,comp.lang.c,comp.sys.ibm.pc Subject: Re: C / IBM REQUIREMENTS...... Message-ID: <735@hplabsz.HPL.HP.COM> Date: Wed, 26-Aug-87 21:02:10 EDT Article-I.D.: hplabsz.735 Posted: Wed Aug 26 21:02:10 1987 Date-Received: Sat, 29-Aug-87 06:13:58 EDT References: <6050@ut-ngp.UUCP> Reply-To: dleigh@hplabsz.UUCP (Darren Leigh) Organization: Hewlett-Packard Laboratories Lines: 34 Summary: peeking and poking from MSC 4.0 Xref: mnetor comp.sources.wanted:2048 comp.lang.c:3945 comp.sys.ibm.pc:7174 In article <6050@ut-ngp.UUCP> marshek@ut-ngp.UUCP (The Genie) writes: > >Anybody out there have any stuff to do a peek & poke function in C ? >(The peek & poke of BASIC). C does lots of interesting things with pointers so that is a good way to start. All you have to do is stuff an absolute address into a pointer. The real problem here is the brain-damaged Intel/IBM architecture, but it can be done. From Microsoft C 4.0 you can do the following: Say you want to deal with a byte at location 0040:0049 that controls the video mode. A BASIC-like videomode = peek(address) would be done like this: videomode = *(char far *) 0x400049L; This takes the absolute value 0040:0049 and casts it to a far pointer to a character (or single byte). The code for poke operates similarly. The BASIC command poke(address,videomode) could be set up as: *(char far *) 0x400049L = videomode; This again casts the absolute address 0040:0049 to a pointer to char and stuffs the value in there. This works from MSC 4.0, and may or may not work from other C's. Try playing around by setting far pointers to the absolute addresses that you need. If your C does not support far pointers and does not have a way of changing the segment registers, you are on your own and will have to play with assembly language. BTW, I pulled these little examples from page 37 of the December 1986 issue of the Microsoft Systems Journal. Darren Leigh dleigh@hplabs.hp.com