; Copyright 1998 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.
;
; File:    toolboxmem.s
; Purpose: veneers onto Toolbox memory allocation SWIs
; Author:  Kevin Bracey
; History: 22-Nov-96: KJB:   created

XToolbox_Memory * &64EF9

	AREA	|ToolboxMemCode|,CODE,READONLY,PIC

	EXPORT	toolbox_memory_alloc
	EXPORT	toolbox_memory_free
	EXPORT	toolbox_memory_extend

        MACRO
        MOVRet  $cond
        [ {CONFIG}=26
        MOV$cond.S    pc,r12
        |
        MOV$cond      pc,r12
        ]
        MEND

toolbox_memory_alloc
	MOV	R12,LR
	MOV	R1,R0
	MOV	R0,#0
	SWI	XToolbox_Memory
	MOVVS	R0,#0
        MOVRet

toolbox_memory_free
	MOV	R12,LR
	MOV	R1,R0
	MOV	R0,#1
	SWI	XToolbox_Memory
        MOVRet

toolbox_memory_extend
	MOV	R12,LR
	MOV	R2,R1
	MOV	R1,R0
	MOV	R0,#2
	SWI	XToolbox_Memory
	MOVVS	R0,#0
        MOVRet

	END