delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/09/02:01:01

From: Shawn Hargreaves <Shawn AT talula DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: far pointers
Date: Sat, 8 Mar 1997 21:43:05 +0000
Organization: None
Distribution: world
Message-ID: <sTf4TUAp1dIzEwAe@talula.demon.co.uk>
References: <5frqr3$em6 AT oban DOT cc DOT ic DOT ac DOT uk>
NNTP-Posting-Host: talula.demon.co.uk
MIME-Version: 1.0
Lines: 31
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Mr P. Steele writes:
>In djgpp do I have to initialise far pointers using the farptr.h
>, if so how do I do it. An example would be something like as follows
>
>unsigned char *rom_char_set = (char far *)0xF000FA6EL;

That's a real mode pointer, which can't be accessed directly in
protected mode. I presume you are trying to read some data from segment
0xF000, offset 0xFA6E, right? You have to convert that into a protected
mode address with the formula (seg*16 + offset), which gives an address
of 0xFFA6E.

You can't access that pointer directly, though, because it refers to the
DOS memory area rather than your address space. The easy way to do it is
with the dosmemget() function, eg:

    char buffer[size];
    dosmemget(0xFFA6E, size, buffer);

Alternatively you can use the functions in <sys/nearptr.h> to get direct
access to conventional memory: type "info libc alpha
__djgpp_nearptr_enable" for details.

btw. these issues are covered in some detail in the FAQ: it's well worth
reading...


/*
 *  Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
 *  Beauty is a French phonetic corruption of a short cloth neck ornament.
 */

- Raw text -


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