4 ; Flexible memory handling
6 ; © 1994-1998 Straylight
9 ;----- Licensing note -------------------------------------------------------
11 ; This file is part of Straylight's Flex.
13 ; Flex is free software; you can redistribute it and/or modify
14 ; it under the terms of the GNU General Public License as published by
15 ; the Free Software Foundation; either version 2, or (at your option)
18 ; Flex is distributed in the hope that it will be useful,
19 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ; GNU General Public License for more details.
23 ; You should have received a copy of the GNU General Public License
24 ; along with Flex. If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ;----- Overview -------------------------------------------------------------
48 ;+ LIB sapphire:^.bsh.flex
56 ; Use: Compacts the flex heap by one iteration.
60 ; --- flex_compact ---
66 ; Use: Completely compacts the flex heap.
72 ; On entry: R0 == pointer to the flex anchor
76 ; Use: Frees a flex block allocated by flex_alloc.
82 ; On entry: R0 == pointer to a flex anchor
83 ; R1 == desired size of flex block
85 ; On exit: CS if no memory could be allocated, CC otherwise
87 ; Use: Allocates a block in the shifting heap.
93 ; On entry: R0 == pointer to flex anchor
95 ; On exit: R0 == size of allocated block
97 ; Use: Reads the size of a flex block.
101 ; --- flex_extend ---
103 ; On entry: R0 == pointer to flex anchor
104 ; R1 == new size of block to set
106 ; On exit: CS if it failed due to lack of memory, CC otherwise
108 ; Use: Alters the size of a block to the given value.
112 ; --- flex_midExtend ---
114 ; On entry: R0 == pointer to a flex anchor
115 ; R1 == `at' -- position in block to extend from
116 ; R2 == `by' -- how many bytes to extend (may be -ve)
118 ; On exit: CS if it failed due to lack of memory, CC otherwise
120 ; Use: Either creates a gap in a block (by>0) or deletes bytes
121 ; from a block. This is always done in such a way that the
122 ; byte originally at offset `at' is now at offset `at'+`by'.
124 IMPORT flex_midExtend
132 ; Use: Initialises the flex heap for use.
142 ; Use: Saves some registers on the flex relocation stack. R13
143 ; and R14 cannot be saved -- these registers are corrupted
144 ; during this routine's execution.
146 ; Values saved on the flex relocation stack are adjusted as
147 ; flex moves blocks of memory around, so that they still point
148 ; to the same thing as they did before. Obviously, values
149 ; which aren't pointers into flex blocks may be corrupted.
150 ; Values pointing to objects deleted (either free blocks, or
151 ; areas removed by flex_midExtend) may also be corrupted.
153 ; Since this routine takes no arguments, some other method has
154 ; to be used. The method chosen is to follow the call to
155 ; flex_save with a LDM or STM instruction containing the
156 ; registers to be saved. This instruction is skipped by the
157 ; routine, and thus not executed.
159 ; Note that if you give the LDM or STM the same condition code
160 ; as the BL preceding it, it will never be executed, since
161 ; flex_save skips it if the condition is true and it can't be
162 ; executed if the condition is false.
172 ; On exit: Registers loaded from relocation stack as requested
174 ; Use: Restores registers saved on flex's relocation stack. See
175 ; flex_save for calling information and details about the
182 ;----- Useful macros --------------------------------------------------------
184 ; --- Macro: FSAVE ---
186 ; Arguments: rList == quoted register list to save on relocation stack
188 ; Use: Assembles code to write the given register list on the
189 ; flex relocation stack. The register list should be in the
190 ; same form as that for an STM or LDM instruction.
192 ; For full details about the flex relocation stack, see
207 ; --- Macro: FLOAD ---
209 ; Arguments: rList == quoted register list to read from relocation stack
211 ; Use: Assembles code to read the given register list from the
212 ; flex relocation stack. The register list should be in the
213 ; same form as that for an STM or LDM instruction.
215 ; For full details about the flex relocation stack, see
230 ;----- That's all, folks ----------------------------------------------------