From: "Michael Stewart" Newsgroups: comp.os.msdos.djgpp Subject: Re: Selector code Date: Thu, 17 Jun 1999 11:21:58 +0100 Organization: (Posted via) Netcom Internet Ltd. Message-ID: <7kai08$f4d$1@taliesin.netcom.net.uk> References: <7kaeck$em5$1 AT taliesin DOT netcom DOT net DOT uk> NNTP-Posting-Host: hgty.capgemini.co.uk X-Trace: taliesin.netcom.net.uk 929614664 15501 194.42.240.2 (17 Jun 1999 10:17:44 GMT) X-Complaints-To: abuse AT corp DOT netcom DOT net DOT uk NNTP-Posting-Date: 17 Jun 1999 10:17:44 GMT X-Newsreader: Microsoft Outlook Express 4.72.3155.0 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0 Lines: 31 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Here's a modified version, hopefully with all the changes Eli suggested implemented correctly. I can't test this until tonight so this is untested. int make_ds (int &ds, int base, int limit) { unsigned char ds_data[8]; limit--; /* Check for the limit being over 1MB */ if (limit > 1024 * 1024) limit |= 0xfff; ds_data[5] = 0xf3; ds_data[2] = base & 0xff; ds_data[3] = base >> 8 & 0xff; ds_data[4] = base >> 16 & 0xff; ds_data[7] = base >> 24 & 0xff; ds_data[0] = limit & 0xff; ds_data[1] = limit >> 8 & 0xff; ds_data[6] = limit >> 16 & 0x0f + 0x41; if (limit > 64 * 1024) ds_data[6] += 0x80; ds = __dpmi_allocate_ldt_descriptors (1); return __dpmi_set_descriptor (ds, ds_data); }