Action
Function Header
= O,Count Header
=
A,Count
ADD TO LIST Store the first word of the header into
(the incoming location A. store the address A into the
element is at first word of the header. Decrement the
location A) second word of the header by one.
DELETE FROM The list is empty. Set the first word of the
LIST header to the value of
the contents of location
A. Use element A.
The following routines
code to perform the
manipulation described
chart.
allow enabled
free-pool-list
in the above
ADD TO FREE LIST Routine:
Initial Conditions:
GR2 contains the address of the element
to be added.
GR4 contains the address of the header.
ADDQ LM 0,1,0(4) GRO,GRI = contents
of the header TRYAGN ST 0,0(2) Point the new ele-
ment to the top
of the list
LR 3,1 Move the count to
GR3
BCTR 3,0 Decrement the count
CDS 0,2,0(4) Update the header
BC 7,TRYAGN DELETE FROM FREE LIST Routine:
Initial conditions:
GR4 contains the address of the header.
DELETQ LM 2,3,0(4) GR2,GR3 = con-
tents of the
header TRYAGN LTR 2,2 Is the list
empty?
BC 8,EMPTY Yes, get help
L 0,0(2) No, GRO = the
pointer from
the first
element
LR 1,3 Move the count
to GRI CDS 2,0,0(4) Update the
header
BC 7,TRYAGN USE [Any instruction] The address of
the removed
element is in
GR2
Note that the LM (LOAD MULTIPLE) instructions at locations ADDQ and
DELETQ would have to be CDS (COMPARE DOUBLE AND SWAP) instructions if it were
not for the rule concerning storage­
operand consistency. This rule requires
the LOAD MULTIPLE instructions to fetch
an eight-byte operand aligned on a
doubleword boundary such that, if anoth­
er CPU changes the doubleword being
fetched by an operation which is also at
least doubleword-consistent, either the
entire new or the entire old value of
the doubleword is obtained, and not a
combination of the two. (See the
section "Storage-Operand Consistency" in
Chapter 5, "Program Execution.")
Appendix A. Number Representation and Instruction-Use Examples A-47
Previous Page Next Page