Mail Archives: djgpp/1997/10/30/00:06:10
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 |
---------------------------------------------------------------------
- Raw text -