Loading the value of zero into an AR
When the code you are writing is in AR mode, you must be very conscious of the contents of the ARs. For instructions that reference data, the ARs must always contain the ALET that identifies the data space that contains the data. When the data is in the primary address space, the AR that accompanies the GPR that has the address of the data must contain the value zero.
The following examples show several ways of placing the value zero in an AR.
Example 1: Set AR 5 to value of zero, when
GPR 5 can be changed.
SLR 5,5 SET GPR 5 TO ZERO
SAR 5,5 LOAD GPR 5 INTO AR 5
Example 2: Set AR 5 to value of zero, without
changing value in GPR 5.
LAM 5,5,=F'0' LOAD AR 5 WITH A VALUE OF ZERO
Another way of doing this is the following:
LAM 5,5,ZERO
ZERO DC F'0'
Example 3: Set AR 5 to value of zero, when
AR 12 is already zero.
CPYA 5,12 COPY AR 12 INTO AR 5
Example 4: Set AR 12 to zero and set GPR
12 to the address contained in GPR 15. This sequence is useful to
establish a program's base register GPR and AR from an entry point
address contained in register 15.
PGMA CSECT ENTRY POINT
.
.
LAE 12,0(15,0) ESTABLISH PROGRAM'S BASE REGISTER
USING PGMA,12
Another way to establish AR/GPR module addressability through register
12 is as follows:
LAE 12,0
BASR 12,0
USING *,12
Example 5: Set AR 5 and GPR 5 to zero.
LAE 5,0(0,0) Set GPR and AR 5 to zero