01h AL$GRAB allocate a new memory cell
Input D register - Initial size of cell in bytes
Output X register - The tag of the cell

Allocates a new memory cell.

Returns the tag (or address) of the 2 byte location containing the address of the base of the allocated cell.

As the allocator may move the base of a cell any time a request is made to the allocator, the base addresses of all cells are held in the table of addresses starting at ALA_BASE. Thus if the tag returned from this call is stored in a memory address called CELL then the following code should always be used to get the base of the memory cell into a memory address called BASE.

        LDX     CELL    ; Load the tag
        LDX     0,X     ; Get the de-referenced address
        STX     BASE    ; Save the real address

This procedure should be called any time a routine is called which could cause the allocator to move the memory cells around.

Corrupts registers A,B and X and UTW_S0.

Example To allocate a new cell of size 100 bytes:
        LDD     #100    ; The initial size of the cell
        OS      AL$GRAB
        BCS     ERROR   ; Report error
        STX     CELL    ; Save the tag
Errors 255 - No more cells can be allocated.
254 - Not enough memory for the cell to be allocated.