[comp.lang.pascal] help TP Pointers

SNYDER%UCLACH.BITNET@cornellc.cit.cornell.edu (08/15/90)

Dear Sir or Madam:

We are having problems and heard about this forum...

I need to know how to get the segment and offset of the address that
an allocated pointer points to (e

SNYDER%UCLACH.BITNET@cornellc.cit.cornell.edu (08/15/90)

Dear Sir or Madam:

We are having problems and hope we can get some help from someone
with more programming skill.

We need to know how to get the address that a newly allocated pointer
(Turbo Pascal ver 4.0) points to for an application involving direct
memory access (DMA). In particular, we are using a software routine
for the DMA which requires the segment and offset of a variable and
we are forced to use dynamic memory allocation and pointers because
our sample density exceeds the 64K Turbo Pascal limit. If you know
how to get the address of the newly allocated memory that the pointer
points to we would greatly appreciate your assistance.

Please send e-mail to snyder@uclac1.chem.ucla.edu or snyder@uclach.bitnet.
Thank you very much.

mangor@disk.UUCP (Darrell Kitchen) (08/24/90)

In article <24138@adm.BRL.MIL> SNYDER%UCLACH.BITNET@cornellc.cit.cornell.edu writes:
>Dear Sir or Madam:
>
>We are having problems and hope we can get some help from someone
>with more programming skill.
>
>We need to know how to get the address that a newly allocated pointer
>(Turbo Pascal ver 4.0) points to for an application involving direct
>memory access (DMA). In particular, we are using a software routine
>for the DMA which requires the segment and offset of a variable and
>we are forced to use dynamic memory allocation and pointers because
>our sample density exceeds the 64K Turbo Pascal limit. If you know
>how to get the address of the newly allocated memory that the pointer
>points to we would greatly appreciate your assistance.
>
>Please send e-mail to snyder@uclac1.chem.ucla.edu or snyder@uclach.bitnet.
>Thank you very much.

Heres a very simple way to access any pointer that you may have.  Type doesn't
seem to differ.

type
     ptype = record case byte of
	  0 : (p     : pointer);
	  1 : (l     : longint);
	  2 : (ofs, seg : word);
     end;

var
     pt  : pointer;
     lnv : longint;
     ofs : word;
     seg : word;

(*  access offset and seg of pt through Turbo Pascal's powerful typecasting
    as

    ofs := ptype(pt).ofs;
    seg := ptype(pt).seg;
          likewise
    ptype(pt).ofs := ofs;
    ptype(pt).seg := seg;
	    also
    ptype(pt).l := lnv;
	    and
    lnv := ptype(pt).l;
*)

Darrell (mangor@disk.uucp)