Mail Archives: djgpp/2002/12/29/11:30:06
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 -