HLASM Language Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


CNOP instruction

HLASM Language Reference
SC26-4940-06

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 diagram
>>-+--------+--CNOP--byte,boundary-----------------------------><
   '-symbol-'                        

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 in a fullword, doubleword, or quadword 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 fullword, doubleword, or quadword. A value of 4 indicates the byte is in a fullword, a value of 8 indicates the byte is in a doubleword, and a value of 16 indicates the byte is in a quadword.

Table 1 shows valid pairs of byte and word.

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
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                                 Quadword                                                                │
├────────────────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────────────┤
│                            Doubleword                              │                            Doubleword                              │
├─────────────────────────────────┬──────────────────────────────────┼─────────────────────────────────┬──────────────────────────────────┤
│           Fullword              │            Fullword              │           Fullword              │            Fullword              │
├───────────────┬─────────────────┼────────────────┬─────────────────┼───────────────┬─────────────────┼────────────────┬─────────────────┤
│   Halfword    │    Halfword     │    Halfword    │    Halfword     │   Halfword    │    Halfword     │    Halfword    │    Halfword     │
├───────┬───────┼────────┬────────┼────────┬───────┼────────┬────────┼───────┬───────┼────────┬────────┼────────┬───────┼────────┬────────┤
│ Byte  │  Byte │  Byte  │  Byte  │  Byte  │ Byte  │  Byte  │  Byte  │ Byte  │  Byte │  Byte  │  Byte  │  Byte  │ Byte  │  Byte  │  Byte  │
├───────┴───────┴────────┴────────┴────────┴───────┴────────┴────────┼───────┴───────┴────────┴────────┴────────┴───────┴────────┴────────┤
│0,4             2,4               0,4              2,4               0,4             2,4               0,4              2,4              │
│0,8             2,8               4,8              6,8               0,8             2,8               4,8              6,8              │
│0,16            2,16              4,16             6,16              8,16            10,16             12,16            14,16            │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
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'
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 a halfword, fullword, doubleword, or quadword boundary. 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.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014