Home » Personal collection » Acorn hard disk » unzip_tools » !Infozip » SHeap/ReadMe

SHeap/ReadMe

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Personal collection » Acorn hard disk » unzip_tools » !Infozip
Filename: SHeap/ReadMe
Read OK:
File size: 0A88 bytes
Load address: 0000
Exec address: 0000
File contents
The Sliding Heap module is � Steven Haslam 1992 and is distributed under the GNU Public Licence.   You will need the procedures in the SHeap BASIC library, or similar, to use it.

It creates and manages a sliding heap of blocks of memory, claimed from a program's Wimpslot as necessary, thus avoiding the fragmentation caused by repeatedly claiming and releasing memory from the RMA.
The module works under RISC OS 2 and RISC OS 3�1, and is compatible with RISC OS 3�5 and greater, and StrongARM, although dynamic areas can be used to perform the same task on such systems.

This new release of SlidingHeap (version 2.11) has been reconstructed from a disassembly, in the absence of the original source code. The module should work in 32-bit ARM modes, and therefore has been flagged as compatible with RISC OS 5.  For further information contact chrisbazley@bigfoot.com.

17th January 2003

Changes to the accompanying BASIC library
-----------------------------------------
�  A new function has been added to the BASIC library - FNsliding_block_size(anchor%), which returns the current size of the specified block.
� Two new procedures have been added - PROCverify_heap, which enables the programmer to force a explicit check for corruption of the sliding heap at any point in his code, and PROCincreaseslots, which allows the programmer to increase the number of available slots in the heap, or to read its current setting.
�  PROCheapsinfo now takes a parameter - PROCheapsinfo(address%), where address% points to a buffer of length 256 bytes.   As a consequence, the library no longer relies on the (undocumented) existence of a block with a certain given name!
�  Variables have been made LOCAL wherever possible, and global variables use the prefix 'sh_', e.g. 'sh_heap_trigger%'.
�  PROCdestroyheaps now ensures that all anchors in use are reset to zero before the heap is destroyed, making it 'safe' to reuse them after a subsequent PROCinitheaps.

Module history
--------------
Version 2.01
� Most SWIs no longer corrupt R0.
� SWIs now *do* preserve flags in 26-bit mode (although not in new 32-bit mode) - which they never did before!
� A few optimisations, i.e. SUBS R1,R1,#1:BNE in place of SUB R1,R1,#1:CMP R1,#0:BNE

Version 2.10 (18 Nov 2002)
� Numbers of heap slots available/used are now reported via OS_ConvertCardinal (e.g. "2048") rather than OS_ConvertSpacedCardinal (e.g. "2 048"), as the leading digit proved too easily overlooked.
� New SWI added - SlidingHeap_IncreaseSlots.   This allows programs to use a indeterminate number of blocks, without having to set an upper limit at the time of initialisation.

