; Copyright 1996 Acorn Computers Ltd ; ; Licensed under the Apache License, Version 2.0 (the "License"); ; you may not use this file except in compliance with the License. ; You may obtain a copy of the License at ; ; http://www.apache.org/licenses/LICENSE-2.0 ; ; Unless required by applicable law or agreed to in writing, software ; distributed under the License is distributed on an "AS IS" BASIS, ; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ; See the License for the specific language governing permissions and ; limitations under the License. ; ; > s.Memory ; lifted from Wimp source (v3.67) ; this OS_Module equivalent looks at ptr-4 which the Heap Manager uses ; to store the real size of the block. In this way the memory use is ; more efficient (especially when extending a block) and RMA should ; fragment less often. XROS_Module ENTRY TEQ R0,#6 TEQNE R0,#7 TEQNE R0,#13 SWINE XOS_Module EXIT NE TEQ R0,#6 BEQ ros_claim TEQ R0,#7 BEQ ros_free ; extend Push "R3-R5" LDR R4,[R2,#-8] LDR R5,[R2,#-4]! ADD R5,R5,R3 ; R5 is proposed new size SUB R4,R4,#4 CMP R4,R5 CMPGE R3,#0 BLT %FT02 STR R5,[R2],#4 ; enough space so just store Pull "R3-R5" ; can never error EXITS 02 SUB R3,R5,R4 SWI XOS_Module STRVC R5,[R2],#4 Pull "R3-R5" EXITS VC EXIT ros_free SUB R2,R2,#4 SWI XOS_Module EXITS VC EXIT ros_claim ADD R3,R3,#4 SWI XOS_Module STRVC R3,[R2],#4 ; so modptr-4 = amount asked for + 4 SUB R3,R3,#4 ; needs to be preserved EXITS VC EXIT END