Large arrays in MSDOS

Scott Linn scott at hpcvca.CV.HP.COM
Fri Oct 27 02:48:43 AEST 1989


/ hpcvca:comp.lang.c / readdm at walt.cc.utexas.edu (David M. Read) / 10:36 am  Oct 25, 1989 /

>In article <4010005 at hpcvca.CV.HP.COM> scott at hpcvca.CV.HP.COM  writes:
>>
>>Hello,
>>
>>I've been having a problem trying to use an array greater than 64k on
>>an msdos machine.  What I have is the following:
>>
>Remember that the 80x86 processors use segmented architecture, so 64K is
>a kind of barrier.  The way to get around the barrier is with use of the
>'huge' keyword.  Read the manuals closely, for there are some limitations
>on what you can do with it.

Yes, this was the problem.  I realize that the architecture is
segmented, but I was under the (mistaken!) impression that far
pointers would be able to address more than 64k.  The problem seems to
be that the pointer arithmetic only applies to the offset, and not the
segment.  Thus, wrapping occurs.  My compiler (Datalight) does not
have the Huge model, so I'm kind of hosed.  I will probably address
the array using two pointers, where the second pointer is composed by
the first one cast to a long, the correct offset added, then cast back
to a far pointer.  This should solve the arithmetic problem.

Thanks to all who replied in notes or mail.

Scott Linn
hplabs!scott at hpcvcbh



More information about the Comp.lang.c mailing list