From: Leon Heller Newsgroups: comp.os.msdos.djgpp Subject: Re: Help: read/write from printer port Date: Fri, 9 Jan 1998 09:43:58 +0000 Organization: at home Distribution: world Message-ID: References: <01bd1cc1$d4914d00$ab51e0ce AT rhasty> NNTP-Posting-Host: lfheller.demon.co.uk MIME-Version: 1.0 Lines: 49 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk In article <01bd1cc1$d4914d00$ab51e0ce AT rhasty>, Richard Hasty writes > >I'm brand new to DJGPP and I'm trying to write stuff to the printer port. >I'm running Win95 if that has anything to do with it. I was thinking I'd >be able to just use "open" and pretend I was writing to a file called LPT1 >or PRN. It does not work as I would have expected though. The code (only a >few lines) is at the end of the message. It bombs on the write operation. > >Is there a better way of doing it? I was thinking of trying to just write >to the correct memory address. >I have an old copy of Turbo C v 1.01 and I tried >poke(0x000,0x0378,1); >but that didn't work either. If I tried that under plain old dos would it >work? Do I even have the right address for the parallel port? >Can I do something equivalent using DJGPP? > >I would love to stop asking these questions. Are there any documents, >books or any other resources for learning about how to do this kind of >thing? Also, any reccomendations for the beginner in assembly and writing >TSR programs and using interrupts? The printer port registers are I/O-mapped, not memory-mapped. The easiest way to access them is to use the outportb(port, value) and inportb(port) functions. Here's a very simple test program which pulses the port O/P lines. You'll need to link in the pc library with -lpc, when compiling. #include #include main() { for(;;) { outportb(0x378,0x00); outportb(0x378,0xFF); } } Leon -- Leon Heller: leon AT lfheller DOT demon DOT co DOT uk http://www.lfheller.demon.co.uk Amateur Radio Callsign G1HSM Tel: +44 (0) 118 947 1424 See http://www.lfheller.demon.co.uk/dds.htm for details of my AD9850 DDS system - schematic and software.