🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #5965

Correction to far_ptr_cmp().

#5965
From: Peter Davidson
Date: Fri, 26 Apr 1991 13:29
23 lines
1162 bytes
days ago, for comparing far pointers, requires a correction.
I forgot to add the (unsigned long) casts in the first two lines.
Shoot!  We'll at least I noticed before anyone else did
(or at least before anyone else posted a correction
(or at least before anyone did and it arrived here)).

The function returns -1 if the physical memory address of ptr1 is
less than that of ptr2, 1 if greater than and 0 if they point to
the same memory location.

int far_ptr_comp(void far *ptr1,void far *ptr2)
{
unsigned long p1 = ( ( (unsigned long)FP_SEG(ptr1)<<4 ) + FP_OFF(ptr1) );
unsigned long p2 = ( ( (unsigned long)FP_SEG(ptr2)<<4 ) + FP_OFF(ptr2) );
int result=0;

if ( p1 < p2 )
    result--;
else if ( p1 > p2 )
    result++;

return ( result );
}
Technical Details
Message-ID: <2351@wet.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!hoptoad!wet!wet.UUCP

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!hoptoad!wet!wet.UUCP
From: naga@wet.UUCP (Peter Davidson)
Newsgroups: comp.os.msdos.programmer
Subject: Correction to far_ptr_cmp().
Message-ID: <2351@wet.UUCP>
Date: 26 Apr 91 13:29:39 GMT
Sender: naga@wet.UUCP
Distribution: usa
Organization: Wetware Diversions, San Francisco
Lines: 23