From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Porting problem from Borland C++ Date: Thu, 30 Oct 1997 10:47:52 +0000 Organization: Two pounds of chaos and a pinch of salt Lines: 41 Message-ID: <345865D8.1024@cs.com> References: <345718dd DOT 193834 AT news DOT dial DOT pipex DOT com> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp245.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Peter Stokes wrote: > > As a newbie to DOS C programming, I have successfully used the djg C > compiler to write my own programs from new. The problem I now have is > trying to port some programs which have run successfully on Borland > C++. The programs compile OK but when I try to get access to the com > ports the following routine causes the program to crash or report a > non valid port which is most definetly present. You are doing illegal things in protected mode. You can't just write to any old random absolute memory address without violating memory protection. I'm also interested to know why you commented out the line that sets the SPA variable; with it you violate protection; without it you are trying to pass outportb() an uninitialized pointer. Either one will crash your program quite nicely. [code snipped] > Can anyone help with either - > > 1) A modified version of the above which will work > > 2) An example of writing to the com ports using outportb as above > > 3) Point me in the direction of documentation where I can get the > relevent info. I don't have time to do 1 or 2, but I can easily tell you 3: the FAQ. Quite simply, all the information you need to get started with hardware interfaces in protected mode is in chapters 17 and 18 of the DJGPP Frequently Asked Questions list (v2/faq210b.zip from SimTel or online at http://www.delorie.com/djgpp/v2faq/). It's so well detailed there that there's no point in rewriting it here. :) -- --------------------------------------------------------------------- | John M. Aldrich | "History does not record anywhere at | | aka Fighteer I | any time a religion that has any | | mailto:fighteer AT cs DOT com | rational basis." | | http://www.cs.com/fighteer | - Lazarus Long | ---------------------------------------------------------------------