Date: Thu, 17 Jun 1999 10:20:54 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: Michael Stewart cc: djgpp AT delorie DOT com Subject: Re: Selector code In-Reply-To: <7k7qc5$pc2$1@taliesin.netcom.net.uk> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Wed, 16 Jun 1999, Michael Stewart wrote: > It creates a selector, given the location and size. So if you wanted a > descriptor which spanned the VGA memory (0xa0000, 64000 bytes) you would > call it like so. > > if (make_ds (video_ds, 0xa0000, 64000)) > return -1; /* Error making descriptor */ I think it might be useful. > int make_ds (int &ds, int base, int limit) { > static char ds_data[8]; Why did you make the ds_data[] array static? Also, I think it's better to declare it "unsigned char". > limit--; > ds_data[0] = limit & 0xff; > ds_data[1] = limit >> 8 & 0xff; It might be better to make sure that if the size of the segment is more than 1MB, the lower 12 bits in the limit you pass to __dpmi_set_descriptor are set. This is because the DPMI spec requires such large segments to be page-aligned, and some servers will fail the call otherwise. Too many people posted here code that didn't work because they failed to comply to that requirement, and it would be a good idea to make this function take care of that for the user. > ds_data[6] = limit >> 16 & 0x0f + 0x40; The 0x40 part is only correct for limits less than 64KB (and even then I think it needs to be 0x41). For larger segments, you need to make it page-granular, so 0xc1 is the value in those cases. > ds_data[7] = 0x00; This is only right for addresses in the first 16MB range. Why the limitation?