From: "A. Sinan Unur" Newsgroups: comp.os.msdos.djgpp Subject: Re: (new question) problem with memory allocation Date: Thu, 08 Jan 1998 22:40:39 -0500 Organization: Cornell University (http://www.cornell.edu/) Lines: 41 Sender: asu1 AT cornell DOT edu (Verified) Message-ID: <34B59C37.CF822FE3@cornell.edu> References: <199801090150 DOT RAA16234 AT adit DOT ap DOT net> <34B58A15 DOT B86CC43B AT xmission DOT com> NNTP-Posting-Host: cu-dialup-0006.cit.cornell.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk David Eberhard wrote: > > Thanks for all the help. It solved my problem, but now I have > another. Here's the code: > > video_selector = __dpmi_allocate_ldt_descriptors(1); > __dpmi_set_segment_base_address(video_selector, linear_address); > //Set limit to around 2 Meg > __dpmi_set_segment_limit(video_selector, 2000000UL); > > Here I am setting up a selector so I can access the linear buffer of > my video card. I wanted to set the segment limit to around 2 meg, but > it crashes my program and gives about the same error that I got with > my last problem. It crashes when I try to write to video memory using > the selector I made above. If I trim down 2000000 to 200000, then my > program works fine. Anyone know why? i think the answer might lie in the following remark in the DPMI spec (i am no expert on this though): INT 0x31 Function 0x0008 Set Segment Limit * Segment limits greater than or equal to 1MB must be page aligned. That is, limits greater than 1MB must have the low 12 bits set also, note that "the value supplied to the function (in CX:DX) is the byte length of the segment-1. so, for 2MB, passing 2048*1024-1 should work, i guess. by the way, do check the return values of such calls. -- ---------------------------------------------------------------------- A. Sinan Unur Department of Policy Analysis and Management, College of Human Ecology, Cornell University, Ithaca, NY 14853, USA mailto:sinan DOT unur AT cornell DOT edu http://www.people.cornell.edu/pages/asu1/