Article View: comp.os.msdos.programmer
Article #5965Correction to far_ptr_cmp().
From: Peter Davidson
Date: Fri, 26 Apr 1991 13:29
Date: Fri, 26 Apr 1991 13:29
23 lines
1162 bytes
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.UUCPShow 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