This procedure is called by
flushtty (8258, 8259, 8264) canon (8292) pcread (8688) ttstart (8520) pcstart (8714) ttread (8544) lpstart (8971) pcclose (8673)
with a single argument which is the address of a “clist” structure.
Copy the parameter to r1 and save the initial processor status word and value of r2 on the stack;
Set the processor priority to five (higher than the interrupt priority of a character device);
r1 points to the first word of a “clist” structure (i.e. a character count). Move the second word of this structure (i.e. a pointer to the head character) to r2;
If the list is empty (head pointer is “NULL”) go to line 0961;
Move the head character to r0 and increment r2 as a side effect;
Mask r0 to get rid of any extended negative sign;
Store the updated head pointer back in the “clist” structure. (This may have to be altered later.);
Decrement the character count and if this is still positive, go to line 0947;
The list is now empty, so reset the head and tail character pointers to “NULL”. Go to line 0952;
Look at the three least significant bits of r2. If these are non-zero, branch to line 0957 (and return to the calling routine forthwith);
At this point, r2 is pointing at the next character position beyond the “cblock”. Move the value stored in the first word of the “cblock” (i.e. at r2 – 8), which is the address of the next “cblock” in the list to the head pointer in the “clist”. (Note that r1 was incremented as a side effect at line 0941):
The last value stored needs to incremented by two (Consult Figures 23.2 and 23.3);
At this point, a “cblock” determined by r2 is to be returned to “cfreelist”. Either r2 points into the “cblock” or just beyond it. Decrement r2 so that r2 will point into the “cblock”;
Reset the three least significant bits of r2, leaving a pointer to the “cblock”;
Link the “cblock” into “cfreelist”;
Restore the values of r2 and PS from the stack and return;
At this point the list is known to be empty because a “NULL” head pointer was encountered. Make sure that the tail pointer is “NULL” also;
Move –1 to r0 as the result to be returned when the list is empty.