CNOP instruction

The CNOP instruction aligns any instruction or other data on a specific halfword boundary. This ensures an unbroken flow of executable instructions, since the CNOP instruction generates no-operation instructions to fill the bytes skipped to achieve specified alignment. If a control section has not been established, CNOP initiates an unnamed (private) control section.
Read syntax diagramSkip visual syntax diagramsymbolCNOPbyte, boundary
symbol
Is one of the following:
  • An ordinary symbol
  • A variable symbol that has been assigned a character string with a value that is valid for an ordinary symbol
  • A sequence symbol

The name is assigned to the next halfword aligned location. If there is a single byte before that location, it is skipped for alignment. Zero or more NOP(R)s might be generated at or after that location.

byte
Is an absolute expression that specifies at which even-numbered byte the location counter is set. The value of the expression must be 0 to boundary-2.
boundary
Is an absolute expression that specifies the byte specified by boundary is in a section of code of length boundary, with the section of code starting on a multiple of the boundary value. A value of 4 indicates the byte is in a fullword, a value of 16 indicates the byte is in a quadword, a value of 4096 indicates the byte is in a page. The maximum value for boundary is linked to the SECTALGN value. Values greater than 16 are only available if the GOFF option is specified.

Table 1 shows examples of valid pairs of byte and boundary. Examples of valid CNOP values:

Table 1. Valid CNOP values
Values Specify
0,4 Beginning of a word
2,4 Middle of a word
0,8 Beginning of a doubleword
2,8 Second halfword of a doubleword
4,8 Middle (third halfword) of a doubleword
6,8 Fourth halfword of a doubleword
0,16 Beginning of a quadword
2,16 Second halfword of a quadword
4,16 Third halfword of a quadword
6,16 Fourth halfword of a quadword
8,16 Fifth halfword of a quadword
10,16 Sixth halfword of a quadword
12,16 Seventh halfword of a quadword
14,16 Eighth halfword of a quadword
Figure 1 shows the position in a doubleword that each of these pairs specifies. Both 0,4 and 2,4 specify two locations in a doubleword.
Figure 1. CNOP alignment

Use the CNOP instruction, for example, when you code the linkage to a subroutine, and you want to pass parameters to the subroutine in fields immediately following the branch and link instructions. These parameters—for example, channel command words—can require alignment on a specific boundary. The subroutine can then address the parameters you pass through the register with the return address, as in the following example:

         CNOP            6,8
LINK     BALR            2,10
         CCW             1,DATADR,X'48',X'50'

CNOP values of 4094,4096 would be used to align on the last halfword of a page.

Assume that the location counter is aligned at a doubleword boundary. Then the CNOP instruction causes the following no-operations to be generated, thus aligning the BALR instruction at the last halfword in a doubleword as follows:
         BCR             0,0
         BC              0,X'700'
         BALR            2,10
LINK     CCW             1,DATADR,X'48',X'50'

After the BALR instruction is generated, the location counter is at a doubleword boundary, thus ensuring that the CCW instruction immediately follows the branch and link instruction.

The CNOP instruction forces the alignment of the location counter to start on a multiple of the boundary value. It does not affect the location counter if the counter is already correctly aligned. If the specified alignment requires the location counter to be incremented, no-operation instructions are generated to fill the skipped bytes. Any single byte skipped to achieve alignment to the first no-operation instruction is filled with zeros, even if the preceding byte contains no machine language object code. A length attribute reference to the name of a CNOP instruction is always invalid. Message ASMA042E is issued, and a default value of 1 is assigned.