.he 'SALLOC (III)'6/15/72'SALLOC (III)'
NAME salloc -- string manipulation routines
SYNOPSIS (get size in r0)
(get source pointer in r0,
destination pointer in r1)
(all following instructions assume r1 contains pointer)
DESCRIPTION This package is a complete set of routines
for dealing with almost arbitrary
length strings of words and bytes.
The strings are stored on a disk file, so the sum of
their lengths can be considerably larger than
For each string there is a header of four words, namely
a write pointer, a read pointer and pointers to the beginning and end of
the block containing the string.
Initially the read and write pointers point to the beginning of the string.
All routines that refer to a string require the header address in r1.
Unless the string is destroyed by the call,
upon return r1 will point to the same string, although
the string may have grown to the extent that it had to be
obtains a string of the requested size and returns
a pointer to its header in r1.
release
\b\b\b\b\b\b\b_______ releases a string back to free storage.
putchar
\b\b\b\b\b\b\b_______ and putword
\b\b\b\b\b\b\b_______ write a byte or word respectively into the string
and advance the write pointer.
a byte or word respectively from the string but do not advance the read pointer.
getchar
\b\b\b\b\b\b\b_______ and getword
\b\b\b\b\b\b\b_______ read a byte or word respectively from the string and advance the read pointer.
alterchar
\b\b\b\b\b\b\b\b\b_________ and alterword
\b\b\b\b\b\b\b\b\b_________ write a byte or word respectively into the string where the read pointer
is pointing and advance the read pointer.
backspace
\b\b\b\b\b\b\b\b\b_________ and backword
\b\b\b\b\b\b\b\b________ read the last byte or word written and decrement the write pointer.
All write operations will automatically get a larger block if the current block is exceeded.
All read operations return with the error bit set if attempting to read beyond the write pointer.
seekchar
\b\b\b\b\b\b\b\b________ moves the read pointer to the offset specified in r0.
length
\b\b\b\b\b\b______ returns the current length of the string (beginning pointer to write pointer) in r0.
position
\b\b\b\b\b\b\b\b________ returns the current offset of the read pointer in r0.
rewind
\b\b\b\b\b\b______ moves the read pointer to the beginning of the string.
create
\b\b\b\b\b\b______ returns the read and write pointers to the beginning of the string.
fsfile
\b\b\b\b\b\b______ moves the read pointer to the current position of the write pointer.
zero
\b\b\b\b____ zeros the whole string and sets the write pointer to the beginning of the string.
copy
\b\b\b\b____ copies the string whose header pointer is in r0 to the string whose header pointer is in
Care should be taken in using the copy instruction since r1 will be changed if the contents of the source string
is bigger than the destination string.
wc
\b\b__ forces the contents of the internal buffers and the header blocks to be written on disc.
FILES The allocator is in
the -s
\b\b__ option to ld
\b\b__ will link edit
references to the allocator.
alloc.d is the temporary file used to contain
DIAGNOSTICS "error in copy" if a disk write error occurs during the execution of the copy instruction.
"error in allocator" if any routine is called with a bad header pointer.
"Cannot open output file" if file alloc.d cannot be created or opened.
"Out of space" if there's no available block of the requested size or no headers available for a new block.