User Tools

Site Tools


fitting_20programs_20in_20the_20demo_20version

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
fitting_20programs_20in_20the_20demo_20version [2018/03/31 13:19] – external edit 127.0.0.1fitting_20programs_20in_20the_20demo_20version [2024/01/05 00:22] (current) – external edit 127.0.0.1
Line 4: Line 4:
 ==== Raising HIMEM ==== ==== Raising HIMEM ====
 \\  If your program (plus its heap and stack space) requires more than the 16K available, but it doesn't INSTALL any libraries or CALL any external code modules, then you can raise HIMEM up to a maximum of 24 Kbytes above [[http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin6.html#page|PAGE]]. To ensure compatibility with the full version of BBC BASIC for Windows you should do this only when necessary:\\ \\  \\  If your program (plus its heap and stack space) requires more than the 16K available, but it doesn't INSTALL any libraries or CALL any external code modules, then you can raise HIMEM up to a maximum of 24 Kbytes above [[http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin6.html#page|PAGE]]. To ensure compatibility with the full version of BBC BASIC for Windows you should do this only when necessary:\\ \\ 
 +<code bb4w>
         IF HIMEM<=PAGE+24576 THEN HIMEM=PAGE+24576         IF HIMEM<=PAGE+24576 THEN HIMEM=PAGE+24576
 +</code>
 If you need some space above HIMEM, but less than the 8K provided by default, you can still raise HIMEM but to a lesser extent. For example if you need to INSTALL the **FNUSING** library, which requires less than 2K (including the 256 byte overhead), then you can raise HIMEM as follows:\\ \\  If you need some space above HIMEM, but less than the 8K provided by default, you can still raise HIMEM but to a lesser extent. For example if you need to INSTALL the **FNUSING** library, which requires less than 2K (including the 256 byte overhead), then you can raise HIMEM as follows:\\ \\ 
 +<code bb4w>
         IF HIMEM<=PAGE+24576 THEN HIMEM=PAGE+22528         IF HIMEM<=PAGE+24576 THEN HIMEM=PAGE+22528
         INSTALL @lib$+"FNUSING"         INSTALL @lib$+"FNUSING"
 +</code>
 \\  \\ 
 ==== Allocating memory from Windows ==== ==== Allocating memory from Windows ====
 \\  If your program uses large arrays or blocks of data consider allocating the memory using the Windows API rather than from the heap. For example suppose you need a 10K block of data, which you would normally allocate from the heap as follows:\\ \\  \\  If your program uses large arrays or blocks of data consider allocating the memory using the Windows API rather than from the heap. For example suppose you need a 10K block of data, which you would normally allocate from the heap as follows:\\ \\ 
 +<code bb4w>
         DIM block% 10240-1         DIM block% 10240-1
 +</code>
 If there is insufficient room to do this with the demo version you can alternatively allocate the memory from Windows as follows:\\ \\  If there is insufficient room to do this with the demo version you can alternatively allocate the memory from Windows as follows:\\ \\ 
 +<code bb4w>
         SYS "GlobalAlloc", 64, 10240 TO block%         SYS "GlobalAlloc", 64, 10240 TO block%
 +</code>
 Remember that you must explicitly free memory allocated this way when you have finished with it:\\ \\  Remember that you must explicitly free memory allocated this way when you have finished with it:\\ \\ 
 +<code bb4w>
         SYS "GlobalFree", block%         SYS "GlobalFree", block%
 +</code>
 If you want to declare an array, but there is insufficient room on the heap, you can use the method described in the article [[/Allocating%20arrays%20using%20the%20Windows%20API|Allocating arrays using the Windows API]]. For example suppose you would like to declare an array as follows:\\ \\  If you want to declare an array, but there is insufficient room on the heap, you can use the method described in the article [[/Allocating%20arrays%20using%20the%20Windows%20API|Allocating arrays using the Windows API]]. For example suppose you would like to declare an array as follows:\\ \\ 
 +<code bb4w>
         DIM array%(1000)         DIM array%(1000)
 +</code>
 If there is insufficient room to do this with the demo version you can allocate the memory from Windows as follows:\\ \\  If there is insufficient room to do this with the demo version you can allocate the memory from Windows as follows:\\ \\ 
 +<code bb4w>
         PROCdim1d(array%(), 4, 1000)         PROCdim1d(array%(), 4, 1000)
 +</code>
 \\  \\ 
 ==== Other techniques ==== ==== Other techniques ====
 \\  Using short variable/function names, omitting unnecessary spaces and limiting comments will obviously help a program to fit in a restricted memory space, but are undesirable if the clarity of the program suffers. Using [[http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin5.html#local|LOCAL]] arrays and structures rather than global ones, where possible, will help limit memory usage.\\ \\  You may find it helpful to incorporate the [[/Memory%20usage%20monitor|Memory usage monitor]] to give you an idea of how the memory is being used (if you use the [[/Tools%20and%20Utilities|Add-In Utility]] version it won't use up any more of your precious memory!). \\  Using short variable/function names, omitting unnecessary spaces and limiting comments will obviously help a program to fit in a restricted memory space, but are undesirable if the clarity of the program suffers. Using [[http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin5.html#local|LOCAL]] arrays and structures rather than global ones, where possible, will help limit memory usage.\\ \\  You may find it helpful to incorporate the [[/Memory%20usage%20monitor|Memory usage monitor]] to give you an idea of how the memory is being used (if you use the [[/Tools%20and%20Utilities|Add-In Utility]] version it won't use up any more of your precious memory!).
fitting_20programs_20in_20the_20demo_20version.1522502362.txt.gz · Last modified: 2024/01/05 00:17 (external edit)