[comp.sys.ibm.pc] ABSOLUTE ADDRESSING IN C

regwan@sonia.math.ucla.edu (Eliaho Regwan) (07/05/89)

HELP

A friend is working on a IBM PC with a 80186 and it has an eprom of some sort.
She needs to set a pointer to an ABSOLUTE ADDRESS (inside the eprom).  She
is only able to get relative addresses with a block of memory.

DOES ANYONE KNOW HOW TO DO THIS??  PLEASE.  THANKS.


ROGER

jian@prodix.liu.se (Jian Hu) (07/05/89)

In article <1344@sunset.MATH.UCLA.EDU> regwan@math.ucla.edu (Eliaho Regwan) writes:
>A friend is working on a IBM PC with a 80186 and it has an eprom of some sort.
>She needs to set a pointer to an ABSOLUTE ADDRESS (inside the eprom).  She
>is only able to get relative addresses with a block of memory.
>
>DOES ANYONE KNOW HOW TO DO THIS??  PLEASE.  THANKS.
>

I think this question belongs to comp.lang.c. But anyway, in MSC5.0
(<dos.h>) two macros are defined which should work under any compiler:

#define FP_SEG(fp) (*((unsigned *) &(fp)+1))
#define FP_OFF(fp) (*((unsigned *) &(fp)))

This is how to use it:

#include <dos.h> /* Or simply define the above macros */

void far *fp;

main ()
{ char var;

	FP_SEG(fp)=0x????; /* EPROM seg. address */
	FP_OFF(fp)=0x????; /* offset into the EPROM */
	var=(char) *fp;
}

I hope this is what you want.

-- J. H.

marco@hpmcaa.mcm.hp.com (Marco Dalla-Gasperina) (07/05/89)

/ hpmcaa:comp.sys.ibm.pc / regwan@sonia.math.ucla.edu (Eliaho Regwan) /  6:10 pm  Jul  4, 1989 /
HELP

A friend is working on a IBM PC with a 80186 and it has an eprom of some sort.
She needs to set a pointer to an ABSOLUTE ADDRESS (inside the eprom).  She
is only able to get relative addresses with a block of memory.

DOES ANYONE KNOW HOW TO DO THIS??  PLEASE.  THANKS.


ROGER
----------
try 

    p = (char far *) 0x12345678L;

that will load p with 1234:5678 (in ssss:oooo form).

or - 

#include	<dos.h>

FP_SEG(p) = 0x1234;
FP_OFF(p) = 0x5678;

for the same results;

marco