delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/12/29/11:30:06

From: Martin Str|mberg <ams AT speedy DOT ludd DOT luth DOT se>
Subject: Re: _far pointer and etc
Newsgroups: comp.os.msdos.djgpp
References: <ifuo0vgqpbmbc0eje0laapktu5ro2kfssi AT 4ax DOT com>
User-Agent: tin/1.4.4-20000803 ("Vet for the Insane") (UNIX) (NetBSD/1.5_BETA (alpha))
Message-ID: <1041179158.716695@queeg.ludd.luth.se>
Cache-Post-Path: queeg.ludd.luth.se!unknown AT speedy DOT ludd DOT luth DOT se
X-Cache: nntpcache 2.4.0b5 (see http://www.nntpcache.org/)
Date: 29 Dec 2002 16:25:58 GMT
Lines: 49
NNTP-Posting-Host: queeg.ludd.luth.se
X-Trace: 1041179158 news.luth.se 26538 130.240.16.109
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Simon <stdf23173 AT yahoo DOT co DOT uk> wrote:

: I came up with another question related to the parallel port.
: It is possible to get the baseaddress from a location some where in
: memory/bios.

: Well, i found a piece of code on the faq :

:   #include <sys/nearptr.h>
:   #include <crt0.h>

:   void * MK_FP (unsigned short seg, unsigned short ofs)
:   {
:     if ( !(_crt0_startup_flags & _CRT0_FLAG_NEARPTR) )
:       if (!__djgpp_nearptr_enable ())
:         return (void *)0;
:     return (void *) (seg*16 + ofs + __djgpp_conventional_base);
:   }


: How do i call the function above ????

You don't. You use the functions starting with _far instead, so you
don't need to disable all memory protection. This will help you find
the problems in your code instead of messing up your OS or file
system.


: Cause i get 

: D:\Program Files\DJGPP\code>gcc hello.c  > outp.txt
: hello.c: In function `get_addresses':
: hello.c:32: warning: dereferencing `void *' pointer
: hello.c:32: void value not ignored as it ought to be
: hello.c: In function `main':
: hello.c:48: warning: return type of `main' is not `int'

If you must know: cast it to some pointer that really points to
something.

: And my the return address is remarkable large but always the same !

So what? You're in protected mode now, so that function needs to
offset your offset so you get the right address.


Right,

						MartinS

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019