Version 2.11 (16 Dec 2002)
�  A few more SUBS optimisations.
00000000  54 68 65 20 53 6c 69 64  69 6e 67 20 48 65 61 70  |The Sliding Heap|
00000010  20 6d 6f 64 75 6c 65 20  69 73 20 a9 20 53 74 65  | module is . Ste|
00000020  76 65 6e 20 48 61 73 6c  61 6d 20 31 39 39 32 20  |ven Haslam 1992 |
00000030  61 6e 64 20 69 73 20 64  69 73 74 72 69 62 75 74  |and is distribut|
00000040  65 64 20 75 6e 64 65 72  20 74 68 65 20 47 4e 55  |ed under the GNU|
00000050  20 50 75 62 6c 69 63 20  4c 69 63 65 6e 63 65 2e  | Public Licence.|
00000060  20 20 20 59 6f 75 20 77  69 6c 6c 20 6e 65 65 64  |   You will need|
00000070  20 74 68 65 20 70 72 6f  63 65 64 75 72 65 73 20  | the procedures |
00000080  69 6e 20 74 68 65 20 53  48 65 61 70 20 42 41 53  |in the SHeap BAS|
00000090  49 43 20 6c 69 62 72 61  72 79 2c 20 6f 72 20 73  |IC library, or s|
000000a0  69 6d 69 6c 61 72 2c 20  74 6f 20 75 73 65 20 69  |imilar, to use i|
000000b0  74 2e 0a 0a 49 74 20 63  72 65 61 74 65 73 20 61  |t...It creates a|
000000c0  6e 64 20 6d 61 6e 61 67  65 73 20 61 20 73 6c 69  |nd manages a sli|
000000d0  64 69 6e 67 20 68 65 61  70 20 6f 66 20 62 6c 6f  |ding heap of blo|
000000e0  63 6b 73 20 6f 66 20 6d  65 6d 6f 72 79 2c 20 63  |cks of memory, c|
000000f0  6c 61 69 6d 65 64 20 66  72 6f 6d 20 61 20 70 72  |laimed from a pr|
00000100  6f 67 72 61 6d 27 73 20  57 69 6d 70 73 6c 6f 74  |ogram's Wimpslot|
00000110  20 61 73 20 6e 65 63 65  73 73 61 72 79 2c 20 74  | as necessary, t|
00000120  68 75 73 20 61 76 6f 69  64 69 6e 67 20 74 68 65  |hus avoiding the|
00000130  20 66 72 61 67 6d 65 6e  74 61 74 69 6f 6e 20 63  | fragmentation c|
00000140  61 75 73 65 64 20 62 79  20 72 65 70 65 61 74 65  |aused by repeate|
00000150  64 6c 79 20 63 6c 61 69  6d 69 6e 67 20 61 6e 64  |dly claiming and|
00000160  20 72 65 6c 65 61 73 69  6e 67 20 6d 65 6d 6f 72  | releasing memor|
00000170  79 20 66 72 6f 6d 20 74  68 65 20 52 4d 41 2e 0a  |y from the RMA..|
00000180  54 68 65 20 6d 6f 64 75  6c 65 20 77 6f 72 6b 73  |The module works|
00000190  20 75 6e 64 65 72 20 52  49 53 43 20 4f 53 20 32  | under RISC OS 2|
000001a0  20 61 6e 64 20 52 49 53  43 20 4f 53 20 33 b7 31  | and RISC OS 3.1|
000001b0  2c 20 61 6e 64 20 69 73  20 63 6f 6d 70 61 74 69  |, and is compati|
000001c0  62 6c 65 20 77 69 74 68  20 52 49 53 43 20 4f 53  |ble with RISC OS|
000001d0  20 33 b7 35 20 61 6e 64  20 67 72 65 61 74 65 72  | 3.5 and greater|
000001e0  2c 20 61 6e 64 20 53 74  72 6f 6e 67 41 52 4d 2c  |, and StrongARM,|
000001f0  20 61 6c 74 68 6f 75 67  68 20 64 79 6e 61 6d 69  | although dynami|
00000200  63 20 61 72 65 61 73 20  63 61 6e 20 62 65 20 75  |c areas can be u|
00000210  73 65 64 20 74 6f 20 70  65 72 66 6f 72 6d 20 74  |sed to perform t|
00000220  68 65 20 73 61 6d 65 20  74 61 73 6b 20 6f 6e 20  |he same task on |
00000230  73 75 63 68 20 73 79 73  74 65 6d 73 2e 0a 0a 54  |such systems...T|
00000240  68 69 73 20 6e 65 77 20  72 65 6c 65 61 73 65 20  |his new release |
00000250  6f 66 20 53 6c 69 64 69  6e 67 48 65 61 70 20 28  |of SlidingHeap (|
00000260  76 65 72 73 69 6f 6e 20  32 2e 31 31 29 20 68 61  |version 2.11) ha|
00000270  73 20 62 65 65 6e 20 72  65 63 6f 6e 73 74 72 75  |s been reconstru|
00000280  63 74 65 64 20 66 72 6f  6d 20 61 20 64 69 73 61  |cted from a disa|
00000290  73 73 65 6d 62 6c 79 2c  20 69 6e 20 74 68 65 20  |ssembly, in the |
000002a0  61 62 73 65 6e 63 65 20  6f 66 20 74 68 65 20 6f  |absence of the o|
000002b0  72 69 67 69 6e 61 6c 20  73 6f 75 72 63 65 20 63  |riginal source c|
000002c0  6f 64 65 2e 20 54 68 65  20 6d 6f 64 75 6c 65 20  |ode. The module |
000002d0  73 68 6f 75 6c 64 20 77  6f 72 6b 20 69 6e 20 33  |should work in 3|
000002e0  32 2d 62 69 74 20 41 52  4d 20 6d 6f 64 65 73 2c  |2-bit ARM modes,|
000002f0  20 61 6e 64 20 74 68 65  72 65 66 6f 72 65 20 68  | and therefore h|
00000300  61 73 20 62 65 65 6e 20  66 6c 61 67 67 65 64 20  |as been flagged |
00000310  61 73 20 63 6f 6d 70 61  74 69 62 6c 65 20 77 69  |as compatible wi|
00000320  74 68 20 52 49 53 43 20  4f 53 20 35 2e 20 20 46  |th RISC OS 5.  F|
00000330  6f 72 20 66 75 72 74 68  65 72 20 69 6e 66 6f 72  |or further infor|
00000340  6d 61 74 69 6f 6e 20 63  6f 6e 74 61 63 74 20 63  |mation contact c|
00000350  68 72 69 73 62 61 7a 6c  65 79 40 62 69 67 66 6f  |hrisbazley@bigfo|
00000360  6f 74 2e 63 6f 6d 2e 0a  0a 31 37 74 68 20 4a 61  |ot.com...17th Ja|
00000370  6e 75 61 72 79 20 32 30  30 33 0a 0a 43 68 61 6e  |nuary 2003..Chan|
00000380  67 65 73 20 74 6f 20 74  68 65 20 61 63 63 6f 6d  |ges to the accom|
00000390  70 61 6e 79 69 6e 67 20  42 41 53 49 43 20 6c 69  |panying BASIC li|
000003a0  62 72 61 72 79 0a 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |brary.----------|
000003b0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
000003c0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 0a  |---------------.|
000003d0  8f 20 20 41 20 6e 65 77  20 66 75 6e 63 74 69 6f  |.  A new functio|
000003e0  6e 20 68 61 73 20 62 65  65 6e 20 61 64 64 65 64  |n has been added|
000003f0  20 74 6f 20 74 68 65 20  42 41 53 49 43 20 6c 69  | to the BASIC li|
00000400  62 72 61 72 79 20 2d 20  46 4e 73 6c 69 64 69 6e  |brary - FNslidin|
00000410  67 5f 62 6c 6f 63 6b 5f  73 69 7a 65 28 61 6e 63  |g_block_size(anc|
00000420  68 6f 72 25 29 2c 20 77  68 69 63 68 20 72 65 74  |hor%), which ret|
00000430  75 72 6e 73 20 74 68 65  20 63 75 72 72 65 6e 74  |urns the current|
00000440  20 73 69 7a 65 20 6f 66  20 74 68 65 20 73 70 65  | size of the spe|
00000450  63 69 66 69 65 64 20 62  6c 6f 63 6b 2e 0a 8f 20  |cified block... |
00000460  54 77 6f 20 6e 65 77 20  70 72 6f 63 65 64 75 72  |Two new procedur|
00000470  65 73 20 68 61 76 65 20  62 65 65 6e 20 61 64 64  |es have been add|
00000480  65 64 20 2d 20 50 52 4f  43 76 65 72 69 66 79 5f  |ed - PROCverify_|
00000490  68 65 61 70 2c 20 77 68  69 63 68 20 65 6e 61 62  |heap, which enab|
000004a0  6c 65 73 20 74 68 65 20  70 72 6f 67 72 61 6d 6d  |les the programm|
000004b0  65 72 20 74 6f 20 66 6f  72 63 65 20 61 20 65 78  |er to force a ex|
000004c0  70 6c 69 63 69 74 20 63  68 65 63 6b 20 66 6f 72  |plicit check for|
000004d0  20 63 6f 72 72 75 70 74  69 6f 6e 20 6f 66 20 74  | corruption of t|
000004e0  68 65 20 73 6c 69 64 69  6e 67 20 68 65 61 70 20  |he sliding heap |
000004f0  61 74 20 61 6e 79 20 70  6f 69 6e 74 20 69 6e 20  |at any point in |
00000500  68 69 73 20 63 6f 64 65  2c 20 61 6e 64 20 50 52  |his code, and PR|
00000510  4f 43 69 6e 63 72 65 61  73 65 73 6c 6f 74 73 2c  |OCincreaseslots,|
00000520  20 77 68 69 63 68 20 61  6c 6c 6f 77 73 20 74 68  | which allows th|
00000530  65 20 70 72 6f 67 72 61  6d 6d 65 72 20 74 6f 20  |e programmer to |
00000540  69 6e 63 72 65 61 73 65  20 74 68 65 20 6e 75 6d  |increase the num|
00000550  62 65 72 20 6f 66 20 61  76 61 69 6c 61 62 6c 65  |ber of available|
00000560  20 73 6c 6f 74 73 20 69  6e 20 74 68 65 20 68 65  | slots in the he|
00000570  61 70 2c 20 6f 72 20 74  6f 20 72 65 61 64 20 69  |ap, or to read i|
00000580  74 73 20 63 75 72 72 65  6e 74 20 73 65 74 74 69  |ts current setti|
00000590  6e 67 2e 0a 8f 20 20 50  52 4f 43 68 65 61 70 73  |ng...  PROCheaps|
000005a0  69 6e 66 6f 20 6e 6f 77  20 74 61 6b 65 73 20 61  |info now takes a|
000005b0  20 70 61 72 61 6d 65 74  65 72 20 2d 20 50 52 4f  | parameter - PRO|
000005c0  43 68 65 61 70 73 69 6e  66 6f 28 61 64 64 72 65  |Cheapsinfo(addre|
000005d0  73 73 25 29 2c 20 77 68  65 72 65 20 61 64 64 72  |ss%), where addr|
000005e0  65 73 73 25 20 70 6f 69  6e 74 73 20 74 6f 20 61  |ess% points to a|
000005f0  20 62 75 66 66 65 72 20  6f 66 20 6c 65 6e 67 74  | buffer of lengt|
00000600  68 20 32 35 36 20 62 79  74 65 73 2e 20 20 20 41  |h 256 bytes.   A|
00000610  73 20 61 20 63 6f 6e 73  65 71 75 65 6e 63 65 2c  |s a consequence,|
00000620  20 74 68 65 20 6c 69 62  72 61 72 79 20 6e 6f 20  | the library no |
00000630  6c 6f 6e 67 65 72 20 72  65 6c 69 65 73 20 6f 6e  |longer relies on|
00000640  20 74 68 65 20 28 75 6e  64 6f 63 75 6d 65 6e 74  | the (undocument|
00000650  65 64 29 20 65 78 69 73  74 65 6e 63 65 20 6f 66  |ed) existence of|
00000660  20 61 20 62 6c 6f 63 6b  20 77 69 74 68 20 61 20  | a block with a |
00000670  63 65 72 74 61 69 6e 20  67 69 76 65 6e 20 6e 61  |certain given na|
00000680  6d 65 21 0a 8f 20 20 56  61 72 69 61 62 6c 65 73  |me!..  Variables|
00000690  20 68 61 76 65 20 62 65  65 6e 20 6d 61 64 65 20  | have been made |
000006a0  4c 4f 43 41 4c 20 77 68  65 72 65 76 65 72 20 70  |LOCAL wherever p|
000006b0  6f 73 73 69 62 6c 65 2c  20 61 6e 64 20 67 6c 6f  |ossible, and glo|
000006c0  62 61 6c 20 76 61 72 69  61 62 6c 65 73 20 75 73  |bal variables us|
000006d0  65 20 74 68 65 20 70 72  65 66 69 78 20 27 73 68  |e the prefix 'sh|
000006e0  5f 27 2c 20 65 2e 67 2e  20 27 73 68 5f 68 65 61  |_', e.g. 'sh_hea|
000006f0  70 5f 74 72 69 67 67 65  72 25 27 2e 0a 8f 20 20  |p_trigger%'...  |
00000700  50 52 4f 43 64 65 73 74  72 6f 79 68 65 61 70 73  |PROCdestroyheaps|
00000710  20 6e 6f 77 20 65 6e 73  75 72 65 73 20 74 68 61  | now ensures tha|
00000720  74 20 61 6c 6c 20 61 6e  63 68 6f 72 73 20 69 6e  |t all anchors in|
00000730  20 75 73 65 20 61 72 65  20 72 65 73 65 74 20 74  | use are reset t|
00000740  6f 20 7a 65 72 6f 20 62  65 66 6f 72 65 20 74 68  |o zero before th|
00000750  65 20 68 65 61 70 20 69  73 20 64 65 73 74 72 6f  |e heap is destro|
00000760  79 65 64 2c 20 6d 61 6b  69 6e 67 20 69 74 20 27  |yed, making it '|
00000770  73 61 66 65 27 20 74 6f  20 72 65 75 73 65 20 74  |safe' to reuse t|
00000780  68 65 6d 20 61 66 74 65  72 20 61 20 73 75 62 73  |hem after a subs|
00000790  65 71 75 65 6e 74 20 50  52 4f 43 69 6e 69 74 68  |equent PROCinith|
000007a0  65 61 70 73 2e 0a 0a 4d  6f 64 75 6c 65 20 68 69  |eaps...Module hi|
000007b0  73 74 6f 72 79 0a 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |story.----------|
000007c0  2d 2d 2d 2d 0a 56 65 72  73 69 6f 6e 20 32 2e 30  |----.Version 2.0|
000007d0  31 0a 8f 20 4d 6f 73 74  20 53 57 49 73 20 6e 6f  |1.. Most SWIs no|
000007e0  20 6c 6f 6e 67 65 72 20  63 6f 72 72 75 70 74 20  | longer corrupt |
000007f0  52 30 2e 0a 8f 20 53 57  49 73 20 6e 6f 77 20 2a  |R0... SWIs now *|
00000800  64 6f 2a 20 70 72 65 73  65 72 76 65 20 66 6c 61  |do* preserve fla|
00000810  67 73 20 69 6e 20 32 36  2d 62 69 74 20 6d 6f 64  |gs in 26-bit mod|
00000820  65 20 28 61 6c 74 68 6f  75 67 68 20 6e 6f 74 20  |e (although not |
00000830  69 6e 20 6e 65 77 20 33  32 2d 62 69 74 20 6d 6f  |in new 32-bit mo|
00000840  64 65 29 20 2d 20 77 68  69 63 68 20 74 68 65 79  |de) - which they|
00000850  20 6e 65 76 65 72 20 64  69 64 20 62 65 66 6f 72  | never did befor|
00000860  65 21 0a 8f 20 41 20 66  65 77 20 6f 70 74 69 6d  |e!.. A few optim|
00000870  69 73 61 74 69 6f 6e 73  2c 20 69 2e 65 2e 20 53  |isations, i.e. S|
00000880  55 42 53 20 52 31 2c 52  31 2c 23 31 3a 42 4e 45  |UBS R1,R1,#1:BNE|
00000890  20 69 6e 20 70 6c 61 63  65 20 6f 66 20 53 55 42  | in place of SUB|
000008a0  20 52 31 2c 52 31 2c 23  31 3a 43 4d 50 20 52 31  | R1,R1,#1:CMP R1|
000008b0  2c 23 30 3a 42 4e 45 0a  0a 56 65 72 73 69 6f 6e  |,#0:BNE..Version|
000008c0  20 32 2e 31 30 20 28 31  38 20 4e 6f 76 20 32 30  | 2.10 (18 Nov 20|
000008d0  30 32 29 0a 8f 20 4e 75  6d 62 65 72 73 20 6f 66  |02).. Numbers of|
000008e0  20 68 65 61 70 20 73 6c  6f 74 73 20 61 76 61 69  | heap slots avai|
000008f0  6c 61 62 6c 65 2f 75 73  65 64 20 61 72 65 20 6e  |lable/used are n|
00000900  6f 77 20 72 65 70 6f 72  74 65 64 20 76 69 61 20  |ow reported via |
00000910  4f 53 5f 43 6f 6e 76 65  72 74 43 61 72 64 69 6e  |OS_ConvertCardin|
00000920  61 6c 20 28 65 2e 67 2e  20 22 32 30 34 38 22 29  |al (e.g. "2048")|
00000930  20 72 61 74 68 65 72 20  74 68 61 6e 20 4f 53 5f  | rather than OS_|
00000940  43 6f 6e 76 65 72 74 53  70 61 63 65 64 43 61 72  |ConvertSpacedCar|
00000950  64 69 6e 61 6c 20 28 65  2e 67 2e 20 22 32 20 30  |dinal (e.g. "2 0|
00000960  34 38 22 29 2c 20 61 73  20 74 68 65 20 6c 65 61  |48"), as the lea|
00000970  64 69 6e 67 20 64 69 67  69 74 20 70 72 6f 76 65  |ding digit prove|
00000980  64 20 74 6f 6f 20 65 61  73 69 6c 79 20 6f 76 65  |d too easily ove|
00000990  72 6c 6f 6f 6b 65 64 2e  0a 8f 20 4e 65 77 20 53  |rlooked... New S|
000009a0  57 49 20 61 64 64 65 64  20 2d 20 53 6c 69 64 69  |WI added - Slidi|
000009b0  6e 67 48 65 61 70 5f 49  6e 63 72 65 61 73 65 53  |ngHeap_IncreaseS|
000009c0  6c 6f 74 73 2e 20 20 20  54 68 69 73 20 61 6c 6c  |lots.   This all|
000009d0  6f 77 73 20 70 72 6f 67  72 61 6d 73 20 74 6f 20  |ows programs to |
000009e0  75 73 65 20 61 20 69 6e  64 65 74 65 72 6d 69 6e  |use a indetermin|
000009f0  61 74 65 20 6e 75 6d 62  65 72 20 6f 66 20 62 6c  |ate number of bl|
00000a00  6f 63 6b 73 2c 20 77 69  74 68 6f 75 74 20 68 61  |ocks, without ha|
00000a10  76 69 6e 67 20 74 6f 20  73 65 74 20 61 6e 20 75  |ving to set an u|
00000a20  70 70 65 72 20 6c 69 6d  69 74 20 61 74 20 74 68  |pper limit at th|
00000a30  65 20 74 69 6d 65 20 6f  66 20 69 6e 69 74 69 61  |e time of initia|
00000a40  6c 69 73 61 74 69 6f 6e  2e 0a 0a 56 65 72 73 69  |lisation...Versi|
00000a50  6f 6e 20 32 2e 31 31 20  28 31 36 20 44 65 63 20  |on 2.11 (16 Dec |
00000a60  32 30 30 32 29 0a 8f 20  20 41 20 66 65 77 20 6d  |2002)..  A few m|
00000a70  6f 72 65 20 53 55 42 53  20 6f 70 74 69 6d 69 73  |ore SUBS optimis|
00000a80  61 74 69 6f 6e 73 2e 0a                           |ations..|
00000a88