⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 limit64.htm

📁 对于学习很有帮助
💻 HTM
字号:
<!-- This document was created with HomeSite v2.5 -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">

<HTML>
<HEAD>
	<TITLE>UDDF - 64K Limit</TITLE>
</HEAD>

<BODY>
<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#ffffff">

<IMG SRC="../images/uddf.jpg">
<P><HR></P>
<FONT FACE="Arial Black" SIZE=7 COLOR="#ff0000">
64K Datasegment Limit
</FONT>
<i>hartnegg@sun2.ruf.uni-freiburg.de (Klaus Hartnegg)</i><P>

<ul>
<li>Q: Can a Borland Pascal program use static variables 
>   with more than 64 kilobytes?
<li>A: No!
<li>Q: You said *static* variables. Are there other and does it work with them?
<li>A: Yes, see "Is there a Solution" below, but first read the rest here 
   to avoid wasting time trying other alternatives, because they
   all do not work.
<li>Q: Does it help to split a large array in several small arrays
   (all parts smaller than 64k, but in total larger than 64k) ?
<li>A: No!
<li>Q: Does it help to declare some of the variables in a Unit?
<li>A: No!
<li>Q: Does it help to declare some in the Implementation Part of a unit?
<li>A: No!
<li>Q: Does it help to use the protected mode of Borland Pascal 7 ?
<li>A: No!
<li>Q: Are you sure ??
<li>A: Yes !!
<li>Q: Why ??
<li>A: All programs written in Borland Pascal use only one segment for all
   variables and the Intel 80xxx processors are limited to 64k per segment.
<li>Q: That's silly!!
<li>A: Tell Borland!! (Or Intel or both).
<li>Q: Is there a Solution ?
<li>A: Yes! There are two solutions: <p>
   1) don't use *STATIC* variables for storing huge amounts of data.
      This will allow to store more than 64k in total, but never 
      more than 64k in *one* array, so yes you must split them but
      that alone doesn't help. You must also make them dynamic. <p>
   2) use another Compiler: there are a few Pascal compilers
      available that are more or less Borland compatible and that
      don't have these limitations (they are 32-bit Compilers).<p>
<li>Q: Why is Borland Pascal not a 32-bit Compiler?
<li>A: It's too old. Tell Borland you want a new version.
<li>Q: What is non-static memory?
<li>A: For example Heap, XMS, EMS, ...
   Heap is directly accessible, XMS needs a driver (himem.sys), 
   EMS too (HIMEM.SYS + EMM386.EXE) and is not commonly available 
   on all computers, so better use XMS instead of EMS.
<li>Q: What is the Heap ?
<li>A: Heap is in real mode all free memory below the 640 kilobyte limit,
   in protected mode (available in Borland Pascal 7 only) all free
   memory below the 16 Megabyte limit (and usually *ALL* free memory 
  but we're only talking about Borland Pascal here).
<li>Q: How can I use the heap?
<li>A: Memory on the heap can only be accessed with pointers.
   Try this example, then adapt the principle to your programs:
<hr><pre>   type 
      arr    = array [1..30000] of longint; { this is your data }
      arrptr = ^arr;                        { that's a pointer to the data }
   var
      data : arrptr;       { this is such a pointer variable }
   begin
      if memavail &lt; sizeof(arr) then halt; { check if enough memory available}
      new (data);                          { allocate the memory }
      for i := 1 to 30000 do data^[i]:=0;  { use it, note the ^ sign here !! }
      dispose (data);                      { release the memory }
   end.
  Note: instead of data you could also do
   var
    data : array [1..10000] of arrptr;</pre><hr>
<li>Q: Does this have disadvantages
<li>A: Yes! It's slower and a bit dangerous.
<li>Q: Using the heap is dangerous?
<li>A: Yes!<p>
   Double-check that you *always*, I mean really *ALWAYS* allocate
   all heap memory before you use it. Otherwise you will see the same
   thing happening that we are used to from C programs:
   in Windows it's called "General Protection Violation", other
   systems call it "Protected Mode Exception #13" or similar.
   In real mode the program will usually not cause such an error,
   it will just silently overwrite imporant things like other data, the
   program itself, other programs, DOS or whatever it finds in memory.<br>
  This can cause anything from no negative effect at all to completely
   freezing the PC with only the reset button and power switch still
   operational. In extreme cases it may also cause data on the hard
   disk to be overwritten. That's very unlike攍y but in theory possible.
<li>Q: How can I use XMS memory?
<li>A: See http://www.brain.uni-freiburg.de/~klaus/pascal/sources/
   for a unit that allows to use XMS.
<li>Q: What about other Pascal compilers?
<li>A: Check FPK-Pascal and GNU-Pascal.
   Both are free 32-bit Pascal compilers available for DOS 
   that are more or less Borland compatible.
   If you want a Pascal compiler for Linux or OS/2, the two same compilers 
   are available for these operating systems too plus a few more, see 
   <a href="http://www.brain.uni-freiburg.de/~klaus/pascal/web-list.html">http://www.brain.uni-freiburg.de/~klaus/pascal/web-list.html</a>
<li>Q: This sounds as if the FAQ writer doesn't like Borland Pascal, right?
<li>A: Wrong, I *love* it and use it all the time,
  but I *hate* Borland for not offering new versions.
<li>Q: What about Delphi?
<li>A: It's not available for DOS,<br>
   it's not available for Linux,<br>
   it's not availalbe for OS/2.<br>
</ul>

<HR SIZE="6" COLOR="LIME">
<FONT SIZE="2">
<a href="mailto:rdb@ktibv">Please email me</a> and tell me if you liked this page.<BR>
<SCRIPT LANGUAGE="JavaScript">
<!--
	document.write("Last modified " + document.lastModified);
// -->
</SCRIPT><P>
<TABLE BORDER=0 ALIGN="CENTER">
<TR>
	<TD>This page has been created with </TD>
	<TD> <A HREF="http://www.dexnet.com./homesite.html"><IMG SRC="../images/hs25ani.gif" WIDTH=88 HEIGHT=31 BORDER=0 ALT="HomeSite 2.5b">
</A></TD>
</TR>
</TABLE>

</FONT>


</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -