
482
Evaluating and Programming the 29K RISC Family
Service 258 – sysfree
Free Memory Space
Description
This service returns memory to the system starting at the address specified in
lr2
. Register
lr3
contains the number of bytes to be released. The pointer passed to the
sysfree
service in
lr2
and the byte count passed in
lr3
must match the address re-
turned by a previous
sysalloc
service request for the identical number of bytes. No
dynamic memory allocation structure is implied by this service. High-level language
library functions such as
malloc()
and
free()
for the C language are required to man-
age random dynamic memory block allocation and deallocation, using the
sysalloc
and
sysfree
kernel functions as their basis.
Register Usage
Type
Regs
Contents
Description
Calling:
gr121
lr2
lr3
258 (0x102)
addrptr
nbytes
Service number
Starting address of area returned
Number of bytes to release
Returns:
gr96
retval
Success: = 0
Failure:
Logical TRUE, service successful
Error number, service not successful
(implementation dependent)
<
0
gr121
0x80000000
errcode
Example Call
blkptr:
.word
const
consth
load
const
const
asneq
jmpf
nop
0
gr120,blkptr
gr120,blkptr
0,0,lr2,gr120
lr3,1200
gr121,258
69,gr1,gr1
gr121,free_err
;set address of previously
;block pointer
;fetch pointer to block
;set number of bytes to release
;service = 258
;call the OS
;jump if error
;
The example calls
sysfree
to deallocate 1200 bytes of contiguous memory, be-
ginning at the address stored in the
blkptr
variable. If the call is successful, the pro-
gram continues; otherwise, if the return value in
gr121
is FALSE, the program jumps
to
free_err
to handle the error condition.