Ibmzarch

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1026

z/Architecture IBM

Principles of Operation

SA22-7832-00
z/Architecture IBM
Principles of Operation

SA22-7832-00
Note:

Before using this information and the product it supports, be sure to read the general information under Notices on page xv.

Softcopy Note:
The reader should be aware of the fact that this publication contains many symbols, such as superscripts, that may not display
correctly with any given hardware or software. The definitive version of this publication is the hardcopy version.

First Edition (December 2000)

This publication is provided for use in conjunction with other relevant IBM publications, and IBM makes no warranty, express or
implied, about its completeness or accuracy. The information in this publication is current as of its publication date but is subject to
change without notice.

Publications are not stocked at the address given below. Requests for IBM publications should be made to your IBM representative
or to the IBM branch office serving your locality.

A form for reader's comments is provided at the back of this publication. If the form has been removed, address your comments to:
International Business Machines Corporation
Department 55JA Mail Station P384
2455 South Road
Poughkeepsie, N.Y., 12601-5400
United States of America

FAX (United States & Canada): 845+432-9405


FAX (Other Countries): Your International Access Code+1+845+432-9405
IBMLink (United States customers only): IBMUSM10(MHVRCFS)
Internet e-mail: mhvrcfs@us.ibm.com
World Wide Web: http://www.ibm.com/s390/os390/webqs.html

When you send information to IBM, you grant IBM a non-exclusive right to use or distribute the information in any way it believes
appropriate without incurring any obligation to you.

Copyright International Business Machines Corporation 1990, 2000. All rights reserved.
US Government Users Restricted Rights Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
Contents
Notices . . . . . . . . . . . . . . . . . . . . . . . xv Storage Addressing . . . . . . . . . . . . . . . 3-2
Trademarks . . . . . . . . . . . . . . . . . . . . xv Information Formats . . . . . . . . . . . . . 3-2
Integral Boundaries . . . . . . . . . . . . . 3-3
Preface . . . . . . . . . . . . . . . . . . . . . . xvii Address Types and Formats . . . . . . . . . . 3-3
Size and Number Notation . . . . . . . . . xviii Address Types . . . . . . . . . . . . . . . . 3-3
Bytes, Characters, and Codes . . . . . . . . xix Absolute Address . . . . . . . . . . . . . 3-3
Other Publications . . . . . . . . . . . . . . . xix Real Address . . . . . . . . . . . . . . . 3-4
Virtual Address . . . . . . . . . . . . . . 3-4
Chapter 1. Introduction . . . . . . . . . . . 1-1 Primary Virtual Address . . . . . . . . . 3-4
Highlights of z/Architecture . . . . . . . . . . . 1-1 Secondary Virtual Address . . . . . . . . 3-4
General Instructions for 64-Bit Integers . . 1-2 AR-Specified Virtual Address . . . . . . 3-5
Other New General Instructions . . . . . . 1-2 Home Virtual Address . . . . . . . . . . 3-5
Floating-Point Instructions . . . . . . . . . . 1-4 Logical Address . . . . . . . . . . . . . . 3-5
Control Instructions . . . . . . . . . . . . . 1-4 Instruction Address . . . . . . . . . . . . 3-5
Trimodal Addressing . . . . . . . . . . . . . 1-4 Effective Address . . . . . . . . . . . . . 3-5
Modal Instructions . . . . . . . . . . . . . 1-4 Address Size and Wraparound . . . . . . . 3-5
Effects on Bits 0-31 of a General Address Wraparound . . . . . . . . . . . 3-6
Register . . . . . . . . . . . . . . . . . 1-5 Storage Key . . . . . . . . . . . . . . . . . . . 3-8
Extended-Translation Facility 2 . . . . . . . 1-5 Protection . . . . . . . . . . . . . . . . . . . . . 3-9
The ESA/390 Base . . . . . . . . . . . . . . . 1-6 Key-Controlled Protection . . . . . . . . . . 3-9
The ESA/370 and 370-XA Base . . . . . . 1-11 Storage-Protection-Override Control . . 3-10
System Program . . . . . . . . . . . . . . . . . 1-13 Fetch-Protection-Override Control . . . 3-11
Compatibility . . . . . . . . . . . . . . . . . . . 1-13 Access-List-Controlled Protection . . . . . 3-11
Compatibility among z/Architecture Page Protection . . . . . . . . . . . . . . . 3-11
Systems . . . . . . . . . . . . . . . . . . 1-13 Low-Address Protection . . . . . . . . . . . 3-12
Compatibility between z/Architecture and Suppression on Protection . . . . . . . . . 3-12
ESA/390 . . . . . . . . . . . . . . . . . 1-14 Reference Recording . . . . . . . . . . . . . . 3-14
Control-Program Compatibility . . . . . . 1-14 Change Recording . . . . . . . . . . . . . . . 3-14
Problem-State Compatibility . . . . . . . 1-14 Prefixing . . . . . . . . . . . . . . . . . . . . . 3-15
Availability . . . . . . . . . . . . . . . . . . . . 1-14 Address Spaces . . . . . . . . . . . . . . . . . 3-16
Changing to Different Address Spaces . 3-17
Chapter 2. Organization . . . . . . . . . . . 2-1 Address-Space Number . . . . . . . . . 3-17
Main Storage . . . . . . . . . . . . . . . . . . . 2-2 ASN Translation . . . . . . . . . . . . . . . . . 3-18
Expanded Storage . . . . . . . . . . . . . . . 2-2 ASN-Translation Controls . . . . . . . . . . 3-18
CPU . . . . . . . . . . . . . . . . . . . . . . . . 2-2 Control Register 14 . . . . . . . . . . . . 3-18
PSW . . . . . . . . . . . . . . . . . . . . . . 2-3 ASN-Translation Tables . . . . . . . . . . . 3-19
General Registers . . . . . . . . . . . . . . 2-3 ASN-First-Table Entries . . . . . . . . . 3-19
Floating-Point Registers . . . . . . . . . . . 2-3 ASN-Second-Table Entries . . . . . . . 3-19
Floating-Point-Control Register . . . . . . . 2-4 ASN-Translation Process . . . . . . . . . . 3-21
Control Registers . . . . . . . . . . . . . . . 2-4 ASN-First-Table Lookup . . . . . . . . . 3-22
Access Registers . . . . . . . . . . . . . . . 2-4 ASN-Second-Table Lookup . . . . . . . 3-23
Cryptographic Facility . . . . . . . . . . . . 2-6 Recognition of Exceptions during ASN
External Time Reference . . . . . . . . . . . . 2-6 Translation . . . . . . . . . . . . . . . 3-23
I/O . . . . . . . . . . . . . . . . . . . . . . . . . 2-6 ASN Authorization . . . . . . . . . . . . . . . . 3-23
Channel Subsystem . . . . . . . . . . . . . 2-6 ASN-Authorization Controls . . . . . . . . . 3-23
Channel Paths . . . . . . . . . . . . . . . . 2-6 Control Register 4 . . . . . . . . . . . . . 3-23
I/O Devices and Control Units . . . . . . . 2-7 ASN-Second-Table Entry . . . . . . . . 3-24
Operator Facilities . . . . . . . . . . . . . . . . 2-7 Authority-Table Entries . . . . . . . . . . . 3-24
ASN-Authorization Process . . . . . . . . . 3-24
Chapter 3. Storage . . . . . . . . . . . . . . 3-1 Authority-Table Lookup . . . . . . . . . . 3-25

Copyright IBM Corp. 1990, 2000 iii


Recognition of Exceptions during ASN Storage-Area Designation . . . . . . . . . . 4-29
Authorization . . . . . . . . . . . . . 3-26 PER Events . . . . . . . . . . . . . . . . . . 4-30
Dynamic Address Translation . . . . . . . . . 3-26 Successful Branching . . . . . . . . . . . 4-30
Translation Control . . . . . . . . . . . . . . 3-28 Instruction Fetching . . . . . . . . . . . . 4-31
Translation Modes . . . . . . . . . . . . 3-28 Storage Alteration . . . . . . . . . . . . . 4-31
Control Register 0 . . . . . . . . . . . . . 3-29 Store Using Real Address . . . . . . . . 4-32
Control Register 1 . . . . . . . . . . . . . 3-29 Indication of PER Events Concurrently
Control Register 7 . . . . . . . . . . . . . 3-30 with Other Interruption Conditions . . . 4-32
Control Register 13 . . . . . . . . . . . . 3-31 Timing . . . . . . . . . . . . . . . . . . . . . . . 4-34
Translation Tables . . . . . . . . . . . . . . 3-31 Time-of-Day Clock . . . . . . . . . . . . . . 4-35
Region-Table Entries . . . . . . . . . . . 3-31 Format . . . . . . . . . . . . . . . . . . . 4-35
Segment-Table Entries . . . . . . . . . . 3-33 States . . . . . . . . . . . . . . . . . . . . 4-35
Page-Table Entries . . . . . . . . . . . . 3-33 Changes in Clock State . . . . . . . . . 4-36
Translation Process . . . . . . . . . . . . . 3-34 Setting and Inspecting the Clock . . . . 4-36
Inspection of Real-Space Control . . . . 3-39 TOD Programmable Register . . . . . . 4-37
Inspection of Designation-Type Control 3-39 TOD-Clock Synchronization . . . . . . . . . 4-39
Lookup in a Table Designated by an Clock Comparator . . . . . . . . . . . . . . 4-39
Address-Space-Control Element . . 3-39 CPU Timer . . . . . . . . . . . . . . . . . . 4-40
Lookup in a Table Designated by a Externally Initiated Functions . . . . . . . . . 4-41
Region-Table Entry . . . . . . . . . . 3-40 Resets . . . . . . . . . . . . . . . . . . . . . 4-41
Page-Table Lookup . . . . . . . . . . . . 3-42 CPU Reset . . . . . . . . . . . . . . . . . 4-45
Formation of the Real Address . . . . . 3-42 Initial CPU Reset . . . . . . . . . . . . . 4-46
Recognition of Exceptions during Subsystem Reset . . . . . . . . . . . . . 4-46
Translation . . . . . . . . . . . . . . . 3-42 Clear Reset . . . . . . . . . . . . . . . . 4-46
Translation-Lookaside Buffer . . . . . . . . 3-42 Power-On Reset . . . . . . . . . . . . . 4-47
TLB Structure . . . . . . . . . . . . . . . 3-43 Initial Program Loading . . . . . . . . . . . 4-47
Formation of TLB Entries . . . . . . . . 3-43 Store Status . . . . . . . . . . . . . . . . . . 4-48
Use of TLB Entries . . . . . . . . . . . . 3-44 Multiprocessing . . . . . . . . . . . . . . . . . 4-49
Modification of Translation Tables . . . 3-45 Shared Main Storage . . . . . . . . . . . . 4-49
Address Summary . . . . . . . . . . . . . . . . 3-47 CPU-Address Identification . . . . . . . . . 4-49
Addresses Translated . . . . . . . . . . . . 3-47 CPU Signaling and Response . . . . . . . . . 4-49
Handling of Addresses . . . . . . . . . . . 3-48 Signal-Processor Orders . . . . . . . . . . 4-49
Assigned Storage Locations . . . . . . . . . . 3-51 Conditions Determining Response . . . . . 4-53
Conditions Precluding Interpretation of
Chapter 4. Control . . . . . . . . . . . . . . 4-1 the Order Code . . . . . . . . . . . . 4-53
Stopped, Operating, Load, and Check-Stop Status Bits . . . . . . . . . . . . . . . . . 4-54
States . . . . . . . . . . . . . . . . . . . . . . 4-1
Stopped State . . . . . . . . . . . . . . . . 4-2 Chapter 5. Program Execution . . . . . . . 5-1
Operating State . . . . . . . . . . . . . . . . 4-2 Instructions . . . . . . . . . . . . . . . . . . . . 5-2
Load State . . . . . . . . . . . . . . . . . . 4-2 Operands . . . . . . . . . . . . . . . . . . . 5-2
Check-Stop State . . . . . . . . . . . . . . 4-3 Instruction Formats . . . . . . . . . . . . . . 5-3
Program-Status Word . . . . . . . . . . . . . . 4-3 Register Operands . . . . . . . . . . . . 5-6
Program-Status-Word Format . . . . . . . 4-5 Immediate Operands . . . . . . . . . . . 5-6
Control Registers . . . . . . . . . . . . . . . . 4-7 Storage Operands . . . . . . . . . . . . 5-6
Tracing . . . . . . . . . . . . . . . . . . . . . . 4-10 Address Generation . . . . . . . . . . . . . . . 5-7
Control-Register Allocation . . . . . . . . . 4-13 Trimodal Addressing . . . . . . . . . . . . . 5-7
Trace Entries . . . . . . . . . . . . . . . . . 4-13 Sequential Instruction-Address Generation . 5-7
Operation . . . . . . . . . . . . . . . . . . . 4-23 Operand-Address Generation . . . . . . . 5-7
Program-Event Recording . . . . . . . . . . . 4-24 Formation of the Intermediate Value . . 5-7
Control-Register Allocation and Formation of the Operand Address . . . 5-8
Address-Space-Control Element . . . . 4-24 Branch-Address Generation . . . . . . . . 5-8
Operation . . . . . . . . . . . . . . . . . . . 4-25 Formation of the Intermediate Value . . 5-8
Identification of Cause . . . . . . . . . . 4-26 Formation of the Branch Address . . . . 5-9
Priority of Indication . . . . . . . . . . . . 4-28 Instruction Execution and Sequencing . . . . 5-9

iv z/Architecture Principles of Operation


Decision Making . . . . . . . . . . . . . . . 5-10 Access-Register-Translation Control . . . . 5-43
Loop Control . . . . . . . . . . . . . . . . . 5-10 Control Register 2 . . . . . . . . . . . . . 5-43
Subroutine Linkage without the Linkage Control Register 5 . . . . . . . . . . . . . 5-43
Stack . . . . . . . . . . . . . . . . . . . 5-10 Control Register 8 . . . . . . . . . . . . . 5-43
Simple Branch Instructions . . . . . . . 5-10 Access Registers . . . . . . . . . . . . . . . 5-44
Other Linkage Instructions . . . . . . . . 5-14 Access-Register-Translation Tables . . . . 5-44
Interruptions . . . . . . . . . . . . . . . . . . 5-19 Dispatchable-Unit Control Table and
Types of Instruction Ending . . . . . . . . . 5-19 Access-List Designations . . . . . . 5-45
Completion . . . . . . . . . . . . . . . . . 5-19 Access-List Entries . . . . . . . . . . . . 5-46
Suppression . . . . . . . . . . . . . . . . 5-19 ASN-Second-Table Entries . . . . . . . 5-47
Nullification . . . . . . . . . . . . . . . . . 5-20 Access-Register-Translation Process . . . 5-48
Termination . . . . . . . . . . . . . . . . 5-20 Selecting the Access-List-Entry Token . 5-51
Interruptible Instructions . . . . . . . . . . . 5-20 Obtaining the Primary or Secondary
Point of Interruption . . . . . . . . . . . . 5-20 Address-Space-Control Element . . 5-51
Unit of Operation . . . . . . . . . . . . . 5-20 Checking the First Byte of the ALET . . 5-51
Execution of Interruptible Instructions . 5-20 Obtaining the Effective Access-List
Condition-Code Alternative to Designation . . . . . . . . . . . . . . 5-51
Interruptibility . . . . . . . . . . . . . 5-21 Access-List Lookup . . . . . . . . . . . . 5-51
Exceptions to Nullification and Locating the ASN-Second-Table Entry . 5-52
Suppression . . . . . . . . . . . . . . . 5-22 Authorizing the Use of the Access-List
Storage Change and Restoration for Entry . . . . . . . . . . . . . . . . . . 5-52
DAT-Associated Access Exceptions 5-22 Checking for Access-List-Controlled
Modification of DAT-Table Entries . . . 5-23 Protection . . . . . . . . . . . . . . . 5-53
Trial Execution for Editing Instructions Obtaining the Address-Space-Control
and Translate Instruction . . . . . . 5-23 Element from the ASN-Second-Table
Authorization Mechanisms . . . . . . . . . . . 5-23 Entry . . . . . . . . . . . . . . . . . . 5-53
Mode Requirements . . . . . . . . . . . 5-24 Recognition of Exceptions during
Extraction-Authority Control . . . . . . . 5-24 Access-Register Translation . . . . 5-53
PSW-Key Mask . . . . . . . . . . . . . . 5-24 ART-Lookaside Buffer . . . . . . . . . . . . 5-53
Secondary-Space Control . . . . . . . . 5-25 ALB Structure . . . . . . . . . . . . . . . 5-53
Subsystem-Linkage Control . . . . . . . 5-25 Formation of ALB Entries . . . . . . . . 5-54
ASN-Translation Control . . . . . . . . . 5-25 Use of ALB Entries . . . . . . . . . . . . 5-54
Authorization Index . . . . . . . . . . . . 5-25 Modification of ART Tables . . . . . . . 5-55
PC-Number Translation . . . . . . . . . . . . . 5-29 Subspace Groups . . . . . . . . . . . . . . . . 5-55
PC-Number Translation Control . . . . . . 5-29 Subspace-Group Tables . . . . . . . . . . 5-55
Control Register 5 . . . . . . . . . . . . . 5-29 Subspace-Group Dispatchable-Unit
PC-Number Translation Tables . . . . . . . 5-29 Control Table . . . . . . . . . . . . . 5-55
Linkage-Table Entries . . . . . . . . . . 5-29 Subspace-Group ASN-Second-Table
Entry-Table Entries . . . . . . . . . . . . 5-30 Entries . . . . . . . . . . . . . . . . . 5-57
PC-Number-Translation Process . . . . . . 5-31 Subspace-Replacement Operations . . . . 5-59
Obtaining the Linkage-Table Linkage-Stack Introduction . . . . . . . . . . . 5-60
Designation . . . . . . . . . . . . . . 5-32 Summary . . . . . . . . . . . . . . . . . . . 5-60
Linkage-Table Lookup . . . . . . . . . . 5-33 Linkage-Stack Functions . . . . . . . . . . 5-60
Entry-Table Lookup . . . . . . . . . . . . 5-33 Transferring Program Control . . . . . . 5-60
Recognition of Exceptions during Branching Using the Linkage Stack . . 5-62
PC-Number Translation . . . . . . . 5-33 Adding and Retrieving Information . . . 5-63
Home Address Space . . . . . . . . . . . . . 5-34 Testing Authorization . . . . . . . . . . . 5-63
Access-Register Introduction . . . . . . . . . . 5-34 Program-Problem Analysis . . . . . . . . 5-64
Summary . . . . . . . . . . . . . . . . . . . 5-35 Linkage-Stack Entry-Table Entries . . . . . . 5-64
Access-Register Functions . . . . . . . . . 5-35 Linkage-Stack Operations . . . . . . . . . . . 5-65
Access-Register-Specified Address Linkage-Stack-Operations Control . . . . . 5-67
Spaces . . . . . . . . . . . . . . . . . 5-35 Control Register 15 . . . . . . . . . . . . 5-67
Access-Register Instructions . . . . . . 5-42 Linkage Stack . . . . . . . . . . . . . . . . . 5-67
Access-Register Translation . . . . . . . . . . 5-43 Entry Descriptors . . . . . . . . . . . . . 5-67

Contents v
Header Entries . . . . . . . . . . . . . . 5-69 Early Exception Recognition . . . . . . . 6-9
Trailer Entries . . . . . . . . . . . . . . . 5-69 Late Exception Recognition . . . . . . . 6-10
State Entries . . . . . . . . . . . . . . . . 5-70 External Interruption . . . . . . . . . . . . . . . 6-10
Stacking Process . . . . . . . . . . . . . . . 5-72 Clock Comparator . . . . . . . . . . . . . . 6-11
Locating Space for a New Entry . . . . 5-72 CPU Timer . . . . . . . . . . . . . . . . . . 6-11
Forming the New Entry . . . . . . . . . . 5-73 Emergency Signal . . . . . . . . . . . . . . 6-11
Updating the Current Entry . . . . . . . 5-74 ETR . . . . . . . . . . . . . . . . . . . . . . 6-12
Updating Control Register 15 . . . . . . 5-74 External Call . . . . . . . . . . . . . . . . . 6-12
Recognition of Exceptions during the Interrupt Key . . . . . . . . . . . . . . . . . 6-12
Stacking Process . . . . . . . . . . . 5-74 Malfunction Alert . . . . . . . . . . . . . . . 6-12
Unstacking Process . . . . . . . . . . . . . 5-75 Service Signal . . . . . . . . . . . . . . . . 6-13
Locating the Current Entry and I/O Interruption . . . . . . . . . . . . . . . . . . 6-13
Processing a Header Entry . . . . . 5-75 Machine-Check Interruption . . . . . . . . . . 6-13
Checking for a State Entry . . . . . . . . 5-76 Program Interruption . . . . . . . . . . . . . . 6-14
Restoring Information . . . . . . . . . . . 5-76 Data-Exception Code (DXC) . . . . . . . . 6-14
Updating the Preceding Entry . . . . . . 5-77 Priority of Program Interruptions for
Updating Control Register 15 . . . . . . 5-77 Data Exceptions . . . . . . . . . . . 6-16
Recognition of Exceptions during the Program-Interruption Conditions . . . . . . 6-16
Unstacking Process . . . . . . . . . 5-77 Addressing Exception . . . . . . . . . . 6-16
Sequence of Storage References . . . . . . . 5-77 AFX-Translation Exception . . . . . . . . 6-19
Conceptual Sequence . . . . . . . . . . 5-77 ALEN-Translation Exception . . . . . . . 6-19
Overlapped Operation of Instruction ALE-Sequence Exception . . . . . . . . 6-19
Execution . . . . . . . . . . . . . . . 5-78 ALET-Specification Exception . . . . . . 6-19
Divisible Instruction Execution . . . . . . 5-78 ASCE-Type Exception . . . . . . . . . . 6-19
Interlocks for Virtual-Storage References . 5-79 ASTE-Sequence Exception . . . . . . . 6-20
Interlocks between Instructions . . . . . 5-79 ASTE-Validity Exception . . . . . . . . . 6-20
Interlocks within a Single Instruction . . 5-80 ASX-Translation Exception . . . . . . . 6-21
Instruction Fetching . . . . . . . . . . . . . 5-81 Crypto-Operation Exception . . . . . . . 6-21
ART-Table and DAT-Table Fetches . . . . 5-83 Data Exception . . . . . . . . . . . . . . 6-21
Storage-Key Accesses . . . . . . . . . . . 5-83 Decimal-Divide Exception . . . . . . . . 6-22
Storage-Operand References . . . . . . . 5-84 Decimal-Overflow Exception . . . . . . . 6-22
Storage-Operand Fetch References . . 5-84 Execute Exception . . . . . . . . . . . . 6-22
Storage-Operand Store References . . 5-84 EX-Translation Exception . . . . . . . . 6-22
Storage-Operand Update References . 5-85 Extended-Authority Exception . . . . . . 6-22
Storage-Operand Consistency . . . . . . . 5-86 Fixed-Point-Divide Exception . . . . . . 6-23
Single-Access References . . . . . . . . 5-86 Fixed-Point-Overflow Exception . . . . . 6-23
Multiple-Access References . . . . . . . 5-86 HFP-Divide Exception . . . . . . . . . . 6-23
Block-Concurrent References . . . . . . 5-87 HFP-Exponent-Overflow Exception . . . 6-23
Consistency Specification . . . . . . . . 5-87 HFP-Exponent-Underflow Exception . . 6-23
Relation between Operand Accesses . . . 5-88 HFP-Significance Exception . . . . . . . 6-24
Other Storage References . . . . . . . . . 5-89 HFP-Square-Root Exception . . . . . . 6-24
Serialization . . . . . . . . . . . . . . . . . . . 5-89 LX-Translation Exception . . . . . . . . 6-24
CPU Serialization . . . . . . . . . . . . . . 5-89 Monitor Event . . . . . . . . . . . . . . . 6-24
Channel-Program Serialization . . . . . . . 5-91 Operand Exception . . . . . . . . . . . . 6-25
Operation Exception . . . . . . . . . . . 6-25
Chapter 6. Interruptions . . . . . . . . . . . 6-1 Page-Translation Exception . . . . . . . 6-26
Interruption Action . . . . . . . . . . . . . . . . 6-2 PC-Translation-Specification Exception 6-26
Interruption Code . . . . . . . . . . . . . . . 6-5 PER Event . . . . . . . . . . . . . . . . . 6-26
Enabling and Disabling . . . . . . . . . . . 6-6 Primary-Authority Exception . . . . . . . 6-26
Handling of Floating Interruption Conditions 6-7 Privileged-Operation Exception . . . . . 6-27
Instruction-Length Code . . . . . . . . . . . 6-7 Protection Exception . . . . . . . . . . . 6-27
Zero ILC . . . . . . . . . . . . . . . . . . 6-7 Region-First-Translation Exception . . . 6-28
ILC on Instruction-Fetching Exceptions . 6-8 Region-Second-Translation Exception . 6-29
Exceptions Associated with the PSW . . . 6-9 Region-Third-Translation Exception . . 6-29

vi z/Architecture Principles of Operation


Secondary-Authority Exception . . . . . 6-29 BRANCH RELATIVE ON INDEX HIGH . . 7-28
Segment-Translation Exception . . . . . 6-30 BRANCH RELATIVE ON INDEX LOW
Space-Switch Event . . . . . . . . . . . 6-30 OR EQUAL . . . . . . . . . . . . . . . . 7-28
Special-Operation Exception . . . . . . 6-31 CHECKSUM . . . . . . . . . . . . . . . . . 7-29
Specification Exception . . . . . . . . . . 6-32 COMPARE . . . . . . . . . . . . . . . . . . 7-32
Stack-Empty Exception . . . . . . . . . . 6-33 COMPARE AND FORM CODEWORD . . 7-33
Stack-Full Exception . . . . . . . . . . . 6-34 COMPARE AND SWAP . . . . . . . . . . . 7-40
Stack-Operation Exception . . . . . . . . 6-34 COMPARE DOUBLE AND SWAP . . . . . 7-40
Stack-Specification Exception . . . . . . 6-34 COMPARE HALFWORD . . . . . . . . . . 7-42
Stack-Type Exception . . . . . . . . . . 6-34 COMPARE HALFWORD IMMEDIATE . . 7-42
Trace-Table Exception . . . . . . . . . . 6-34 COMPARE LOGICAL . . . . . . . . . . . . 7-42
Translation-Specification Exception . . . 6-35 COMPARE LOGICAL CHARACTERS
Collective Program-Interruption Names . . 6-35 UNDER MASK . . . . . . . . . . . . . . 7-43
Recognition of Access Exceptions . . . . . 6-35 COMPARE LOGICAL LONG . . . . . . . . 7-44
Multiple Program-Interruption Conditions . 6-39 COMPARE LOGICAL LONG EXTENDED 7-46
Access Exceptions . . . . . . . . . . . . 6-42 COMPARE LOGICAL LONG UNICODE . 7-50
ASN-Translation Exceptions . . . . . . . 6-45 COMPARE LOGICAL STRING . . . . . . . 7-53
Subspace-Replacement Exceptions . . 6-46 COMPARE UNTIL SUBSTRING EQUAL . 7-54
Trace Exceptions . . . . . . . . . . . . . 6-46 COMPRESSION CALL . . . . . . . . . . . 7-58
Restart Interruption . . . . . . . . . . . . . . . 6-46 CONVERT TO BINARY . . . . . . . . . . . 7-69
Supervisor-Call Interruption . . . . . . . . . . 6-47 CONVERT TO DECIMAL . . . . . . . . . . 7-70
Priority of Interruptions . . . . . . . . . . . . . 6-47 CONVERT UNICODE TO UTF-8 . . . . . 7-71
CONVERT UTF-8 TO UNICODE . . . . . 7-74
Chapter 7. General Instructions . . . . . . 7-1 COPY ACCESS . . . . . . . . . . . . . . . 7-77
Data Format . . . . . . . . . . . . . . . . . . . 7-2 DIVIDE . . . . . . . . . . . . . . . . . . . . 7-77
Binary-Integer Representation . . . . . . . . . 7-2 DIVIDE LOGICAL . . . . . . . . . . . . . . 7-77
Binary Arithmetic . . . . . . . . . . . . . . . . 7-3 DIVIDE SINGLE . . . . . . . . . . . . . . . 7-78
Signed Binary Arithmetic . . . . . . . . . . 7-4 EXCLUSIVE OR . . . . . . . . . . . . . . . 7-79
Addition and Subtraction . . . . . . . . . 7-4 EXECUTE . . . . . . . . . . . . . . . . . . . 7-80
Fixed-Point Overflow . . . . . . . . . . . 7-4 EXTRACT ACCESS . . . . . . . . . . . . . 7-81
Unsigned Binary Arithmetic . . . . . . . . . 7-4 EXTRACT PSW . . . . . . . . . . . . . . . 7-81
Signed and Logical Comparison . . . . . . . . 7-5 INSERT CHARACTER . . . . . . . . . . . 7-81
Instructions . . . . . . . . . . . . . . . . . . . . 7-6 INSERT CHARACTERS UNDER MASK . 7-81
ADD . . . . . . . . . . . . . . . . . . . . . . 7-16 INSERT IMMEDIATE . . . . . . . . . . . . 7-82
ADD HALFWORD . . . . . . . . . . . . . . 7-16 INSERT PROGRAM MASK . . . . . . . . . 7-83
ADD HALFWORD IMMEDIATE . . . . . . 7-16 LOAD . . . . . . . . . . . . . . . . . . . . . 7-83
ADD LOGICAL . . . . . . . . . . . . . . . . 7-17 LOAD ACCESS MULTIPLE . . . . . . . . . 7-84
ADD LOGICAL WITH CARRY . . . . . . . 7-17 LOAD ADDRESS . . . . . . . . . . . . . . 7-84
AND . . . . . . . . . . . . . . . . . . . . . . 7-18 LOAD ADDRESS EXTENDED . . . . . . . 7-84
AND IMMEDIATE . . . . . . . . . . . . . . 7-19 LOAD ADDRESS RELATIVE LONG . . . 7-85
BRANCH AND LINK . . . . . . . . . . . . . 7-19 LOAD AND TEST . . . . . . . . . . . . . . 7-86
BRANCH AND SAVE . . . . . . . . . . . . 7-20 LOAD COMPLEMENT . . . . . . . . . . . . 7-86
BRANCH AND SAVE AND SET MODE . 7-21 LOAD HALFWORD . . . . . . . . . . . . . 7-87
BRANCH AND SET MODE . . . . . . . . . 7-22 LOAD HALFWORD IMMEDIATE . . . . . 7-87
BRANCH ON CONDITION . . . . . . . . . 7-23 LOAD LOGICAL . . . . . . . . . . . . . . . 7-87
BRANCH ON COUNT . . . . . . . . . . . . 7-24 LOAD LOGICAL CHARACTER . . . . . . 7-87
BRANCH ON INDEX HIGH . . . . . . . . . 7-24 LOAD LOGICAL HALFWORD . . . . . . . 7-88
BRANCH ON INDEX LOW OR EQUAL . . 7-25 LOAD LOGICAL IMMEDIATE . . . . . . . 7-88
BRANCH RELATIVE AND SAVE . . . . . 7-26 LOAD LOGICAL THIRTY ONE BITS . . . 7-88
BRANCH RELATIVE AND SAVE LONG . 7-26 LOAD MULTIPLE . . . . . . . . . . . . . . 7-88
BRANCH RELATIVE ON CONDITION . . 7-26 LOAD MULTIPLE DISJOINT . . . . . . . . 7-89
BRANCH RELATIVE ON CONDITION LOAD MULTIPLE HIGH . . . . . . . . . . . 7-89
LONG . . . . . . . . . . . . . . . . . . . 7-26 LOAD NEGATIVE . . . . . . . . . . . . . . 7-90
BRANCH RELATIVE ON COUNT . . . . . 7-27 LOAD PAIR FROM QUADWORD . . . . . 7-90

Contents vii
LOAD POSITIVE . . . . . . . . . . . . . . . 7-90 TEST UNDER MASK (TEST UNDER
LOAD REVERSED . . . . . . . . . . . . . . 7-91 MASK HIGH, TEST UNDER MASK
MONITOR CALL . . . . . . . . . . . . . . . 7-92 LOW) . . . . . . . . . . . . . . . . . . 7-147
MOVE . . . . . . . . . . . . . . . . . . . . . 7-93 TRANSLATE . . . . . . . . . . . . . . . . 7-148
MOVE INVERSE . . . . . . . . . . . . . . . 7-93 TRANSLATE AND TEST . . . . . . . . . 7-149
MOVE LONG . . . . . . . . . . . . . . . . . 7-94 TRANSLATE EXTENDED . . . . . . . . 7-150
MOVE LONG EXTENDED . . . . . . . . . 7-97 TRANSLATE ONE TO ONE . . . . . . . 7-152
MOVE LONG UNICODE . . . . . . . . . 7-101 TRANSLATE ONE TO TWO . . . . . . . 7-152
MOVE NUMERICS . . . . . . . . . . . . . 7-104 TRANSLATE TWO TO ONE . . . . . . . 7-152
MOVE STRING . . . . . . . . . . . . . . . 7-104 TRANSLATE TWO TO TWO . . . . . . . 7-153
MOVE WITH OFFSET . . . . . . . . . . . 7-106 UNPACK . . . . . . . . . . . . . . . . . . 7-157
MOVE ZONES . . . . . . . . . . . . . . . 7-106 UNPACK ASCII . . . . . . . . . . . . . . 7-158
MULTIPLY . . . . . . . . . . . . . . . . . 7-107 UNPACK UNICODE . . . . . . . . . . . . 7-159
MULTIPLY HALFWORD . . . . . . . . . 7-107 UPDATE TREE . . . . . . . . . . . . . . . 7-160
MULTIPLY HALFWORD IMMEDIATE . . 7-108
MULTIPLY LOGICAL . . . . . . . . . . . 7-108 Chapter 8. Decimal Instructions . . . . . . 8-1
MULTIPLY SINGLE . . . . . . . . . . . . 7-109 Decimal-Number Formats . . . . . . . . . . . 8-1
OR . . . . . . . . . . . . . . . . . . . . . . 7-110 Zoned Format . . . . . . . . . . . . . . . . . 8-1
OR IMMEDIATE . . . . . . . . . . . . . . 7-111 Packed Format . . . . . . . . . . . . . . . . 8-1
PACK . . . . . . . . . . . . . . . . . . . . 7-111 Decimal Codes . . . . . . . . . . . . . . . . 8-2
PACK ASCII . . . . . . . . . . . . . . . . 7-112 Decimal Operations . . . . . . . . . . . . . . . 8-2
PACK UNICODE . . . . . . . . . . . . . . 7-113 Decimal-Arithmetic Instructions . . . . . . . 8-2
PERFORM LOCKED OPERATION . . . 7-114 Editing Instructions . . . . . . . . . . . . . . 8-3
ROTATE LEFT SINGLE LOGICAL . . . 7-129 Execution of Decimal Instructions . . . . . 8-3
SEARCH STRING . . . . . . . . . . . . . 7-130 Other Instructions for Decimal Operands . 8-3
SET ACCESS . . . . . . . . . . . . . . . 7-131 Decimal-Operand Data Exception . . . . . 8-4
SET ADDRESSING MODE . . . . . . . . 7-131 Instructions . . . . . . . . . . . . . . . . . . . . 8-4
SET PROGRAM MASK . . . . . . . . . . 7-132 ADD DECIMAL . . . . . . . . . . . . . . . . 8-5
SHIFT LEFT DOUBLE . . . . . . . . . . . 7-132 COMPARE DECIMAL . . . . . . . . . . . . 8-6
SHIFT LEFT DOUBLE LOGICAL . . . . 7-133 DIVIDE DECIMAL . . . . . . . . . . . . . . 8-6
SHIFT LEFT SINGLE . . . . . . . . . . . 7-134 EDIT . . . . . . . . . . . . . . . . . . . . . . 8-7
SHIFT LEFT SINGLE LOGICAL . . . . . 7-134 EDIT AND MARK . . . . . . . . . . . . . . 8-9
SHIFT RIGHT DOUBLE . . . . . . . . . . 7-135 MULTIPLY DECIMAL . . . . . . . . . . . . 8-11
SHIFT RIGHT DOUBLE LOGICAL . . . 7-135 SHIFT AND ROUND DECIMAL . . . . . . 8-11
SHIFT RIGHT SINGLE . . . . . . . . . . 7-136 SUBTRACT DECIMAL . . . . . . . . . . . 8-12
SHIFT RIGHT SINGLE LOGICAL . . . . 7-136 TEST DECIMAL . . . . . . . . . . . . . . . 8-13
STORE . . . . . . . . . . . . . . . . . . . 7-137 ZERO AND ADD . . . . . . . . . . . . . . . 8-13
STORE ACCESS MULTIPLE . . . . . . . 7-137
STORE CHARACTER . . . . . . . . . . . 7-137 Chapter 9. Floating-Point Overview and
STORE CHARACTERS UNDER MASK .7-138 Support Instructions . . . . . . . . . . . . 9-1
STORE CLOCK . . . . . . . . . . . . . . 7-138 Registers And Controls . . . . . . . . . . . . . 9-2
STORE CLOCK EXTENDED . . . . . . . 7-139 Floating-Point Registers . . . . . . . . . . . 9-2
STORE HALFWORD . . . . . . . . . . . 7-141 Additional Floating-Point (AFP)
STORE MULTIPLE . . . . . . . . . . . . 7-141 Registers . . . . . . . . . . . . . . . . 9-2
STORE MULTIPLE HIGH . . . . . . . . . 7-142 Valid Floating-Point-Register
STORE PAIR TO QUADWORD . . . . . 7-142 Designations . . . . . . . . . . . . . . 9-2
STORE REVERSED . . . . . . . . . . . . 7-142 Floating-Point-Control (FPC) Register . . . 9-2
SUBTRACT . . . . . . . . . . . . . . . . . 7-143 AFP-Register-Control Bit . . . . . . . . . . 9-2
SUBTRACT HALFWORD . . . . . . . . . 7-144 Explicit Rounding Methods . . . . . . . . . 9-3
SUBTRACT LOGICAL . . . . . . . . . . . 7-144 Summary of Rounding Action . . . . . . 9-3
SUBTRACT LOGICAL WITH BORROW .7-145 Comparison of BFP and HFP Number
SUPERVISOR CALL . . . . . . . . . . . 7-146 Representations . . . . . . . . . . . . . . . . 9-4
TEST ADDRESSING MODE . . . . . . . 7-146 BFP and HFP Number Ranges . . . . . . 9-4
TEST AND SET . . . . . . . . . . . . . . 7-146

viii z/Architecture Principles of Operation


Equivalent BFP and HFP Number SET CLOCK COMPARATOR . . . . . . 10-86
Representations . . . . . . . . . . . . . . 9-4 SET CLOCK PROGRAMMABLE FIELD .10-86
Instructions . . . . . . . . . . . . . . . . . . . . 9-8 SET CPU TIMER . . . . . . . . . . . . . . 10-86
CONVERT BFP TO HFP . . . . . . . . . . 9-10 SET PREFIX . . . . . . . . . . . . . . . . 10-87
CONVERT HFP TO BFP . . . . . . . . . . 9-11 SET PSW KEY FROM ADDRESS . . . . 10-87
LOAD . . . . . . . . . . . . . . . . . . . . . 9-12 SET SECONDARY ASN . . . . . . . . . 10-88
LOAD ZERO . . . . . . . . . . . . . . . . . 9-13 SET STORAGE KEY EXTENDED . . . . 10-91
STORE . . . . . . . . . . . . . . . . . . . . 9-13 SET SYSTEM MASK . . . . . . . . . . . 10-91
Summary of All Floating-Point Instructions . . 9-13 SIGNAL PROCESSOR . . . . . . . . . . 10-91
STORE CLOCK COMPARATOR . . . . 10-93
Chapter 10. Control Instructions . . . . . . 10-1 STORE CONTROL . . . . . . . . . . . . 10-93
BRANCH AND SET AUTHORITY . . . . . 10-6 STORE CPU ADDRESS . . . . . . . . . 10-94
BRANCH AND STACK . . . . . . . . . . 10-10 STORE CPU ID . . . . . . . . . . . . . . 10-94
BRANCH IN SUBSPACE GROUP . . . . 10-13 STORE CPU TIMER . . . . . . . . . . . . 10-95
COMPARE AND SWAP AND PURGE . 10-18 STORE FACILITY LIST . . . . . . . . . . 10-95
DIAGNOSE . . . . . . . . . . . . . . . . . 10-20 STORE PREFIX . . . . . . . . . . . . . . 10-95
EXTRACT AND SET EXTENDED STORE REAL ADDRESS . . . . . . . . . 10-96
AUTHORITY . . . . . . . . . . . . . . 10-20 STORE SYSTEM INFORMATION . . . . 10-97
EXTRACT PRIMARY ASN . . . . . . . . 10-20 STORE THEN AND SYSTEM MASK . 10-107
EXTRACT SECONDARY ASN . . . . . . 10-21 STORE THEN OR SYSTEM MASK . . 10-107
EXTRACT STACKED REGISTERS . . . 10-21 STORE USING REAL ADDRESS . . . 10-107
EXTRACT STACKED STATE . . . . . . 10-23 TEST ACCESS . . . . . . . . . . . . . . 10-108
INSERT ADDRESS SPACE CONTROL .10-26 TEST BLOCK . . . . . . . . . . . . . . . 10-110
INSERT PSW KEY . . . . . . . . . . . . . 10-27 TEST PROTECTION . . . . . . . . . . 10-113
INSERT STORAGE KEY EXTENDED . 10-27 TRACE . . . . . . . . . . . . . . . . . . 10-115
INSERT VIRTUAL STORAGE KEY . . . 10-28 TRAP . . . . . . . . . . . . . . . . . . . 10-116
INVALIDATE PAGE TABLE ENTRY . . . 10-29
LOAD ADDRESS SPACE Chapter 11. Machine-Check Handling . . . 11-1
PARAMETERS . . . . . . . . . . . . . 10-30 Machine-Check Detection . . . . . . . . . . . 11-2
LOAD CONTROL . . . . . . . . . . . . . 10-39 Correction of Machine Malfunctions . . . . . . 11-2
LOAD PSW . . . . . . . . . . . . . . . . . 10-39 Error Checking and Correction . . . . . . . 11-2
LOAD PSW EXTENDED . . . . . . . . . 10-40 CPU Retry . . . . . . . . . . . . . . . . . . . 11-2
LOAD REAL ADDRESS . . . . . . . . . . 10-41 Effects of CPU Retry . . . . . . . . . . . 11-3
LOAD USING REAL ADDRESS . . . . . 10-46 Checkpoint Synchronization . . . . . . . 11-3
MODIFY STACKED STATE . . . . . . . 10-46 Handling of Machine Checks during
MOVE PAGE . . . . . . . . . . . . . . . . 10-48 Checkpoint Synchronization . . . . . 11-3
MOVE TO PRIMARY . . . . . . . . . . . 10-50 Checkpoint-Synchronization Operations 11-3
MOVE TO SECONDARY . . . . . . . . . 10-50 Checkpoint-Synchronization Action . . . 11-4
MOVE WITH DESTINATION KEY . . . . 10-52 Channel-Subsystem Recovery . . . . . . . 11-4
MOVE WITH KEY . . . . . . . . . . . . . 10-53 Unit Deletion . . . . . . . . . . . . . . . . . 11-4
MOVE WITH SOURCE KEY . . . . . . . 10-54 Handling of Machine Checks . . . . . . . . . 11-5
PAGE IN . . . . . . . . . . . . . . . . . . 10-55 Validation . . . . . . . . . . . . . . . . . . . 11-5
PAGE OUT . . . . . . . . . . . . . . . . . 10-56 Invalid CBC in Storage . . . . . . . . . . . 11-6
PROGRAM CALL . . . . . . . . . . . . . 10-57 Programmed Validation of Storage . . . 11-7
PROGRAM RETURN . . . . . . . . . . . 10-70 Invalid CBC in Storage Keys . . . . . . . . 11-7
PROGRAM TRANSFER . . . . . . . . . . 10-74 Invalid CBC in Registers . . . . . . . . . 11-10
PURGE ALB . . . . . . . . . . . . . . . . 10-79 Check-Stop State . . . . . . . . . . . . . . . 11-11
PURGE TLB . . . . . . . . . . . . . . . . 10-80 System Check Stop . . . . . . . . . . . 11-11
RESET REFERENCE BIT EXTENDED . 10-80 Machine-Check Interruption . . . . . . . . . 11-11
RESUME PROGRAM . . . . . . . . . . . 10-81 Exigent Conditions . . . . . . . . . . . . . 11-11
SET ADDRESS SPACE CONTROL . . . 10-83 Repressible Conditions . . . . . . . . . . 11-12
SET ADDRESS SPACE CONTROL Interruption Action . . . . . . . . . . . . . 11-12
FAST . . . . . . . . . . . . . . . . . . 10-83 Point of Interruption . . . . . . . . . . . . 11-14
SET CLOCK . . . . . . . . . . . . . . . . 10-85 Machine-Check-Interruption Code . . . . . . 11-15

Contents ix
Subclass . . . . . . . . . . . . . . . . . . . 11-16 Machine-Check Masking . . . . . . . . . . . 11-24
System Damage . . . . . . . . . . . . 11-16 Channel-Report-Pending Subclass
Instruction-Processing Damage . . . . 11-16 Mask . . . . . . . . . . . . . . . . . 11-24
System Recovery . . . . . . . . . . . . 11-16 Recovery Subclass Mask . . . . . . . 11-25
Timing-Facility Damage . . . . . . . . 11-16 Degradation Subclass Mask . . . . . . 11-25
External Damage . . . . . . . . . . . . 11-17 External-Damage Subclass Mask . . . 11-25
Degradation . . . . . . . . . . . . . . . 11-17 Warning Subclass Mask . . . . . . . . 11-25
Warning . . . . . . . . . . . . . . . . . 11-17 Machine-Check Logout . . . . . . . . . . . . 11-25
Channel Report Pending . . . . . . . . 11-17 Summary of Machine-Check Masking . . . 11-25
Service-Processor Damage . . . . . . 11-18
Channel-Subsystem Damage . . . . . 11-18 Chapter 12. Operator Facilities . . . . . . . 12-1
Subclass Modifiers . . . . . . . . . . . . . 11-18 Manual Operation . . . . . . . . . . . . . . . . 12-1
Backed Up . . . . . . . . . . . . . . . . 11-18 Basic Operator Facilities . . . . . . . . . . . . 12-1
Delayed Access Exception . . . . . . . 11-18 Address-Compare Controls . . . . . . . . . 12-1
Ancillary Report . . . . . . . . . . . . . 11-18 Alter-and-Display Controls . . . . . . . . . 12-2
Synchronous Architectural-Mode Indicator . . . . . . . . 12-2
Machine-Check-Interruption Conditions 11-18 Architectural-Mode-Selection Controls . . . 12-2
Processing Backup . . . . . . . . . . . 11-18 Check-Stop Indicator . . . . . . . . . . . . 12-3
Processing Damage . . . . . . . . . . 11-19 IML Controls . . . . . . . . . . . . . . . . . 12-3
Storage Errors . . . . . . . . . . . . . . . 11-19 Interrupt Key . . . . . . . . . . . . . . . . . 12-3
Storage Error Uncorrected . . . . . . . 11-19 Load Indicator . . . . . . . . . . . . . . . . 12-3
Storage Error Corrected . . . . . . . . 11-20 Load-Clear Key . . . . . . . . . . . . . . . . 12-3
Storage-Key Error Uncorrected . . . . 11-20 Load-Normal Key . . . . . . . . . . . . . . . 12-3
Storage Degradation . . . . . . . . . . 11-20 Load-Unit-Address Controls . . . . . . . . . 12-3
Indirect Storage Error . . . . . . . . . . 11-20 Manual Indicator . . . . . . . . . . . . . . . 12-3
Machine-Check Interruption-Code Power Controls . . . . . . . . . . . . . . . . 12-4
Validity Bits . . . . . . . . . . . . . . . 11-21 Rate Control . . . . . . . . . . . . . . . . . 12-4
PSW-MWP Validity . . . . . . . . . . . 11-21 Restart Key . . . . . . . . . . . . . . . . . . 12-4
PSW Mask and Key Validity . . . . . . 11-21 Start Key . . . . . . . . . . . . . . . . . . . 12-4
PSW Program-Mask and Stop Key . . . . . . . . . . . . . . . . . . . 12-4
Condition-Code Validity . . . . . . 11-21 Store-Status Key . . . . . . . . . . . . . . . 12-5
PSW-Instruction-Address Validity . . . 11-21 System-Reset-Clear Key . . . . . . . . . . 12-5
Failing-Storage-Address Validity . . . 11-21 System-Reset-Normal Key . . . . . . . . . 12-5
External-Damage-Code Validity . . . . 11-21 Test Indicator . . . . . . . . . . . . . . . . . 12-5
Floating-Point-Register Validity . . . . 11-21 TOD-Clock Control . . . . . . . . . . . . . . 12-5
General-Register Validity . . . . . . . . 11-21 Wait Indicator . . . . . . . . . . . . . . . . . 12-6
Control-Register Validity . . . . . . . . 11-21 Multiprocessing Configurations . . . . . . . . 12-6
Storage Logical Validity . . . . . . . . 11-22
Access-Register Validity . . . . . . . . 11-22 Chapter 13. I/O Overview . . . . . . . . . . 13-1
TOD-Programmable-Register Validity .11-22 Input/Output (I/O) . . . . . . . . . . . . . . . . 13-1
Floating-Point-Control-Register The Channel Subsystem . . . . . . . . . . . . 13-1
Validity . . . . . . . . . . . . . . . . 11-22 Subchannels . . . . . . . . . . . . . . . . . 13-2
CPU-Timer Validity . . . . . . . . . . . 11-22 Attachment of Input/Output Devices . . . . . 13-2
Clock-Comparator Validity . . . . . . . 11-22 Channel Paths . . . . . . . . . . . . . . . . 13-2
Machine-Check Extended Interruption Control Units . . . . . . . . . . . . . . . . . 13-4
Information . . . . . . . . . . . . . . . . . 11-22 I/O Devices . . . . . . . . . . . . . . . . . . 13-4
Register-Save Areas . . . . . . . . . . . . 11-22 I/O Addressing . . . . . . . . . . . . . . . . . . 13-5
External-Damage Code . . . . . . . . . . 11-23 Channel-Path Identifier . . . . . . . . . . . 13-5
Failing-Storage Address . . . . . . . . . . 11-23 Subchannel Number . . . . . . . . . . . . . 13-5
Handling of Machine-Check Conditions . . 11-23 Device Number . . . . . . . . . . . . . . . . 13-5
Floating Interruption Conditions . . . . . 11-23 Device Identifier . . . . . . . . . . . . . . . 13-5
Floating Machine-Check-Interruption Execution of I/O Operations . . . . . . . . . . 13-6
Conditions . . . . . . . . . . . . . . 11-24 Start-Function Initiation . . . . . . . . . . . 13-6
Floating I/O Interruptions . . . . . . . . 11-24 Path Management . . . . . . . . . . . . . . 13-6

x z/Architecture Principles of Operation


Channel-Program Execution . . . . . . . . 13-7 Channel-Command Word . . . . . . . . . 15-26
Conclusion of I/O Operations . . . . . . . . 13-7 Command Code . . . . . . . . . . . . . . 15-28
I/O Interruptions . . . . . . . . . . . . . . . 13-9 Designation of Storage Area . . . . . . . 15-28
Chaining . . . . . . . . . . . . . . . . . . . 15-30
Chapter 14. I/O Instructions . . . . . . . . . 14-1 Data Chaining . . . . . . . . . . . . . . 15-32
I/O-Instruction Formats . . . . . . . . . . . . . 14-1 Command Chaining . . . . . . . . . . . 15-33
I/O-Instruction Execution . . . . . . . . . . . . 14-1 Skipping . . . . . . . . . . . . . . . . . . . 15-34
Serialization . . . . . . . . . . . . . . . . . . 14-1 Program-Controlled Interruption . . . . . 15-34
Operand Access . . . . . . . . . . . . . . . 14-1 CCW Indirect Data Addressing . . . . . . 15-35
Condition Code . . . . . . . . . . . . . . . . 14-2 Suspension of Channel-Program
Program Exceptions . . . . . . . . . . . . . 14-2 Execution . . . . . . . . . . . . . . . . 15-37
Instructions . . . . . . . . . . . . . . . . . . . . 14-2 Commands and Flags . . . . . . . . . . . 15-39
CANCEL SUBCHANNEL . . . . . . . . . . 14-4 Branching in Channel Programs . . . . . 15-40
CLEAR SUBCHANNEL . . . . . . . . . . . 14-4 Transfer in Channel . . . . . . . . . . . 15-40
HALT SUBCHANNEL . . . . . . . . . . . . 14-5 Command Retry . . . . . . . . . . . . . . 15-41
MODIFY SUBCHANNEL . . . . . . . . . . 14-7 Concluding I/O Operations Prior to Initiation 15-41
RESET CHANNEL PATH . . . . . . . . . . 14-8 Concluding I/O Operations during Initiation .15-41
RESUME SUBCHANNEL . . . . . . . . . . 14-9 Immediate Conclusion of I/O Operations . . 15-42
SET ADDRESS LIMIT . . . . . . . . . . . 14-11 Concluding I/O Operations During Data
SET CHANNEL MONITOR . . . . . . . . 14-12 Transfer . . . . . . . . . . . . . . . . . . 15-42
START SUBCHANNEL . . . . . . . . . . 14-14 Channel-Path-Reset Function . . . . . . . . 15-44
STORE CHANNEL PATH STATUS . . . 14-15 Channel-Path-Reset-Function Signaling . 15-44
STORE CHANNEL REPORT WORD . . 14-16 Channel-Path-Reset
STORE SUBCHANNEL . . . . . . . . . . 14-17 Function-Completion Signaling . . . . 15-44
TEST PENDING INTERRUPTION . . . . 14-17
TEST SUBCHANNEL . . . . . . . . . . . 14-19 Chapter 16. I/O Interruptions . . . . . . . . 16-1
Interruption Conditions . . . . . . . . . . . . . 16-2
Chapter 15. Basic I/O Functions . . . . . . 15-1 Intermediate Interruption Condition . . . . 16-4
Control of Basic I/O Functions . . . . . . . . . 15-1 Primary Interruption Condition . . . . . . . 16-4
Subchannel-Information Block . . . . . . . 15-1 Secondary Interruption Condition . . . . . 16-4
Path-Management-Control Word . . . . 15-2 Alert Interruption Condition . . . . . . . . . 16-4
Subchannel-Status Word . . . . . . . . . 15-7 Priority of Interruptions . . . . . . . . . . . . . 16-5
Model-Dependent Area . . . . . . . . . . 15-7 Interruption Action . . . . . . . . . . . . . . . . 16-5
Summary of Modifiable Fields . . . . . . 15-7 Interruption-Response Block . . . . . . . . . . 16-6
Channel-Path Allegiance . . . . . . . . . . . 15-10 Subchannel-Status Word . . . . . . . . . . . . 16-6
Working Allegiance . . . . . . . . . . . . . 15-11 Subchannel Key . . . . . . . . . . . . . . 16-8
Active Allegiance . . . . . . . . . . . . . . 15-11 Suspend Control (S) . . . . . . . . . . . 16-8
Dedicated Allegiance . . . . . . . . . . . 15-11 Extended-Status-Word Format (L) . . . 16-8
Channel-Path Availability . . . . . . . . . 15-12 Deferred Condition Code (CC) . . . . . 16-8
Control-Unit Type . . . . . . . . . . . . . 15-12 Format (F) . . . . . . . . . . . . . . . . 16-10
Clear Function . . . . . . . . . . . . . . . . . 15-13 Prefetch (P) . . . . . . . . . . . . . . . 16-10
Clear-Function Path Management . . . . 15-13 Initial-Status-Interruption Control (I) . . 16-11
Clear-Function Subchannel Modification .15-13 Address-Limit-Checking Control (A) . 16-11
Clear-Function Signaling and Suppress-Suspended Interruption (U) .16-11
Completion . . . . . . . . . . . . . . . 15-14 Subchannel-Control Field . . . . . . . . . 16-11
Halt Function . . . . . . . . . . . . . . . . . . 15-14 Zero Condition Code (Z) . . . . . . . . 16-11
Halt-Function Path Management . . . . . 15-15 Extended Control (E) . . . . . . . . . . 16-11
Halt-Function Signaling and Completion .15-15 Path Not Operational (N) . . . . . . . . 16-12
Start Function and Resume Function . . . . 15-17 Function Control (FC) . . . . . . . . . 16-12
Start-Function and Resume-Function Activity Control (AC) . . . . . . . . . . 16-13
Path Management . . . . . . . . . . . 15-18 Status Control (SC) . . . . . . . . . . . 16-16
Execution of I/O Operations . . . . . . . . . 15-20 CCW-Address Field . . . . . . . . . . . . 16-18
Blocking of Data . . . . . . . . . . . . . . 15-21 Device-Status Field . . . . . . . . . . . . 16-23
Operation-Request Block . . . . . . . . . 15-21 Subchannel-Status Field . . . . . . . . . 16-23

Contents xi
Program-Controlled Interruption . . . . 16-23 Incorrect-Length-Indication Suppression . . 17-18
Incorrect Length . . . . . . . . . . . . . 16-23 Concurrent Sense . . . . . . . . . . . . . . . 17-18
Program Check . . . . . . . . . . . . . 16-24 Channel-Subsystem Recovery . . . . . . . . 17-19
Protection Check . . . . . . . . . . . . 16-26 Channel Report . . . . . . . . . . . . . . . 17-19
Channel-Data Check . . . . . . . . . . 16-26 Channel-Report Word . . . . . . . . . . . 17-21
Channel-Control Check . . . . . . . . 16-27 Channel Subsystem I/O-Priority Facility . . 17-22
Interface-Control Check . . . . . . . . 16-28 Number of Channel Subsystem
Chaining Check . . . . . . . . . . . . . 16-29 Priority Levels . . . . . . . . . . . . 17-23
Count Field . . . . . . . . . . . . . . . . . 16-29
Extended-Status Word . . . . . . . . . . . . 16-32 Chapter 18. Hexadecimal-Floating-Point
Extended-Status Format 0 . . . . . . . . 16-32 Instructions . . . . . . . . . . . . . . . . . 18-1
Subchannel Logout . . . . . . . . . . . 16-32 HFP Arithmetic . . . . . . . . . . . . . . . . . . 18-1
Extended-Report Word . . . . . . . . . 16-36 HFP Number Representation . . . . . . . . 18-1
Failing-Storage Address . . . . . . . . 16-37 Normalization . . . . . . . . . . . . . . . . . 18-3
Secondary-CCW Address . . . . . . . 16-38 HFP Data Format . . . . . . . . . . . . . . 18-3
Extended-Status Format 1 . . . . . . . . 16-38 Instructions . . . . . . . . . . . . . . . . . . . . 18-4
Extended-Status Format 2 . . . . . . . . 16-38 ADD NORMALIZED . . . . . . . . . . . . . 18-8
Extended-Status Format 3 . . . . . . . . 16-39 ADD UNNORMALIZED . . . . . . . . . . . 18-9
Extended-Control Word . . . . . . . . . . . . 16-40 COMPARE . . . . . . . . . . . . . . . . . 18-10
CONVERT FROM FIXED . . . . . . . . . 18-11
Chapter 17. I/O Support Functions . . . . 17-1 CONVERT TO FIXED . . . . . . . . . . . 18-11
Channel-Subsystem Monitoring . . . . . . . . 17-1 DIVIDE . . . . . . . . . . . . . . . . . . . 18-12
Channel-Subsystem Timing . . . . . . . . . 17-1 HALVE . . . . . . . . . . . . . . . . . . . . 18-13
Channel-Subsystem Timer . . . . . . . . 17-2 LOAD AND TEST . . . . . . . . . . . . . 18-14
Measurement-Block Update . . . . . . . . 17-2 LOAD COMPLEMENT . . . . . . . . . . . 18-14
Measurement Block . . . . . . . . . . . . 17-3 LOAD FP INTEGER . . . . . . . . . . . . 18-15
Measurement-Block Origin . . . . . . . . 17-5 LOAD LENGTHENED . . . . . . . . . . . 18-15
Measurement-Block Key . . . . . . . . . 17-6 LOAD NEGATIVE . . . . . . . . . . . . . 18-16
Measurement-Block Index . . . . . . . . 17-6 LOAD POSITIVE . . . . . . . . . . . . . . 18-16
Measurement-Block-Update Mode . . . 17-6 LOAD ROUNDED . . . . . . . . . . . . . 18-17
Measurement-Block-Update Enable . . 17-6 MULTIPLY . . . . . . . . . . . . . . . . . 18-18
Control-Unit-Queuing Measurement . . 17-7 SQUARE ROOT . . . . . . . . . . . . . . 18-19
Control-Unit-Defer Time . . . . . . . . . 17-7 SUBTRACT NORMALIZED . . . . . . . . 18-21
Device-Active-Only Measurement . . . . 17-7 SUBTRACT UNNORMALIZED . . . . . . 18-21
Time-Interval-Measurement Accuracy . 17-7
Device-Connect-Time Measurement . . . . 17-8 Chapter 19. Binary-Floating-Point
Device-Connect-Time-Measurement Instructions . . . . . . . . . . . . . . . . . 19-1
Mode . . . . . . . . . . . . . . . . . . 17-8 Binary-Floating-Point Facility . . . . . . . . . . 19-1
Device-Connect-Time-Measurement Floating-Point-Control (FPC) Register . . . 19-2
Enable . . . . . . . . . . . . . . . . . 17-8 IEEE Masks and Flags . . . . . . . . . . 19-3
Signals and Resets . . . . . . . . . . . . . . . 17-9 FPC DXC Byte . . . . . . . . . . . . . . 19-3
Signals . . . . . . . . . . . . . . . . . . . . . 17-9 Operations on the FPC Register . . . . 19-3
Halt Signal . . . . . . . . . . . . . . . . . 17-9 BFP Arithmetic . . . . . . . . . . . . . . . . . . 19-4
Clear Signal . . . . . . . . . . . . . . . . 17-9 BFP Data Formats . . . . . . . . . . . . . . 19-4
Reset Signal . . . . . . . . . . . . . . . 17-10 BFP Short Format . . . . . . . . . . . . . 19-4
Resets . . . . . . . . . . . . . . . . . . . . 17-10 BFP Long Format . . . . . . . . . . . . . 19-4
Channel-Path Reset . . . . . . . . . . 17-10 BFP Extended Format . . . . . . . . . . 19-4
I/O-System Reset . . . . . . . . . . . . 17-10 Biased Exponent . . . . . . . . . . . . . 19-4
Externally Initiated Functions . . . . . . . . 17-14 Significand . . . . . . . . . . . . . . . . . 19-4
Initial Program Loading . . . . . . . . . . 17-15 Values of Nonzero Numbers . . . . . . 19-4
Reconfiguration of the I/O System . . . . 17-17 Classes of BFP Data . . . . . . . . . . . . 19-5
Status Verification . . . . . . . . . . . . . . . 17-17 Zeros . . . . . . . . . . . . . . . . . . . . 19-6
Address-Limit Checking . . . . . . . . . . . 17-17 Denormalized Numbers . . . . . . . . . 19-6
Configuration Alert . . . . . . . . . . . . . . 17-18 Normalized Numbers . . . . . . . . . . . 19-6

xii z/Architecture Principles of Operation


Infinities . . . . . . . . . . . . . . . . . . 19-6 Instruction-Use Examples . . . . . . . . . . . A-6
Signaling and Quiet NaNs . . . . . . . . 19-6 Machine Format . . . . . . . . . . . . . . . A-7
BFP-Format Conversion . . . . . . . . . . . 19-7 Assembler-Language Format . . . . . . . . A-7
BFP Rounding . . . . . . . . . . . . . . . . 19-7 Addressing Mode in Examples . . . . . A-7
Rounding Mode . . . . . . . . . . . . . . 19-7 General Instructions . . . . . . . . . . . . . . . A-7
Normalization and Denormalization . . . . 19-8 ADD HALFWORD (AH) . . . . . . . . . . . A-7
BFP Comparison . . . . . . . . . . . . . . . 19-8 AND (N, NC, NI, NR) . . . . . . . . . . . . A-8
Condition Codes for BFP Instructions . . . 19-9 NI Example . . . . . . . . . . . . . . . . A-8
Remainder . . . . . . . . . . . . . . . . . . 19-9 Linkage Instructions (BAL, BALR, BAS,
IEEE Exception Conditions . . . . . . . . 19-10 BASR, BASSM, BSM) . . . . . . . . . . . A-8
IEEE Invalid Operation . . . . . . . . . 19-10 Other BALR and BASR Examples . . . A-9
IEEE Division-By-Zero . . . . . . . . . 19-11 BRANCH AND STACK (BAKR) . . . . . A-10
IEEE Overflow . . . . . . . . . . . . . . 19-11 BAKR Example 1 . . . . . . . . . . . . A-10
IEEE Underflow . . . . . . . . . . . . . 19-12 BAKR Example 2 . . . . . . . . . . . . A-11
IEEE Inexact . . . . . . . . . . . . . . . 19-12 BAKR Example 3 . . . . . . . . . . . . A-11
Result Figures . . . . . . . . . . . . . . . . . 19-13 BRANCH ON CONDITION (BC, BCR) . A-11
Data-Exception Codes (DXC) and BRANCH ON COUNT (BCT, BCTR) . . A-12
Abbreviations . . . . . . . . . . . . . . 19-14 BRANCH ON INDEX HIGH (BXH) . . . . A-12
Instructions . . . . . . . . . . . . . . . . . . . 19-14 BXH Example 1 . . . . . . . . . . . . . A-12
ADD . . . . . . . . . . . . . . . . . . . . . 19-18 BXH Example 2 . . . . . . . . . . . . . A-13
COMPARE . . . . . . . . . . . . . . . . . 19-23 BRANCH ON INDEX LOW OR EQUAL
COMPARE AND SIGNAL . . . . . . . . . 19-24 (BXLE) . . . . . . . . . . . . . . . . . . A-13
CONVERT FROM FIXED . . . . . . . . . 19-26 BXLE Example 1 . . . . . . . . . . . . A-13
CONVERT TO FIXED . . . . . . . . . . . 19-26 BXLE Example 2 . . . . . . . . . . . . A-14
DIVIDE . . . . . . . . . . . . . . . . . . . 19-29 COMPARE AND FORM CODEWORD
DIVIDE TO INTEGER . . . . . . . . . . . 19-29 (CFC) . . . . . . . . . . . . . . . . . . . A-14
EXTRACT FPC . . . . . . . . . . . . . . . 19-34 COMPARE HALFWORD (CH) . . . . . . A-14
LOAD AND TEST . . . . . . . . . . . . . 19-35 COMPARE LOGICAL (CL, CLC, CLI,
LOAD COMPLEMENT . . . . . . . . . . . 19-35 CLR) . . . . . . . . . . . . . . . . . . . . A-14
LOAD FP INTEGER . . . . . . . . . . . . 19-36 CLC Example . . . . . . . . . . . . . . A-14
LOAD FPC . . . . . . . . . . . . . . . . . 19-37 CLI Example . . . . . . . . . . . . . . . A-15
LOAD LENGTHENED . . . . . . . . . . . 19-38 CLR Example . . . . . . . . . . . . . . A-15
LOAD NEGATIVE . . . . . . . . . . . . . 19-38 COMPARE LOGICAL CHARACTERS
LOAD POSITIVE . . . . . . . . . . . . . . 19-39 UNDER MASK (CLM) . . . . . . . . . . A-15
LOAD ROUNDED . . . . . . . . . . . . . 19-39 COMPARE LOGICAL LONG (CLCL) . . A-16
MULTIPLY . . . . . . . . . . . . . . . . . 19-40 COMPARE LOGICAL STRING (CLST) . A-17
MULTIPLY AND ADD . . . . . . . . . . . 19-42 CONVERT TO BINARY (CVB) . . . . . . A-18
MULTIPLY AND SUBTRACT . . . . . . . 19-42 CONVERT TO DECIMAL (CVD) . . . . . A-18
SET FPC . . . . . . . . . . . . . . . . . . 19-44 DIVIDE (D, DR) . . . . . . . . . . . . . . . A-19
SET ROUNDING MODE . . . . . . . . . 19-44 EXCLUSIVE OR (X, XC, XI, XR) . . . . A-19
SQUARE ROOT . . . . . . . . . . . . . . 19-45 XC Example . . . . . . . . . . . . . . . A-19
STORE FPC . . . . . . . . . . . . . . . . 19-45 XI Example . . . . . . . . . . . . . . . A-20
SUBTRACT . . . . . . . . . . . . . . . . . 19-46 EXECUTE (EX) . . . . . . . . . . . . . . . A-21
TEST DATA CLASS . . . . . . . . . . . . 19-46 INSERT CHARACTERS UNDER MASK
(ICM) . . . . . . . . . . . . . . . . . . . A-21
Appendix A. Number Representation and LOAD (L, LR) . . . . . . . . . . . . . . . . A-22
Instruction-Use Examples . . . . . . . . . A-1 LOAD ADDRESS (LA) . . . . . . . . . . . A-22
Number Representation . . . . . . . . . . . . A-2 LOAD HALFWORD (LH) . . . . . . . . . A-23
Binary Integers . . . . . . . . . . . . . . . . A-2 MOVE (MVC, MVI) . . . . . . . . . . . . . A-23
Signed Binary Integers . . . . . . . . . . A-2 MVC Example . . . . . . . . . . . . . . A-23
Unsigned Binary Integers . . . . . . . . A-3 MVI Example . . . . . . . . . . . . . . A-24
Decimal Integers . . . . . . . . . . . . . . . A-4 MOVE INVERSE (MVCIN) . . . . . . . . A-24
Hexadecimal-Floating-Point Numbers . . . A-5 MOVE LONG (MVCL) . . . . . . . . . . . A-25
Conversion Example . . . . . . . . . . . . . A-6 MOVE NUMERICS (MVN) . . . . . . . . A-25

Contents xiii
MOVE STRING (MVST) . . . . . . . . . . A-26 MULTIPLY (MD, MDR, MDE, MDER,
MOVE WITH OFFSET (MVO) . . . . . . A-26 MXD, MXDR, MXR) . . . . . . . . . . . A-41
MOVE ZONES (MVZ) . . . . . . . . . . . A-27 Hexadecimal-Floating-Point-Number
MULTIPLY (M, MR) . . . . . . . . . . . . A-27 Conversion . . . . . . . . . . . . . . . . A-42
MULTIPLY HALFWORD (MH) . . . . . . A-27 Fixed Point to Hexadecimal Floating
OR (O, OC, OI, OR) . . . . . . . . . . . . A-28 Point . . . . . . . . . . . . . . . . . . A-42
OI Example . . . . . . . . . . . . . . . A-28 Hexadecimal Floating Point to Fixed
PACK (PACK) . . . . . . . . . . . . . . . A-28 Point . . . . . . . . . . . . . . . . . . A-42
SEARCH STRING (SRST) . . . . . . . . A-29 Multiprogramming and Multiprocessing
SRST Example 1 . . . . . . . . . . . . A-29 Examples . . . . . . . . . . . . . . . . . . A-43
SRST Example 2 . . . . . . . . . . . . A-29 Example of a Program Failure Using OR
SHIFT LEFT DOUBLE (SLDA) . . . . . . A-29 Immediate . . . . . . . . . . . . . . . . A-43
SHIFT LEFT SINGLE (SLA) . . . . . . . A-30 Conditional Swapping Instructions (CS,
STORE CHARACTERS UNDER MASK CDS) . . . . . . . . . . . . . . . . . . . A-44
(STCM) . . . . . . . . . . . . . . . . . . A-30 Setting a Single Bit . . . . . . . . . . . A-44
STORE MULTIPLE (STM) . . . . . . . . A-30 Updating Counters . . . . . . . . . . . A-45
TEST UNDER MASK (TM) . . . . . . . . A-31 Bypassing Post and Wait . . . . . . . . . A-45
TRANSLATE (TR) . . . . . . . . . . . . . A-31 Bypass Post Routine . . . . . . . . . . A-45
TRANSLATE AND TEST (TRT) . . . . . A-32 Bypass Wait Routine . . . . . . . . . . A-46
UNPACK (UNPK) . . . . . . . . . . . . . A-33 Lock/Unlock . . . . . . . . . . . . . . . . . A-46
UPDATE TREE (UPT) . . . . . . . . . . . A-34 Lock/Unlock with LIFO Queuing for
Decimal Instructions . . . . . . . . . . . . . . A-34 Contentions . . . . . . . . . . . . . . A-46
ADD DECIMAL (AP) . . . . . . . . . . . . A-34 Lock/Unlock with FIFO Queuing for
COMPARE DECIMAL (CP) . . . . . . . . A-34 Contentions . . . . . . . . . . . . . . A-47
DIVIDE DECIMAL (DP) . . . . . . . . . . A-34 Free-Pool Manipulation . . . . . . . . . . A-48
EDIT (ED) . . . . . . . . . . . . . . . . . . A-35 PERFORM LOCKED OPERATION (PLO) A-50
EDIT AND MARK (EDMK) . . . . . . . . A-36 Sorting Instructions . . . . . . . . . . . . . . A-51
MULTIPLY DECIMAL (MP) . . . . . . . . A-36 Tree Format . . . . . . . . . . . . . . . . . A-51
SHIFT AND ROUND DECIMAL (SRP) . A-37 Example of Use of Sort Instructions . . . A-53
Decimal Left Shift . . . . . . . . . . . . A-37
Decimal Right Shift . . . . . . . . . . . A-37 Appendix B. Lists of Instructions . . . . . B-1
Decimal Right Shift and Round . . . . A-38
Multiplying by a Variable Power of 10 . A-38 Appendix C. Condition-Code Settings . . C-1
ZERO AND ADD (ZAP) . . . . . . . . . . A-38
Hexadecimal-Floating-Point Instructions . . A-39 Appendix G. Table of Powers of 2 . . . . . G-1
ADD NORMALIZED (AD, ADR, AE, AER,
AXR) . . . . . . . . . . . . . . . . . . . . A-39 Appendix H. Hexadecimal Tables . . . . . H-1
ADD UNNORMALIZED (AU, AUR, AW,
AWR) . . . . . . . . . . . . . . . . . . . A-39 Appendix I. EBCDIC and Other Codes . . . I-1
COMPARE (CD, CDR, CE, CER) . . . . A-40
DIVIDE (DD, DDR, DE, DER) . . . . . . A-40 Index . . . . . . . . . . . . . . . . . . . . . . . X-1
HALVE (HDR, HER) . . . . . . . . . . . . A-41

xiv z/Architecture Principles of Operation


Notices
References in this publication to IBM products,
programs or services do not imply that IBM Trademarks
intends to make these available in all countries in
The following terms, denoted by an asterisk (*) at
which IBM operates. Any reference to an IBM
the first or most prominent occurrence in this pub-
product, program, or service is not intended to
lication, are trademarks of the International Busi-
state or imply that only IBM's product, program, or
ness Machines Corporation in the United States or
service may be used. Any functionally equivalent
other countries:
product, program, or service that does not infringe
any of IBM's intellectual property rights may be AIX/ESA
used instead of the IBM product, program, or BookMaster
service. Evaluation and verification of operation in CICS
conjunction with other products, except those DB2
expressly designated by IBM, is the user's respon- Enterprise Systems Architecture/370
sibility. Enterprise Systems Architecture/390
Enterprise Systems Connection Architecture
IBM may have patents or pending patent applica- ESA/370
tions covering subject matter in this document. ESA/390
The furnishing of this document does not give you ESCON
any license to these patents. You can send FICON
license inquiries, in writing, to the IBM Director of MVS/ESA
Licensing, IBM Corporation, 500 Columbus OS/390
Avenue, Thornwood, NY, 10594 USA. Processor Resource/Systems Manager
PR/SM
Sysplex Timer
System/370
VM/ESA
z/Architecture
z/OS

Copyright IBM Corp. 1990, 2000 xv


xvi z/Architecture Principles of Operation
Preface
This publication provides, for reference purposes, Largely because this publication is arranged for
a detailed z/Architecture* description. reference, certain words and phrases appear, of
necessity, earlier in the publication than the prin-
The publication applies only to systems operating cipal discussions explaining them. The reader
as defined by z/Architecture. For systems oper- who encounters a problem because of this
ating in accordance with the Enterprise Systems arrangement should refer to the index, which indi-
Architecture/390* (ESA/390*) definition, the IBM cates the location of the key description.
ESA/390 Principles of Operation, SA22-7201,
should be consulted. The information presented in this publication is
grouped in 19 chapters and several appendixes:
The publication describes each function at the
level of detail needed to prepare an assembler- Chapter 1, Introduction, highlights the major facili-
language program that relies on that function. It ties of z/Architecture.
does not, however, describe the notation and con-
ventions that must be employed in preparing such Chapter 2, Organization, describes the major
a program, for which the user must instead refer groupings within the systemmain storage,
to the appropriate assembler-language publication. expanded storage, the central processing unit
(CPU), the external time reference (ETR), and
The information in this publication is provided prin- input/outputwith some attention given to the
cipally for use by assembler-language program- composition and characteristics of those
mers, although anyone concerned with the groupings.
functional details of z/Architecture will find it
useful. Chapter 3, Storage, explains the information
formats, the addressing of storage, and the facili-
This publication is written as a reference and ties for storage protection. It also deals with
should not be considered an introduction or a text- dynamic address translation (DAT), which,
book. It assumes the user has a basic knowledge coupled with special programming support, makes
of data-processing systems. the use of a virtual storage possible.

All facilities discussed in this publication are not Chapter 4, Control, describes the facilities for the
necessarily available on every model. Further- switching of system status, for special externally
more, in some instances the definitions have been initiated operations, for debugging, and for timing.
structured to allow for some degree of It deals specifically with CPU states, control
extendibility, and therefore certain capabilities may modes, the program-status word (PSW), control
be described or implied that are not offered on registers, tracing, program-event recording, timing
any model. Examples of such capabilities are the facilities, resets, store status, and initial program
use of a 16-bit field in the subsystem-identification loading.
word to identify the channel subsystem, the size of
the CPU address, and the number of CPUs Chapter 5, Program Execution, explains the role of
sharing main storage. The allowance for this type instructions in program execution, looks in detail at
of extendibility should not be construed as instruction formats, and describes briefly the use
implying any intention by IBM to provide such of the program-status word (PSW), of branching,
capabilities. For information about the character- and of interruptions. It contains the principal
istics and availability of facilities on a specific description of the advanced address-space facili-
model, see the functional characteristics publica- ties that were introduced in ESA/370*. It also
tion for that model. details the aspects of program execution on one

z/Architecture, Enterprise Systems Architecture/390, ESA/390, and ESA/370 are trademarks of the International Business
Machines Corporation.

Copyright IBM Corp. 1990, 2000 xvii


CPU as observed by other CPUs and by channel Chapter 14, I/O Instructions, contains the
programs. description of the I/O instructions.

Chapter 6, Interruptions, details the mechanism Chapter 15, Basic I/O Functions, describes the
that permits the CPU to change its state as a basic I/O functions performed by the channel sub-
result of conditions external to the system, within system, including the initiation, control, and con-
the system, or within the CPU itself. Six classes clusion of I/O operations.
of interruptions are identified and described:
machine-check interruptions, program inter- Chapter 16, I/O Interruptions, covers I/O inter-
ruptions, supervisor-call interruptions, external ruptions and interruption conditions.
interruptions, input/output interruptions, and restart
interruptions. Chapter 17, I/O Support Functions, describes such
functions as channel-subsystem usage monitoring,
Chapter 7, General Instructions, contains detailed resets, initial-program loading, reconfiguration, and
descriptions of logical and binary-integer data channel-subsystem recovery.
formats and of all unprivileged instructions except
the decimal and floating-point instructions. Chapter 18, Hexadecimal-Floating-Point
Instructions, contains detailed descriptions of the
Chapter 8, Decimal Instructions, describes in hexadecimal-floating-point (HFP) data formats and
detail decimal data formats and the decimal the HFP instructions.
instructions.
Chapter 19, Binary-Floating-Point Instructions,
Chapter 9, Floating-Point Overview and Support contains detailed descriptions of the binary-
Instructions, includes an introduction to the floating-point (BFP) data formats and the BFP
floating-point operations, detailed descriptions of instructions.
those instructions common to both hexadecimal-
floating-point and binary-floating-point operations, The Appendixes include:
and summaries of all floating-point instructions. Information about number representation
Instruction-use examples
Chapter 10, Control Instructions, contains detailed Lists of the instructions arranged in several
descriptions of all of the semiprivileged and privi- sequences
leged instructions except for the I/O instructions. A summary of the condition-code settings
A table of the powers of 2
Chapter 11, Machine-Check Handling, describes
Tabular information helpful in dealing with
the mechanisms for detecting, correcting, and
hexadecimal numbers
reporting machine malfunctions.
A table of EBCDIC and other codes.
Chapter 12, Operator Facilities, describes the
basic manual functions and controls available for Size and Number Notation
operating and controlling the system.
In this publication, the letters K, M, G, T, P, and E
Chapters 13-17 of this publication provide a denote the multipliers 2, 2, 2, 2, 2, and
detailed definition of the functions performed by 2, respectively. Although the letters are bor-
the channel subsystem and the logical interface rowed from the decimal system and stand for kilo
between the CPU and the channel subsystem. (10), mega (10), giga (10), tera (10), peta
(10), and exa (10), they do not have the
Chapter 13, I/O Overview, provides a brief decimal meaning but instead represent the power
description of the basic components and operation of 2 closest to the corresponding power of 10.
of the channel subsystem. Their meaning in this publication is as follows:

xviii z/Architecture Principles of Operation


EBCDIC, ASCII, or any other code which can be
Symbol Value represented in eight or fewer bits per character.

K (kilo) 1,24 = 2
In this publication, unless otherwise specified, the

M (mega) 1,48,576 = 2 value given for a byte is the value obtained by
considering the bits of the byte to represent a
G (giga) 1,73,741,824 = 2 binary code. Thus, when a byte is said to contain
a zero, the value 00000000 binary, or 00 hex, is
T (tera) 1,99,511,627,776 = 2 meant, and not the value for an EBCDIC character

P (peta) 1,125,899,96,842,624 = 2 0, which would be F0 hex.

E (exa) 1,152,921,54,66,846,976 = 2 Other Publications

The following are some examples of the use of K, The parallel-I/O interface is described in the publi-
M, G, T, and E: cation IBM System/360 and System/370 I/O Inter-
face Channel to Control Unit Original Equipment
2,048 is expressed as 2K.
Manufacturers' Information, GA22-6974.
4,096 is expressed as 4K.
65,536 is expressed as 64K (not 65K).
The parallel-I/O channel-to-channel adapter is
2 is expressed as 16M.
described in the publication IBM Enterprise
2 is expressed as 2G.
Systems Architecture/390 Channel-to-Channel
2 is expressed as 4T.
Adapter for the System/360 and System/370 I/O
2 is expressed as 16E.
Interface, SA22-7091.
When the words thousand and million are
used, no special power-of-2 meaning is assigned The Enterprise Systems Connection Architecture*
to them. (ESCON*) I/O interface, referred to in this publi-
cation along with the FICON I/O interface as the
All numbers in this publication are in decimal serial-I/O interface, is described in the publication
unless they are explicitly noted as being in binary IBM Enterprise Systems Architecture/390 ESCON
or hexadecimal (hex). I/O Interface, SA22-7202.

The FICON I/O interface is described in the ANSI


Bytes, Characters, and Codes standards document Fibre Channel - Single-Byte
Although the System/360 architecture was ori-
Command Code Sets-2 (FC-SB-2).
ginally designed to support the Extended Binary-
The channel-to-channel adapter for the serial-I/O
Coded-Decimal Interchange Code (EBCDIC), the
interface is described in the publication IBM Enter-
instructions and data formats of the architecture
prise Systems Architecture/390 ESCON Channel-
are for the most part independent of the external
to-Channel-Adapter, SA22-7203.
code which is to be processed by the machine.
For most instructions, all 256 possible combina- The commands, status, and sense data that are
tions of bit patterns for a particular byte can be common to all I/O devices that comply with
processed, independent of the character which the z/Architecture are described in the publication IBM
bit pattern is intended to represent. For Enterprise Systems Architecture/390 Common
instructions which use the zoned format, and for I/O-Device Commands and Self Description,
those few instructions which are dependent on a SA22-7204.
particular external code, the instruction TRANS-
LATE may be used to convert data from one code The compression facility is described in the publi-
to another code. Thus, a machine operating in cation IBM Enterprise Systems Architecture/390
accordance with z/Architecture can process Data Compression, SA22-7208. The

Enterprise Systems Connection Architecture and ESCON are trademarks of the International Business Machines Corporation.

Preface xix
z/Architecture form of the COMPRESSION CALL The interpretive-execution facility is described in
instruction is described in this publication. the publication IBM 370-XA Interpretive Execution,
SA22-7095.

xx z/Architecture Principles of Operation


Chapter 1. Introduction
Highlights of z/Architecture . . . . . . . . . . . 1-1 The ESA/370 and 370-XA Base . . . . . . 1-11
General Instructions for 64-Bit Integers . . 1-2 System Program . . . . . . . . . . . . . . . . . 1-13
Other New General Instructions . . . . . . 1-2 Compatibility . . . . . . . . . . . . . . . . . . . 1-13
Floating-Point Instructions . . . . . . . . . . 1-4 Compatibility among z/Architecture
Control Instructions . . . . . . . . . . . . . 1-4 Systems . . . . . . . . . . . . . . . . . . 1-13
Trimodal Addressing . . . . . . . . . . . . . 1-4 Compatibility between z/Architecture and
Modal Instructions . . . . . . . . . . . . . 1-4 ESA/390 . . . . . . . . . . . . . . . . . 1-14
Effects on Bits 0-31 of a General Control-Program Compatibility . . . . . . 1-14
Register . . . . . . . . . . . . . . . . . 1-5 Problem-State Compatibility . . . . . . . 1-14
Extended-Translation Facility 2 . . . . . . . 1-5 Availability . . . . . . . . . . . . . . . . . . . . 1-14
The ESA/390 Base . . . . . . . . . . . . . . . 1-6

This publication provides, for reference purposes, A 64-bit addressing mode, in addition to the
a detailed description of z/Architecture. 24-bit and 31-bit addressing modes of
ESA/390, which are carried forward to
The architecture of a system defines its attributes z/Architecture.
as seen by the programmer, that is, the concep-
Both operand addresses and instruction
tual structure and functional behavior of the
addresses can be 64-bit addresses. The
machine, as distinct from the organization of the
program-status word (PSW) is expanded to 16
data flow, the logical design, the physical design,
bytes to contain the larger instruction address.
and the performance of any particular implementa-
The PSW also contains a newly assigned bit
tion. Several dissimilar machine implementations
that specifies the 64-bit addressing mode.
may conform to a single architecture. When the
execution of a set of programs on different Up to three additional levels of dynamic-
machine implementations produces the results address-translation (DAT) tables, called region
that are defined by a single architecture, the tables, for translating 64-bit virtual addresses.
implementations are considered to be compatible
A virtual address space may be specified
for those programs.
either by a segment-table designation as in
ESA/390 or by a region-table designation, and
either of these types of designation is called
Highlights of z/Architecture an address-space-control element (ASCE).
z/Architecture is the next step in the evolution An ASCE may alternatively be a real-space
from the System/360 to the System/370, designation that causes virtual addresses to
System/370 extended architecture (370-XA), be treated simply as real addresses without
Enterprise Systems Architecture/370* (ESA/370), the use of DAT tables.
and Enterprise Systems Architecture/390
An 8K-byte prefix area for containing larger
(ESA/390). z/Architecture includes all of the facili-
old and new PSWs and register save areas.
ties of ESA/390 except for the asynchronous-
pageout, asynchronous-data-mover, A SIGNAL PROCESSOR order for switching
program-call-fast, and vector facilities. between the ESA/390 and z/Architecture
z/Architecture also provides significant extensions, architectural modes.
as follows: Initial program loading sets the ESA/390 archi-
Sixty-four-bit general registers and control reg- tectural mode. The new SIGNAL
isters. PROCESSOR order then can be used to set
the z/Architecture mode or to return from

Enterprise Systems Architecture/370 is a trademark of the International Business Machines Corporation.

Copyright IBM Corp. 1990, 2000 1-1


z/Architecture to ESA/390. This order causes Other New General Instructions
all CPUs in the configuration always to be in
the same architectural mode. The other additional or significantly enhanced
Many new instructions, many of which operate general instructions of z/Architecture are high-
on 64-bit binary integers lighted as follows:
Some of the new instructions that do not operate ADD LOGICAL WITH CARRY and SUB-
on 64-bit binary integers have also been added to TRACT LOGICAL WITH BORROW operate
ESA/390. on either 32-bit or 64-bit unsigned binary inte-
gers and include a carry or borrow, as repres-
All of the ESA/390 instructions, except for those of ented by the leftmost bit of the two-bit
the four facilities named above, are included in condition code in the PSW, in the computa-
z/Architecture. tion. This can improve the performance of
operating on extended-precision integers (inte-
The bit positions of the general registers and gers longer than 64 bits).
control registers of z/Architecture are numbered
AND IMMEDIATE and OR IMMEDIATE
0-63. An ESA/390 instruction that operates on bit
combine a two-byte immediate operand with
positions 0-31 of a 32-bit register in ESA/390
any of the two bytes on two-byte boundaries
operates instead on bit positions 32-63 of a 64-bit
in a 64-bit general register.
register in z/Architecture.
BRANCH AND SAVE AND SET MODE and
General Instructions for 64-Bit BRANCH AND SET MODE are enhanced so
that they set bit 63 of the R general register
Integers to one if the current addressing mode is the
64-bit mode and they set the 64-bit
The 32-bit-binary-integer instructions of ESA/390
addressing mode if bit 63 of the R general
have new analogs in z/Architecture that operate
register is one. This allows pointer-directed
on 64-bit binary integers. There are two types of
linkages between programs in different
analogs:
addressing modes, including any of the 24-bit,
Analogs that use two 64-bit binary integers to 31-bit, and 64-bit modes.
produce a 64-bit binary integer. For example,
BRANCH RELATIVE AND SAVE LONG and
the ESA/390 ADD instruction (A for a storage-
BRANCH RELATIVE ON CONDITION LONG
to-register operation or AR for a register-to-
are like the BRANCH RELATIVE AND SAVE
register operation) has the analogs AG (adds
and BRANCH RELATIVE ON CONDITION
64 bits from storage to the contents of a 64-bit
instructions of ESA/390 except that the new
general register) and AGR (adds the contents
instructions use a 32-bit immediate field. This
of a 64-bit general register to the contents of
increases the target range available through
another 64-bit general register). These
relative branching.
analogs are distinguished by having G in
their mnemonics. COMPARE AND FORM CODEWORD is
enhanced so that, in the 64-bit addressing
Analogs that use a 64-bit binary integer and a
mode, the comparison unit is six bytes instead
32-bit binary integer to produce a 64-bit binary
of two and the resulting codeword is eight
integer. The 32-bit integer is either sign-
bytes instead of four. UPDATE TREE is
extended or extended on the left with zeros,
enhanced so that, in the 64-bit addressing
depending on whether the operation is signed
mode, a node is 16 bytes instead of eight and
or unsigned, respectively. For example, the
the codeword in a node is eight bytes instead
ESA/390 ADD (A or AR) instruction has the
of four. This improves the performance of
analogs AGF (adds 32 bits from storage to the
sorting records having long keys.
contents of a 64-bit general register) and
AGFR (adds the contents of bit positions DIVIDE LOGICAL and MULTIPLY LOGICAL
32-63 of a 64-bit general register to the con- provide operations on unsigned binary inte-
tents of another 64-bit general register). gers and produce either 32-bit or 64-bit quo-
These analogs are distinguished by having tients and remainders or products.
GF in their mnemonics.

1-2 z/Architecture Principles of Operation


DIVIDE SINGLE divides a 64-bit dividend by a 16-byte boundary). These instructions provide
32-bit or 64-bit divisor and produces a 64-bit quadword consistency (all bytes appear to be
quotient and remainder. MULTIPLY SINGLE loaded or stored concurrently in a
is enhanced so it can multiply a 64-bit multipli- multiple-CPU system). (Only the 64-bit form
cand by a 32-bit or 64-bit multiplier and of COMPARE DOUBLE AND SWAP also pro-
produce a 64-bit product. vides quadword consistency.)
EXTRACT PSW, extracts the entire current LOAD REVERSED and STORE REVERSED
PSW to allow determination of the current load or store a two-byte, four-byte, or eight-
machine state, for example, determination of byte unit in storage with the left-to-right
whether the CPU is in the problem state or sequence of the bytes reversed. LOAD
the supervisor state. REVERSED also can move a four-byte or
eight-byte unit between two general registers.
INSERT IMMEDIATE inserts a two-byte imme-
These operations allow conversion between
diate operand into a 64-bit general register on
little-endian and big-endian formats.
any of the two-byte boundaries in the register.
LOAD LOGICAL IMMEDIATE does the same PERFORM LOCKED OPERATION is
and also clears the remainder of the register. enhanced with two more sets of function
codes, with each set providing six different
LOAD ADDRESS RELATIVE LONG forms an
operations. One of the additional sets pro-
address relative to the current (unupdated)
vides operations on 64-bit operands in 64-bit
instruction address by means of a signed
general registers, and the other provides oper-
32-bit immediate field.
ations on 128-bit operands in a parameter list.
LOAD LOGICAL THIRTY ONE BITS places
ROTATE LEFT SINGLE LOGICAL obtains 32
the rightmost 31 bits of either a general reg-
bits or 64 bits from a general register, rotates
ister or a word in storage, with 33 zeros
them (the leftmost bit replaces the rightmost
appended on the left, in a general register.
bit), and places the result in another general
LOAD MULTIPLE DISJOINT loads the left- register (a nondestructive rotate).
most 32 bits of each register in a range of
SET ADDRESSING MODE can set any of the
general registers from one area in storage and
24-bit, 31-bit, and 64-bit addressing modes.
the rightmost 32 bits of each of those registers
from another area in storage. This is for use SHIFT LEFT SINGLE, SHIFT LEFT SINGLE
in place of a LOAD MULTIPLE HIGH instruc- LOGICAL, SHIFT RIGHT SINGLE, and SHIFT
tion and a 32-bit LOAD MULTIPLE instruction RIGHT SINGLE LOGICAL are enhanced with
when one of the storage areas is addressed 64-bit forms that obtain the source operand
by one of the registers loaded. from one general register and place the result
operand in another general register (a nonde-
LOAD MULTIPLE HIGH and STORE MUL-
structive shift).
TIPLE HIGH load or store the leftmost 32 bits
of each register in a range of general regis- TEST UNDER MASK HIGH and TEST
ters, allowing augmentation of existing pro- UNDER MASK LOW, which are ESA/390
grams that load or store the rightmost 32 bits instructions, are given the alternative name
by means of LOAD MULTIPLE and STORE TEST UNDER MASK, and two additional
MULTIPLE. (Sixty-four-bit forms of LOAD forms are added so that a two-byte immediate
MULTIPLE and STORE MULTIPLE also are operand can be used to test the bits of two
provided.) bytes located on any of the two-byte bounda-
ries in a 64-bit general register. (The
LOAD PAIR FROM QUADWORD and STORE
ESA/390 instruction TEST UNDER MASK,
PAIR TO QUADWORD operate between an
which uses a one-byte immediate operand to
even-odd pair of 64-bit general registers and a
test a byte in storage, continues to be pro-
quadword in storage (16 bytes aligned on a
vided.)

Chapter 1. Introduction 1-3


Floating-Point Instructions cation of whether z/Architecture is installed
and of whether it is active. This instruction is
The z/Architecture floating-point instructions are added also to ESA/390 and indicates also
the same as in ESA/390 except that instructions whether the new z/Architecture instructions
are added for converting between 64-bit signed that have been added to ESA/390 are avail-
binary integers and either hexadecimal or binary able. Real location 200 has previously con-
floating-point data. These new instructions have tained all zeros in most systems and can be
G in their mnemonics. examined by a problem-state program
whether or not STORE FACILITY LIST is
installed. The information stored at real
Control Instructions location 200 also indicates whether the
extended-translation facility 2 is installed.
The new or enhanced control instructions of
z/Architecture are highlighted as follows: STORE REAL ADDRESS is like LOAD REAL
ADDRESS except that STORE REAL
EXTRACT AND SET EXTENDED ADDRESS stores the resulting address
AUTHORITY is a privileged instruction for instead of placing it in a register.
changing the extended authorization index in
a control register. This enables real-space TRACE is enhanced to record optionally the
designations to be used more efficiently by contents of 64-bit general registers.
means of access lists.
EXTRACT STACKED REGISTERS is Trimodal Addressing
enhanced to extract optionally all 64 bits of
the contents of one or more saved general Trimodal addressing refers to the ability to switch
registers. between the 24-bit, 31-bit, and 64-bit addressing
modes. This switching can be done by means of:
EXTRACT STACKED STATE is enchanced to
extract optionally the entire contents of the The old instructions BRANCH AND SAVE
saved PSW, including a 64-bit instruction AND SET MODE and BRANCH AND SET
address. MODE. Both of these instructions set the
64-bit addressing mode if bit 63 of the R
LOAD CONTROL and STORE CONTROL are general register is one. If bit 63 is zero, the
enhanced for operating optionally on 64-bit instructions set the 24-bit or 31-bit addressing
control registers. mode if bit 32 of the register is zero or one,
LOAD PSW uses an eight-byte storage respectively.
operand as in ESA/390 and expands this The new instruction SET ADDRESSING
operand to a 16-byte z/Architecture PSW. MODE (SAM24, SAM31, and SAM64). The
LOAD PSW EXTENDED directly loads a instruction sets the 24-bit, 31-bit, or 64-bit
16-byte PSW. addressing mode as determined by the opera-
tion code.
LOAD REAL ADDRESS in its ESA/390 form
and in the 24-bit or 31-bit addressing mode
Modal Instructions
operates as in ESA/390 if the translation is
Trimodal addressing affects the general
successful and the obtained real address has
instructions only in the manner in which logical
a value less than 2G bytes. LOAD REAL
storage addresses are handled, except as follows.
ADDRESS in its ESA/390 form and in the
64-bit addressing mode, or in its enhanced The instructions BRANCH AND LINK,
z/Architecture form in any addressing mode, BRANCH AND SAVE, BRANCH AND SAVE
loads a 64-bit real address. AND SET MODE, BRANCH AND SET MODE,
and BRANCH RELATIVE AND SAVE place
LOAD USING REAL ADDRESS and STORE
information in bit positions 32-39 of general
USING REAL ADDRESS are enhanced to
register R as in ESA/390 in the 24-bit or
have optionally 64-bit operands.
31-bit addressing mode or place address bits
STORE FACILITY LIST is a privileged instruc- in those bit positions in the 64-bit addressing
tion that stores at real location 200 an indi-

1-4 z/Architecture Principles of Operation


mode. The new instruction BRANCH RELA- Extended-Translation Facility 2
TIVE AND SAVE LONG does the same.
The instructions BRANCH AND SAVE AND The extended-translation facility 2 may be avail-
SET MODE and BRANCH AND SET MODE able on a model implementing z/Architecture. The
place a zero in bit position 63 of general reg- facility performs operations on double-byte, ASCII,
ister R in the 24-bit or 31-bit addressing and decimal data. The double-byte data may be
mode or place a one in that bit position in the Unicode data -- data that uses the binary codes of
64-bit addressing mode. the Unicode Worldwide Character Standard and
enables the use of characters of most of the
Certain instructions leave bits 0-31 of a
world's written languages. The facility provides
general register unchanged in the 24-bit or
the following instructions:
31-bit addressing mode but place or update
address or length information in them in the COMPARE LOGICAL LONG UNICODE
64-bit addressing mode. These are listed in a MOVE LONG UNICODE
programming note on page 7-6 and are some- PACK ASCII
times called modal instructions. PACK UNICODE
TEST DECIMAL
Effects on Bits 0-31 of a General TRANSLATE ONE TO ONE
Register TRANSLATE ONE TO TWO
Bits 0-31 of general registers are changed by two TRANSLATE TWO TO ONE
types of instructions. The first type is a modal TRANSLATE TWO TO TWO
instruction (see the preceding section) when the UNPACK ASCII
instruction is executed in the 64-bit addressing UNPACK UNICODE
mode. The second type is an instruction having,
independent of the addressing mode, either a The extended-translation facility 2 is called facility
64-bit result operand in a single general register or 2 since an extended-translation facility, now called
a 128-bit result operand in an even-odd general- facility 1, was introduced in ESA/390. Facility 1 is
register pair. standard in z/Architecture. Facility 1 provides the
instructions:
Most of the instructions of the second type are CONVERT UNICODE TO UTF-8
indicated by a G, either alone or in GF, in their CONVERT UTF-8 TO UNICODE
mnemonics. The other instructions that change or TRANSLATE EXTENDED
may change bits 0-31 of a general register regard-
less of the current addressing mode are listed in a For when either or both of facility 1 and facility 2
programming note on page 7-7. All of the are not installed on the machine, both facilities are
instructions of the second type are sometimes simulated by the MVS CSRUNIC macro instruc-
referred to as G-type instructions. tion, which is provided in OS/390* Release 10 and
z/OS*.
If a program is not executed in the 64-bit
addressing mode and does not contain a G-type OS/390 MVS Assembler Services Reference,
instruction, it cannot change bits 0-31 of any GC28-1910-10, contains programming require-
general register. ments, register information, syntax, return codes,
and examples for the CSRUNIC macro instruction.

When CSRUNIC is used, the program exceptions


listed in this publication do not cause program
interruptions; instead, the exception conditions are
indicated by CSRUNIC by means of return codes,
as described in GC28-1910-10.

OS/390 and z/OS are trademarks of the International Business Machines Corporation.

Chapter 1. Introduction 1-5


rate I/O operation to obtain the sense informa-
The ESA/390 Base tion.
z/Architecture includes all of the facilities of Broadcasted purging provides the COMPARE
ESA/390 except for the asynchronous-pageout, AND SWAP AND PURGE instruction for con-
asynchronous-data-mover, program-call-fast, and ditionally updating tables associated with
vector facilities. This section briefly outlines most dynamic address translation and access-
of the remaining facilities that were additions in register translation and clearing associated
ESA/390 as compared to ESA/370. buffers in multiple CPUs. This is described in
detail beginning in the eighth edition of
ESA/390 is described in Enterprise Systems
SA22-7201.
Architecture/390 Principles of Operation,
SA22-7201. Storage-protection override provides a new
form of subsystem storage protection that
The CPU-related facilities that were new in improves the reliability of a subsystem exe-
ESA/390 are summarized below. ESA/390 was cuted in an address space along with possibly
announced in September, 1990. Any extension erroneous application programs. When
added subsequently has the date of its announce- storage-protection override is made active by
ment in parentheses at the end of its summary. a control-register bit, fetches and stores by the
CPU are permitted to storage locations having
The following extensions are described in detail in a storage key of 9 regardless of the access
SA22-7201 and in this publication: key used by the CPU. If the subsystem is in
Access-list-controlled protection allows store- key-8 storage and is executed with a PSW
type storage references to an address space key of 8, for example, and the application pro-
to be prohibited by means of a bit in the grams are in key-9 storage and are executed
access-list entry used to access the space. with a PSW key of 9, accesses by the sub-
Thus, different users having different access system to the application-program areas are
lists can have different capabilities to store in permitted while accesses by the application
the same address space. programs to the subsystem area are denied.
(September, 1991)
The program-event-recording facility 2 (PER
2) is an alternative to the original PER facility, Move-page facility 2 extends the MOVE PAGE
which is now named PER 1. (Neither of the instruction introduced in ESA/370 by allowing
names PER 1 and PER 2 is used in use of a specified access key for either the
z/Architecture; only PER is used.) PER 2 source or the destination operand, by allowing
provides the option of having a successful- improved performance when the destination
branching event occur only when the branch operand will soon be referenced, and by
target is within the designated storage area, allowing improved performance when an
and it provides the option of having a storage- operand is invalid in both main and expanded
alteration event occur only when the storage storage. The ESA/370 version of MOVE
area is within designated address spaces. PAGE is now called move-page facility 1 and
The use of these options improves perform- is in Chapter 7, General Instructions. MOVE
ance by allowing only PER events of interest PAGE of move-page facility 2 is in Chapter
to occur. PER 2 deletes the ability to monitor 10, Control Instructions. Some details about
for general-register-alteration events. the means for control-program support of
MOVE PAGE are not provided. (September,
PER 2 includes extensions that provide addi- 1991) (The z/Architecture MOVE PAGE
tional information about PER events. The instruction is described only in Chapter 10 of
extensions were described in detail beginning this publication. MOVE PAGE no longer can
in the fourth edition of SA22-7201. move data to or from expanded storage, and
Concurrent sense improves performance by all details about MOVE PAGE are provided.)
allowing sense information to be presented at The square-root facility consists of the
the time of an interruption due to a unit-check SQUARE ROOT instruction and the square-
condition, thus avoiding the need for a sepa- root exception. The instruction extracts the
square root of a floating-point operand in

1-6 z/Architecture Principles of Operation


either the long or short format. The instruction SAC, does not perform the serialization and
is the same as that provided on some models checkpoint-synchronization functions, nor does
of the IBM 4341, 4361, and 4381 Processors. it cause copies of prefetched instructions to be
(September, 1991) discarded. SACF provides improved perform-
ance on some models. (February, 1993)
The cancel-I/O facility allows the program to
withdraw a pending start function from a des- The subspace-group facility includes the
ignated subchannel without signaling the BRANCH IN SUBSPACE GROUP instruction,
device, which is useful in certain error- which can be used to give or return control
recovery situations. (September, 1991) from one address space to another in a group
of address spaces called a subspace group,
The cancel-I/O facility provides the CANCEL
with this giving and returning of control being
SUBCHANNEL instruction and is described in
done with better performance than can be
detail beginning in the eighth edition of
obtained by means of the PROGRAM CALL
SA22-7201.
and PROGRAM RETURN or PROGRAM
The string-instruction facility (or logical string TRANSFER instructions. One address space
assist) provides instructions for (1) moving a in the subspace group is called the base
string of bytes until a specified ending byte is space, and the other address spaces in the
found, (2) logically comparing two strings until group are called subspaces. It is intended
an inequality or a specified ending byte is that each subspace contain a different subset
found, and (3) searching a string of a speci- of the storage in the base space, that the
fied length for a specified byte. The first two base space and each subspace contain a
instructions are particularly useful in a C subsystem control program, such as CICS*,
program in which strings are normally delim- and application programs, and that each sub-
ited by an ending byte of all zeros. (June, space contain the data for a single transaction
1992) being processed under the subsystem control
The suppression-on-protection facility causes program. The placement of the data for each
a protection exception due to page protection transaction in a different subspace prevents
to result in suppression of instruction exe- the processing of a transaction from erro-
cution instead of termination of instruction neously damaging the data of other trans-
execution, and it causes the address and an actions. The data of the control program can
address-space identifier of the protected page be protected from the transaction processing
to be stored in low storage. This is useful in by means of the storage-protection-override
performing the AIX/ESA* copy-on-write func- facility. (April, 1994)
tion, in which AIX/ESA causes the same page The virtual-address enhancement of sup-
of different address spaces to map to a single pression on protection provides that if dynamic
page frame of real storage so long as a store address translation (DAT) was on when a pro-
in the page is not attempted and then, when a tection exception was recognized, the
store is attempted in a particular address suppression-on-protection result is indicated,
space, assigns a unique page frame to the and the address of the protected location is
page in that address space and copies the stored, only if the address is one that was to
contents of the page to the new page frame. be translated by DAT; the suppression-on-
(February, 1993) protection result is not indicated if the address
The set-address-space-control-fast facility con- that would be stored is a real address. This
sists of the SET ADDRESS SPACE enhancement allows the stored address to be
CONTROL FAST (SACF) instruction, which translated reliably by the control program to
possibly can be used instead of the previously determine if the exception was due to page
existing SET ADDRESS SPACE CONTROL protection as opposed to key-controlled pro-
(SAC) instruction, depending on whether all of tection. The enhancement extends the useful-
the SAC functions are required. SACF, unlike ness of suppression on protection to operating

AIX/ESA, CICS, and MVS/ESA are trademarks of the International Business Machines Corporation.

Chapter 1. Introduction 1-7


systems like MVS/ESA* that use key- swap and double store, and compare and
controlled protection. (September, 1994) swap and triple store. The function code
further specifies either word or doubleword
The immediate-and-relative-instruction facility
operands. The instruction can be used to
includes 13 new instructions, most of which
avoid the use of programmed locks in a multi-
use a halfword-immediate value for either
processing system. (June, 1997)
signed-binary arithmetic operations or relative
branching. The facility reduces the need for Four additional floating-point facilities improve
general registers, and, in particular, it elimi- the hexadecimal-floating-point (HFP) capability
nates the need to use general registers to of the machine and add a binary-floating-point
address branch targets. As a result, the (BFP) capability. The facilities are:
general registers and access registers can be
Basic floating-point extensions, which pro-
allocated more efficiently in programs that
vides 12 additional floating-point registers
require many registers. (September, 1996)
to make a total of 16 floating-point regis-
The compare-and-move-extended facility pro- ters. This facility also includes a floating-
vides new versions of the COMPARE point-control register and means for
LOGICAL LONG and MOVE LONG saving the contents of the new registers
instructions. The new versions increase the during a store-status operation or a
size of the operand-length specifications from machine-check interruption.
24 bits to 32 bits, which can be useful when
Floating-point-support (FPS) extensions,
objects larger than 16M bytes are processed
which provides eight new instructions,
through the use of 31-bit addressing. The
including four to convert data between the
new versions also periodically complete to
HFP and BFP formats.
allow software polling in a multiprocessing
system. (September, 1996) Hexadecimal-floating-point (HFP) exten-
sions, which provides 26 new instructions
The checksum facility consists of the
to operate on data in the HFP format. All
CHECKSUM instruction, which can be used to
of these are counterparts to new
compute a 16-bit or 32-bit checksum in order
instructions provided by the BFP facility,
to improve TCP/IP (transmission-control
including conversion between floating-
protocol/internet protocol) performance. (Sep-
point and fixed-point formats, and a more
tember, 1996)
complete set of operations on the
The called-space-identification facility extended format.
improves serviceability by further identifying
Binary floating-point (BFP), which defines
the called address space in a linkage-stack
short, long, and extended binary-floating-
state entry formed by the PROGRAM CALL
point (BFP) data formats and provides 87
instruction. (September, 1996)
new instructions to operate on data in
The branch-and-set-authority facility consists these formats. The BFP formats and
of the BRANCH AND SET AUTHORITY operations provide everything necessary
instruction, which can be used to improve the to conform to the IEEE standard
performance of linkages within an address (ANSI/IEEE Std 754-1985, IEEE Standard
space by replacing PROGRAM CALL, for Binary Floating-Point Arithmetic, dated
PROGRAM TRANSFER, and SET PSW KEY August 12, 1985) except for conversion
FROM ADDRESS instructions. (June, 1997) between binary-floating-point numbers and
decimal strings, which must be provided in
The perform-locked-operation facility consists
software.
of the unprivileged PERFORM LOCKED
OPERATION instruction, which appears to (May, 1998)
provide concurrent interlocked-update refer-
The resume-program facility consists of the
ences to multiple storage operands. A func-
RESUME PROGRAM instruction, which
tion code of the instruction can specify any of
restores, from a specified save area, the
six operations: compare and load, compare
instruction address and certain other fields in
and swap, double compare and swap,
the current PSW and also the contents of an
compare and swap and store, compare and

1-8 z/Architecture Principles of Operation


access-and-general-register pair. RESUME The extended-translation facility includes the
PROGRAM allows a problem-state CONVERT UNICODE TO UTF-8, CONVERT
interruption-handling program to restore the UTF-8 TO UNICODE, and TRANSLATE
state of an interrupted program and return to EXTENDED instructions, all of which can
that program despite that a register is required improve performance. TRANSLATE
for addressing the save area from which the EXTENDED can be used in place of a
state is restored. (May, 1998) TRANSLATE AND TEST instruction that
locates an escape character, followed by a
The trap facility provides the TRAP
TRANSLATE instruction that translates the
instructions (a two-byte TRAP2 instruction and
bytes preceding the escape character. (April,
a four-byte TRAP4 instruction) that can
1999)
overlay instructions in an application program
to give control to a program that can perform The following extensions are described in detail in
fix-up operations on data being processed, other publications:
such as dates that may be a Year-2000
The Enterprise Systems Connection Architec-
problem. RESUME PROGRAM can be used
ture (ESCON) introduces a new type of
to return from the fix-up program. TRAP and
channel that uses an optical-fiber communi-
RESUME PROGRAM can improve perform-
cation link between channels and control
ance by avoiding program interruptions that
units. Information is transferred serially by bit,
would otherwise be needed to give control to
at 200 million bits per second, up to a
and from the fix-up program. (May, 1998)
maximum distance of 60 kilometers. The
The extended-TOD-clock facility includes optical-fiber technology and serial trans-
(1) an extension of the TOD clock from 64 mission simplify cabling and improve reliability.
bits to 104 bits, allowing greater resolution; See the publication IBM Enterprise Systems
(2) a TOD programmable register, which con- Architecture/390 ESCON I/O Interface,
tains a TOD programmable field that can be SA22-7202.
used to identify the configuration providing a
The ESCON channel-to-channel adapter
TOD-clock value in a sysplex; (3) the SET
(ESCON CTCA) provides the same type of
CLOCK PROGRAMMABLE FIELD instruction,
function for serial channel paths as is avail-
for setting the TOD programmable field in the
able for the parallel-I/O-interface channel
TOD programmable register; and (4) the
paths. See the publication IBM Enterprise
STORE CLOCK EXTENDED instruction,
Systems Architecture/390 ESCON Channel-to-
which stores both the longer TOD-clock value
Channel Adapter, SA22-7203.
and the TOD programmable field. STORE
CLOCK EXTENDED can be used in the future I/O-device self-description allows a device to
when the TOD clock is further extended to describe itself and its position in the I/O con-
contain time values that exceed the current figuration. See the publication IBM Enterprise
year-2042 limit (when there is a carry out of Systems Architecture/390 Common I/O-Device
the current bit 0 of the TOD clock). (August, Commands and Self Description, SA22-7204.
1998) The compression facility performs a Ziv-
The TOD-clock-control-override facility pro- Lempel type of compression and expansion by
vides a control-register bit that allows setting means of static (nonadaptive) dictionaries that
the TOD clock under program control, without are to be prepared by a program before the
use of the manual TOD-clock control of any compression and expansion operations.
CPU. (August, 1998) Because the dictionaries are static, the com-
pression facility can provide good com-
The store-system-information facility provides
pression not only for long sequential data
the privileged STORE SYSTEM INFORMA-
streams (for example, archival or network
TION instruction, which can be used to obtain
data) but also for randomly accessed short
information about a component or components
records (for example, 80 bytes). See the pub-
of a virtual machine, a logical partition, or the
lication IBM Enterprise Systems
basic machine. (January, 1999)
Architecture/390 Data Compression,
SA22-7208. (February, 1993) (The

Chapter 1. Introduction 1-9


z/Architecture COMPRESSION CALL instruc- received from a remote location by means
tion is described in this publication. However, of a telephone or radio. (September,
introductory information and information about 1991)
dictionary formats still is provided only in
Extended sorting provides instructions that
SA22-7208.)
improve the performance of the DB2* sorting
The remaining extensions of ESA/390, for which function.
detailed descriptions are not provided, are as
Other PER extensions, besides those
follows:
described beginning in the fourth edition of
The integrated cryptographic facility provides a this publication, are an augmentation of PER
number of instructions to protect data privacy, 2 that provide additional PER function in the
to support message authentication and per- interpretive-execution mode.
sonal identification, and to facilitate key man-
Channel-subsystem call provides various func-
agement. The high-performance cipher
tions for use in the management of the I/O
capability of the facility is designed for
configuration. Some of the functions acquire
financial-transaction and bulk-encryption envi-
information about the configuration from the
ronments, and it complies with the Data
accessible elements of the configuration, while
Encryption Standard (DES).
others dynamically change the configuration.
Usability of the cryptographic facility is
The operational extensions are a number of
extended to virtual-machine environments,
other improvements that result in increased
which allows the facility to be used by
availability and ease of use of the system, as
MVS/ESA being executed under
follows:
VM/ESA*, which in turn may be executed
either under another VM/ESA or in a Automatic-reconfiguration permits an oper-
logical partition. (September, 1991) ating system in an LPAR partition to
declare itself willing to be terminated sud-
The external-time-reference facility provides a
denly, usually to permit its storage and
means to initiate and maintain the synchroni-
CPU resources to be acquired by an adja-
zation of TOD clocks to an external time refer-
cent partition that is dynamically absorbing
ence (ETR). Synchronization tolerance of a
the work load of another system that has
few microseconds can be achieved, and the
failed. Other functions deactivate and
effect of leap seconds is taken into account.
reset designated participating partitions.
The facility consists of an ETR sending unit
(Sysplex Timer*), which may be duplexed, two A new storage-reconfiguration command
or more ETR receiving units, and optical-fiber decreases the time needed to reconfigure
cables. The cables are used to connect the storage by allowing multiple requests for
ETR sending unit, which is an external device, reconfiguration to be made by means of a
to ETR receiving units of the configuration. single communication with the service
CPU instructions are provided for setting the processor.
TOD clock to the value supplied by the ETR SCP-initiated reset allows a system
sending unit. control program (SCP) to reset its I/O con-
The ETR automatic-propagation-delay- figuration prior to entering the disabled
adjustment function adjusts the time wait state following certain check condi-
signals from the ETR to the attached tions.
processors to compensate for the propa- Console integration simplifies configuration
gation delay on the cables to the requirements by reducing by one the
processors, thus allowing the cables to be number of consoles required by MVS.
of different lengths. (September, 1991)
The processor-availability facility enables
The ETR external-time-source function a CPU experiencing an unrecoverable
synchronizes the ETR to a time signal

MVS/ESA, VM/ESA, Sysplex Timer, and DB2 are trademarks of the International Business Machines Corporation.

1-10 z/Architecture Principles of Operation


error that will cause a check stop to save are connected by means of the facility. The
its state and alert the other CPUs in the coupling facility provides storage that can be
configuration. This allows, in many cases, dynamically partitioned for caching data in
another CPU to continue execution of the shared buffers, maintaining work queues and
program that was in execution on the status information in shared lists, and locking
failing CPU. The facility is applicable in data by means of shared lock controls.
both the ESA/390 mode and the LPAR MVS/ESA services provide access to and
mode. (April, 1991) manipulation of the coupling-facility contents.
(April, 1994)
Extensions for virtual machines are a number
of improvements to the interpretive-execution
facility, as follows: The ESA/370 and 370-XA Base
The VM-data-space facility provides for
ESA/390 includes the complete set of facilities of
making the ESA/390 access-register archi-
ESA/370 as its base. This section briefly outlines
tecture more useful in virtual-machine
most of the facilities that were additions in 370-XA
applications. The facility improves the
as compared to System/370 and that were addi-
ability to address a larger amount of data
tions in ESA/370 as compared to 370-XA.
and to share data. For information on
how VM/ESA uses the VM-data-space The CPU-related facilities that were new in
facility, see the publication VM/ESA CP 370-XA are as follows:
Programming Services, SC24-5520.
Bimodal addressing provides two modes of
A new storage-key function improves per- operation: a 24-bit addressing mode for the
formance by removing the need for the execution of old programs and a 31-bit
previously used RCP area. addressing mode.
Interpreted SIE (available with region relo- 31-bit logical addressing extends the virtual
cation) is improved to permit preferred address space from the 16M bytes address-
guests under VM when VM itself is oper- able with 24-bit addresses to 2G bytes
ating as a high-performance guest. (2,147,483,648 bytes).
Other improvements include an optional 31-bit real and absolute addressing provides
special-purpose lookaside for some of the addressability for up to 2G bytes of main
guest-state information and greater storage.
freedom in certain implementation
choices. The 370-XA protection facilities include key-
controlled protection on only 4K-byte blocks,
The ESCON-multiple-image facility (EMIF) page protection, and, as in System/370, low-
allows multiple logical partitions to share address protection for addresses below 512.
ESCON channels (and FICON channels) and Fetch-protection override eliminates fetch pro-
optionally to share any of the control units and tection for locations 0-2047.
associated I/O devices configured to these
shared channels. This can reduce channel The tracing facility assists in the determination
requirements, improve channel utilization, and of system problems by providing an ongoing
improve I/O connectivity. (June, 1992) record in storage of significant events.

PR/SM LPAR mode is enhanced to allow up The COMPARE AND FORM CODEWORD
to 10 logical partitions in a single-image con- and UPDATE TREE instructions facilitate
figuration and 20 in a physically-partitioned sorting applications.
configuration. The previous limits were seven The interpretive-execution facility allows cre-
and 14, respectively. (June, 1992) ation of virtual machines that may operate
Coincident with z/Architecture, PR/SM LPAR according to several architectures and whose
mode allows 15 logical partitions, and physical performance is enhanced because many
partitioning is not supported. virtual-machine functions are directly inter-
preted by the machine rather than simulated
The coupling facility enables high-performance by the program. This facility is described in
data sharing among MVS/ESA systems that

Chapter 1. Introduction 1-11


the publication IBM 370-XA Interpretive Exe- Status-verification facility, which reports inap-
cution, SA22-7095. propriate combinations of device-status bits
presented by a device.
The service-call-logical-processor (SCLP)
facility provides a means of communicating A set of 13 I/O instructions, with associated
between the control program and the service control blocks, which are provided for the
processor for the purpose of describing and control of the channel subsystem.
changing the configuration. This facility is not
described. The facilities that were new in ESA/370 are as
follows:
The I/O-related differences between 370-XA and
System/370 result from the 370-XA channel sub- Sixteen access registers permit the program
system, which includes: to have immediate access to storage oper-
ands in up to 16 2G-byte address spaces,
Path-independent addressing of I/O devices,
including the address space in which the
which permits the initiation of I/O operations
program resides. In a dynamic-address-
without regard to which CPU is executing the
translation mode named access-register
I/O instruction or how the I/O device is
mode, the instruction B field, or for certain
attached to the channel subsystem. Any I/O
instructions the R field, designates both a
interruption can be handled by any CPU
general register and an access register, and
enabled for it.
the contents of the access register, along with
Path management, whereby the channel sub- the contents of protected tables, specify the
system determines which paths are available operand address space to be accessed. By
for selection, chooses a path, and manages changing the contents of the access registers,
any busy conditions encountered while the program, under the control of an authori-
attempting to initiate I/O processing with the zation mechanism, can have fast access to
associated devices. hundreds of different operand address spaces.
Dynamic reconnection, which permits any I/O A linkage stack is used in a functionally
device using this capability to reconnect to expanded mechanism for passing control
any available channel path to which it has between programs in either the same or dif-
access in order to continue execution of a ferent address spaces. This mechanism
chain of commands. makes use also of the previously existing
PROGRAM CALL instruction, an extended
Programmable interruption subclasses, which
entry-table entry, and a new PROGRAM
permit the programmed assignment of
RETURN instruction. The mechanism saves
I/O-interruption requests from individual I/O
various elements of status, including access-
devices to any one of eight maskable inter-
register and general-register contents, during
ruption queues.
a calling linkage, provides for changing the
An additional CCW format for the direct use of current status during the calling linkage, and
31-bit addresses in channel programs. The restores the original status during the
new CCW format, called format 1, is provided returning linkage. The linkage stack can also
in addition to the System/370 CCW format, be used to save and restore access-register
now called format 0. and general-register contents during a branch-
Address-limit checking, which provides an type linkage performed by the new instruction
additional storage-protection facility to prevent BRANCH AND STACK.
data access to storage locations above or A translation mode named home-space mode
below a specified absolute address. provides an efficient means for the control
Monitoring facilities, which can be invoked by program to obtain control in the address
the program to cause the channel subsystem space, called the home address space, in
to measure and accumulate key I/O-resource which the principal control blocks for a
usage parameters. dispatchable unit (a task or process) are kept.
The semiprivileged MOVE WITH SOURCE
KEY and MOVE WITH DESTINATION KEY

1-12 z/Architecture Principles of Operation


instructions allow bidirectional movement of
data between storage areas having different Compatibility
storage keys, without the need to change the
PSW key. Compatibility among
The privileged LOAD USING REAL z/Architecture Systems
ADDRESS and STORE USING REAL
ADDRESS instructions allow the control Although systems operating as defined by
program to access data in real storage more z/Architecture may differ in implementation and
efficiently. physical capabilities, logically they are upward and
downward compatible. Compatibility provides for
The private-space facility allows an address
simplicity in education, availability of system
space not to contain any common segments
backup, and ease in system growth. Specifically,
and causes low-address protection and fetch-
any program written for z/Architecture gives iden-
protection override not to apply to the address
tical results on any z/Architecture implementation,
space.
provided that the program:
The unprivileged MOVE PAGE instruction
1. Is not time-dependent.
allows the program to move a page of data
between main and expanded storage, pro- 2. Does not depend on system facilities (such as
vided that the source and destination pages storage capacity, I/O equipment, or optional
are both valid. Some details about the means facilities) being present when the facilities are
for control-program support of MOVE PAGE not included in the configuration.
are not provided. The ESA/370 version of 3. Does not depend on system facilities being
MOVE PAGE is now called move-page facility absent when the facilities are included in the
1. configuration. For example, the program must
The Processor Resource/Systems Manager* not depend on interruptions caused by the use
(PR/SM*) feature provides support for multiple of operation codes or command codes that
preferred guests under VM/XA and provides are not installed in some models. Also, it
the logically partitioned (LPAR) mode, with the must not use or depend on fields associated
latter providing flexible partitioning of with uninstalled facilities. For example, data
processor resources among multiple logical should not be placed in an area used by
partitions. Certain aspects of the LPAR use of another model for fixed-logout information.
PR/SM are described in the publication IBM Similarly, the program must not use or depend
ES/3090 Processor Complex Processor on unassigned fields in machine formats
Resource/Systems Manager Planning Guide, (control registers, instruction formats, etc.) that
GA22-7123. are not explicitly made available for program
use.
The COMPARE UNTIL SUBSTRING EQUAL
instruction provides improved performance of 4. Does not depend on results or functions that
the compression of IMS log data sets and can are defined to be unpredictable or model-
be useful in other programs also. dependent or are identified as undefined.
This includes the requirement that the
program should not depend on the assign-
System Program ment of device numbers and CPU addresses.
z/Architecture is designed to be used with a 5. Does not depend on results or functions that
control program that coordinates the use of are defined in the functional-characteristics
system resources and executes all I/O publication for a particular model to be devi-
instructions, handles exceptional conditions, and ations from the architecture.
supervises scheduling and execution of multiple
programs.

Processor Resource/Systems Manager and PR/SM are trademarks of the International Business Machines Corporation.

Chapter 1. Introduction 1-13


6. Takes into account any changes made to the should not use unassigned low-storage locations
architecture that are identified as affecting for keeping information since these locations may
compatibility. be assigned in the future in such a way that the
machine causes the contents of the locations to
Compatibility between be changed.
z/Architecture and ESA/390
Availability
Control-Program Compatibility
Control programs written for ESA/390 cannot be Availability is the capability of a system to accept
directly transferred to systems operating as and successfully process an individual job.
defined by z/Architecture. This is because the Systems operating in accordance with
general-register and control-register sizes, PSW z/Architecture permit substantial availability by
size, assigned storage locations, and dynamic (1) allowing a large number and broad range of
address translation are changed. jobs to be processed concurrently, thus making
the system readily accessible to any particular job,
Problem-State Compatibility and (2) limiting the effect of an error and identi-
A high degree of compatibility exists at the fying more precisely its cause, with the result that
problem-state level in going forward from ESA/390 the number of jobs affected by errors is minimized
to z/Architecture. Because the majority of a user's and the correction of the errors facilitated.
applications are written for the problem state, this
Several design aspects make this possible.
problem-state compatibility is useful in many
installations. A program is checked for the correctness of
instructions and data as the program is exe-
A problem-state program written for ESA/390 cuted, and program errors are indicated sepa-
operates with z/Architecture, provided that the rate from equipment errors. Such checking
program: and reporting assists in locating failures and
1. Complies with the limitations described in isolating effects.
Compatibility among z/Architecture Systems The protection facilities, in conjunction with
on page 1-13. dynamic address translation and the sepa-
2. Is not dependent on control-program facilities ration of programs and data in different
which are unavailable on the system. address spaces, permit the protection of the
contents of storage from destruction or misuse
Programming Note: This publication assigns caused by erroneous or unauthorized storing
meanings to various operation codes, to bit posi- or fetching by a program. This provides
tions in instructions, channel-command words, increased security for the user, thus permitting
registers, and table entries, and to fixed locations applications with different security require-
in the low 512 bytes and bytes 4096-8191 of ments to be processed concurrently with other
storage. Unless specifically noted, the remaining applications.
operation codes, bit positions, and low-storage
locations are reserved for future assignment to Dynamic address translation allows isolation
new facilities and other extensions of the architec- of one application from another, still permitting
ture. them to share common resources. Also, it
permits the implementation of virtual
To ensure that existing programs operate if and machines, which may be used in the design
when such new facilities are installed, programs and testing of new versions of operating
should not depend on an indication of an excep- systems along with the concurrent processing
tion as a result of invalid values that are currently of application programs. Additionally, it pro-
defined as being checked. If a value must be vides for the concurrent operation of incom-
placed in unassigned positions that are not patible operating systems.
checked, the program should enter zeros. When The use of access registers allows programs,
the machine provides a code or field, the program data, and different collections of data to reside
should take into account that new codes and bits in different address spaces, and this further
may be assigned in the future. The program

1-14 z/Architecture Principles of Operation


reduces the likelihood that a store using an it provides model-independent recording of
incorrect address will produce either erro- machine-status information. This leads to
neous results or a system-wide failure. greater machine-check-handling compatibility
between models and improves the capability
Multiprocessing and the channel subsystem
for loading and operating a program on a dif-
permit better use of storage and processing
ferent model when a system failure occurs.
capabilities, more direct communication
between CPUs, and duplication of resources, A small number of manual controls are
thus aiding in the continuation of system oper- required for basic system operation, permitting
ation in the event of machine failures. most operator-system interaction to take place
via a unit operating as an I/O device and thus
MONITOR CALL, program-event recording,
reducing the possibility of operator errors.
and the timing facilities permit the testing and
debugging of programs without manual inter- The logical partitions made available by the
vention and with little effect on the concurrent PR/SM feature allow continued reliable pro-
processing of other programs. duction operations in one or more partitions
while new programming systems are tested in
On most models, error checking and cor-
other partitions. This is an advancement in
rection (ECC) in main storage, CPU retry, and
particular for non-VM installations.
command retry provide for circumventing inter-
mittent equipment malfunctions, thus reducing The operational extensions and channel-
the number of equipment failures. subsystem-call facility of ESA/390 improve the
ability to continue execution of application pro-
An enhanced machine-check-handling mech-
grams in the presence of system incidents
anism provides model-independent fault iso-
and the ability to make configuration changes
lation, which reduces the number of programs
with less disruption to operations.
impacted by uncorrected errors. Additionally,

Chapter 1. Introduction 1-15


1-16 z/Architecture Principles of Operation
Chapter 2. Organization
Main Storage . . . . . . . . . . . . . . . . . . . 2-2 Access Registers . . . . . . . . . . . . . . . 2-4
Expanded Storage . . . . . . . . . . . . . . . 2-2 Cryptographic Facility . . . . . . . . . . . . 2-6
CPU . . . . . . . . . . . . . . . . . . . . . . . . 2-2 External Time Reference . . . . . . . . . . . . 2-6
PSW . . . . . . . . . . . . . . . . . . . . . . 2-3 I/O . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
General Registers . . . . . . . . . . . . . . 2-3 Channel Subsystem . . . . . . . . . . . . . 2-6
Floating-Point Registers . . . . . . . . . . . 2-3 Channel Paths . . . . . . . . . . . . . . . . 2-6
Floating-Point-Control Register . . . . . . . 2-4 I/O Devices and Control Units . . . . . . . 2-7
Control Registers . . . . . . . . . . . . . . . 2-4 Operator Facilities . . . . . . . . . . . . . . . . 2-7


Logically, a system consists of main storage, one /ETR/
or more central processing units (CPUs), operator
facilities, a channel subsystem, and I/O devices.

I/O devices are attached to the channel sub-
system through control units. The connection
CPU
between the channel subsystem and a control unit
is called a channel path.


A channel path employs either a parallel- Expanded Storage Main Storage

transmission protocol or a serial-transmission pro- CPU
tocol and, accordingly, is called either a parallel or
Crypto
a serial channel path. A serial channel path may
connect to a control unit through a dynamic switch

that is capable of providing different internal con-
nections between the ports of the switch.


Expanded storage may also be available in the
system, a cryptographic unit may be included in a Channel
Subsystem
CPU, and an external time reference (ETR) may
be connected to the system. ............... ...

Serial Channel Paths Parallel Channel Paths
The physical identity of the above functions may
/ / /
vary among implementations, called models.
Figure 2-1 depicts the logical structure of a Dynamic Dynamic /
Switch Switch
two-CPU multiprocessing system that includes CU CU/
expanded storage and a cryptographic unit and ... ... O O O

that is connected to an ETR. /
O O O
Specific processors may differ in their internal CU

characteristics, the installed facilities, the number CUCU CU /
of subchannels, channel paths, and control units
CU/
which can be attached to the channel subsystem, / CU/ O O O
the size of main and expanded storage, and the O O O O O O
/ /
representation of the operator facilities. O O O O O O
Figure 2-1. Logical Structure of an ESA/390 System
with Two CPUs

A system viewed without regard to its I/O devices


is referred to as a configuration. All of the phys-

Copyright IBM Corp. 1990, 2000 2-1


ical equipment, whether in the configuration or not,
is referred to as the installation. Expanded Storage
Expanded storage may be available on some
Model-dependent reconfiguration controls may be models. Expanded storage, when available, can
provided to change the amount of main and be accessed by all CPUs in the configuration by
expanded storage and the number of CPUs and means of instructions that transfer 4K-byte blocks
channel paths in the configuration. In some of data from expanded storage to main storage or
instances, the reconfiguration controls may be from main storage to expanded storage. These
used to partition a single configuration into mul- instructions are the PAGE IN and PAGE OUT
tiple configurations. Each of the configurations so instructions, described in Chapter 10, Control
reconfigured has the same structure, that is, main Instructions.
and expanded storage, one or more CPUs, and
one or more subchannels and channel paths in Each 4K-byte block of expanded storage is
the channel subsystem. addressed by means of a 32-bit unsigned binary
integer called an expanded-storage block number.
Each configuration is isolated in that the main and
expanded storage in one configuration is not
directly addressable by the CPUs and the channel CPU
subsystem of another configuration. It is,
however, possible for one configuration to commu- The central processing unit (CPU) is the control-
nicate with another by means of shared I/O ling center of the system. It contains the
devices or a channel-to-channel adapter. At any sequencing and processing facilities for instruction
one time, the storage, CPUs, subchannels, and execution, interruption action, timing functions,
channel paths connected together in a system are initial program loading, and other machine-related
referred to as being in the configuration. Each functions.
CPU, subchannel, channel path, main-storage
The physical implementation of the CPU may
location, and expanded-storage location can be in
differ among models, but the logical function
only one configuration at a time.
remains the same. The result of executing an
instruction is the same for each model, providing
that the program complies with the compatibility
Main Storage rules.
Main storage, which is directly addressable, pro-
vides for high-speed processing of data by the The CPU, in executing instructions, can process
CPUs and the channel subsystem. Both data and binary integers and floating-point numbers (binary
programs must be loaded into main storage from and hexadecimal) of fixed length, decimal integers
input devices before they can be processed. The of variable length, and logical information of either
amount of main storage available in the system fixed or variable length. Processing may be in
depends on the model, and, depending on the parallel or in series; the width of the processing
model, the amount in the configuration may be elements, the multiplicity of the shifting paths, and
under control of model-dependent configuration the degree of simultaneity in performing the dif-
controls. The storage is available in multiples of ferent types of arithmetic differ from one CPU to
4K-byte blocks. At any instant, the channel sub- another without affecting the logical results.
system and all CPUs in the configuration have
access to the same blocks of storage and refer to Instructions which the CPU executes fall into
a particular block of main-storage locations by seven classes: general, decimal, floating-point-
using the same absolute address. support (FPS), binary-floating-point (BFP),
hexadecimal-floating-point (HFP), control, and I/O
Main storage may include a faster-access buffer instructions. The general instructions are used in
storage, sometimes called a cache. Each CPU performing binary-integer-arithmetic operations
may have an associated cache. The effects, and logical, branching, and other nonarithmetic
except on performance, of the physical con- operations. The decimal instructions operate on
struction and the use of distinct storage media are data in the decimal format. The BFP and HFP
not observable by the program.

2-2 z/Architecture Principles of Operation


instructions operate on data in the BFP and HFP visor call. Each class has a distinct pair of
formats, respectively, while the FPS instructions old-PSW and new-PSW locations permanently
operate on floating-point data independent of the assigned in real storage.
format or convert it from one format to the other.
The privileged control instructions and the I/O General Registers
instructions can be executed only when the CPU
is in the supervisor state; the semiprivileged Instructions may designate information in one or
control instructions can be executed in the more of 16 general registers. The general regis-
problem state, subject to the appropriate authori- ters may be used as base-address registers and
zation mechanisms. index registers in address arithmetic and as accu-
mulators in general arithmetic and logical oper-
The CPU provides registers which are available to
ations. Each register contains 64 bit positions.
programs but do not have addressable represen-
The general registers are identified by the
tations in main storage. They include the current
numbers 0-15 and are designated by a four-bit R
program-status word (PSW), the general registers,
field in an instruction. Some instructions provide
the floating-point registers and floating-point-
for addressing multiple general registers by having
control register, the control registers, the access
several R fields. For some instructions, the use of
registers, the prefix register, and the registers for
a specific general register is implied rather than
the clock comparator and the CPU timer. Each
explicitly designated by an R field of the instruc-
CPU in an installation provides access to a time-
tion.
of-day (TOD) clock, which is shared by all CPUs
in the installation. The instruction operation code For some operations, either bits 32-63 or bits 0-63
determines which type of register is to be used in of two adjacent general registers are coupled, pro-
an operation. See Figure 2-2 on page 2-5 for viding a 64-bit or 128-bit format, respectively. In
the format of the control, access, general, and these operations, the program must designate an
floating-point registers. even-numbered register, which contains the left-
most (high-order) 32 or 64 bits. The next higher-
PSW numbered register contains the rightmost
(low-order) 32 or 64 bits.
The program-status word (PSW) includes the
instruction address, condition code, and other In addition to their use as accumulators in general
information used to control instruction sequencing arithmetic and logical operations, 15 of the 16
and to determine the state of the CPU. The active general registers are also used as base-address
or controlling PSW is called the current PSW. It and index registers in address generation. In
governs the program currently being executed. these cases, the registers are designated by a
four-bit B field or X field in an instruction. A value
The CPU has an interruption capability, which of zero in the B or X field specifies that no base or
permits the CPU to switch rapidly to another index is to be applied, and, thus, general register
program in response to exceptional conditions and 0 cannot be designated as containing a base
external stimuli. When an interruption occurs, the address or index.
CPU places the current PSW in an assigned
storage location, called the old-PSW location, for Floating-Point Registers
the particular class of interruption. The CPU
fetches a new PSW from a second assigned All floating-point instructions (FPS, BFP, and HFP)
storage location. This new PSW determines the use the same floating-point registers. The CPU
next program to be executed. When it has fin- has 16 floating-point registers. The floating-point
ished processing the interruption, the program registers are identified by the numbers 0-15 and
handling the interruption may reload the old PSW, are designated by a four-bit R field in floating-point
making it again the current PSW, so that the inter- instructions. Each floating-point register is 64 bits
rupted program can continue. long and can contain either a short (32-bit) or a
long (64-bit) floating-point operand. As shown in
There are six classes of interruption: external,
Figure 2-2 on page 2-5, pairs of floating-point
I/O, machine check, program, restart, and super-
registers can be used for extended (128-bit) oper-

Chapter 2. Organization 2-3


ands. Each of the eight pairs is referred to by the translation (DAT) mechanism to translate refer-
number of the lower-numbered register of the pair. ences to a corresponding address space. When
the CPU is in a mode called the access-register
Floating-Point-Control Register mode (controlled by bits in the PSW), an instruc-
tion B field, used to specify a logical address for a
The floating-point-control (FPC) register is a 32-bit storage-operand reference, designates an access
register that contains mask bits, flag bits, a data- register, and the address-space-control element
exception code, and rounding-mode bits. The specified by the access register is used by DAT
FPC register is described in the section Floating- for the reference being made. For some
Point-Control (FPC) Register on page 19-2. instructions, an R field is used instead of a B field.
Instructions are provided for loading and storing
the contents of the access registers and for
Control Registers moving the contents of one access register to
another.
The CPU has 16 control registers, each having 64
bit positions. The bit positions in the registers are Each of access registers 1-15 can designate any
assigned to particular facilities in the system, such address space, including the current instruction
as program-event recording, and are used either space (the primary address space). Access reg-
to specify that an operation can take place or to ister 0 always designates the current instruction
furnish special information required by the facility. space. When one of access registers 1-15 is
used to designate an address space, the CPU
The control registers are identified by the numbers determines which address space is designated by
0-15 and are designated by four-bit R fields in the translating the contents of the access register.
instructions LOAD CONTROL and STORE When access register 0 is used to designate an
CONTROL. Multiple control registers can be address space, the CPU treats the access register
addressed by these instructions. as designating the current instruction space, and it
does not examine the actual contents of the
Access Registers access register. Therefore, the 16 access regis-
ters can designate, at any one time, the current
The CPU has 16 access registers numbered 0-15. instruction space and a maximum of 15 other
An access register consists of 32 bit positions spaces.
containing an indirect specification (not described
here in detail) of an address-space-control
element. An address-space-control element is a
parameter used by the dynamic-address-

2-4 z/Architecture Principles of Operation


R Field Control Access General Floating-Point
and Registers Registers Registers Registers
Register
Number %64 bits5 %32 bits5 %64 bits5 %64 bits5


5 5



1 1 5 %



1 2 5 5



11 3 5 %


1 4 5 5



11 5 5 %



11 6 5 5



111 7 5 %


1 8 5 5



11 9 5 %



11 1 5 5



111 11 5 %


11 12 5 5



111 13 5 %



111 14 5 5



1111 15 5 %

Note: The arrows indicate that the two registers may be coupled as a double-register pair,
designated by specifying the lower-numbered register in the R field. For example, the floating-point
register pair 13 and 15 is designated by 1101 binary in the R field.
Figure 2-2. Control, Access, General, and Floating-Point Registers

Chapter 2. Organization 2-5


Cryptographic Facility CPUs using I/O instructions as well as by the
channel subsystem and serves as the means of
Depending on the model, an integrated communication between any CPU and the channel
cryptographic facility may be provided as an subsystem concerning the associated I/O device.
extension of the CPU. When the cryptographic The actual number of subchannels provided
facility is provided on a CPU, it functions as an depends on the model and the configuration; the
integral part of that CPU. A summary of the bene- maximum number of subchannels is 65,536.
fits of the cryptographic facility is given on page
1-10; the facility is otherwise not described. Channel Paths
I/O devices are attached through control units to
External Time Reference the channel subsystem via channel paths. Control
units may be attached to the channel subsystem
Depending on the model, an external time refer-
via more than one channel path, and an I/O
ence (ETR) may be connected to the configura-
device may be attached to more than one control
tion. A summary of the benefits of the ETR is
unit. In all, an individual I/O device may be acces-
given on page 1-10; the facility is otherwise not
sible to a channel subsystem by as many as eight
described.
different channel paths, depending on the model
and the configuration. The total number of
channel paths provided by a channel subsystem
I/O depends on the model and the configuration; the
Input/output (I/O) operations involve the transfer of maximum number of channel paths is 256.
information between main storage and an I/O
device. I/O devices and their control units attach A channel path can use one of three types of
to the channel subsystem, which controls this data communication links:
transfer.
System/360 and System/370 I/O interface,
called the parallel-I/O interface; the channel
Channel Subsystem path is called a parallel channel path

The channel subsystem directs the flow of infor- ESCON I/O interface, called a serial-I/O inter-
mation between I/O devices and main storage. It face; the channel path is called a serial
relieves CPUs of the task of communicating channel path
directly with I/O devices and permits data proc- FICON I/O interface, also called a serial-I/O
essing to proceed concurrently with I/O proc- interface; the channel path again is called a
essing. The channel subsystem uses one or more serial channel path
channel paths as the communication link in man-
Each parallel-I/O interface consists of a number of
aging the flow of information to or from I/O
electrical signal lines between the channel sub-
devices. As part of I/O processing, the channel
system and one or more control units. Eight
subsystem also performs the path-management
control units can share a single parallel-I/O inter-
function of testing for channel-path availability,
face. Up to 256 I/O devices can be addressed on
selecting an available channel path, and initiating
a single parallel-I/O interface. The parallel-I/O
execution of the operation with the I/O device.
interface is described in the publication IBM
Within the channel subsystem are subchannels.
System/360 and System/370 I/O Interface
One subchannel is provided for and dedicated to Channel to Control Unit Original Equipment Man-
each I/O device accessible to the channel sub- ufacturers' Information, GA22-6974.
system. Each subchannel contains storage for
Each serial-I/O interface consists of two optical-
information concerning the associated I/O device
fiber conductors between any two of a channel
and its attachment to the channel subsystem. The
subsystem, a dynamic switch, and a control unit.
subchannel also provides storage for information
A dynamic switch can be connected by means of
concerning I/O operations and other functions
multiple serial-I/O interfaces to either the same or
involving the associated I/O device. Information
different channel subsystems and to multiple
contained in the subchannel can be accessed by
control units. The number of control units which

2-6 z/Architecture Principles of Operation


can be connected on one channel path depends operation is regulated by a control unit that pro-
on the channel-subsystem and dynamic-switch vides the logical and buffering capabilities neces-
capabilities. Up to 256 devices can be attached to sary to operate the associated I/O device. From
each control unit that uses the serial-I/O interface, the programming point of view, most control-unit
depending on the control unit. The ESCON I/O functions merge with I/O-device functions. The
interface is described in the publication ESA/390 control-unit function may be housed with the I/O
ESCON I/O Interface, SA22-7202. The FICON device or in the CPU, or a separate control unit
I/O interface is described in the ANSI standards may be used.
document Fibre Channel - Single-Byte Command
Code Sets-2 (FC-SB-2).
Operator Facilities
I/O Devices and Control Units The operator facilities provide the functions neces-
sary for operator control of the machine. Associ-
I/O devices include such equipment as printers, ated with the operator facilities may be an
magnetic-tape units, direct-access-storage operator-console device, which may also be used
devices, displays, keyboards, communications as an I/O device for communicating with the
controllers, teleprocessing devices, and sensor- program.
based equipment. Many I/O devices function with
an external medium, such as paper or magnetic The main functions provided by the operator facili-
tape. Other I/O devices handle only electrical ties include resetting, clearing, initial program
signals, such as those found in displays and com- loading, start, stop, alter, and display.
munications networks. In all cases, I/O-device

Chapter 2. Organization 2-7


2-8 z/Architecture Principles of Operation
Chapter 3. Storage
Storage Addressing . . . . . . . . . . . . . . . 3-2 Recognition of Exceptions during ASN
Information Formats . . . . . . . . . . . . . 3-2 Translation . . . . . . . . . . . . . . . 3-23
Integral Boundaries . . . . . . . . . . . . . 3-3 ASN Authorization . . . . . . . . . . . . . . . . 3-23
Address Types and Formats . . . . . . . . . . 3-3 ASN-Authorization Controls . . . . . . . . . 3-23
Address Types . . . . . . . . . . . . . . . . 3-3 Control Register 4 . . . . . . . . . . . . . 3-23
Absolute Address . . . . . . . . . . . . . 3-3 ASN-Second-Table Entry . . . . . . . . 3-24
Real Address . . . . . . . . . . . . . . . 3-4 Authority-Table Entries . . . . . . . . . . . 3-24
Virtual Address . . . . . . . . . . . . . . 3-4 ASN-Authorization Process . . . . . . . . . 3-24
Primary Virtual Address . . . . . . . . . 3-4 Authority-Table Lookup . . . . . . . . . . 3-25
Secondary Virtual Address . . . . . . . . 3-4 Recognition of Exceptions during ASN
AR-Specified Virtual Address . . . . . . 3-5 Authorization . . . . . . . . . . . . . 3-26
Home Virtual Address . . . . . . . . . . 3-5 Dynamic Address Translation . . . . . . . . . 3-26
Logical Address . . . . . . . . . . . . . . 3-5 Translation Control . . . . . . . . . . . . . . 3-28
Instruction Address . . . . . . . . . . . . 3-5 Translation Modes . . . . . . . . . . . . 3-28
Effective Address . . . . . . . . . . . . . 3-5 Control Register 0 . . . . . . . . . . . . . 3-29
Address Size and Wraparound . . . . . . . 3-5 Control Register 1 . . . . . . . . . . . . . 3-29
Address Wraparound . . . . . . . . . . . 3-6 Control Register 7 . . . . . . . . . . . . . 3-30
Storage Key . . . . . . . . . . . . . . . . . . . 3-8 Control Register 13 . . . . . . . . . . . . 3-31
Protection . . . . . . . . . . . . . . . . . . . . . 3-9 Translation Tables . . . . . . . . . . . . . . 3-31
Key-Controlled Protection . . . . . . . . . . 3-9 Region-Table Entries . . . . . . . . . . . 3-31
Storage-Protection-Override Control . . 3-10 Segment-Table Entries . . . . . . . . . . 3-33
Fetch-Protection-Override Control . . . 3-11 Page-Table Entries . . . . . . . . . . . . 3-33
Access-List-Controlled Protection . . . . . 3-11 Translation Process . . . . . . . . . . . . . 3-34
Page Protection . . . . . . . . . . . . . . . 3-11 Inspection of Real-Space Control . . . . 3-39
Low-Address Protection . . . . . . . . . . . 3-12 Inspection of Designation-Type Control 3-39
Suppression on Protection . . . . . . . . . 3-12 Lookup in a Table Designated by an
Reference Recording . . . . . . . . . . . . . . 3-14 Address-Space-Control Element . . 3-39
Change Recording . . . . . . . . . . . . . . . 3-14 Lookup in a Table Designated by a
Prefixing . . . . . . . . . . . . . . . . . . . . . 3-15 Region-Table Entry . . . . . . . . . . 3-40
Address Spaces . . . . . . . . . . . . . . . . . 3-16 Page-Table Lookup . . . . . . . . . . . . 3-42
Changing to Different Address Spaces . 3-17 Formation of the Real Address . . . . . 3-42
Address-Space Number . . . . . . . . . 3-17 Recognition of Exceptions during
ASN Translation . . . . . . . . . . . . . . . . . 3-18 Translation . . . . . . . . . . . . . . . 3-42
ASN-Translation Controls . . . . . . . . . . 3-18 Translation-Lookaside Buffer . . . . . . . . 3-42
Control Register 14 . . . . . . . . . . . . 3-18 TLB Structure . . . . . . . . . . . . . . . 3-43
ASN-Translation Tables . . . . . . . . . . . 3-19 Formation of TLB Entries . . . . . . . . 3-43
ASN-First-Table Entries . . . . . . . . . 3-19 Use of TLB Entries . . . . . . . . . . . . 3-44
ASN-Second-Table Entries . . . . . . . 3-19 Modification of Translation Tables . . . 3-45
ASN-Translation Process . . . . . . . . . . 3-21 Address Summary . . . . . . . . . . . . . . . . 3-47
ASN-First-Table Lookup . . . . . . . . . 3-22 Addresses Translated . . . . . . . . . . . . 3-47
ASN-Second-Table Lookup . . . . . . . 3-23 Handling of Addresses . . . . . . . . . . . 3-48
Assigned Storage Locations . . . . . . . . . . 3-51

This chapter discusses the representation of infor- address spaces, the various types of addresses,
mation in main storage, as well as addressing, and the manner in which one type of address is
protection, and reference and change recording. translated to another type of address. A list of
The aspects of addressing which are covered permanently assigned storage locations appears
include the format of addresses, the concept of at the end of the chapter.

Copyright IBM Corp. 1990, 2000 3-1


Main storage provides the system with directly
addressable fast-access storage of data. Both Storage Addressing
data and programs must be loaded into main Storage is viewed as a long horizontal string of
storage (from input devices) before they can be bits. For most operations, accesses to storage
processed. proceed in a left-to-right sequence. The string of
bits is subdivided into units of eight bits. An
Main storage may include one or more smaller eight-bit unit is called a byte, which is the basic
faster-access buffer storages, sometimes called building block of all information formats.
caches. A cache is usually physically associated
with a CPU or an I/O processor. The effects, Each byte location in storage is identified by a
except on performance, of the physical con- unique nonnegative integer, which is the address
struction and use of distinct storage media are not of that byte location or, simply, the byte address.
observable by the program. Adjacent byte locations have consecutive
addresses, starting with 0 on the left and pro-
Fetching and storing of data by a CPU are not ceeding in a left-to-right sequence. Addresses are
affected by any concurrent channel-subsystem unsigned binary integers and are 24, 31, or 64
activity or by a concurrent reference to the same bits. Addresses are described in Address Size
storage location by another CPU. When concur- and Wraparound on page 3-5.
rent requests to a main-storage location occur,
access normally is granted in a sequence deter-
mined by the system. If a reference changes the
Information Formats
contents of the location, any subsequent storage
Information is transmitted between storage and a
fetches obtain the new contents.
CPU or the channel subsystem one byte, or a
Main storage may be volatile or nonvolatile. If it is group of bytes, at a time. Unless otherwise speci-
volatile, the contents of main storage are not pre- fied, a group of bytes in storage is addressed by
served when power is turned off. If it is nonvola- the leftmost byte of the group. The number of
tile, turning power off and then back on does not bytes in the group is either implied or explicitly
affect the contents of main storage, provided all specified by the operation to be performed. When
CPUs are in the stopped state and no references used in a CPU operation, a group of bytes is
are made to main storage when power is being called a field.
turned off. In both types of main storage, the con-
Within each group of bytes, bits are numbered in
tents of the storage key are not necessarily pre-
a left-to-right sequence. The leftmost bits are
served when the power for main storage is turned
sometimes referred to as the high-order bits and
off.
the rightmost bits as the low-order bits. Bit
Note: Because most references in this publica- numbers are not storage addresses, however.
tion apply to virtual storage, the abbreviated term Only bytes can be addressed. To operate on indi-
storage is often used in place of virtual storage. vidual bits of a byte in storage, it is necessary to
The term storage may also be used in place of access the entire byte.
main storage, absolute storage, or real
storage when the meaning is clear. The terms The bits in a byte are numbered 0 through 7, from
main storage and absolute storage are used to left to right.
describe storage which is addressable by means
of an absolute address. The terms describe fast- The bits in an address may be numbered 8-31 or
access storage, as opposed to auxiliary storage, 40-63 for 24-bit addresses or 1-31 or 33-63 for
such as provided by direct-access storage 31-bit addresses; they are numbered 0-63 for
devices. Real storage is synonymous with 64-bit addresses. Within any other fixed-length
absolute storage except for the effects of pre- format of multiple bytes, the bits making up the
fixing. format are consecutively numbered starting from
0.

For purposes of error detection, and in some


models for correction, one or more check bits may
be transmitted with each byte or with a group of

3-2 z/Architecture Principles of Operation


bytes. Such check bits are generated automat- Programming Note: For fixed-field-length oper-
ically by the machine and cannot be directly con- ations with field lengths that are a power of 2, sig-
trolled by the program. References in this nificant performance degradation is possible when
publication to the length of data fields and regis- storage operands are not positioned at addresses
ters exclude mention of the associated check bits. that are integral multiples of the operand length.
All storage capacities are expressed in number of To improve performance, frequently used storage
bytes. operands should be aligned on integral bounda-
ries.
When the length of a storage-operand field is
implied by the operation code of an instruction, the
field is said to have a fixed length, which can be Address Types and Formats
one, two, four, or eight bytes. Larger fields may
be implied for some instructions.
Address Types
When the length of a storage-operand field is not
implied but is stated explicitly, the field is said to For purposes of addressing main storage, three
have a variable length. Variable-length operands basic types of addresses are recognized: abso-
can vary in length by increments of one byte. lute, real, and virtual. The addresses are distin-
guished on the basis of the transformations that
When information is placed in storage, the con- are applied to the address during a storage
tents of only those byte locations are replaced that access. Address translation converts virtual to
are included in the designated field, even though real, and prefixing converts real to absolute. In
the width of the physical path to storage may be addition to the three basic address types, addi-
greater than the length of the field being stored. tional types are defined which are treated as one
or another of the three basic types, depending on
the instruction and the current mode.
Integral Boundaries
Absolute Address
Certain units of information must be on an integral
An absolute address is the address assigned to a
boundary in storage. A boundary is called integral
main-storage location. An absolute address is
for a unit of information when its storage address
used for a storage access without any transforma-
is a multiple of the length of the unit in bytes.
tions performed on it.
Special names are given to fields of 2, 4, 8, and
16 bytes on an integral boundary. A halfword is a
The channel subsystem and all CPUs in the con-
group of two consecutive bytes on a two-byte
figuration refer to a shared main-storage location
boundary and is the basic building block of
by using the same absolute address. Available
instructions. A word is a group of four consec-
main storage is usually assigned contiguous abso-
utive bytes on a four-byte boundary. A
lute addresses starting at 0, and the addresses
doubleword is a group of eight consecutive bytes
are always assigned in complete 4K-byte blocks
on an eight-byte boundary. A quadword is a
on integral boundaries. An exception is recog-
group of 16 consecutive bytes on a 16-byte
nized when an attempt is made to use an absolute
boundary. (See Figure 3-1 on page 3-4.)
address in a block which has not been assigned
to physical locations. On some models, storage-
When storage addresses designate halfwords,
reconfiguration controls may be provided which
words, doublewords, and quadwords, the binary
permit the operator to change the correspondence
representation of the address contains one, two,
between absolute addresses and physical
three, or four rightmost zero bits, respectively.
locations. However, at any one time, a physical
Instructions must be on two-byte integral bounda- location is not associated with more than one
ries, and CCWs, IDAWs, and the storage oper- absolute address.
ands of certain instructions must be on other
Storage consisting of byte locations sequenced
integral boundaries. The storage operands of
according to their absolute addresses is referred
most instructions do not have boundary-alignment
to as absolute storage.
requirements.

Chapter 3. Storage 3-3



5 Storage Addresses



Bytes 1 2 3 4 5 6 7 8 9 1 11 12 13 14 15 16





Halfwords 2 4 6 8 1 12 14 16





Words 4 8 12 16





Doublewords 8 16





Quadwords 16

Figure 3-1. Integral Boundaries with Storage Addresses

Real Address Primary Virtual Address


A real address identifies a location in real storage. A primary virtual address is a virtual address
When a real address is used for an access to which is to be translated by means of the primary
main storage, it is converted, by means of pre- address-space-control element. Logical
fixing, to an absolute address. addresses are treated as primary virtual
addresses when in the primary-space mode.
At any instant there is one real-address to Instruction addresses are treated as primary
absolute-address mapping for each CPU in the virtual addresses when in the primary-space
configuration. When a real address is used by a mode, secondary-space mode, or access-register
CPU to access main storage, it is converted to an mode. The first-operand address of MOVE TO
absolute address by prefixing. The particular PRIMARY and the second-operand address of
transformation is defined by the value in the prefix MOVE TO SECONDARY are always treated as
register for the CPU. primary virtual addresses.

Storage consisting of byte locations sequenced Secondary Virtual Address


according to their real addresses is referred to as A secondary virtual address is a virtual address
real storage. which is to be translated by means of the sec-
ondary address-space-control element. Logical
Virtual Address addresses are treated as secondary virtual
A virtual address identifies a location in virtual addresses when in the secondary-space mode.
storage. When a virtual address is used for an The second-operand address of MOVE TO
access to main storage, it is translated by means PRIMARY and the first-operand address of MOVE
of dynamic address translation to a real address, TO SECONDARY are always treated as sec-
which is then further converted by prefixing to an ondary virtual addresses.
absolute address.

3-4 z/Architecture Principles of Operation


AR-Specified Virtual Address Address Size and Wraparound
An AR-specified virtual address is a virtual
address which is to be translated by means of an An address size refers to the maximum number of
access-register-specified address-space-control significant bits that can represent an address.
element. Logical addresses are treated as Three sizes of addresses are provided: 24-bit,
AR-specified addresses when in the access- 31-bit, and 64-bit. A 24-bit address can accom-
register mode. modate a maximum of 16,777,216 (16M) bytes;
with a 31-bit address, 2,147,483,648 (2G) bytes
Home Virtual Address can be addressed; and, with a 64-bit address,
A home virtual address is a virtual address which 18,446,744,073,709,551,616 (16E) bytes can be
is to be translated by means of the home address- addressed.
space-control element. Logical addresses and
instruction addresses are treated as home virtual The bits of a 24-bit, 31-bit, or 64-bit address
addresses when in the home-space mode. produced by address arithmetic under the control
of the current addressing mode are numbered
Logical Address 40-63, 33-63, and 0-63, respectively, corre-
Except where otherwise specified, the storage- sponding to the numbering of base-address and
operand addresses for most instructions are index bits in a general register:
logical addresses. Logical addresses are treated /
as real addresses in the real mode, as primary 24-Bit Address
virtual addresses in the primary-space mode, as /
secondary virtual addresses in the secondary- 4 63
space mode, as AR-specified virtual addresses in /
the access-register mode, and as home virtual 31-Bit Address
addresses in the home-space mode. Some /
instructions have storage-operand addresses or 33 63
storage accesses associated with the instruction
/
which do not follow the rules for logical addresses.
64-Bit Address
In all such cases, the instruction definition con- /
tains a definition of the type of address. 63
The bits of an address that is 31 bits regardless of
Instruction Address the addressing mode are numbered 1-31, and,
Addresses used to fetch instructions from storage
when a 24-bit or 31-bit address is contained in a
are called instruction addresses. Instruction
four-byte field in storage, the bits are numbered
addresses are treated as real addresses in the
8-31 or 1-31, respectively:
real mode, as primary virtual addresses in the
primary-space mode, secondary-space mode, or
access-register mode, and as home virtual 24-Bit Address

addresses in the home-space mode. The instruc- 8 31
tion address in the current PSW and the target
address of EXECUTE are instruction addresses.
31-Bit Address

Effective Address 1 31
In some situations, it is convenient to use the term
effective address. An effective address is the A 24-bit or 31-bit virtual address is expanded to
address which exists before any transformation by 64 bits by appending 40 or 33 zeros, respectively,
dynamic address translation or prefixing is per- on the left before it is translated by means of the
formed. An effective address may be specified DAT process, and a 24-bit or 31-bit real address
directly in a register or may result from address is similarly expanded to 64 bits before it is trans-
arithmetic. Address arithmetic is the addition of formed by prefixing. A 24-bit or 31-bit absolute
the base and displacement or of the base, index, address is expanded to 64 bits before main
and displacement. storage is accessed. Thus, the 24-bit address
always designates a location in the first 16M-byte

Chapter 3. Storage 3-5


block of the 16E-byte storage addressable by a Format-1 and format-2 IDAWs are described in
64-bit address, and the 31-bit address always des- Chapter 15, Basic I/O Functions.
ignates a location in the first 2G-byte block.
Address Wraparound
Unless specifically stated to the contrary, the fol- The CPU performs address generation when it
lowing definition applies in this publication: when- forms an operand or instruction address or when it
ever the machine generates and provides to the generates the address of a table entry from the
program a 24-bit or 31-bit address, the address is appropriate table origin and index. It also per-
made available (placed in storage or loaded into a forms address generation when it increments an
general register) by being imbedded in a 32-bit address to access successive bytes of a field.
field, with the leftmost eight bits or one bit in the Similarly, the channel subsystem performs
field, respectively, set to zeros. When the address address generation when it increments an address
is loaded into a general register, bits 0-31 of the (1) to fetch a CCW, (2) to fetch an IDAW, (3) to
register remain unchanged. transfer data, or (4) to compute the address of an
I/O measurement block.
The size of effective addresses is controlled by
bits 31 and 32 of the PSW, the extended- When, during the generation of the address, an
addressing-mode bit and the basic-addressing- address is obtained that exceeds the value
mode bit, respectively. When bits 31 and 32 are allowed for the address size (2 - 1, 2 - 1, or
both zero, the CPU is in the 24-bit addressing 2 - 1), one of the following two actions is taken:
mode, and 24-bit operand and instruction effective
addresses are specified. When bit 31 is zero and 1. The carry out of the high-order bit position of
bit 32 is one, the CPU is in the 31-bit addressing the address is ignored. This handling of an
mode, and 31-bit operand and instruction effective address of excessive size is called
addresses are specified. When bits 31 and 32 are wraparound.
both one, the CPU is in the 64-bit addressing 2. An interruption condition is recognized.
mode, and 64-bit operand and instruction effective
The effect of wraparound is to make an address
addresses are specified (see Address
space appear circular; that is, address 0 appears
Generation on page 5-7).
to follow the maximum allowable address.
The sizes of the real or absolute addresses used Address arithmetic and wraparound occur before
or yielded by the ASN-translation, transformation, if any, of the address by DAT or
ASN-authorization, PC-number-translation, and prefixing.
access-register-translation processes are always
Addresses generated by the CPU that may be
31 bits regardless of the current addressing mode.
virtual addresses always wrap. Wraparound also
Similarly, the sizes of the real or absolute
occurs when the linkage-stack-entry address in
addresses used or yielded by the DAT, stacking,
control register 15 is decremented below 0 by
unstacking, and tracing processes are always 64
PROGRAM RETURN. For CPU table entries that
bits.
are addressed by real or absolute addresses, it is
The size of the data address in a CCW is under unpredictable whether the address wraps or an
control of the CCW-format-control bit in the addressing exception is recognized.
operation-request block (ORB) designated by a
For channel-program execution, when the gener-
START SUBCHANNEL instruction. The CCWs
ated address exceeds the value for the address
with 24-bit and 31-bit addresses are called
size (or, for the read-backward command is decre-
format-0 and format-1 CCWs, respectively.
mented below 0), an I/O program-check condition
Format-0 and format-1 CCWs are described in
is recognized.
Chapter 15, Basic I/O Functions. Similarly, the
size of the data address in an IDAW is under
Figure 3-2 on page 3-7 identifies what limit values
control of the IDAW-format-control bit in the ORB.
apply to the generation of different addresses and
The IDAWs with 31-bit and 64-bit addresses are
how addresses are handled when they exceed the
called format-1 and format-2 IDAWs, respectively.
allowed value.

3-6 z/Architecture Principles of Operation



Handling when
Address Address Would
Address Generation for Type Wrap

Instructions and operands when EAM and BAM are zero L,I,R,V W24

Successive bytes of instructions and operands when EAM and I,L,V W24
BAM are zero

Instructions and operands when EAM is zero and BAM is one L,I,R,V W31

Successive bytes of instructions and operands when EAM is I,L,V W31
zero and BAM is one

Instructions and operands when EAM and BAM are one L,I,R,V W64

Successive bytes of instructions and operands when EAM and I,L,V W64
BAM are one

DAT-table entries when used for implicit translation or LRA A or R X64
or STRAG

ASN-second-table, authority-table (during ASN authorization), R X31
linkage-table, and entry-table entries

Authority-table (during access-register translation) and A or R X31
access-list entries

Linkage-stack entry V W64

I/O measurement block A P31

For a channel program with format- CCWs:

Successive CCWs A P24

Successive IDAWs A P24

Successive bytes of I/O data (without IDAWs) A P24

Successive bytes of I/O data (with format-1 IDAWs) A P31

Successive bytes of I/O data (with format-2 IDAWs) A P64

For a channel program with format-1 CCWs:

Successive CCWs A P31

Successive IDAWs A P31

Successive bytes of I/O data (without IDAWs) A P31

Successive bytes of I/O data (with format-1 IDAWs) A P31

Successive bytes of I/O data (with format-2 IDAWs) A P64

Figure 3-2 (Part 1 of 2). Address Wraparound

Chapter 3. Storage 3-7



Explanation:

Real addresses do not apply in this case since the instructions which designate
operands by means of real addresses cannot designate operands that cross
boundary 2, 2, or 2.
It is unpredictable whether the address is absolute or real.
A Absolute address.
BAM Basic-addressing-mode bit in the PSW.
EAM Extended-addressing-mode bit in the PSW.
I Instruction address.
L Logical address.
P24 An I/O program-check condition is recognized when the address exceeds 2 - 1
or is decremented below zero.
P31 An I/O program-check condition is recognized when the address exceeds 2 - 1
or is decremented below zero.
P64 An I/O program-check condition is recognized when the address exceeds 2 - 1
or is decremented below zero.
R Real address.
V Virtual address.
W24 Wrap to location after location 2 - 1 and vice versa.
W31 Wrap to location after location 2 - 1 and vice versa.
W64 Wrap to location after location 2 - 1 and vice versa.
X31 When the address exceeds 2 - 1, it is unpredictable whether the address wraps
to location after location 2 - 1 or whether an addressing exception is
recognized.
X64 When the address exceeds 2 - 1, it is unpredictable whether the address wraps
to location after location 2 - 1 or whether an addressing exception is
recognized.

Figure 3-2 (Part 2 of 2). Address Wraparound

any access key is permitted; a one indicates that


Storage Key key-controlled protection applies to both fetching
A storage key is associated with each 4K-byte and storing. No distinction is made between the
block of storage that is available in the configura- fetching of instructions and of operands.
tion. The storage key has the following format:
Reference Bit (R): The reference bit, bit 5,
ACC FRC normally is set to one each time a location in the
corresponding storage block is referred to either
4 6 for storing or for fetching of information.
The bit positions in the storage key are allocated
Change Bit (C): The change bit, bit 6, is set to
as follows:
one each time information is stored at a location in
Access-Control Bits (ACC): If a reference is the corresponding storage block.
subject to key-controlled protection, the four
Storage keys are not part of addressable storage.
access-control bits, bits 0-3, are matched with the
The entire storage key is set by SET STORAGE
four-bit access key when information is stored, or
KEY EXTENDED and inspected by INSERT
when information is fetched from a location that is
STORAGE KEY EXTENDED. Additionally, the
protected against fetching.
instruction RESET REFERENCE BIT EXTENDED
Fetch-Protection Bit (F): If a reference is provides a means of inspecting the reference and
subject to key-controlled protection, the fetch- change bits and of setting the reference bit to
protection bit, bit 4, controls whether key- zero. Bits 0-4 of the storage key are inspected by
controlled protection applies to fetch-type the INSERT VIRTUAL STORAGE KEY instruction.
references: a zero indicates that only store-type The contents of the storage key are unpredictable
references are monitored and that fetching with during and after the execution of the usability test
of the TEST BLOCK instruction.

3-8 z/Architecture Principles of Operation



Protection Conditions Is Access to
Storage Permitted?
Four protection facilities are provided to protect Fetch-Protection
the contents of main storage from destruction or Bit of
Storage Key Key Relation Fetch Store
misuse by programs that contain errors or are
unauthorized: key-controlled protection, access- Match Yes Yes
list-controlled protection, page protection, and low- Mismatch Yes No
1 Match Yes Yes
address protection. The protection facilities are 1 Mismatch No No
applied independently; access to main storage is
only permitted when none of the facilities prohibit Explanation:
the access.
Match The four access-control bits of the
storage key are equal to the access
Key-controlled protection affords protection against key, or the access key is zero.
improper storing or against both improper storing
Yes Access is permitted.
and fetching, but not against improper fetching
alone. No Access is not permitted. On fetching,
the information is not made available
to the program; on storing, the con-
Key-Controlled Protection tents of the storage location are not
changed.

When key-controlled protection applies to a
storage access, a store is permitted only when the Figure 3-3. Summary of Protection Action
storage key matches the access key associated
with the request for storage access; a fetch is per- When a CPU access is prohibited because of key-
mitted when the keys match or when the fetch- controlled protection, the execution of the instruc-
protection bit of the storage key is zero. tion is terminated, and a program interruption for a
protection exception takes place. However, the
The keys are said to match when the four access- unit of operation or the execution of the instruction
control bits of the storage key are equal to the may be suppressed, as described in the section
access key, or when the access key is zero. Suppression on Protection on page 3-12. When
a channel-program access is prohibited, the start
The protection action is summarized in Figure 3-3. function is ended, and the protection-check condi-
tion is indicated in the associated interruption-
When the access to storage is initiated by the response block (IRB). When a
CPU and key-controlled protection applies, the measurement-block access is prohibited, the I/O
PSW key is the access key, except that the measurement-block protection-check condition is
access key is specified in a general register for indicated.
the first operand of MOVE TO SECONDARY and
MOVE WITH DESTINATION KEY and for the When a store access is prohibited because of key-
second operand of MOVE TO PRIMARY, MOVE controlled protection, the contents of the protected
WITH KEY, and MOVE WITH SOURCE KEY. location remain unchanged. When a fetch access
The PSW key occupies bit positions 8-11 of the is prohibited, the protected information is not
current PSW. loaded into a register, moved to another storage
location, or provided to an I/O device. For a pro-
When the access to storage is for the purpose of hibited instruction fetch, the instruction is sup-
channel-program execution, the subchannel key pressed, and an arbitrary instruction-length code is
associated with that channel program is the indicated.
access key. The subchannel key for a channel
program is specified in the operation-request block Key-controlled protection is independent of
(ORB). When, for purposes of channel-subsystem whether the CPU is in the problem or the super-
monitoring, an access to the measurement block visor state and, except as described below, does
is made, the measurement-block key is the access not depend on the type of CPU instruction or
key. The measurement-block key is specified by channel-command word being executed.
the SET CHANNEL MONITOR instruction.

Chapter 3. Storage 3-9


Except where otherwise specified, all accesses to Storage-Protection-Override Control
storage locations that are explicitly designated by Bit 39 of control register 0 is the storage-
the program and that are used by the CPU to protection-override control. When this bit is one,
store or fetch information are subject to key- storage-protection override is active. When this
controlled protection. bit is zero, storage-protection override is inactive.
When storage-protection override is active, key-
Key-controlled protection does not apply when the controlled storage protection is ignored for storage
storage-protection-override control is one and the locations having an associated storage-key value
value of the four access-control bits of the storage of 9. When storage-protection override is inactive,
key is 9. Key-controlled protection for fetches no special action is taken for a storage-key value
may or may not apply when the fetch-protection- of 9.
override control is one, depending on the effective
address and the private-space control. Storage-protection override applies to instruction
fetch and to the fetch and store accesses of
Accesses to the second operand of TEST BLOCK instructions whose operand addresses are logical,
are not subject to key-controlled protection. virtual, or real. It does not apply to accesses
made for the purpose of channel-program exe-
All storage accesses by the channel subsystem to cution or for the purpose of channel-subsystem
access the I/O measurement block, or by a monitoring.
channel program to fetch a CCW or IDAW or to
access a data area designated during the exe- Storage-protection override has no effect on
cution of a CCW, are subject to key-controlled accesses which are not subject to key-controlled
protection. However, if a CCW, an IDAW, or protection.
output data is prefetched, a protection check is not
indicated until the CCW or IDAW is due to take Programming Notes:
control or until the data is due to be written.
1. Storage-protection override can be used to
Key-controlled protection is not applied to improve reliability in the case when a possibly
accesses that are implicitly made for any of such erroneous application program is executed in
sequences as: conjunction with a reliable subsystem, pro-
vided that the application program needs to
An interruption access only a portion of the storage accessed
CPU logout by the subsystem. The technique for doing
Fetching of table entries for access-register this is as follows. The storage accessed by
translation, dynamic-address translation, the application program is given storage key
PC-number translation, ASN translation, or 9. The storage accessed by only the sub-
ASN authorization system is given some other nonzero storage
Tracing key, for example, key 8. The application is
A store-status function executed with PSW key 9. The subsystem is
Storing in real locations 184-191 when TEST executed with PSW key 8 (in this example).
PENDING INTERRUPTION has an operand As a result, the subsystem can access both
address of zero the key-8 and the key-9 storage, while the
Initial program loading application program can access only the key-9
Similarly, protection does not apply to accesses storage.
initiated via the operator facilities for altering or 2. Storage-protection override affects the
displaying information. However, when the accesses to storage made by the CPU and
program explicitly designates these locations, they also affects the result set by TEST PRO-
are subject to protection. TECTION. However, those instructions which,
in the problem state, test the PSW-key mask
to determine if a particular key value may be
used are not affected by whether storage-
protection override is active. These
instructions include, among others, MOVE
WITH KEY and SET PSW KEY FROM

3-10 z/Architecture Principles of Operation


ADDRESS. To permit these instructions to The fetch-only bit is included in the ALB access-
use an access key of 9 in the problem state, list entry. A change to the fetch-only bit in an
bit 9 of the PSW-key mask must be one. access-list entry in main storage does not neces-
sarily have an immediate, if any, effect on whether
Fetch-Protection-Override Control a protection exception is recognized. However,
Bit 38 of control register 0 is the fetch-protection- this change to the bit will have an effect imme-
override control. When the bit is one, fetch pro- diately after PURGE ALB or a COMPARE AND
tection is ignored for locations at effective SWAP AND PURGE instruction that purges the
addresses 0-2047. An effective address is the ALB is executed.
address which exists before any transformation by
dynamic address translation or prefixing. TEST PROTECTION takes into consideration
However, fetch protection is not ignored if the access-list-controlled protection when the CPU is
effective address is subject to dynamic address in the access-register mode. A violation of
translation and the private-space control, bit 55 is access-list-controlled protection causes condition
one in the address-space-control element used in code 1 to be set, except that it does not prevent
the translation. condition code 2 or 3 from being set when the
conditions for those codes are satisfied.
Fetch-protection override applies to instruction Programming Note: A violation of access-list-
fetch and to the fetch accesses of instructions controlled protection always causes suppression.
whose operand addresses are logical, virtual, or A violation of any of the other protection types
real. It does not apply to fetch accesses made for may cause termination.
the purpose of channel-program execution or for
the purpose of channel-subsystem monitoring.
When this bit is set to zero, fetch protection of Page Protection
locations at effective addresses 0-2047 is deter-
mined by the state of the fetch-protection bit of the The page-protection facility controls access to
storage key associated with those locations. virtual storage by using the page-protection bit in
each page-table entry and segment-table entry. It
Fetch-protection override has no effect on provides protection against improper storing.
accesses which are not subject to key-controlled
protection. The page-protection bit, bit 54, of the page-table
entry controls whether storing is allowed into the
Programming Note: The fetch-protection- corresponding 4K-byte page. When the bit is
override control allows fetch protection of locations zero, both fetching and storing are permitted;
at addresses 2048-4095 along with no fetch pro- when the bit is one, only fetching is permitted.
tection of locations at addresses 0-2047. When an attempt is made to store into a protected
page, the contents of the page remain unchanged,
Access-List-Controlled Protection the unit of operation or the execution of the
instruction is suppressed, and a program inter-
In the access-register mode, bit 6 of the access- ruption for protection takes place.
list entry, the fetch-only bit, controls which types of
operand references are permitted to the address The page-protection bit, bit 54, of the segment-
space specified by the access-list entry. When table entry is treated as being ORed into the
the entry is used in the access-register-translation page-protection-bit position of each entry in the
part of a reference and bit 6 is zero, both fetch- page table designated by the segment-table entry.
type and store-type references are permitted; Thus, when the segment-table-entry page-
when bit 6 is one, only fetch-type references are protection bit is one, the effect is as if the page-
permitted, and an attempt to store causes a pro- protection bit is one in each entry in the
tection exception to be recognized and the exe- designated page table.
cution of the instruction to be suppressed.
Page protection applies to all store-type refer-
ences that use a virtual address.

Chapter 3. Storage 3-11


Low-Address Protection storing of the I/O-interruption code in real locations
184-191 by TEST PENDING INTERRUPTION,
The low-address-protection facility provides pro- and the initial-program-loading and store-status
tection against the destruction of main-storage functions, nor is it applied to data stores during I/O
information used by the CPU during interruption data transfer. However, explicit stores by a
processing. This is accomplished by prohibiting program at any of these locations are subject to
instructions from storing with effective addresses low-address protection.
in the ranges 0 through 511 and 4096 through
Programming Notes:
4607 (the first 512 bytes of each of the first and
second 4K-byte effective-address blocks). The 1. Low-address protection and key-controlled
range criterion is applied before address transfor- protection apply to the same store accesses,
mation, if any, of the address by dynamic address except that:
translation or prefixing. However, the range crite-
a. Low-address protection does not apply to
rion is not applied, with the result that low-address
storing performed by the channel sub-
protection does not apply, if the effective address
system, whereas key-controlled protection
is subject to dynamic address translation and the
does.
private-space control, bit 55, is one in the
address-space-control element used in the trans- b. Key-controlled protection does not apply
lation. Low-address protection does not apply if to tracing, the second operand of TEST
the address-space-control element to be used is BLOCK, or instructions that operate spe-
not available due to another type of exception. cifically on the linkage stack, whereas low-
address protection does.
Low-address protection is under control of bit 35
2. Because fetch-protection override and low-
of control register 0, the low-address-protection-
address protection do not apply to an address
control bit. When the bit is zero, low-address pro-
space for which the private-space control is
tection is off; when the bit is one, low-address
one in the address-space-control element,
protection is on.
locations 0-2047 and 4096-4607 in the
address space are usable the same as the
If an access is prohibited because of low-address
other locations in the space.
protection, the contents of the protected location
remain unchanged, the execution of the instruction
is terminated, and a program interruption for a Suppression on Protection
protection exception takes place. However, the
unit of operation or the execution of the instruction Some instruction definitions specify that the opera-
may be suppressed, as described in the section tion is always suppressed if a protection exception
Suppression on Protection. due to any type of protection is recognized. When
that specification is absent, the execution of an
Any attempt by the program to store by using instruction is always suppressed if a protection
effective addresses in the range 0 through 511 or exception due to access-list-controlled protection
4096 through 4607 is subject to low-address pro- or page protection is recognized, and it may be
tection. Low-address protection is applied to the either suppressed or terminated if a protection
store accesses of instructions whose operand exception due to low-address protection or key-
addresses are logical, virtual, or real. Low- controlled protection is recognized.
address protection is also applied to the trace
table. The suppression-on-protection function allows the
control program to locate the segment-table entry
Low-address protection is not applied to accesses and page-table entry used in the translation of a
made by the CPU or the channel subsystem for virtual address that caused a protection exception,
such sequences as interruptions, CPU logout, the in order to determine if the exception was due to
page protection.1 This is necessary for the imple-

1 The suppression-on-protection function originated as the ESA/390 suppression-on-protection facility. Suppression for page pro-
tection was new as part of that facility.

3-12 z/Architecture Principles of Operation


mentation of the Posix fork function (discussed in tents of the remainder of real locations 168-175,
a programming note). The function also allows and of real location 160 are unpredictable.
the control program to avoid locating the segment-
table and page-table entries if the address was Bit 61 is set to one if the protection exception was
not virtual or the exception was due to access-list- due to access-list-controlled protection or page
controlled protection. protection. Bit 61 may be set to one if the pro-
tection exception was due to low-address pro-
During a program interruption due to a protection tection or key-controlled protection.
exception, either a one or a zero is stored in bit
position 61 of real locations 168-175. The storing If a protection-exception condition exists due to
of a one in bit position 61 indicates that: either access-list-controlled protection or page pro-
tection but also exists due to either low-address
The unit of operation or instruction execution
protection or key-controlled protection, it is unpre-
during which the exception was recognized
dictable for which reason the protection exception
was suppressed.
is recognized, and it is unpredictable whether bit
If dynamic address translation (DAT) was on, 61 is set to zero or one.
as indicated by the DAT-mode bit in the
program old PSW, the effective address that Programming Notes:
caused the exception is one that was to be 1. The suppression-on-protection function is
translated by DAT. (The effective address is useful in performing the Posix fork function,
the address which exists before any transfor- which causes a duplicate address space to be
mation by DAT or prefixing.) Bit 61 is set to created. When forking occurs, the control
zero if DAT was on but the effective address program causes the same page of different
was not to be translated by DAT because it is address spaces to map to a single page frame
a real address. If DAT was off, the protection of real storage so long as a store in the page
exception cannot have been due to page pro- is not attempted. Then, when a store is
tection. attempted in a particular address space, the
Bit positions 0-51 of real locations 168-175 control program assigns a unique page frame
contain bits 0-51 of the effective address that to the page in that address space and copies
caused the exception. If DAT was on, indi- the contents of the page to the new page
cating that the effective address was to be frame. This last action is sometimes called
translated by DAT, bit positions 62 and 63 of the copy-on-write function. The control
real locations 168-175, and real location 160, program sets the page-protection bit to one in
contain the same information as is stored the page-table entry for a page in order to
during a program interruption due to a page- detect an attempt to store in the page. The
translation exceptionthis information identi- control program may initially set the page-
fies the address space containing the protection bit to one in a segment-table entry
protected address. Also, bit 60 of real to detect an attempt to store anywhere in the
locations 168-175 is zero if the protection the specified segment.
exception was not due to access-list-controlled 2. Bit 61 being one in real locations 168-175
protection or is one if the exception was due when DAT was on indicates that the address
to access-list-controlled protection. A one in that caused a protection exception is virtual.
bit position 60 indicates that the exception This indication allows programmed forms of
was not due to page protection. If DAT was access-register translation and dynamic
off, the contents of bit positions 60, 62, and 63 address translation to be performed to deter-
of real locations 168-175, and the contents of mine whether the exception was due to page
real location 160, are unpredictable. The con- protection as opposed to low-address or key-
tents of bit positions 52-59 of real locations controlled protection.
168-175 are always unpredictable.
3. The results of suppression on protection are
Bit 61 being zero indicates that the operation was summarized in Figure 3-4 on page 3-14.
either suppressed or terminated and that the con-

Chapter 3. Storage 3-13


Reference recording does not occur for operand
If Bit 61 One accesses of the following instructions since they
LA or ALC directly refer to a storage key without accessing a
Key- or Bits 62,
Cont. Page Eff. Bit63 and Bit storage location:
Prot.DATProt.Addr.61 Loc. 16 6 INSERT STORAGE KEY EXTENDED

No On Yes Log. 1 P 1A RESET REFERENCE BIT EXTENDED (refer-


Yes On Yes Log. U1 P 1A ence bit is set to zero)
SET STORAGE KEY EXTENDED (reference
Yes Off No Log. U2 U3 U3 bit is set to a specified value)
Yes Off No Real U2 U3 U3
Yes On No Log. U2 P The record provided by the reference bit is sub-
Yes On No Real R - - stantially accurate. The reference bit may be set
to one by fetching data or instructions that are
Explanation: neither designated nor used by the program, and,

- Immaterial or not applicable. under certain conditions, a reference may be
R Zero because effective address made without the reference bit being set to one.
is real. Under certain unusual circumstances, a reference
1A One if bit 61 is set to one bit may be set to zero by other than explicit
because of access-list- program action.
controlled protection; zero
otherwise.
ALC Access-list-controlled.
LA Low-address. Change Recording
Log. Logical.
Change recording provides information as to
P Predictable.
U1 Unpredictable because low- which pages have to be saved in auxiliary storage
address or key-controlled when they are replaced in main storage. Change
protection may be recognized recording uses the change bit, bit 6 of the storage
instead of access-list- key.
controlled or page protection.
U2 Unpredictable because bit 61 is
The change bit is set to one each time a store
only required to be set to one
for access-list-controlled or access causes the contents in the corresponding
page protection. storage block to be changed. A store access that
U3 Unpredictable because DAT is does not change the contents of storage may or
off. may not set the change bit to one.

Figure 3-4. Suppression-on-Protection Results The change bit is not set to one for an attempt to
store if the access is prohibited. In particular:
1. For the CPU, a store access is prohibited
Reference Recording whenever an access exception exists for that
Reference recording provides information for use access, or whenever an exception exists
in selecting pages for replacement. Reference which is of higher priority than the priority of
recording uses the reference bit, bit 5 of the an access exception for that access.
storage key. The reference bit is set to one each 2. For the channel subsystem, a store access is
time a location in the corresponding storage block prohibited whenever a key-controlled-
is referred to either for fetching or storing informa- protection violation exists for that access.
tion, regardless of whether DAT is on or off.
Change recording is always active and takes
Reference recording is always active and takes place for all store accesses to storage, including
place for all storage accesses, including those those made by any CPU, any operator facility, or
made by any CPU, any operator facility, or the the channel subsystem. It takes place for implicit
channel subsystem. It takes place for implicit references made by the machine, such as those
accesses made by the machine, such as those which are part of interruptions.
which are part of interruptions and I/O-instruction
execution.

3-14 z/Architecture Principles of Operation


Change recording does not take place for the /
operands of the following instructions since they Prefix Bits 33-5 /////////////
directly modify a storage key without modifying a /
33 51 63
storage location:
Bits 0-32 of the register are always all zeros. Bits
RESET REFERENCE BIT EXTENDED
33-50 of the register can be set and inspected by
SET STORAGE KEY EXTENDED (change bit
the privileged instructions SET PREFIX and
is set to a specified value)
STORE PREFIX, respectively.
Change bits which have been changed from zeros
SET PREFIX sets bits 33-50 of the prefix register
to ones are not necessarily restored to zeros on
with the value in bit positions 1-18 of a word in
CPU retry (see CPU Retry on page 11-2). See
storage, and it ignores the contents of bit positions
Exceptions to Nullification and Suppression on
0 and 19-31 of the word. STORE PREFIX stores
page 5-22 for a description of the handling of the
the value in bit positions 33-50 of the prefix reg-
change bit in certain unusual situations.
ister in bit positions 1-18 of a word in storage, and
it stores zeros in bit positions 0 and 19-31 of the
word.
Prefixing
Prefixing provides the ability to assign the range of When the contents of the prefix register are
real addresses 0-8191 to a different block in abso- changed, the change is effective for the next
lute storage for each CPU, thus permitting more sequential instruction.
than one CPU sharing main storage to operate
concurrently with a minimum of interference, espe- When prefixing is applied, the real address is
cially in the processing of interruptions. transformed into an absolute address by using
one of the following rules, depending on bits 0-50
Prefixing causes real addresses in the range of the real address:
0-8191 to correspond one-for-one to the block of 1. Bits 0-50 of the address, if all zeros, are
8K-byte absolute addresses (the prefix area) iden- replaced with bits 0-50 of the prefix.
tified by the value in bit positions 0-50 of the prefix
register for the CPU, and the block of real 2. Bits 0-50 of the address, if equal to bits 0-50
addresses identified by that value in the prefix reg- of the prefix, are replaced with zeros.
ister to correspond one-for-one to absolute 3. Bits 0-50 of the address, if not all zeros and
addresses 0-8191. The remaining real addresses not equal to bits 0-50 of the prefix, remain
are the same as the corresponding absolute unchanged.
addresses. This transformation allows each CPU
to access all of main storage, including the first 8K Only the address presented to storage is trans-
bytes and the locations designated by the prefix lated by prefixing. The contents of the source of
registers of other CPUs. the address remain unchanged.

The relationship between real and absolute The distinction between real and absolute
addresses is graphically depicted in Figure 3-5 on addresses is made even when the prefix register
page 3-16. contains all zeros, in which case a real address
and its corresponding absolute address are iden-
The prefix is a 51-bit quantity contained in bit posi- tical.
tions 0-50 of the prefix register. The register has
the following format:

Chapter 3. Storage 3-15


Prefixing Prefixing


No Change5
/ / /
Apply %No Change
1Zeros 52

/ / /
Apply
2% Zeros1



/ / /
No Change5

%No Change



8192 Apply 8192 Apply 8192
Prefix 5 % Prefix

Real Addresses Absolute Real Addresses
for CPU A Addresses for CPU B

(1) Real addresses in which bits 0-50 are equal to bits 0-50 of the prefix for this CPU (A or B).

(2) Absolute addresses of the block that contains for this CPU (A or B) the real locations 0-8191.
Figure 3-5. Relationship between Real and Absolute Addresses

treating it as a real address and without using any


Address Spaces tables.
An address space is a consecutive sequence of
integer numbers (virtual addresses), together with DAT uses, at different times, the address-space-
the specific transformation parameters which allow control elements in different control registers or
each number to be associated with a byte location specified by the access registers. The choice is
in storage. The sequence starts at zero and pro- determined by the translation mode specified in
ceeds left to right. the current PSW. Four translation modes are
available: primary-space mode, secondary-space
When a virtual address is used by a CPU to mode, access-register mode, and home-space
access main storage, it is first converted, by mode. Different address spaces are addressable
means of dynamic address translation (DAT), to a depending on the translation mode.
real address, and then, by means of prefixing, to
an absolute address. DAT may use from five to At any instant when the CPU is in the primary-
two levels of tables (region first table, region space mode or secondary-space mode, the CPU
second table, region third table, segment table, can translate virtual addresses belonging to two
and page table) as transformation parameters. address spacesthe primary address space and
The designation (origin and length) of the highest- the secondary address space. At any instant
level table for a specific address space is called when the CPU is in the access-register mode, it
an address-space-control element, and it is found can translate virtual addresses of up to 16
for use by DAT in a control register or as specified address spacesthe primary address space and
by an access register. Alternatively, the address- up to 15 AR-specified address spaces. At any
space-control element for an address space may instant when the CPU is in the home-space mode,
be a real-space designation, which indicates that it can translate virtual addresses of the home
DAT is to translate the virtual address simply by address space.

3-16 z/Architecture Principles of Operation


The primary address space is identified as such mechanism which, given an ASN, can locate the
because it consists of primary virtual addresses, designated ASN-second-table entry.
which are translated by means of the primary
address-space-control element (ASCE). Similarly, The 16-bit unsigned binary format of the ASN
the secondary address space consists of sec- permits 64K unique ASNs.
ondary virtual addresses translated by means of
the secondary ASCE, the AR-specified address The ASNs for the primary and secondary address
spaces consist of AR-specified virtual addresses spaces are assigned positions in control registers.
translated by means of AR-specified ASCEs, and The ASN for the primary address space, called
the home address space consists of home virtual the primary ASN, is assigned bits 48-63 in control
addresses translated by means of the home register 4, and that for the secondary address
ASCE. The primary and secondary ASCEs are in space, called the secondary ASN, is assigned bits
control registers 1 and 7, respectively. The 48-63 in control register 3. The registers have the
AR-specified ASCEs are in control registers 1 and following formats:
7 and in table entries called ASN-second-table
entries. The home ASCE is in control register 13. Control Register 4

PASN
Changing to Different Address Spaces
A program can cause different address spaces to 48 63
be addressable by using the semiprivileged SET
ADDRESS SPACE CONTROL or SET ADDRESS Control Register 3
SPACE CONTROL FAST instruction to change
the translation mode to the primary-space mode, SASN
secondary-space mode, access-register mode, or
home-space mode. However, SET ADDRESS 48 63
SPACE CONTROL and SET ADDRESS SPACE
CONTROL FAST can set the home-space mode A semiprivileged instruction that loads the primary
only in the supervisor state. The program can or secondary address-space-control element into
cause still other address spaces to be address- the appropriate control register also loads the cor-
able by using other semiprivileged instructions to responding ASN into the appropriate control reg-
change the address-space-control elements in ister.
control registers 1 and 7 and by using unprivileged
instructions to change the contents of the access The ASN for the home address space is not
registers. Only the privileged LOAD CONTROL assigned a position in a control register.
instruction is available for changing the home
address-space-control element in control register An access register containing the value 0 or 1
13. specifies the primary or secondary address space,
respectively; and the address-space-control
Address-Space Number element specified by the access register is in
An address space may be assigned an address- control register 1 or 7, respectively. An access
space number (ASN) by the control program. The register containing any other value designates an
ASN designates, within a two-level table structure entry in a table called an access list. The desig-
in main storage, an ASN-second-table entry con- nated access-list entry contains the real address
taining information about the address space. If of an ASN-second-table entry for the address
the ASN-second-table entry is marked as valid, it space specified by the access register. The
contains the address-space-control element that address-space-control element specified by the
defines the address space. access register is in the ASN-second-table entry.
Translating the contents of an access register to
Under certain circumstances, the semiprivileged obtain an address-space-control element for use
instructions which place a new address-space- by DAT does not involve the use of an ASN.
control element in control register 1 or 7 fetch this Note: Virtual storage consisting of byte locations
element from an ASN-second-table entry. Some ordered according to their virtual addresses in an
of these instructions use an ASN-translation address space is usually referred to as storage.

Chapter 3. Storage 3-17


Programming Note: Because an are used to locate the ASN-second-table entry
ASN-second-table entry is located from an and a third table, the authority table, which is used
access-list entry by means of its address instead when ASN authorization is performed.
of by means of its ASN, the ASN-second-table
entries designated by access-list entries can be For the purposes of this translation, the 16-bit
pseudo ASN-second-table entries, that is, entries ASN is considered to consist of two parts: the
which are not in the two-level structure able to be ASN-first-table index (AFX) is the leftmost 10 bits
indexed by means of the ASN-translation process. of the ASN, and the ASN-second-table index
The number of unique pseudo ASN-second-table (ASX) is the six rightmost bits. The ASN has the
entries can be greater than the number of unique following format:
ASNs and is limited only by the amount of storage
available to be occupied by the ASN-second-table ASN
entries. Thus, in a sense, there is no limit on the
AFX ASX
number of possible address spaces.
1 15

ASN Translation The AFX is used to select an entry from the ASN
ASN translation is the process of translating a first table. The origin of the ASN first table is des-
16-bit ASN to locate the ASN-second-table entry ignated by the ASN-first-table origin in control reg-
designated by the ASN. ASN translation is per- ister 14. The ASN-first-table entry contains the
formed as part of PROGRAM TRANSFER with origin of the ASN second table. The ASX is used
space switching (PT-ss) and SET SECONDARY to select an entry from the ASN second table.
ASN with space switching (SSAR-ss), and it may
be performed as part of LOAD ADDRESS SPACE As a result of primary ASN translation and during
PARAMETERS. For PT-ss, the ASN which is the operation of PROGRAM CALL with space
translated replaces the primary ASN in control switching, the address of the located
register 4. For SSAR-ss, the ASN which is trans- ASN-second-table entry (ASTE) is placed in
lated replaces the secondary ASN in control reg- control register 5 as the new primary-ASTE origin
ister 3. These two translation processes are (PASTEO).
called primary ASN translation and secondary
ASN translation, respectively, and both can occur ASN-Translation Controls
for LOAD ADDRESS SPACE PARAMETERS.
The ASN-translation process is the same for both ASN translation is controlled by the
primary and secondary ASN translation; only the ASN-translation-control bit and the ASN-first-table
uses of the results of the process are different. origin, both of which reside in control register 14.

ASN translation may also be performed as part of


Control Register 14
PROGRAM RETURN. Primary ASN translation is
performed as part of PROGRAM RETURN with
space switching (PR-ss). Secondary ASN trans- T AFTO

lation is performed if the secondary ASN restored 44 63
by PROGRAM RETURN (PR-ss or PROGRAM
RETURN to current primary) does not equal the ASN-Translation Control (T): Bit 44 of control
primary ASN restored by PROGRAM RETURN. register 14 is the ASN-translation-control bit. This
bit provides a mechanism whereby the control
PROGRAM CALL with space switching (PC-ss) program can indicate whether ASN translation can
performs the equivalent of primary ASN translation occur while a particular program is being exe-
by obtaining a primary ASN and the address of cuted, and also whether the execution of
the corresponding ASN-second-table entry from PROGRAM CALL with space switching is allowed.
an entry-table entry. Bit 44 must be one to allow completion of these
instructions:
The ASN-translation process uses two tables, the
ASN first table and the ASN second table. They LOAD ADDRESS SPACE PARAMETERS
PROGRAM CALL with space switching

3-18 z/Architecture Principles of Operation


PROGRAM RETURN with space switching or
when the restored SASN does not equal the AX ATL
restored PASN
32 48 6 63
PROGRAM TRANSFER with space switching
SET SECONDARY ASN
ASCE (RTD, STD, or RSD) Part 1
Otherwise, a special-operation exception is recog-
nized. The ASN-translation-control bit is exam- RTO, STO, or RSTKO
ined in both the problem and the supervisor
64 95
states.

ASN-First-Table Origin (AFTO): Bits 45-63 of RTD or STD Part 2


control register 14, with 12 zeros appended on the
RTO/STO (Cont.) GPSXR DTTL R=
right, form a 31-bit real address that designates

the beginning of the ASN first table. 96 115 118 122 124 127

ASN-Translation Tables RSD Part 2



The ASN-translation process consists in a two- RSTKO (Cont.) GPSXR R=1
level lookup using two tables: an ASN first table
96 115 118 122 127
and an ASN second table. These tables reside in
real storage.
ALD

ASN-First-Table Entries ALO ALL
An entry in the ASN first table has the following
format: 128 153 159

I ASTO
ASTESN
1 26 31
16 191
The fields in the entry are allocated as follows:
LTD
AFX-Invalid Bit (I): Bit 0 controls whether the
ASN second table associated with the V LTO LTL
ASN-first-table entry is available. When bit 0 is
zero, ASN translation proceeds by using the des- 192 217 223
ignated ASN second table. When the bit is one,
the ASN translation cannot continue.
/////////////////////////////////
ASN-Second-Table Origin (ASTO): Bits 1-25,
224 255
with six zeros appended on the right, are used to
form a 31-bit real address that designates the
beginning of the ASN second table. The fields in bytes 0-31 of the ASN-second-table
entry are allocated as follows. Only the fields that
ASN-Second-Table Entries are used in or as a result of ASN translation or
The ASN-second-table entry has a length of 64 PROGRAM CALL with space switching are
bytes, with only the first 32 bytes currently in use. described in detail.
Bytes 0-31 of the entry have the following format:
ASX-Invalid Bit (I): Bit 0 controls whether the
address space associated with the
I ATO B ASN-second-table entry is available. When bit 0
is zero, ASN translation proceeds. When the bit is
1 3 31 one, the ASN translation cannot continue.

Chapter 3. Storage 3-19


Authority-Table Origin (ATO): Bits 1-29, with field replaces the SASCE. The contents of the
two zeros appended on the right, are used to form entire ASCE field are placed in the appropriate
a 31-bit real address that designates the begin- control registers without being inspected for
ning of the authority table. validity.

Base-Space Bit (B): Bit 31 specifies, when one, The subspace-group-control bit (G), bit 118 of the
that the address space associated with the ASCE field, indicates, when one, that the ASCE
ASN-second-table entry is the base space of a specifies an address space that is the base space
subspace group. Bit 31 is further described in or a subspace of a subspace group. The bit is
Subspace-Group ASN-Second-Table Entries on further described in Subspace-Group
page 5-57. ASN-Second-Table Entries on page 5-57.

Authorization Index (AX): Bits 32-47 are used Bit 121 (X) of the ASCE field is the space-switch-
in ASN authorization as an index to locate the event-control bit. When, in the space-switching
authority bits in the authority table. The AX field is operations of PROGRAM CALL, PROGRAM
used as a result of primary ASN translation by RETURN, and PROGRAM TRANSFER, this bit is
PROGRAM RETURN and PROGRAM one in control register 1 either before or after the
TRANSFER and, possibly, LOAD ADDRESS execution of the instruction, a program interruption
SPACE PARAMETERS. It is also used by for a space-switch event occurs after the exe-
PROGRAM CALL with space switching. The AX cution of the instruction is completed. A space-
field is ignored after secondary ASN translation. switch-event program interruption also occurs after
the completion of a SET ADDRESS SPACE
Authority-Table Length (ATL): Bits 48-59 CONTROL, SET ADDRESS SPACE CONTROL
specify the length of the authority table in units of FAST, or RESUME PROGRAM instruction that
four bytes, thus making the authority table variable changes the translation mode either to or from the
in multiples of 16 entries. The length of the home-space mode when this bit is one in either
authority table, in units of four bytes, is one more control register 1 or control register 13. When, in
than the ATL value. The contents of the ATL field LOAD ADDRESS SPACE PARAMETERS, this bit
are used to establish whether the entry designated is one during primary ASN translation, this fact is
by a particular AX falls within the authority table. indicated by the condition code.

Address-Space-Control Element (ASCE): Bits The real-space-control bit (R), bit 122 of the ASCE
64-127 are an eight-byte address-space-control field, indicates, when zero, that the ASCE is a
element (ASCE) that may be a region-table desig- region-table or segment-table designation or,
nation (RTD), a segment-table designation (STD), when one, that the ASCE is a real-space desig-
or a real-space designation (RSD). (The term nation.
region-table designation is used to mean a
region-first-table designation, region-second-table When bit 122 is zero, the designation-type-control
designation, or region-third-table designation.) bits (DT), bits 124 and 125 of the ASCE field, indi-
The ASCE field is used as a result of ASN trans- cate the designation type of the ASCE. A value
lation or in PROGRAM CALL with space switching 11, 10, 01, or 00 binary of bits 124 and 125 indi-
to replace the primary ASCE (PASCE) or the sec- cates a region-first-table designation, region-
ondary ASCE (SASCE). For PROGRAM CALL second-table designation, region-third-table
with space switching, the ASCE field replaces the designation, or segment-table designation, respec-
PASCE, bits 0-63 of control register 1. For SET tively.
SECONDARY ASN, the ASCE field replaces the
SASCE, bits 0-63 of control register 7. Each of The other fields in the ASCE (RTO, STO, P, S,
these actions may occur independently for LOAD TL, and RSTKO) are described in Control Reg-
ADDRESS SPACE PARAMETERS. For ister 1 on page 3-29.
PROGRAM TRANSFER, the ASCE field replaces
both the PASCE and the SASCE. For PROGRAM The linkage-table-designation (LTD) field in the
RETURN, as a result of primary ASN translation, ASN-second-table entry is described in
the ASCE field replaces the PASCE, and, as a PC-Number Translation Control on page 5-29.
result of secondary ASN translation, the ASCE The access-list-designation (ALD) field and the

3-20 z/Architecture Principles of Operation


ASTE-sequence-number (ASTESN) field are code. Translation of an ASN is performed by
described in ASN-Second-Table Entries on means of two tables, an ASN first table and an
page 5-47. Bits 224-255 in the ASN-second-table ASN second table, both of which reside in main
entry are available for use by programming. storage.
Programming Note: All unused fields in the
The ASN first index is used to select an entry from
ASN-second-table entry, including the unused
the ASN first table. This entry designates the
fields in bytes 0-31 and all of bytes 32-63, should
ASN second table to be used.
be set to zeros. These fields are reserved for
future extensions, and programs which place The ASN second index is used to select an entry
nonzero values in these fields may not operate from the ASN second table.
compatibly on future machines.
If the I bit is one in either the ASN-first-table entry
ASN-Translation Process or ASN-second-table entry, the entry is invalid,
and the ASN-translation process cannot be com-
This section describes the ASN-translation pleted. An AFX-translation exception or
process as it is performed during the execution of ASX-translation exception is recognized.
the space-switching forms of PROGRAM
RETURN, PROGRAM TRANSFER, and SET Whenever access to main storage is made during
SECONDARY ASN, and also in PROGRAM the ASN-translation process for the purpose of
RETURN when the restored secondary ASN does fetching an entry from an ASN first table or ASN
not equal the restored primary ASN. ASN trans- second table, key-controlled protection does not
lation for LOAD ADDRESS SPACE PARAME- apply.
TERS is the same, except that AFX-translation
and ASX-translation exceptions do not occur; such The ASN-translation process is shown in
conditions are instead indicated by the condition Figure 3-6 on page 3-22.

Chapter 3. Storage 3-21


ASN

CR14 T AFTO AFX ASX

(x496) (x4) (x64)





6
ASN First Table
5+



5
R I ASTO

(x64)







6
ASN Second Table
5+



5
R I ATO B AX ATL ASCE \



R: Address is real
\: Last 48 bytes of ASTE are not shown
Figure 3-6. ASN Translation

ASN-First-Table Lookup All four bytes of the ASN-first-table entry appear to


The AFX portion of the ASN, in conjunction with be fetched concurrently as observed by other
the ASN-first-table origin, is used to select an CPUs. The fetch access is not subject to pro-
entry from the ASN first table. tection. When the storage address which is gen-
erated for fetching the ASN-first-table entry
The 31-bit real address of the ASN-first-table entry designates a location which is not available in the
is obtained by appending 12 zeros on the right to configuration, an addressing exception is recog-
the AFT origin contained in bit positions 45-63 of nized, and the operation is suppressed.
control register 14 and adding the AFX portion
with two rightmost and 19 leftmost zeros Bit 0 of the four-byte AFT entry specifies whether
appended. This addition cannot cause a carry the corresponding AST is available. If this bit is
into bit position 0. The 31-bit address is formed one, an AFX-translation exception is recognized.
and used regardless of whether the current PSW The entry fetched from the AFT is used to access
specifies the 24-bit, 31-bit, or 64-bit addressing the AST.
mode.

3-22 z/Architecture Principles of Operation


ASN-Second-Table Lookup ASN with space switching (SSAR-ss) and may be
The ASX portion of the ASN, in conjunction with performed as part of LOAD ADDRESS SPACE
the ASN-second-table origin contained in the PARAMETERS. ASN authorization is performed
ASN-first-table entry, is used to select an entry after the ASN-translation process for these
from the ASN second table. instructions.

The 31-bit real address of the ASN-second-table ASN authorization is also performed as part of
entry is obtained by appending six zeros on the PROGRAM RETURN when the restored sec-
right to bits 1-25 of the ASN-first-table entry and ondary ASN does not equal the restored primary
adding the ASX with six rightmost and 19 leftmost ASN. ASN authorization of the restored sec-
zeros appended. When a carry into bit position 0 ondary ASN is performed after ASN translation of
occurs during the addition, an addressing excep- the restored secondary ASN.
tion may be recognized, or the carry may be
ignored, causing the table to wrap from 2 - 1 to When performed as part of PT-ss, the ASN
zero. The 31-bit address is formed and used authorization tests whether the ASN can be estab-
regardless of whether the current PSW specifies lished as the primary ASN and is called
the 24-bit, 31-bit, or 64-bit addressing mode. primary-ASN authorization. When performed as
part of LOAD ADDRESS SPACE PARAMETERS,
The fetch of the 64 bytes of the ASN-second-table PROGRAM RETURN, or SSAR-ss, the ASN
entry appears to be word-concurrent as observed authorization tests whether the ASN can be estab-
by other CPUs, with the leftmost word fetched lished as the secondary ASN and is called
first. The order in which the remaining 15 words secondary-ASN authorization.
are fetched is unpredictable. The fetch access is
not subject to protection. When the storage The ASN authorization is performed by means of
address which is generated for fetching the an authority table in real storage which is desig-
ASN-second-table entry designates a location nated by the authority-table-origin and authority-
which is not available in the configuration, an table-length fields in the ASN-second-table entry.
addressing exception is recognized, and the oper-
ation is suppressed. ASN-Authorization Controls
Bit 0 of the ASN-second-table entry specifies ASN authorization uses the authority-table origin
whether the address space is accessible. If this and the authority-table length from the
bit is one, an ASX-translation exception is recog- ASN-second-table entry, together with an authori-
nized. zation index.

Recognition of Exceptions during ASN Control Register 4


Translation For PT-ss and SSAR-ss, the current contents of
The exceptions which can be encountered during control register 4 include the authorization index.
the ASN-translation process are collectively For LOAD ADDRESS SPACE PARAMETERS and
referred to as ASN-translation exceptions. A list PROGRAM RETURN, the value which will
of these exceptions and their priorities is given in become the new contents of control register 4 is
Chapter 6, Interruptions. used. The register has the following format:

AX
ASN Authorization
32 48
ASN authorization is the process of testing
whether the program associated with the current Authorization Index (AX): Bits 32-47 of control
authorization index is permitted to establish a par- register 4 are used as an index to locate the
ticular address space. The ASN authorization is authority bits in the authority table.
performed as part of PROGRAM TRANSFER with
space switching (PT-ss) and SET SECONDARY

Chapter 3. Storage 3-23


ASN-Second-Table Entry the establishment is permitted. If the P bit is zero,
The ASN-second-table entry which is fetched as the establishment is not permitted.
part of the ASN translation process contains infor-
mation which is used to designate the authority Secondary Authority (S): The right bit of an
table. An entry in the ASN second table has the authority-table entry controls whether the program
following format: with the corresponding authorization index is per-
mitted to establish the address space as a sec-
ondary address space. If the S bit is one, the
ATO B establishment is permitted. If the S bit is zero, the
establishment is not permitted.
1 31
The authority table is also used in the extended-
authorization process, as part of access-register
ATL translation. Extended authorization is described in

32 48 6 64 Authorizing the Use of the Access-List Entry on


page 5-52.

Authority-Table Origin (ATO): Bits 1-29, with


two zeros appended on the right, are used to form ASN-Authorization Process
a 31-bit real address that designates the begin-
This section describes the ASN-authorization
ning of the authority table.
process as it is performed during the execution of
Authority-Table Length (ATL): Bits 48-59 PROGRAM TRANSFER with space switching and
specify the length of the authority table in units of SET SECONDARY ASN with space switching.
four bytes, thus making the authority table variable For these two instructions, the ASN-authorization
in multiples of 16 entries. The length of the process is performed by using the authorization
authority table, in units of four bytes, is equal to index currently in control register 4. Secondary
one more than the ATL value. The contents of authorization for PROGRAM RETURN, when the
the length field are used to establish whether the restored secondary ASN does not equal the
entry designated by the authorization index falls restored primary ASN, and for LOAD ADDRESS
within the authority table. SPACE PARAMETERS is the same, except that
the value which will become the new contents of
control register 4 is used for the authorization
Authority-Table Entries index. Also, for LOAD ADDRESS SPACE
PARAMETERS, a secondary-authority exception
The authority table consists of entries of two bits does not occur. Instead, such a condition is indi-
each; accordingly, each byte of the authority table cated by the condition code.
contains four entries in the following format:
The ASN-authorization process is performed by
PSPSPSPS using the authorization index, in conjunction with
the authority-table origin and length from the AST
7
entry, to select an authority-table entry. The entry
The fields are allocated as follows: is fetched, and either the primary- or secondary-
authority bit is examined, depending on whether
Primary Authority (P): The left bit of an the primary- or secondary-ASN-authorization
authority-table entry controls whether the program process is being performed. The
with the authorization index corresponding to the ASN-authorization process is shown in Figure 3-7
entry is permitted to establish the address space on page 3-25.
as a primary address space. If the P bit is one,

3-24 z/Architecture Principles of Operation



CR4 AX

(x1/4)




ASN Second Table



ASN-Second-Table Entry

I ATO B AX ATL ASCE \

(x4)




6
Authority Table
5+
For primary ASN authorization (PT-ss only):
Primary-authority exception if P bit
zero or table length exceeded.
5
R PS For secondary ASN authorization (PR and SSAR-ss only):
Secondary-authority exception if S bit
zero or table length exceeded.

For secondary ASN authorization (LASP only):
Set condition code 2 if S bit zero or
table length exceeded.

R: Address is real
\: Last 48 bytes of ASTE are not shown
Figure 3-7. ASN Authorization

Authority-Table Lookup zeros appended on the left. When a carry into bit
The authorization index, in conjunction with the position 0 occurs during the addition, an
authority-table origin contained in the addressing exception may be recognized, or the
ASN-second-table entry, is used to select an entry carry may be ignored, causing the table to wrap
from the authority table. from 2 - 1 to zero. The 31-bit address is
formed and used regardless of whether the
The authorization index is contained in bit posi- current PSW specifies the 24-bit, 31-bit, or 64-bit
tions 32-47 of control register 4. addressing mode.

Bit positions 1-29 of the AST entry contain the left- As part of the authority-table-entry-lookup process,
most 29 bits of the 31-bit real address of the bits 0-11 of the authorization index are compared
authority table (ATO), and bit positions 48-59 against the authority-table length. If the compared
contain the length of the authority table (ATL). portion is greater than the authority-table length, a
primary-authority exception or secondary-authority
The 31-bit real address of a byte in the authority exception is recognized for PT-ss or SSAR-ss,
table is obtained by appending two zeros on the respectively. For LOAD ADDRESS SPACE
right to the authority-table origin and adding the 14 PARAMETERS, when the authority-table length is
leftmost bits of the authorization index with 17 exceeded, condition code 2 is set.

Chapter 3. Storage 3-25


The fetch access to the byte in the authority table in order to permit dynamic modification of the
is not subject to protection. When the storage authority table. Thus, when an address space is
address which is generated for fetching the byte created or swapped in, the authority table can
designates a location which is not available in the first be set to all zeros and the appropriate
configuration, an addressing exception is recog- authority bits set to one only when required.
nized, and the operation is suppressed.

The byte contains four authority-table entries of Dynamic Address Translation


two bits each. The rightmost two bits of the
Dynamic address translation (DAT) provides the
authorization index, bits 46 and 47 of control reg-
ability to interrupt the execution of a program at an
ister 4, are used to select one of the four entries.
arbitrary moment, record it and its data in auxiliary
The left or right bit of the entry is then tested,
storage, such as a direct-access storage device,
depending on whether the authorization test is for
and at a later time return the program and the
a primary ASN or a secondary ASN. The fol-
data to different main-storage locations for
lowing table shows the bit which is selected from
resumption of execution. The transfer of the
the byte as a function of bits 46 and 47 of the
program and its data between main and auxiliary
authorization index and the instruction PT-ss,
storage may be performed piecemeal, and the
SSAR-ss, PROGRAM RETURN, or LOAD
return of the information to main storage may take
ADDRESS SPACE PARAMETERS.
place in response to an attempt by the CPU to
access it at the time it is needed for execution.
Bit Selected from These functions may be performed without change
Authority-Table Byte
for Test or inspection of the program and its data, do not
Authorization- require any explicit programming convention for
Index Bits S Bit the relocated program, and do not disturb the exe-
P Bit (SSAR-ss, cution of the program except for the time delay
46 47 (PT-ss) PR, or LASP) involved.

1
With appropriate support by an operating system,
1 2 3 the dynamic-address-translation facility may be
used to provide to a user a system wherein
1 4 5 storage appears to be larger than the main
storage which is available in the configuration.
1 1 6 7
This apparent main storage is referred to as virtual
storage, and the addresses used to designate
If the selected bit is one, the ASN is authorized, locations in the virtual storage are referred to as
and the appropriate fields in the AST entry are virtual addresses. The virtual storage of a user
loaded into the appropriate control registers. If the may far exceed the size of the main storage which
selected bit is zero, the ASN is not authorized, is available in the configuration and normally is
and a primary-authority exception is recognized for maintained in auxiliary storage. The virtual
PT-ss or a secondary-authority exception is recog- storage is considered to be composed of blocks of
nized for SSAR-ss or PROGRAM RETURN. For addresses, called pages. Only the most recently
LOAD ADDRESS SPACE PARAMETERS, when referred-to pages of the virtual storage are
the ASN is not authorized, condition code 2 is set. assigned to occupy blocks of physical main
storage. As the user refers to pages of virtual
Recognition of Exceptions during ASN storage that do not appear in main storage, they
Authorization are brought in to replace pages in main storage
The exceptions which can be encountered during that are less likely to be needed. The swapping of
the primary- and secondary-ASN-authorization pages of storage may be performed by the oper-
processes and their priorities are described in the ating system without the user's knowledge.
definitions of the instructions in which ASN author-
ization is performed. The sequence of virtual addresses associated with
a virtual storage is called an address space. With
Programming Note: The primary- and
appropriate support by an operating system, the
secondary-authority exceptions cause nullification

3-26 z/Architecture Principles of Operation


dynamic-address-translation facility may be used addresses are translated by means of the primary,
to provide a number of address spaces. These the secondary, an AR-specified, or the home
address spaces may be used to provide degrees address-space-control element, respectively. After
of isolation between users. Such support can selection of the appropriate address-space-control
consist of a completely different address space for element, the translation process is the same for all
each user, thus providing complete isolation, or a of the four types of virtual address. An address-
shared area may be provided by mapping a space-control element may be a segment-table
portion of each address space to a single common designation specifying a 2G-byte address space, a
storage area. Also, instructions are provided region-table designation specifying a 4T-byte,
which permit a semiprivileged program to access 8P-byte, or 16E-byte space, or a real-space desig-
more than one such address space. Dynamic nation specifying a 16E-byte space. (The letters
address translation provides for the translation of K, M, G, T, P, and E represent kilo, 2, mega,
virtual addresses from multiple different address 2, giga, 2, tera, 2, peta, 2, and exa, 2,
spaces without requiring that the translation respectively.) A segment-table designation or
parameters in the control registers be changed. region-table designation causes translation to be
These address spaces are called the primary performed by means of tables established by the
address space, secondary address space, and operating system in real or absolute storage. A
AR-specified address spaces. A privileged real-space designation causes the virtual address
program can also cause the home address space simply to be treated as a real address, without the
to be accessed. use of tables in storage.

In the process of replacing blocks of main storage In the process of translation when using a
by new information from an external medium, it segment-table designation or a region-table desig-
must be determined which block to replace and nation, three types of units of information are
whether the block being replaced should be recognizedregions, segments, and pages. A
recorded and preserved in auxiliary storage. To region is a block of sequential virtual addresses
aid in this decision process, a reference bit and a spanning 2G bytes and beginning at a 2G-byte
change bit are associated with the storage key. boundary. A segment is a block of sequential
virtual addresses spanning 1M bytes and begin-
Dynamic address translation may be specified for ning at a 1M-byte boundary. A page is a block of
instruction and data addresses generated by the sequential virtual addresses spanning 4K bytes
CPU but is not available for the addressing of data and beginning at a 4K-byte boundary.
and of CCWs and IDAWs in I/O operations. The
CCW-indirect-data-addressing facility is provided The virtual address, accordingly, is divided into
to aid I/O operations in a virtual-storage environ- four principal fields. Bits 0-32 are called the
ment. region index (RX), bits 33-43 are called the
segment index (SX), bits 44-51 are called the
Address computation can be carried out in the page index (PX), and bits 52-63 are called the
24-bit, 31-bit, or 64-bit addressing mode. When byte index (BX). The virtual address has the fol-
address computation is performed in the 24-bit or lowing format:
31-bit addressing mode, 40 or 33 zeros, respec- /
tively, are appended on the left to form a 64-bit RX SX PX BX
address. Therefore, the resultant logical address /
is always 64 bits in length. The real address that 33 44 52 63
is formed by dynamic address translation, and the As determined by its address-space-control
absolute address that is then formed by prefixing, element, a virtual address space may be a
are always 64 bits in length. 2G-byte space consisting of one region, or it may
be up to a 16E-byte space consisting of up to 8G
Dynamic address translation is the process of
regions. The RX part of a virtual address applying
translating a virtual address during a storage refer-
to a 2G-byte address space must be all zeros;
ence into the corresponding real address. The
otherwise, an exception is recognized.
virtual address may be a primary virtual address,
secondary virtual address, AR-specified virtual The RX part of a virtual address is itself divided
address, or home virtual address. These into three fields. Bits 0-10 are called the region

Chapter 3. Storage 3-27


first index (RFX), bits 11-21 are called the region To improve performance, translation normally is
second index (RSX), and bits 22-32 are called the performed by means of table copies maintained in
region third index (RTX). Bits 0-32 of the virtual a special buffer called the translation-lookaside
address have the following format: buffer (TLB). The TLB may also contain entries
that provide the virtual-equals-real translation
RFX RSX RTX specified by a real-space designation.

11 22 33
Translation Control
A virtual address in which the RTX is the leftmost
significant part (a 42-bit address) is capable of Address translation is controlled by three bits in
addressing 4T bytes (2K regions), one in which the PSW and by a set of bits referred to as the
the RSX is the leftmost significant part (a 53-bit translation parameters. The translation parame-
address) is capable of addressing 8P bytes (4M ters are in control registers 0, 1, 7, and 13. Addi-
regions), and one in which the RFX is the leftmost tional controls are located in the translation tables.
significant part (a 64-bit address) is capable of
addressing 16E bytes (8G regions). Additional controls are provided as described in
Chapter 5, Program Execution. These controls
A virtual address in which the RX is always zero determine whether the contents of each access
can be translated into real addresses by means of register can be used to obtain an address-space-
two translation tables: a segment table and a control element for use by DAT.
page table. If the RX may be nonzero, from one
to three additional translation tables are required, Translation Modes
as follows. If the RFX may be nonzero, a region The three bits in the PSW that control dynamic
first table, region second table, and region third address translation are bit 5, the DAT-mode bit,
table are required. If the RFX is always zero but and bits 16 and 17, the address-space-control
the RSX may be nonzero, a region second table bits. When the DAT-mode bit is zero, then DAT is
and region third table are required. If the RFX off, and the CPU is in the real mode. When the
and RSX are always zero but the RTX may be DAT-mode bit is one, then DAT is on, and the
nonzero, a region third table is required. An CPU is in the translation mode designated by the
exception is recognized if the address-space- address-space-control bits: 00 designates the
control element for an address space does not primary-space mode, 01 designates the access-
designate the highest level of table (beginning with register mode, 10 designates the secondary-space
the region first table and continuing downward to mode, and 11 designates the home-space mode.
the segment table) needed to translate a refer- The various modes are shown in Figure 3-8,
ence to the address space. along with the handling of addresses in each
mode.
A region first table, region second table, or region

third table is sometimes referred to simply as a Handling of Addresses
region table. Similarly, a region-first-table desig- PSW Bit
Instruction Logical
nation, region-second-table designation, or region- 51617DAT Mode Addresses Addresses
third-table designation is sometimes referred to as
OffReal mode Real Real
a region-table designation. 1OffReal mode Real Real
1 OffReal mode Real Real
The region, segment, and page tables reflect the 1 1OffReal mode Real Real
1 On Primary-space mode Primary Primary
current assignment of real storage. The assign- virtual virtual
ment of real storage occurs in units of pages, the 1 1On Access-register mode Primary AR-speci-
virtual fied
real locations being assigned contiguously within a virtual
page. The pages need not be adjacent in real 1 1 On Secondary-space mode Primary Secondary
virtual virtual
storage even though assigned to a set of sequen- 1 1 1On Home-space mode Home Home
tial virtual addresses. virtual virtual

Figure 3-8. Translation Modes

3-28 z/Architecture Principles of Operation


Control Register 0 Primary Subspace-Group Control (G): Bit 54
One bit is provided in control register 0 for use in of control register 1, when one, indicates that the
controlling dynamic address translation. The bit is address space specified by the PASCE is the
assigned as follows: base space or a subspace of a subspace group.
When bit 54 is zero, the address space is not in a

S subspace group.
S
Primary Private-Space Control (P): If bit 55 of
37 control register 1 is one, then (1) a one value of
the common-segment bit in a translation-
Secondary-Space Control (SS): Bit 37 of lookaside-buffer (TLB) representation of a
control register 0 is the secondary-space-control segment-table entry prevents the entry and the
bit. When this bit is zero and execution of MOVE TLB page-table copy it designates from being
TO PRIMARY, MOVE TO SECONDARY, or SET used when translating references to the primary
ADDRESS SPACE CONTROL is attempted, a address space, even with a match between the
special-operation exception is recognized. When table or token origin in control register 1 and the
this bit is one, it indicates that the region table or table origin in the TLB entry, (2) low-address pro-
segment table designated by the secondary tection and fetch-protection override do not apply
address-space-control element is attached when to the primary address space; and (3) a
the CPU is in the primary-space mode. translation-specification exception is recognized if
a reference to the primary address space is trans-
Control Register 1 lated by means of a segment-table entry in
Control register 1 contains the primary address- storage and the common-segment bit is one in the
space-control element (PASCE). The register has entry. Item 1 in the above list applies simply if,
one of the following two formats, depending on the and item 2 applies even when, the contents of
real-space-control bit (R) in the register: control register 1 are a real-space designation.
Primary Region-Table or Segment-Table
Designation (R=) Primary Storage-Alteration-Event Control (S):
/ When the storage-alteration-space control in
Primary Region-Table control register 9 is one, bit 56 of control register 1
or Segment-Table Origin GPSXR DTTL specifies, when one, that the primary address
/
space is one for which storage-alteration events
52 54 58 6 63
can occur. Bit 56 is examined when the PASCE
Primary Real-Space Designation (R=1) is used to perform dynamic-address translation for
/
a storage-operand store reference. Bit 56 is
Primary Real-Space
Token Origin GPSXR ignored when the storage-alteration-space control
/ is zero.
52 54 58 63
Primary Space-Switch-Event Control (X):
The fields in the primary address-space-control
When bit 57 of control register 1 is one:
element are allocated as follows:
A space-switch-event program interruption
Primary Region-Table or Segment-Table occurs when execution of the space-switching
Origin: Bits 0-51 of the primary region-table or form of PROGRAM CALL (PC-ss),
segment-table designation in control register 1, PROGRAM RETURN (PR-ss), or PROGRAM
with 12 zeros appended on the right, form a 64-bit TRANSFER (PT-ss) is completed. The inter-
address that designates the beginning of the ruption occurs if bit 57 is one either before or
primary region table or segment table. It is unpre- after the operation.
dictable whether the address is real or absolute.
A space-switch-event program interruption
This table is called the primary region table or
occurs upon completion of a RESUME
segment table since it is used to translate virtual
PROGRAM, SET ADDRESS SPACE
addresses in the primary address space.
CONTROL, or SET ADDRESS SPACE
CONTROL FAST instruction that changes the
address space from which instructions are

Chapter 3. Storage 3-29


fetched either to or from the home address table or segment table, in units of 4096 bytes, is
space; that is, when instructions are fetched one more than the TL value. The contents of the
from the home address space either before or length field are used to establish whether the
after the operation but not both before and portion of the virtual address (RFX, RSX, RTX, or
after the operation. SX) to be translated by means of the table desig-
nates an entry that falls within the table.
Condition code 3 is set by LOAD ADDRESS
SPACE PARAMETERS.
Primary Real-Space Token Origin: Bits 0-51 of
the primary real-space designation in control reg-
Primary Real-Space Control (R): If bit 58 of
ister 1, with 12 zeros appended on the right, form
control register 1 is zero, the register contains a
a 64-bit address that may be used in forming and
region-table or segment-table designation. If bit
using TLB entries that provide a virtual-equals-real
58 is one, the register contains a real-space des-
translation for references to the primary address
ignation. When bit 58 is one, a one value of the
space. Although this address is used only as a
common-segment bit in a translation-lookaside-
token and is not used to perform a storage refer-
buffer (TLB) representation of a segment-table
ence, it still must be a valid address; otherwise, an
entry prevents the entry and the TLB page-table
incorrect TLB entry may be used when the con-
copy it designates from being used when trans-
tents of control register 1 are used.
lating references to the primary address space,
even with a match between the token origin in
The following bits of control register 1 are not
control register 1 and the table origin in the TLB
assigned and are ignored: bits 52, 53, and 59 if
entry.
the register contains a region-table designation or
segment-table designation, and bits 52, 53 and
Primary Designation-Type Control (DT): When
59-63 if the register contains a real-space desig-
R is zero, the type of table designation in control
nation.
register 1 is specified by bits 60 and 61 in the reg-
ister, as follows:
Control Register 7
Bits 60 Control register 7 contains the secondary address-
and 61 Designation Type space-control element (SASCE). The register has
one of the following two formats, depending on the
11 Region-first-table real-space-control bit (R) in the register:
10 Region-second-table
Secondary Region-Table or Segment-Table
01 Region-third-table
Designation (R=)
00 Segment-table /
Secondary Region-Table
When R is zero, bits 60 and 61 must be 11 binary or Segment-Table Origin GPS R DTTL
when an attempt is made to use the PASCE to /
translate a virtual address in which the leftmost 52 54 58 6 63
one bit is in bit positions 0-10 of the address. Secondary Real-Space Designation (R=1)
Similarly, bits 60 and 61 must be 11 or 10 binary /
when the leftmost one bit is in bit positions 11-21 Secondary Real-Space
Token Origin GPS R
of the address, and they must be 11, 10, or 01
/
binary when the leftmost one bit is in bit positions 52 54 58 63
22-32 of the address. Otherwise, an ASCE-type
exception is recognized. The secondary region-table origin, secondary
segment-table origin, secondary subspace-group
Primary Region-Table or Segment-Table control (G), secondary private-space control (P),
Length (TL): Bits 62 and 63 of the primary secondary storage-alteration-event control (S),
region-table designation or segment-table desig- secondary real-space control (R), secondary
nation in control register 1 specify the length of designation-type control (DT), secondary region-
the primary region table or segment table in units table or segment-table length (TL), and secondary
of 4096 bytes, thus making the length of the real-space token origin in control register 7 are
region table or segment table variable in multiples defined the same as the fields in the same bit
of 512 entries. The length of the primary region

3-30 z/Architecture Principles of Operation


positions in control register 1, except that control The following bits of control register 13 are not
register 7 applies to the secondary address space. assigned and are ignored: bits 52-54 and 59 if
the register contains a region-table designation or
The following bits of control register 7 are not segment-table designation, and bits 52-54 and
assigned and are ignored: bits 52, 53, 57, and 59 59-63 if the register contains a real-space desig-
if the register contains a region-table designation nation.
or segment-table designation, and bits 52, 53, 57,
and 59-63 if the register contains a real-space Programming Notes:
designation.
1. The validity of the information loaded into a
control register, including that pertaining to
Control Register 13 dynamic address translation, is not checked at
Control register 13 contains the home address- the time the register is loaded. This informa-
space-control element (HASCE). The register has tion is checked and the program exception, if
one of the following two formats, depending on the any, is indicated at the time the information is
real-space-control bit (R) in the register: used.
Home Region-Table or Segment-Table
Designation (R=) 2. The information pertaining to dynamic address
/ translation is considered to be used when an
Home Region-Table or instruction is executed with DAT on or when
Segment-Table Origin PSXR DTTL INVALIDATE PAGE TABLE ENTRY, LOAD
/ REAL ADDRESS, or STORE REAL
52 54 58 6 63
ADDRESS is executed. The information is
Home Real-Space Designation (R=1) not considered to be used when the PSW
/ specifies translation but an I/O, external,
Home Real-Space
Token Origin PSXR restart, or machine-check interruption occurs
/ before an instruction is executed, or when the
52 54 58 63 PSW specifies the wait state.

Home Space-Switch-Event Control (X): When Translation Tables


bit 57 of control register 13 is one, a space-switch-
event program interruption occurs upon com- When the address-space-control element (ASCE)
pletion of a RESUME PROGRAM, SET used in a translation is a region-first-table desig-
ADDRESS SPACE CONTROL, or SET ADDRESS nation, the translation process consists in a five-
SPACE CONTROL FAST instruction that changes level lookup using five tables: a region first table,
the address space from which instructions are a region second table, a region third table a
fetched either to or from the home address space; segment table, and a page table. These tables
that is, when instructions are fetched from the reside in real or absolute storage. When the
home address space either before or after the ASCE is a region-second-table designation,
operation but not both before and after the opera- region-third-table designation, or segment-table
tion. designation, the lookups in the levels of tables
above the designated level are omitted, and the
The home region-table origin, home segment-table
higher-level tables themselves are omitted.
origin, home private-space control (P), home
storage-alteration-event control (S), home real-
Region-Table Entries
space control (R), home designation-type control
The term region-table entry means a region-first-
(DT), home region-table or segment-table length
table entry, region-second-table entry, or region-
(TL), and home real-space token origin in control
third-table entry.
register 13 are defined the same as the fields in
the same bit positions in control register 1, except
The entries fetched from the region first table,
that control register 13 applies to the home
region second table, and region third table have
address space.
the following formats. The level (first, second, or
third) of the table containing an entry is identified
by the table-type (TT) bits in the entry.

Chapter 3. Storage 3-31


Region-First-Table Entry (TT=11) portion of the virtual address (RSX, RTX, or SX)
/ to be translated by means of the next-lower-level
Region-Second- table designates an entry that actually exists in the
Table Origin TFI TTTL
/ table.
52 56 58 6 63
Region-Invalid Bit (I): Bit 58 in a region-first-
Region-Second-Table Entry (TT=1)
/ table entry or region-second-table entry controls
Region-Third- whether the set of regions associated with the
Table Origin TFI TTTL entry is available. Bit 58 in a region-third-table
/ entry controls whether the single region associ-
52 56 58 6 63 ated with the entry is available. When bit 58 is
Region-Third-Table Entry (TT=1) zero, address translation proceeds by using the
/ region-table entry. When the bit is one, the entry
Segment-Table cannot be used for translation.
Origin TFI TTTL
/
52 56 58 6 63 Table-Type Bits (TT): Bits 60 and 61 of the
region-first-table entry, region-second-table entry,
The fields in the three levels of region-table and region-third-table entry identify the level of the
entries are allocated as follows: table containing the entry, as follows:

Region-Second-Table Origin, Region-Third- Bits 60


Table Origin, and Segment-Table Origin: A and 61 Region-Table Level
region-first-table entry contains a region-second-
table origin. A region-second-table entry contains 11 First
a region-third-table origin. A region-third-table 10 Second
entry contains a segment-table origin. The fol- 01 Third
lowing description applies to each of the three
Bits 60 and 61 must identify the correct table
origins. Bits 0-51 of the entry, with 12 zeros
level, considering the type of table designation
appended on the right, form a 64-bit address that
that is the address-space-control element being
designates the beginning of the next-lower-level
used in the translation and the number of table
table. It is unpredictable whether the address is
levels that have so far been used; otherwise, a
real or absolute.
translation-specification exception is recognized.
Region-Second-Table Offset, Region-Third-
Region-Second-Table Length, Region-Third-
Table Offset, and Segment-Table Offset (TF):
Table Length, and Segment-Table Length
A region-first-table entry contains a region-second-
(TL): A region-first-table entry contains a region-
table offset. A region-second-table entry contains
second-table length. A region-second-table entry
a region-third-table offset. A region-third-table
contains a region-third-table length. A region-
entry contains a segment-table offset. The fol-
third-table entry contains a segment-table length.
lowing description applies to each of the three
The following description applies to each of the
offsets. Bits 56 and 57 of the entry specify the
three lengths. Bits 62 and 63 of the entry specify
length of a portion of the next-lower-level table
the length of the next-lower-level table in units of
that is missing at the beginning of the table, that
4096 bytes, thus making the length of the table
is, the bits specify the location of the first entry
variable in multiples of 512 entries. The length of
actually existing in the next-lower-level table. The
the next-lower-level table, in units of 4096 bytes,
bits specify the length of the missing portion in
is one more than the TL value. The contents of
units of 4096 bytes, thus making the length of the
the length field, in conjunction with the offset field,
missing portion variable in multiples of 512 entries.
bits 56 and 57, are used to establish whether the
The length of the missing portion, in units of 4096
portion of the virtual address (RSX, RTX, or SX)
bytes, is equal to the TF value. The contents of
to be translated by means of the next-lower-level
the offset field, in conjunction with the length field,
table designates an entry that actually exists in the
bits 62 and 63, are used to establish whether the
table.

3-32 z/Architecture Principles of Operation


Segment-Table Entries must be zero if the segment-table entry is fetched
The entry fetched from the segment table has the from storage during a translation when the private-
following format: space control is one in the address-space-control
element being used; otherwise, a translation-
Segment-Table Entry (TT=)
/ specification exception is recognized.
Page-Table
Origin P ICTT Table-Type Bits (TT): Bits 60 and 61 of the
/ segment-table entry are 00 binary to identify the
53 55 58 6 63 level of the table containing the entry. The
The fields in the segment-table entry are allocated meanings of all possible values of bits 60 and 61
as follows: in a region-table entry or segment-table entry are
as follows:
Page-Table Origin: Bits 0-52, with 11 zeros
appended on the right, form a 64-bit address that Bits 60
designates the beginning of a page table. It is and 61 Table Level
unpredictable whether the address is real or abso- 11 Region-First
lute. 10 Region-Second
01 Region-Third
Page-Protection Bit (P): Bit 54 is treated as 00 Segment
being ORed with the page-protection bit in each
entry in the page table designated by this Bits 60 and 61 must identify the correct table
segment-table entry. Thus, when the bit is one, level, considering the type of table designation
page protection applies to the entire segment that is the address-space-control element being
specified by the segment-table entry. used in the translation and the number of table
levels that have so far been used; otherwise, a
Segment-Invalid Bit (I): Bit 58 controls whether translation-specification exception is recognized.
the segment associated with the segment-table
entry is available. When the bit is zero, address Bits 53, 55-57, 62, and 63 of the segment-table
translation proceeds by using the segment-table entry are reserved for possible future extensions.
entry. When the bit is one, the segment-table
entry cannot be used for translation. Page-Table Entries
The entry fetched from the page table entry has
Common-Segment Bit (C): Bit 59 controls the
the following format:
use of the translation-lookaside-buffer (TLB)
copies of the segment-table entry and of the page /
Page-Frame Real Address IP
table which it designates. A zero identifies a /
private segment; in this case, the segment-table 52 56 63
entry and the page table it designates may be
used only in association with the segment-table The fields in the page-table entry are allocated as
origin that designates the segment table in which follows:
the segment-table entry resides. A one identifies
Page-Frame Real Address (PFRA): Bits 0-51
a common segment; in this case, the segment-
provide the leftmost bits of a real storage address.
table entry and the page table it designates may
When these bits are concatenated with the 12-bit
continue to be used for translating addresses cor-
byte-index field of the virtual address on the right,
responding to the segment index, even though a
a 64-bit real address is obtained.
different segment table is specified. However,
TLB copies of the segment-table entry and page
Page-Invalid Bit (I): Bit 53 controls whether the
table for a common segment are not usable if the
page associated with the page-table entry is avail-
private-space control, bit 55, is one in the
able. When the bit is zero, address translation
address-space-control element used in the trans-
proceeds by using the page-table entry. When
lation or if that address-space-control element is a
the bit is one, the page-table entry cannot be used
real-space designation. The common-segment bit
for translation.

Chapter 3. Storage 3-33


Page-Protection Bit (P): Bit 54 controls ignation (region-second-table designation, region-
whether store accesses can be made in the page. third-table designation, or segment-table
This protection mechanism is in addition to the designation) the translation is performed by means
key-controlled-protection and low-address- of only the table levels beginning with the desig-
protection mechanisms. The bit has no effect on nated level, and the virtual-address bits that
fetch accesses. If the bit is zero, stores are per- would, if nonzero, require use of a higher level or
mitted to the page, subject to the page-protection levels of table must be all zeros; otherwise, an
bit in the segment-table entry used in the trans- ASCE-type exception is recognized. When the
lation and to the other protection mechanisms. If ASCE is a real-space designation, the virtual
the bit is one, stores are disallowed. An attempt address is treated as a real address, and table
to store when the page-protection bit is one entries in real or absolute storage are not used.
causes a protection exception to be recognized.
The page-protection bit in the segment-table entry The address-space-control element (ASCE) used
is treated as being ORed with bit 54 when deter- for a particular address translation is called the
mining whether page protection applies to the effective ASCE. Accordingly, when a primary
page. virtual address is translated, the contents of
control register 1 are used as the effective ASCE.
Bit positions 52 and 55 of the entry must contain Similarly, for a secondary virtual address, the con-
zeros; otherwise, a translation-specification excep- tents of control register 7 are used; for an
tion is recognized as part of the execution of an AR-specified virtual address, the ASCE specified
instruction using that entry for address translation. by the access register is used; and for a home
Bit positions 56-63 are not assigned and are virtual address, the contents of control register 13
ignored. are used.

When the real-space control in the effective ASCE


Translation Process is zero, the designation-type control in the ASCE
specifies the table-designation type of the ASCE:
This section describes the translation process as it
region-first-table designation, region-second-table
is performed implicitly before a virtual address is
designation, region-third-table designation, or
used to access main storage. Explicit translation,
segment-table designation. The corresponding
which is the process of translating the operand
portion of the virtual address (region first index,
address of LOAD REAL ADDRESS, STORE
region second index, region third index, or
REAL ADDRESS, and TEST PROTECTION, is
segment index) is checked against the table-
the same, except that, for LOAD REAL ADDRESS
length field in the designation, and it is added to
and TEST PROTECTION, region-first-translation,
the origin in the designation to select an entry in
region-second-translation, region-third-translation,
the designated table. If the selected entry is
segment-translation, and page-translation
outside its table, as determined by the table-length
exceptions are not recognized; such conditions
field in the designation, or if the I bit is one in the
are instead indicated by the condition code.
selected entry, a region-first-translation, region-
Translation of the operand address of LOAD
second-translation, region-third-translation, or
REAL ADDRESS and STORE REAL ADDRESS
segment-translation exception is recognized,
also differs in that the CPU may be in the real
depending on the table level specified by the des-
mode.
ignation. If the table-type bits in the selected entry
Translation of a virtual address is controlled by the do not indicate the expected table level, a
DAT-mode bit and address-space-control bits in translation-specification exception is recognized.
the PSW and by the address-space-control ele-
The table entry selected by means of the effective
ments (ASCEs) in control registers 1, 7, and 13
ASCE designates the next-lower-level table to be
and as specified by the access registers. When
used. If the current table is a region first table,
the ASCE used in a translation is a region-first-
region second table, or region third table, the next
table designation, the translation is performed by
portion of the virtual address (region second
means of a region first table, region second table,
index, region third index, or segment index,
region third table, segment table, and page table,
respectively) is checked against the table-offset
all of which reside in real or absolute storage.
and table-length fields in the current table entry,
When the ASCE is a lower-level type of table des-

3-34 z/Architecture Principles of Operation


and it is added to the origin in the entry to select bit that applies only to the page specified by the
an entry in the next-lower-level table. If the page-table entry.
selected entry in the next table is outside its table,
as determined by the table-offset and table-length The byte-index field of the virtual address is used
fields in the current table entry, or if the I bit is one unchanged as the rightmost bit positions of the
in the selected entry, a region-second-translation, real address.
region-third-translation, or segment-translation
exception is recognized, depending on the level of In order to eliminate the delay associated with ref-
the next table. If the table-type bits in the erences to translation tables in real or absolute
selected entry do not indicate the expected table storage, the information fetched from the tables
level, a translation-specification exception is normally is also placed in a special buffer, the
recognized. translation-lookaside buffer (TLB), and subsequent
translations involving the same table entries may
Processing of portions of the virtual address by be performed by using the information recorded in
means of successive table levels continues until a the TLB. The TLB may also record virtual-equals-
segment-table entry has been selected. This real translations related to a real-space desig-
entry designates the page table to be used. The nation. The operation of the TLB is described in
segment-table entry contains a page-protection bit Translation-Lookaside Buffer on page 3-42.
that applies to all pages in the specified segment.
Whenever access to real or absolute storage is
The page-index portion of the virtual address is made during the address-translation process for
added to the page-table origin in the segment- the purpose of fetching an entry from a region
table entry to select an entry in the page table. If table, segment table, or page table, key-controlled
the I bit is one in the page-table entry, a page- protection does not apply.
translation exception is recognized. The page-
table entry contains the leftmost bits of the real The translation process, including the effect of the
address that represents the translation of the TLB, is shown graphically in Figure 3-9 on
virtual address, and it contains a page-protection page 3-36.

Chapter 3. Storage 3-35


Control Reg. 1, 7, or 1 ASN-Second Table Entry Virtual Address

PASCE, SASCE, or HASCE AR-Specified ASCE RFX RSX RTX SX PX BX

(x8) (x8) (x8) (x8)
51%

Effective
6 ASCE

TO RDTTL TO and
virtual address 55
(x496)
6
Yes ASCE is RSD
R=1 ?55

No
6

If
DT=11
2 5 + %

Region First Table


5
R/A RSTO TFITTTL5 A in
Part 2

If
DT=1
2 5 + %

Region Second Table


5
R/A RTTO TFITTTL5 B in
Part 2

If
DT=1
2 5 + %

Region Third Table


5
R/A STO TFITTTL5 C in
Part 2

If
DT=
2 5 + %

Segment Table


5
R/A PTO PICTT5 D in
Part 3

R/A: Address is real or absolute.
Figure 3-9 (Part 1 of 3). Translation Process

3-36 z/Architecture Principles of Operation


Region-First-Table Entry Virtual Address

A RSTO TFITTTL RFX RSX RTX SX PX BX

(x496) (x8) (x8) (x8)

5+%

Region Second Table


3 5
R/A RTTO TFITTTL5 B




Region-Second-Table Entry

B RTTO TFITTTL

(x496)

5+%

Region Third Table


3 5
R/A STO TFITTTL5 C




Region-Third-Table Entry

C STO TFITTTL

(x496)

5+%

Segment Table


3 5
R/A PTO PICTT5 D in
Part 3

R/A: Address is real or absolute.


Figure 3-9 (Part 2 of 3). Translation Process

Chapter 3. Storage 3-37


Segment-Table Entry Virtual Address

D PTO PICTT RFX RSX RTX SX PX BX

(x248) (x8)

5+%

Page Table

Translation
4 5 6 Lookaside
R/A PFRA IP 5 Buffer (TLB)
PFRA



& 6
555 6

6 6


R/A: Address is real or absolute.

Real Address

1 Control register 1 provides the primary address-space-control element (ASCE) for


translation of a primary virtual address, control register 7 provides the secondary ASCE
for translation of a secondary virtual address, and control register 13 provides the home
ASCE for translation of a home virtual address. An ASN-second-table entry provides an
AR-specified (access-register-specified) ASCE for translation of an AR-specified virtual
address.

2 The portion of the virtual address to the left of the index selected by DT must be zero;
otherwise, an ASCE-type exception is recognized. Bits and 1 of the index must be less
than or equal to TL in the ASCE, and I in the selected table entry must be zero;
otherwise, a region-first-translation, region-second-translation, region-third-translation
or segment-translation exception is recognized, depending on the table level selected by
DT. TT in the selected table entry must equal DT; otherwise, a translation-specification
exception is recognized.

3 Bits and 1 of the next index must be equal to or greater than TF, and less than or equal
to TL, in the current table entry, and I in the next selected table entry must be zero;
otherwise, a region-second-translation, region-third-translation, or segment-translation
exception is recognized, depending on the table level of the next selected entry. TT in
the next selected entry must be one less than TT in the current entry; otherwise, a
translation-specification exception is recognized.

4 I in the page-table entry must be zero; otherwise, a page-translation exception is


recognized. Bits 52 and 55 in the page-table entry must be zero; otherwise, a
translation-specification exception is recognized.

5 Information, which may include portions of the virtual address and the table origin or
real-space token origin in the effective ASCE, is used to search the TLB.

6 If a match exists, the page-frame real address from the TLB is used in forming the real
address. If no match exists and the effective ASCE is a table designation, table entries
in real or absolute storage are fetched. The resulting fetched entries are used to
translate the address and, in conjunction with the search information, may be used to form
entries in the TLB. If the effective ASCE is a real-space designation, a TLB entry that
translates the virtual address to the equal real address may be formed.
Figure 3-9 (Part 3 of 3). Translation Process

3-38 z/Architecture Principles of Operation


Inspection of Real-Space Control Bits
When the effective address-space-control element 60 Virtual-Address
(ASCE) contains a real-space control, bit 58, and Portion Translated
having the value zero, the ASCE is a region-table 61 Designation Type by the Table
or segment-table designation. When the real-
11 Region-first-table Region first index
space control is one, the ASCE is a real-space
(bits 0-10)
designation.
10 Region-second- Region second index
Inspection of Designation-Type Control table (bits 11-21)
When the real-space control is zero, the 01 Region-third-table Region third index
designation-type control, bits 60 and 61 of the (bits 22-32)
effective address-space-control element (ASCE),
specifies the table-designation type of the ASCE. 00 Segment-table Segment index (bits
Depending on the type, some number of leftmost 33-43)
bits of the virtual address being translated must be
zeros; otherwise, an ASCE-type exception is When bits 60 and 61 have the value 11 binary,
recognized. For each possible value of bits 60 the region-first-index portion of the virtual address,
and 61, the table-designation type and the virtual- in conjunction with the region-first-table origin con-
address bits required to be zeros are as follows: tained in the ASCE, is used to select an entry
from the region first table.
Bits
60 Virtual-Address Bits The 64-bit address of the region-first-table entry in
and Required to Be real or absolute storage is obtained by appending
61 Designation Type Zeros 12 zeros to the right of bits 0-51 of the region-first-
table designation and adding the region first index
11 Region-first-table None
with three rightmost and 50 leftmost zeros
10 Region-second- 0-10 appended. When a carry out of bit position 0
table occurs during the addition, an addressing excep-
01 Region-third-table 0-21 tion may be recognized, or the carry may be
ignored, causing the table to wrap from 2 - 1 to
00 Segment-table 0-32 zero. All 64 bits of the address are used, regard-
less of whether the current PSW specifies the
Lookup in a Table Designated by an 24-bit, 31-bit, or 64-bit addressing mode.
Address-Space-Control Element
As part of the region-first-table-lookup process,
The designation-type control, bits 60 and 61 of the
bits 0 and 1 of the virtual address (which are bits
effective address-space-control element (ASCE),
0 and 1 of the region first index) are compared
specifies both the table-designation type of the
against the table length, bits 62 and 63 of the
ASCE and the portion of the virtual address that is
region-first-table designation, to establish whether
to be translated by means of the designated table,
the addressed entry is within the region first table.
as follows:
If the value in the table-length field is less than the
value in the corresponding bit positions of the
virtual address, a region-first-translation exception
is recognized. The comparison against the table
length may be omitted if the equivalent of a
region-first-table entry in the translation-lookaside
buffer is used in the translation.

All eight bytes of the region-first-table entry appear


to be fetched concurrently as observed by other
CPUs. The fetch access is not subject to pro-
tection. When the storage address generated for
fetching the region-first-table entry designates a
location which is not available in the configuration,

Chapter 3. Storage 3-39


an addressing exception is recognized, and the region-third-translation exception is recognized.
unit of operation is suppressed. The comparison against the table length may be
omitted if the equivalent of a region-third-table
Bit 58 of the entry fetched from the region first entry in the translation-lookaside buffer is used in
table specifies whether the corresponding set of the translation. The region-third-table-lookup
regions is available. This bit is inspected, and, if it process is otherwise the same as the region-first-
is one, a region-first-translation exception is recog- table-lookup process, including the checking of the
nized. table-type bits in the region-third-table entry,
except that a region-third-translation exception is
A translation-specification exception is recognized recognized if bit 58 is one in the region-third-table
if the table-type bits, bits 60 and 61, in the region- entry. When no exceptions are recognized, the
first-table entry do not have the same value as entry fetched from the region third table desig-
bits 60 and 61 of the ASCE. nates the beginning and specifies the offset and
length of the corresponding segment table.
When no exceptions are recognized in the
process of region-first-table lookup, the entry When bits 60 and 61 of the ASCE have the value
fetched from the region first table designates the 00 binary, the segment-index portion of the virtual
beginning and specifies the offset and length of address, in conjunction with the segment-table
the corresponding region second table. origin contained in the ASCE, is used to select an
entry from the segment table. Bits 33 and 34 of
When bits 60 and 61 of the ASCE have the value the virtual address (which are bits 0 and 1 of the
10 binary, the region-second-index portion of the segment index) are compared against the table
virtual address, in conjunction with the region- length in the ASCE. If the value in the table-
second-table origin contained in the ASCE, is length field is less than the value in the corre-
used to select an entry from the region second sponding bit positions of the virtual address, a
table. Bits 11 and 12 of the virtual address (which segment-translation exception is recognized. The
are bits 0 and 1 of the region second index) are comparison against the table length may be
compared against the table length in the ASCE. If omitted if the equivalent of a segment-table entry
the value in the table-length field is less than the in the translation-lookaside buffer is used in the
value in the corresponding bit positions of the translation. A segment-translation exception is
virtual address, a region-second-translation excep- recognized if bit 58 is one in the segment-table
tion is recognized. The comparison against the entry. A translation-specification exception is
table length may be omitted if the equivalent of a recognized if (1) the private-space control, bit 55,
region-second-table entry in the translation- in the ASCE is one and (2) the common-segment
lookaside buffer is used in the translation. The bit, bit 59, in the entry fetched from the segment
region-second-table-lookup process is otherwise table is one. The segment-table-lookup process is
the same as the region-first-table-lookup process, otherwise the same as the region-first-table-lookup
except that a region-second-translation exception process, including the checking of the table-type
is recognized if bit 58 is one in the region-second- bits in the segment-table entry. When no
table entry. When no exceptions are recognized, exceptions are recognized, the entry fetched from
the entry fetched from the region second table the segment table designates the beginning of the
designates the beginning and specifies the offset corresponding page table.
and length of the corresponding region third table.
Lookup in a Table Designated by a
When bits 60 and 61 of the ASCE have the value
01 binary, the region-third-index portion of the
Region-Table Entry
When the effective address-space-control element
virtual address, in conjunction with the region-
(ASCE) is a region-table designation, a region-
third-table origin contained in the ASCE, is used to
table entry is selected as described in the pre-
select an entry from the region third table. Bits 22
ceding section. Then the contents of the selected
and 23 of the virtual address (which are bits 0 and
entry and the next index portion of the virtual
1 of the region third index) are compared against
address are used to select an entry in the next-
the table length in the ASCE. If the value in the
lower-level table, which may be another region
table-length field is less than the value in the cor-
table or a segment table.
responding bit positions of the virtual address, a

3-40 z/Architecture Principles of Operation


When the table entry selected by means of the less than the value of those bits in the next-
ASCE is a region-first-table entry, the region- higher-level table.
second-index portion of the virtual address, in con-
junction with the region-second-table origin When no exceptions are recognized in the
contained in the region-first-table entry, is used to process of region-second-table lookup, the entry
select an entry from the region second table. fetched from the region second table designates
the beginning and specifies the offset and length
The 64-bit address of the region-second-table of the corresponding region third table.
entry in real or absolute storage is obtained by
appending 12 zeros to the right of bits 0-51 of the When the table entry selected by means of the
region-first-table entry and adding the region ASCE is a region-second-table entry, or if a
second index with three rightmost and 50 leftmost region-second-table entry has been selected by
zeros appended. When a carry out of bit position means of the contents of a region-first-table entry,
0 occurs during the addition, an addressing excep- the region-third-index portion of the virtual
tion may be recognized, or the carry may be address, in conjunction with the region-third-table
ignored, causing the table to wrap from 2 - 1 to origin contained in the region-second-table entry,
zero. All 64 bits of the address are used, regard- is used to select an entry from the region third
less of whether the current PSW specifies the table. Bits 22 and 23 of the virtual address (which
24-bit, 31-bit, or 64-bit addressing mode. are bits 0 and 1 of the region third index) are com-
pared against the table offset and table length in
As part of the region-second-table-lookup process, the region-second-table entry. A region-third-
bits 11 and 12 of the virtual address (which are translation exception is recognized if the table
bits 0 and 1 of the region second index) are com- offset is greater than bits 22 and 23, if the table
pared against the table offset, bits 56 and 57 of length is less than bits 22 and 23, or if bit 58 is
the region-first-table entry, and against the table one in the region-third-table entry. The region-
length, bits 62 and 63 of the region-first-table third-table-lookup process is otherwise the same
entry, to establish whether the addressed entry is as the region-second-table-lookup process,
within the region second table. If the value in the including the checking of the table-type bits in the
table-offset field is greater than the value in the region-third-table entry. When no exceptions are
corresponding bit positions of the virtual address, recognized, the entry fetched from the region third
or if the value in the table-length field is less than table designates the beginning and specifies the
the value in the corresponding bit positions of the offset and length of the corresponding segment
virtual address, a region-second-translation excep- table.
tion is recognized.
When the table entry selected by means of the
All eight bytes of the region-second-table entry ASCE is a region-third-table entry, or if a region-
appear to be fetched concurrently as observed by third-table entry has been selected by means of
other CPUs. The fetch access is not subject to the contents of a region-second-table entry, the
protection. When the storage address generated segment-index portion of the virtual address, in
for fetching the region-second-table entry desig- conjunction with the segment-table origin con-
nates a location which is not available in the con- tained in the region-third-table entry, is used to
figuration, an addressing exception is recognized, select an entry from the segment table. Bits 33
and the unit of operation is suppressed. and 34 of the virtual address (which are bits 0 and
1 of the segment index) are compared against the
Bit 58 of the entry fetched from the region second table offset and table length in the region-third-
table specifies whether the corresponding set of table entry. A segment-translation exception is
regions is available. This bit is inspected, and, if it recognized if the table offset is greater than bits
is one, a region-second-translation exception is 33 and 34, if the table length is less than bits 33
recognized. and 34, or if bit 58 is one in the segment-table
entry. A translation-specification exception is
A translation-specification exception is recognized recognized if (1) the private-space control, bit 55,
if the table-type bits, bits 60 and 61, in the region- in the ASCE is one and (2) the common-segment
second-table entry do not have a value that is one bit, bit 59, in the entry fetched from the segment
table is one. The segment-table-lookup process is

Chapter 3. Storage 3-41


otherwise the same as the region-second-table- nation, bits 0-51 of the virtual address are used as
lookup process, including the checking of the a page-frame real address. In either case, the
table-type bits in the segment-table entry. When page-frame real address and the byte-index
no exceptions are recognized, the entry fetched portion of the virtual address are concatenated,
from the segment table designates the beginning with the page-frame real address forming the left-
of the corresponding page table. most part. The result is the real storage address
which corresponds to the virtual address. All 64
Page-Table Lookup bits of the address are used, regardless of
The page-index portion of the virtual address, in whether the current PSW specifies the 24-bit,
conjunction with the page-table origin contained in 31-bit, or 64-bit addressing mode.
the segment-table entry, is used to select an entry
from the page table. Recognition of Exceptions during
Translation
The 64-bit address of the page-table entry in real Invalid addresses and invalid formats can cause
or absolute storage is obtained by appending 11 exceptions to be recognized during the translation
zeros to the right of the page-table origin and process. Exceptions are recognized when infor-
adding the page index, with three rightmost and mation contained in table entries is used for trans-
53 leftmost zeros appended. A carry out of bit lation and is found to be incorrect.
position 0 cannot occur. All 64 bits of the address
are used, regardless of whether the current PSW The information pertaining to DAT is considered to
specifies the 24-bit, 31-bit, or 64-bit addressing be used when an instruction is executed with DAT
mode. on or when INVALIDATE PAGE TABLE ENTRY,
LOAD REAL ADDRESS, or STORE REAL
All eight bytes of the page-table entry appear to ADDRESS is executed. The information is not
be fetched concurrently as observed by other considered to be used when the PSW specifies
CPUs. The fetch access is not subject to pro- DAT on but an I/O, external, restart, or machine-
tection. When the storage address generated for check interruption occurs before an instruction is
fetching the page-table entry designates a location executed, or when the PSW specifies the wait
which is not available in the configuration, an state. Only that information required in order to
addressing exception is recognized, and the unit translate a virtual address is considered to be in
of operation is suppressed. use during the translation of that address, and, in
particular, addressing exceptions that would be
The entry fetched from the page table indicates caused by the use of an address-space-control
the availability of the page and contains the left- element are not recognized when that address-
most bits of the page-frame real address. The space-control element is not the one actually used
page-invalid bit, bit 53, is inspected to establish in the translation.
whether the corresponding page is available. If
this bit is one, a page-translation exception is A list of translation exceptions, with the action
recognized. If bit position 52 or 55 contains a taken for each exception and the priority in which
one, a translation-specification exception is recog- the exceptions are recognized when more than
nized. If the page-protection bit, bit 54, is one one is applicable, is provided in Recognition of
either in the segment-table entry used in the trans- Access Exceptions on page 6-35.
lation or in the page-table entry, and the storage
reference for which the translation is being per-
formed is a store, a protection exception is recog-
Translation-Lookaside Buffer
nized.
To enhance performance, the dynamic-address-
translation mechanism normally is implemented
Formation of the Real Address such that some of the information specified in the
When the effective address-space-control element region tables, segment tables, and page tables is
(ASCE) is a region-table designation or a maintained in a special buffer, referred to as the
segment-table designation and no exceptions in translation-lookaside buffer (TLB). The CPU nec-
the translation process are encountered, the page- essarily refers to a DAT-table entry in real or
frame real address is obtained from the page-table absolute storage only for the initial access to that
entry. When the ASCE is a real-space desig-

3-42 z/Architecture Principles of Operation


entry. This information may be placed in the TLB, Note: The following sections describe the condi-
and subsequent translations may be performed by tions under which information may be placed in
using the information in the TLB. For consistency the TLB, the conditions under which information
of operation, the virtual-equals-real translation from the TLB may be used for address translation,
specified by a real-space designation also may be and how changes to the translation tables affect
performed by using information in the TLB. The the translation process.
presence of the TLB affects the translation
process to the extent that (1) a modification of the Formation of TLB Entries
contents of a table entry in real or absolute The formation of TLB combined region-and-
storage does not necessarily have an immediate segment-table entries and TLB page-table entries
effect, if any, on the translation, (2) a region-first- from table entries in real or absolute storage, and
table origin, region-second-table origin, region- the effect of any manipulation of the contents of
third-table origin, segment-table origin, or table entries in storage by the program, depend
real-space token origin in an address-space- on whether the entries in storage are attached to
control element (ASCE) may select a TLB entry a particular CPU and on whether the entries are
that was formed by means of an ASCE containing valid.
an origin of the same value even when the two
origins are of different types, and (3) the compar- The attached state of a table entry denotes that
ison against the table length in an address-space- the CPU to which it is attached can attempt to use
control element may be omitted if a TLB the table entry for implicit address translation.
equivalent of the designated table entry is used. The table entry may be attached to more than one
In a multiple-CPU configuration, each CPU has its CPU at a time.
own TLB.
The valid state of a table entry denotes that the
Entries within the TLB are not explicitly address- region set, region, segment, or page associated
able by the program. with the table entry is available. An entry is valid
when the region-invalid, segment-invalid, or page-
Information is not necessarily retained in the TLB invalid bit in the entry is zero.
under all conditions for which such retention is
permissible. Furthermore, information in the TLB The region-table entries, if any, and the segment-
may be cleared under conditions additional to table entry used to form a TLB combined region-
those for which clearing is mandatory. and-segment-table entry are called a translation
path. A translation path may be placed in the TLB
TLB Structure as a combined region-and-segment-table entry
The description of the logical structure of the TLB whenever all entries in the path are attached and
covers the implementation by all systems oper- valid and would not cause a translation-
ating as defined by z/Architecture. The TLB specification exception if used for translation.
entries are considered as being of three types: Similarly, a page-table entry may be placed in the
TLB combined region-and-segment-table entries, TLB whenever the entry is attached and valid and
TLB page-table entries, and TLB real-space would not cause a translation-specification excep-
entries. A TLB combined region-and-segment- tion if used for translation.
table entry or TLB page-table entry is considered
as containing within it both the information The highest-level table entry in a translation path
obtained from the table entry or entries in real or is attached when it is within a table designated by
absolute storage and the attributes used to fetch an attaching address-space-control element
this information from storage. A TLB real-space (ASCE). Within a table means as determined by
entry is considered as containing a page-frame the origin and length fields in the ASCE. An
real address and the real-space token origin and ASCE is an attaching ASCE when all of the fol-
region, segment, and page indexes used to form lowing conditions are met:
the entry. The token origin in a TLB real-space 1. The current PSW specifies DAT on.
entry is indistinguishable from the table origin in a
TLB combined region-and-segment-table entry. 2. The current PSW contains no errors that
would cause an early specification exception
to be recognized.

Chapter 3. Storage 3-43


3. The ASCE meets the requirements in a, b, c, common-segment bit is one in the entry. A page-
or d below. table entry causes a translation-specification
exception if bit 52 or 55 in the entry is one.
a. The ASCE is the primary ASCE in control
register 1, and the CPU is not in the
A TLB real-space entry may be formed whenever
home-space mode.
an attaching real-space designation exists. The
b. The ASCE is the secondary ASCE in entry is formed using the real-space token origin
control register 7, and either of the fol- in the designation and any value of bits 0-51 of a
lowing requirements is met: virtual address.
The CPU is in the secondary-space
mode or access-register mode. Use of TLB Entries
The usable state of a TLB entry denotes that the
The CPU is in the primary-space CPU can attempt to use the TLB entry for implicit
mode, and the secondary-space address translation. A usable TLB entry attaches
control, bit 37 of control register 0, is the next-lower-level table, if any, and may be
one. usable for a particular instance of implicit address
c. The ASCE is in either an attached and translation.
valid ASN-second-table entry (ASTE) or a
usable ALB ASTE, and the CPU is in the A TLB combined region-and-segment-table entry
access-register mode. See is in the usable state when all of the following con-
ART-Lookaside Buffer on page 5-53 for ditions are met:
the meaning of the terminology used here. 1. The current PSW specifies DAT on.
d. The ASCE is the home ASCE in control 2. The current PSW contains no errors that
register 13, and the CPU is not in the would cause an early specification exception
secondary-space mode. to be recognized.

Each of the remaining table entries in a translation 3. The TLB combined region-and-segment-table
path is attached when the next-higher-level entry entry meets either one of the following
is attached and valid and would not cause a requirements:
translation-specification exception if used for trans- a. The common-segment bit is one in the
lation and the subject entry is within the table des- TLB entry.
ignated by the next-higher-level entry. Within the
b. The table-origin (TO) field in the TLB entry
table means as determined by the origin, offset,
matches the table- or token-origin field in
and length fields in the next-higher-level entry.
an attaching address-space-control
A page-table entry is attached when it is within the element.
page table designated by either an attached and A TLB combined region-and-segment-table entry
valid segment-table entry that would not cause a may be used for a particular instance of implicit
translation-specification exception if used for trans- address translation only when the entry is in the
lation or a usable TLB combined region-and- usable state, either the common-segment bit is
segment-table entry. A usable TLB combined one in the TLB entry or the table-origin (TO) field
region-and-segment-table entry is explained in the in the TLB entry matches the table- or token-origin
next section. field in the address-space-control element being
used in the translation, and the region-index and
A region-table entry or segment-table entry causes segment-index fields in the TLB entry match those
a translation-specification exception if the table- of the virtual address being translated. However,
type bits, bits 60 and 61, in the entry are incon- the TLB combined region-and-segment-table entry
sistent with the level at which the entry would be is not used if the common-segment bit is one in
encountered when using the translation path in the the entry and either the private-space-control bit is
translation process. A segment-table entry also one in the address-space-control element being
causes a translation-specification exception if the used in the translation or that address-space-
private-space-control bit is one in the address- control element is a real-space designation. In
space-control element used to select it and the both these cases, the TLB entry is not used even

3-44 z/Architecture Principles of Operation


if the table-origin field in the entry and the table- 3. More than one copy of contents of a table
or token-origin field in the address-space-control entry may exist in the TLB. For example,
element match. some implementations may cause a copy of
contents of a valid table entry to be placed in
A TLB page-table entry may be used for a partic- the TLB for the table origin in each address-
ular instance of implicit address translation only space-control element by which the entry
when the page-table-origin field in the entry becomes attached.
matches the page-table-origin field in the
segment-table entry or TLB combined region-and- Modification of Translation Tables
segment-table entry being used in the translation When an attached and invalid table entry is made
and the page-index field in the TLB page-table valid and no entry usable for translation of the
entry matches the page index of the virtual associated virtual address is in the TLB, the
address being translated. change takes effect no later than the end of the
current unit of operation. Similarly, when an unat-
A TLB real-space entry may be used for implicit tached and valid table entry is made attached and
address translation only when the token-origin no usable entry for the associated virtual address
field in the TLB entry matches the table- or token- is in the TLB, the change takes effect no later
origin field in the address-space-control element than the end of the current unit of operation.
being used in the translation and the region-index,
segment-index, and page-index fields in the TLB When a valid and attached table entry is changed,
entry match those of the virtual address being and when, before the TLB is cleared of entries
translated that qualify for substitution for that entry, an
attempt is made to refer to storage by using a
The operand address of LOAD REAL ADDRESS virtual address requiring that entry for translation,
may be translated with the use of the TLB con- unpredictable results may occur, to the following
tents whether DAT is on or off, but TLB entries extent. The use of the new value may begin
still are formed only if DAT is on. between instructions or during the execution of an
instruction, including the instruction that caused
Programming Notes: the change. Moreover, until the TLB is cleared of
1. Although contents of a table entry may be entries that qualify for substitution for that entry,
copied into the TLB only when the table entry the TLB may contain both the old and the new
is both attached and valid, the copy may values, and it is unpredictable whether the old or
remain in the TLB even when the table entry new value is selected for a particular access. If
itself is no longer attached or valid. both old and new values of a translation path are
present in the TLB, a page-table entry may be
2. No contents can be copied into the TLB when
fetched by using one value and placed in the TLB
DAT is off because the table entries at this
associated with the other value. If the new value
time are not attached. In particular, trans-
of the path is a value that would cause an excep-
lation of the operand address of LOAD REAL
tion, the exception may or may not cause an inter-
ADDRESS with DAT off does not cause
ruption to occur. If an interruption does occur, the
entries to be placed in the TLB.
result fields of the instruction may be changed
Conversely, when DAT is on, information may even though the exception would normally cause
be copied into the TLB from all translation- suppression or nullification.
table entries that could be used for address
translation, given the current translation Entries are cleared from the TLB in accordance
parameters, the setting of the address-space- with the following rules:
control bits, and the contents of the access 1. All entries are cleared from the TLB by the
registers. The loading of the TLB does not execution of PURGE TLB or SET PREFIX and
depend on whether the entry is used for trans- by CPU reset.
lation as part of the execution of the current
instruction, and such loading can occur when 2. All entries may be cleared from all TLBs in the
the wait state is specified. configuration by the execution of COMPARE
AND SWAP AND PURGE by any of the CPUs

Chapter 3. Storage 3-45


in the configuration, depending on a bit in a instruction, including the instruction that
general register used by the instruction. caused the change. When an instruction,
such as MOVE (MVC), makes a change to an
3. Selected entries are cleared from all TLBs in
attached table entry, including a change that
the configuration by the execution of INVALI-
makes the entry invalid, and subsequently
DATE PAGE TABLE ENTRY by any of the
uses the entry for translation, a changed entry
CPUs in the configuration.
is being used without a prior clearing of the
4. Some or all TLB entries may be cleared at entry from the TLB, and the associated unpre-
times other than those required by the pre- dictability of result values and of exception
ceding rules. recognition applies.

Programming Notes: Manipulation of attached table entries may


cause spurious table-entry values to be
1. Entries in the TLB may continue to be used recorded in a TLB. For example, if changes
for translation after the table entries from are made piecemeal, modification of a valid
which they have been formed have become attached entry may cause a partially updated
unattached or invalid. These TLB entries are entry to be recorded, or, if an intermediate
not necessarily removed unless explicitly value is introduced in the process of the
cleared from the TLB. change, a supposedly invalid entry may tem-
A change made to an attached and valid entry porarily appear valid and may be recorded in
or a change made to a table entry that causes the TLB. Such an intermediate value may be
the entry to become attached and valid is introduced if the change is made by an I/O
reflected in the translation process for the next operation that is retried, or if an intermediate
instruction, or earlier than the next instruction, value is introduced during the execution of a
unless a TLB entry qualifies for substitution for single instruction.
that table entry. However, a change made to As another example, if a segment-table entry
a table entry that causes the entry to become is changed to designate a different page table
unattached or invalid is not necessarily and used without clearing the TLB, the new
reflected in the translation process until the page-table entries may be fetched and associ-
TLB is cleared of entries that qualify for sub- ated with the old page-table origin. In such a
stitution for that table entry. case, execution of INVALIDATE PAGE TABLE
2. Exceptions associated with dynamic address ENTRY designating the new page-table origin
translation may be established by a pretest for will not necessarily clear the page-table
operand accessibility that is performed as part entries fetched from the new page table.
of the initiation of instruction execution. Con- 4. To facilitate the manipulation of page tables,
sequently, a region-first-translation, region- the INVALIDATE PAGE TABLE ENTRY
second-translation, region-third-translation, instruction is provided. This instruction sets
segment-translation, or page-translation the I bit in a page-table entry to one and
exception may be indicated when a table entry clears all TLBs in the configuration of entries
is invalid at the start of execution even if the formed from that table entry.
instruction would have validated the table
entry it uses and the table entry would have INVALIDATE PAGE TABLE ENTRY is useful
appeared valid if the instruction was consid- for setting the I bit to one in a page-table entry
ered to process the operands one byte at a and causing TLB copies of the entry to be
time. cleared from the TLB of each CPU in the con-
figuration. The following aspects of the TLB
3. A change made to an attached table entry, operation should be considered when using
except to set the I bit to zero or to alter the INVALIDATE PAGE TABLE ENTRY. (See
rightmost byte of a page-table entry, may also the programming notes following INVALI-
produce unpredictable results if that entry is DATE PAGE TABLE ENTRY.)
used for translation before the TLB is cleared
of all copies of contents of that entry. The a. INVALIDATE PAGE TABLE ENTRY
use of the new value may begin between should be executed before making any
instructions or during the execution of an change to a page-table entry other than

3-46 z/Architecture Principles of Operation


changing the rightmost byte; otherwise, valid, this rule applies when it is known
the selective-clearing portion of INVALI- that a program is not being executed that
DATE PAGE TABLE ENTRY may not may require the entry for translation.
clear the TLB copies of the entry.
c. When any change is made to an invalid
b. Invalidation of all the page-table entries table entry in such a way as to allow inter-
within a page table by means of INVALI- mediate valid values to appear in the
DATE PAGE TABLE ENTRY does not entry, each CPU to which the entry is
necessarily clear the TLB of any combined attached must be caused to purge its TLB
region-and-segment-table entry desig- after the change occurs and prior to the
nating the page table. When it is desired use of the entry for implicit address trans-
to invalidate and clear the TLB of a com- lation by that CPU.
bined region-and-segment-table entry, the
d. When any change is made to an offset or
rules in note 5 below must be followed.
length specified for a table, each CPU
c. When a large number of page-table which may have a TLB entry formed from
entries are to be invalidated at a single a table entry that no longer lies within its
time, the overhead involved in using table must be caused to purge its TLB
COMPARE AND SWAP AND PURGE after the change occurs and prior to the
(one that purges the TLB) or PURGE TLB use of the table for implicit translation by
and in following the rules in note 5 below that CPU.
may be less than in issuing INVALIDATE
Note that when an invalid page-table entry is
PAGE TABLE ENTRY for each page-table
made valid without introducing intermediate
entry.
valid values, the TLB need not be cleared in a
5. Manipulation of table entries should be in CPU which does not have any TLB entries
accordance with the following rules. If these formed from that entry. Similarly, when an
rules are complied with, translation is per- invalid region-table or segment-table entry is
formed as if the table entries from real or made valid without introducing intermediate
absolute storage were always used in the valid values, the TLB need not be cleared in a
translation process. CPU which does not have any TLB entries
formed from that validated entry and which
a. A valid table entry must not be changed
does not have any TLB entries formed from
while it is attached to any CPU and may
entries in a page table attached by means of
be used for translation by that CPU except
that validated entry.
to (1) invalidate the entry, by using
INVALIDATE PAGE TABLE ENTRY, The execution of PURGE TLB, COMPARE
(2) alter bits 56-63 of a page-table entry, AND SWAP AND PURGE, or SET PREFIX
or (3) make a change by means of a may have an adverse effect on the perform-
COMPARE AND SWAP AND PURGE ance of some models. Use of these
instruction that purges the TLB. instructions should, therefore, be minimized in
conformance with the above rules.
b. When any change is made to an attached
and valid or unattached or invalid table
entry other than a change to bits 56-63 of
a page-table entry, each CPU which may
Address Summary
have a TLB entry formed from that entry
must be caused to purge its TLB after the Addresses Translated
change occurs and prior to the use of that
entry for implicit translation by that CPU. Most addresses that are explicitly specified by the
(Note that a separate purge is unneces- program and are used by the CPU to refer to
sary if the change was made by using storage are instruction or logical addresses and
INVALIDATE PAGE TABLE ENTRY or a are subject to implicit translation when DAT is on.
COMPARE AND SWAP AND PURGE Analogously, the corresponding addresses indi-
instruction that purges the TLB.) In the cated to the program on an interruption or as the
case when the table entry is attached and result of executing an instruction are instruction or

Chapter 3. Storage 3-47


logical addresses. The operand address of LOAD addresses implicitly used by the CPU for such
REAL ADDRESS and STORE REAL ADDRESS is sequences as interruptions are real addresses.
explicitly translated, regardless of whether the
PSW specifies DAT on or off. The addresses used by channel programs to
transfer data and to refer to CCWs or IDAWs are
Translation is not applied to quantities that are absolute addresses.
formed from the values specified in the B and D
fields of an instruction but that are not used to The handling of storage addresses associated
address storage. This includes operand with DIAGNOSE is model-dependent.
addresses in LOAD ADDRESS, LOAD ADDRESS
EXTENDED, MONITOR CALL, and the shifting The processing of addresses, including dynamic
instructions. This also includes the addresses in address translation and prefixing, is discussed in
control registers 10 and 11 designating the Address Types on page 3-3. Prefixing, when
starting and ending locations for PER. provided, is applied after the address has been
translated by means of the dynamic-address-
With the exception of INSERT VIRTUAL translation facility. For a description of prefixing,
STORAGE KEY and TEST PROTECTION, the see Prefixing on page 3-15.
addresses explicitly designating storage keys
(operand addresses in SET STORAGE KEY Handling of Addresses
EXTENDED, INSERT STORAGE KEY
EXTENDED, and RESET REFERENCE BIT The handling of addresses is summarized in
EXTENDED) are real addresses. Similarly, the Figure 3-10 on page 3-49. This figure lists all
addresses that are encountered by the program
and specifies the address type.

3-48 z/Architecture Principles of Operation



Virtual Addresses

Address of storage operand for INSERT VIRTUAL STORAGE KEY
Operand address in LOAD REAL ADDRESS and STORE REAL ADDRESS
Addresses of storage operands for MOVE TO PRIMARY and MOVE TO
SECONDARY
Address stored in the doubleword at real location 168 on a program
interruption for ASCE-type, region-first-translation, region-second-
translation, region-third-translation, segment-translation, or page-
translation exception
Linkage-stack-entry address in control register 15
Backward stack-entry address in linkage-stack header entry
Forward-section-header address in linkage-stack trailer entry
Trap-control-block address in dispatchable-unit-control table
Trap-save-area address and trap-program address in trap control
block

Instruction Addresses

Instruction address in PSW
Branch address
Target of EXECUTE
Address stored in the doubleword at real location 152 on a program
interruption for PER
Address placed in general register by BRANCH AND LINK, BRANCH AND
SAVE, BRANCH AND SAVE AND SET MODE, BRANCH AND STACK, BRANCH IN
SUBSPACE GROUP, BRANCH RELATIVE AND SAVE, BRANCH RELATIVE AND SAVE
LONG, and PROGRAM CALL
Address used in general register by BRANCH AND STACK.
Address placed in general register by BRANCH AND SET AUTHORITY
executed in reduced-authority state

Logical Addresses

Addresses of storage operands for instructions not otherwise
specified
Address placed in general register 1 by EDIT AND MARK and TRANSLATE
AND TEST
Addresses in general registers updated by MOVE LONG, MOVE LONG
EXTENDED, COMPARE LOGICAL LONG, and COMPARE LOGICAL LONG EXTENDED
Addresses in general registers updated by CHECKSUM, COMPARE AND FORM
CODEWORD, and UPDATE TREE
Address for TEST PENDING INTERRUPTION when the second-operand ad-
dress is nonzero
Address of parameter list of RESUME PROGRAM

Figure 3-10 (Part 1 of 3). Handling of Addresses

Chapter 3. Storage 3-49



Real Addresses

Address of storage key for INSERT STORAGE KEY EXTENDED, RESET
REFERENCE BIT EXTENDED, and SET STORAGE KEY EXTENDED
Address of storage operand for LOAD USING REAL ADDRESS, STORE USING
REAL ADDRESS, and TEST BLOCK
The translated address generated by LOAD REAL ADDRESS and STORE REAL
ADDRESS
Page-frame real address in page-table entry
Trace-entry address in control register 12
ASN-first-table origin in control register 14
ASN-second-table origin in ASN-first-table entry
Authority-table origin in ASN-second-table entry, except when used
by access-register translation
Linkage-table origin in primary ASN-second-table entry
Entry-table origin in linkage-table entry
Dispatchable-unit-control-table origin in control register 2
Primary-ASN-second-table-entry origin in control register 5
Base-ASN-second-table-entry origin and subspace-ASN-second-table-
entry origin in dispatchable-unit control table
ASN-second-table-entry address in entry-table entry and access-list
entry

Permanently Assigned Real Addresses

Address of the doubleword into which TEST PENDING INTERRUPTION
stores when the second-operand address is zero
Addresses of PSWs, interruption codes, and the associated informa-
tion used during interruption
Addresses used for machine-check logout and save areas
Address of STORE FACILITY LIST operand

Addresses Which Are Unpredictably Real or Absolute

Region-first-table origin, region-second-table origin, region-third-
table origin, or segment-table origin in control registers 1, 7, and
13, in access-register-specified address-space-control element, and
in region-first-table entry, region-second-table entry, or region-
third-table entry
Page-table origin in segment-table entry and in INVALIDATE PAGE
TABLE ENTRY
Address of segment-table entry or page-table entry provided by LOAD
REAL ADDRESS
The dispatchable-unit or primary-space access-list origin and the
authority-table origin (in the ASTE designated by the ALE used) used
by access-register translation

Figure 3-10 (Part 2 of 3). Handling of Addresses

3-50 z/Architecture Principles of Operation



Absolute Addresses

Prefix value
Channel-program address in ORB
Data address in CCW
IDAW address in a CCW specifying indirect data addressing
CCW address in a CCW specifying transfer in channel
Data address in IDAW
Measurement-block origin specified in SET CHANNEL MONITOR
Address limit specified in SET ADDRESS LIMIT
Addresses used by the store-status-at-address SIGNAL PROCESSOR order
Failing-storage address stored in the doubleword at real location
248
CCW address in SCSW

Permanently Assigned Absolute Addresses

Addresses used for the store-status function
Addresses of PSW and first two CCWs used for initial program loading

Addresses Not Used to Reference Storage

PER starting address in control register 1
PER ending address in control register 11
Address stored in the doubleword at real location 176 for a monitor
event
Address in shift instructions and other instructions specified not
to use the address to reference storage
Real-space token origin in real-space designation

Figure 3-10 (Part 3 of 3). Handling of Addresses

completion of the IPL initial-read opera-


Assigned Storage Locations tion.
Figure 3-11 on page 3-58 shows the format and
16-23 (Absolute Address)
extent of the assigned locations in storage. The
locations are used as follows. Initial-Program-Loading CCW2: Bytes
16-23 read during the initial-program
0-7 (Absolute Address)
loading (IPL) initial-read operation are
Initial-Program-Loading PSW: The first stored at locations 16-23. The contents
eight bytes read during the initial- of these locations may be used as
program-loading (IPL) initial-read opera- another CCW in the IPL CCW chain to
tion are stored at locations 0-7. The follow IPL CCW1.
contents of these locations are used as
128-131 (Real Address)
the new PSW at the completion of the
IPL operation. These locations may also External-Interruption Parameter: During
be used for temporary storage at the ini- an external interruption due to service
tiation of the IPL operation. signal or the external time reference
(ETR), the parameter associated with the
8-15 (Absolute Address)
interruption is stored at locations
Initial-Program-Loading CCW1: Bytes 128-131.
8-15 read during the initial-program-
132-133 (Real Address)
loading (IPL) initial-read operation are
stored at locations 8-15. The contents of CPU Address: During an external inter-
these locations are ordinarily used as the ruption due to malfunction alert, emer-
next CCW in an IPL CCW chain after gency signal, or external call, the CPU
address associated with the source of

Chapter 3. Storage 3-51


the interruption is stored at locations 152-159 (Real Address)
132-133. For all other external-
PER Address: During a program inter-
interruption conditions, zeros are stored
ruption due to a PER event, the PER
at locations 132-133.
address is stored at locations 152-159.
134-135 (Real Address)
160 (Real Address)
External-Interruption Code: During an
Exception Access Identification: During
external interruption, the interruption
a program interruption due to an
code is stored at locations 134-135.
ASCE-type, region-first-translation,
136-139 (Real Address) region-second-translation, region-third-
translation, segment-translation, or page-
Supervisor-Call-Interruption Identification:
translation exception, an indication of the
During a supervisor-call interruption, the
address space to which the exception
instruction-length code is stored in bit
applies may be stored at location 160. If
positions 5 and 6 of location 137, and
the CPU was in the access-register
the interruption code is stored at
mode and the access was an instruction
locations 138-139. Zeros are stored at
fetch, including a fetch of the target of an
location 136 and in the remaining bit
EXECUTE instruction, zeros are stored
positions of location 137.
at location 160. If the CPU was in the
140-143 (Real Address) access-register mode and the access
Program-Interruption Identification: was a storage-operand reference that
During a program interruption, the used an AR-specified address-space-
instruction-length code is stored in bit control element, the number of the
positions 5 and 6 of location 141, and access register used is stored in bit posi-
the interruption code is stored at tions 4-7 of location 160, and zeros are
locations 142-143. Zeros are stored at stored in bit positions 0-3. (In either of
location 140 and in the remaining bit the two cases described so far, storing
positions of location 141. at location 160 occurs regardless of the
value stored in bit positions 62 and 63 of
144-147 (Real Address) real locations 168-175.) If the CPU was
Data-Exception Code (DXC): During a in the access-register mode but the
program interruption due to a data access was an implicit reference to the
exception, the data-exception code is linkage stack, or if the CPU was not in
stored at location 147, and zeros are the access-register mode, the contents
stored at locations 144-146. The DXC is of location 160 are unpredictable.
described in Data-Exception Code During a program interruption due to an
(DXC) on page 6-14. ALEN-translation, ALE-sequence,
148-149 (Real Address) ASTE-validity, ASTE-sequence, or
extended-authority exception recognized
Monitor-Class Number: During a during access-register translation, the
program interruption due to a monitor number of the access register used is
event, the monitor-class number is stored in bit positions 4-7 of location
stored at location 149, and zeros are 160, and zeros are stored in bit positions
stored at location 148. 0-3. During a program interruption due
150-151 (Real Address) to an ASTE-validity or ASTE-sequence
exception recognized during a subspace-
PER Code: During a program inter- replacement operation, all zeros are
ruption due to a PER event the PER
stored at location 160.
code is stored in bit positions 0-2 and 4
of locations 150-151, and other informa- During a program interruption due to a
tion is or may be stored as described in protection exception, information is
Identification of Cause on page 4-26. stored at location 160 as described in

3-52 z/Architecture Principles of Operation


Suppression on Protection on store-status operation, zeros are stored
page 3-12. in bit positions 0-6 of location 163, and a
one is stored in bit position 7.
161 (Real Address)
163 (Real Address)
PER Access Identification: During a
Machine-Check Architectural-Mode Iden-
program interruption due to a PER
tification: During a machine-check inter-
storage-alteration event, an indication of
ruption, zeros are stored in bit positions
the address space to which the event
0-6 of location 163, and a one is stored
applies may be stored at location 161. If
in bit position 7.
the access used an AR-specified
address-space-control element, the 168-175 (Real Address)
number of the access register used is
Translation-Exception Identification:
stored in bit positions 4-7 of location
During a program interruption due to an
161, and zeros are stored in bit positions
ASCE-type, region-first-translation,
0-3. The contents of location 161 are
region-second-translation, region-third-
unpredictable if (1) the CPU was in the
translation, segment-translation, or page-
access-register mode but the access
translation exception, bits 0-51 of the
was an implicit reference to the linkage
virtual address causing the exception are
stack or (2) the CPU was not in the
stored in bit positions 0-51 of locations
access-register mode.
168-175. This address is sometimes
162 (Real Address) referred to as the translation-exception
address. Bits 52-60 of locations 168-175
Operand Access Identification: During a
are unpredictable. If the exception was
program interruption due to a page-
a page-translation exception that was
translation exception recognized by the
recognized during the execution of
MOVE PAGE instruction, the contents of
MOVE PAGE, bit 61 of locations
the R field of the instruction are stored
168-175 is set to one. If the exception
in bit positions 0-3 of location 162, and
was a page-translation exception recog-
the contents of the R field are stored in
nized during the execution of an instruc-
bit positions 4-7. If the page-translation
tion other than MOVE PAGE, bit 61 is
exception was recognized during the
set to zero. If the exception was an
execution of an instruction other than
ASCE-type, region-first-translation,
MOVE PAGE, or if an ASCE-type,
region-second-translation, region-third-
region-first-translation, region-second-
translation, or segment-translation
translation, region-third-translation, or
exception, bit 61 of locations 168-175 is
segment-translation exception was
unpredictable. See the definition of real
recognized, the contents of location 162
location 162 for related information.
are unpredictable.
Bits 62 and 63 of locations 168-175 are
163 (Absolute Address)
set to identify the address-space-control
Store-Status Architectural-Mode Identifi- element (ASCE) used in the translation,
cation: During the execution of the as follows:

Chapter 3. Storage 3-53


Bit Bit of locations 168-171 remain unchanged.
62 63 Meaning The identification and bit stored are as
0 0 Primary ASCE was used. follows:
0 1 CPU was in the access- If the CPU was in the primary-space,
register mode, and either the secondary-space, or access-register
access was an instruction fetch mode before the operation, the old
or it was a storage-operand PASN, bits 48-63 of control register
reference that used an 4 before the operation, is stored at
AR-specified ASCE (the locations 174 and 175, and the old
access was not an implicit ref- primary space-switch-event-control
erence to the linkage stack). bit, bit 57 of control register 1 before
The exception access id, real the operation, is placed in bit posi-
location 160, can be examined tion 0 of locations 172 and 173.
to determine the ASCE used.
However, if the primary, sec- If the CPU was in the home-space
ondary, or home ASCE was mode before the operation, zeros are
used, bits 62 and 63 may be stored at locations 174 and 175, and
set to 00, 10, or 11, respec- the home space-switch-event-control
tively, instead of to 01. bit, bit 57 of control register 13, is
1 0 Secondary ASCE was used. placed in bit position 0 of locations
1 1 Home ASCE was used 172 and 173.
(includes the case of an During a program interruption due to an
implicit reference to the linkage LX-translation or EX-translation excep-
stack). tion recognized by PROGRAM CALL,
the PC number is stored in bit positions
The CPU may avoid setting bits 62 and 12-31 of locations 172-175, zeros are
63 to 01 by recognizing that the access stored in bit positions 0-11, and the con-
was an instruction fetch, that access-list- tents of locations 168-171 remain
entry token 00000000 or 00000001 hex unchanged.
was used, or that the access-list-entry
token designated, through an access-list During a program interruption due to a
entry, an ASN-second-table entry con- protection exception, information is
taining an ASCE equal to the primary stored at locations 168-175 as described
ASCE, secondary ASCE, or home in Suppression on Protection on
ASCE. page 3-12.

During a program interruption due to an 176-183 (Real Address)


AFX-translation, ASX-translation, Monitor Code: During a program inter-
primary-authority, or secondary-authority ruption due to a monitor event, the
exception, the ASN being translated is monitor code is stored at locations
stored at locations 174 and 175, zeros 176-183.
are stored at locations 172 and 173, and
the contents of locations 168-171 remain 184-187 (Real Address)
unchanged. Subsystem-Identification Word: During
During a program interruption due to a an I/O interruption, the subsystem-
space-switch event, an identification of identification word is stored at locations
the old instruction space is stored at 184-187.
locations 174 and 175, the old 188-191 (Real Address)
instruction-space space-switch-event-
I/O-Interruption Parameter: During an
control bit is placed in bit position 0 and
I/O interruption, the interruption param-
zeros are placed in bit positions 1-15 of
eter from the associated subchannel is
locations 172 and 173, and the contents
stored at locations 188-191.

3-54 z/Architecture Principles of Operation


192-195 (Real Address) 320-335 (Real Address)
I/O-Interruption-Identification Word: Supervisor-Call Old PSW: The current
During an I/O interruption, the PSW is stored as the old PSW at
I/O-interruption-identification word, which locations 320-335 during a supervisor-
further identifies the source of the I/O call interruption.
interruption, is stored at locations
336-351 (Real Address)
192-195.
Program Old PSW: The current PSW is
200-203 (Real Address)
stored as the old PSW at locations
STFL Facility List: The STORE 336-351 during a program interruption.
FACILITY LIST instruction stores infor-
352-367 (Real Address)
mation at real locations 200-203. Bit 0
indicates, when one, that the instructions Machine-Check Old PSW: The current
marked with N3 in the instruction- PSW is stored as the old PSW at
summary figure at the beginning of locations 352-367 during a machine-
Chapter 7, General Instructions, and check interruption.
Chapter 10, Control Instructions, are 368-383 (Real Address)
available in the ESA/390 mode. Bit 1
indicates, when one, that z/Architecture Input/Output Old PSW: The current
is installed. Bit 2 indicates, when one, PSW is stored as the old PSW at
that z/Architecture is active. Bits 3-31 locations 368-383 during an I/O inter-
are stored as zeros. ruption.

232-239 (Real Address) 416-431 (Real Address)

Machine-Check-Interruption Code: Restart New PSW: The new PSW is


During a machine-check interruption, the fetched from locations 416-431 during a
machine-check-interruption code is restart interruption.
stored at locations 232-239. 432-447 (Real Address)
244-247 (Real Address) External New PSW: The new PSW is
External-Damage Code: During a fetched from locations 432-447 during an
machine-check interruption due to external interruption.
certain external-damage conditions, 448-463 (Real Address)
depending on the model, an external-
damage code may be stored at locations Supervisor-Call New PSW: The new
244-247. PSW is fetched from locations 448-463
during a supervisor-call interruption.
248-255 (Real Address)
464-479 (Real Address)
Failing-Storage Address: During a
machine-check interruption, a 64-bit Program New PSW: The new PSW is
failing-storage address may be stored at fetched from locations 464-479 during a
locations 248-255. program interruption.

288-303 (Real Address) 480-495 (Real Address)

Restart Old PSW: The current PSW is Machine-Check New PSW: The new
stored as the old PSW at locations PSW is fetched from locations 480-495
288-303 during a restart interruption. during a machine-check interruption.

304-319 (Real Address) 496-511 (Real Address)

External Old PSW: The current PSW is Input/Output New PSW: The new PSW
stored as the old PSW at locations is fetched from locations 496-511 during
304-319 during an external interruption. an I/O interruption.

Chapter 3. Storage 3-55


4544-4607 (Real Address) contents of the floating-point control reg-
ister are stored at locations 4892-4895.
Available for Programming: Locations
4544-4607 are available for use by pro- 4892-4895 (Real Address)
gramming.
Machine-Check Floating-Point-Control-
4608-4735 (Absolute Address) Register Save Area: During a machine-
check interruption, the contents of the
Store-Status Floating-Point-Register
floating-point control register are stored
Save Area: During the execution of the
at locations 4892-4895.
store-status operation, the contents of
the floating-point registers are stored at 4900-4903 (Absolute Address)
locations 4608-4735.
Store-Status
4608-4735 (Real Address) TOD-Programmable-Register Save Area:
During the execution of the store-status
Machine-Check Floating-Point-Register
operation, the contents of the TOD pro-
Save Area: During a machine-check
grammable register are stored at
interruption, the contents of the floating-
locations 4900-4903.
point registers are stored at locations
4608-4735. 4900-4903 (Real Address)
4736-4863 (Absolute Address) Machine-Check
TOD-Programmable-Register Save Area:
Store-Status General-Register Save
During a machine-check interruption, the
Area: During the execution of the store-
contents of the TOD programmable reg-
status operation, the contents of the
ister are stored at locations 4900-4903.
general registers are stored at locations
4736-4863. 4904-4911 (Absolute Address)
4736-4863 (Real Address) Store-Status CPU-Timer Save Area:
During the execution of the store-status
Machine-Check General-Register Save
operation, the contents of the CPU timer
Area: During a machine-check inter-
are stored at locations 4904-4911.
ruption, the contents of the general reg-
isters are stored at locations 4736-4863. 4904-4911 (Real Address)
4864-4879 (Absolute Address) Machine-Check CPU-Timer Save Area:
During a machine-check interruption, the
Store-Status PSW Save Area: During
contents of the CPU timer are stored at
the execution of the store-status opera-
locations 4904-4911.
tion, the contents of the current PSW are
stored at locations 4864-4879. 4913-4919 (Absolute Address)
4864-4879 (Real Address) Store-Status Clock-Comparator Save
Area: During the execution of the store-
Fixed-Logout Area: Depending on the
status operation, the contents of bit posi-
model, logout information may be stored
tions 0-55 of the clock comparator are
at locations 4864-4879 during a
stored at locations 4913-4919. When
machine-check interruption.
this store occurs, zeros are stored at
4888-4891 (Absolute Address) location 4912.
Store-Status Prefix Save Area: During 4913-4919 (Real Address)
the execution of the store-status opera-
Machine-Check Clock-Comparator Save
tion, the contents of the prefix register
Area: During a machine-check inter-
are stored at locations 4888-4891.
ruption, the contents of bit positions 0-55
4892-4895 (Absolute Address) of the clock comparator are stored at
Store-Status Floating-Point-Control- locations 4913-4919. When this store
Register Save Area: During the exe- occurs, zeros are stored at location
cution of the store-status operation, the 4912.

3-56 z/Architecture Principles of Operation


4928-4991 (Absolute Address) Programming Notes:
Store-Status Access-Register Save Area: 1. When the CPU is in the access-register mode,
During the execution of the store-status some instructions, such as MVCL, which
operation, the contents of the access address operands in more than one address
registers are stored at locations space, may cause a storage-alteration PER
4928-4991. event in one address space concurrently with
a region-translation, segment-translation, or
4928-4991 (Real Address)
page-translation exception in another address
Machine-Check Access-Register Save space. The access registers used to cause
Area: During a machine-check inter- these conditions in such a case are different.
ruption, the contents of the access regis- In order to identify both access registers, two
ters are stored at locations 4928-4991. access identifications, namely the exception
4992-5119 (Absolute Address) access identification and the PER access
identification, are provided.
Store-Status Control-Register Save Area:
During the execution of the store-status 2. The store-status and machine-check
operation, the contents of the control architectural-mode identifications at absolute
registers are stored at locations and real locations 163, respectively, indicate
4992-5119. that the CPU is in the z/Architecture architec-
tural mode. When z/Architecture is installed
4992-5119 (Real Address) on the CPU but the CPU is in the ESA/390
Machine-Check Control-Register Save mode, the store-status and machine-check-
Area: During a machine-check inter- interruption operations store zero at location
ruption, the contents of the control regis- 163.
ters are stored at locations 4992-5119.

Chapter 3. Storage 3-57



Hex Dec Fields

Initial-Program-Loading PSW

4 4

8 8 Initial-Program-Loading CCW1

C 12

1 16 Initial-Program Loading CCW2



14 2

18 24

1C 28

2 32

24 36

28 4

2C 44

3 48

34 52

38 56

3C 6

4 64

44 68

48 72

4C 76

5 8

54 84

58 88

5C 92

6 96

64 1

68 14

6C 18

7 112

74 116

78 12

7C 124

Figure 3-11 (Part 1 of 6). Assigned Storage Locations

3-58 z/Architecture Principles of Operation



Hex Dec Fields

8 128 External-Interruption Parameter

84 132 CPU Address External-Interruption Code

88 136 ILC SVC-Interruption Code

8C 14 ILC Program-Interruption Code

9 144 Data-Exception Code

94 148 Monitor-Class Number PER CdeATMIDAI

98 152 PER Address



9C 156

A 16 Exc. Access ID PER Access ID Op. Access Id SS/MC Ar-Md Id

A8 168 Translation-Exception Identification



AC 172

B 176 Monitor Code



B4 18

B8 184 Subsystem-Identification Word

BC 188 I/O-Interruption Parameter

C 192 I/O-Interruption-Identification Word

C4 196

C8 2 STFL Facility List

CC 24

D 28

D4 212

D8 216

DC 22

E 224

E4 228

E8 232 Machine-Check Interruption Code



EC 236

F4 244 External-Damage Code

F8 248 Failing-Storage Address



FC 252

Figure 3-11 (Part 2 of 6). Assigned Storage Locations

Chapter 3. Storage 3-59



Hex Dec Fields

1 256

14 26

18 264

1C 268

11 272

114 276

118 28

11C 284

12 288 Restart Old PSW



124 292

128 296

12C 3

13 34 External Old PSW



134 38

138 312

13C 316

14 32 Supervisor-Call Old PSW



144 324

148 328

14C 332

15 336 Program Old PSW



154 34

158 344

15C 348

16 352 Machine-Check Old PSW



164 356

168 36

16C 364

17 368 Input/Output Old PSW



174 372

178 376

17C 38

Figure 3-11 (Part 3 of 6). Assigned Storage Locations

3-60 z/Architecture Principles of Operation



Hex Dec Fields

18 384

184 388

188 392

18C 396

19 4

194 44

198 48

19C 412

1A 416 Restart New PSW



1A4 42

1A8 424

1AC 428

1B 432 External New PSW



1B4 436

1B8 44

1BC 444

1C 448 Supervisor-Call New PSW



1C4 452

1C8 456

1CC 46

1D 464 Program New PSW



1D4 468

1D8 472

1DC 476

1E 48 Machine-Check New PSW



1E4 484

1E8 488

1EC 492

1F 496 Input/Output New PSW



1F4 5

1F8 54

1FC 58

Figure 3-11 (Part 4 of 6). Assigned Storage Locations

Chapter 3. Storage 3-61



Hex Dec Fields

1 496

14 41

18 414

1C 418

11 4112

114 4116

/ / (448 bytes) /

11A8 452

11AC 4524

11B 4528

11B4 4532

11B8 4536

11BC 454

11C 4544 Available for Use by Programming



11C4 4548

/ / (64 bytes) /

11F8 46

11FC 464

Figure 3-11 (Part 5 of 6). Assigned Storage Locations

3-62 z/Architecture Principles of Operation



Hex Dec Fields

12 468 Store-Status Floating-Point-Register Save Area; or Machine-


Check Floating-Point-Register Save Area
124 4612

/ / (128 bytes) /

1278 4728

127C 4732

128 4736 Store-Status General-Register Save Area; or Machine-Check


General-Register Save Area
1284 474

/ / (128 bytes) /

12F8 4856

12FC 486

13 4864 Store-Status PSW Save Area; or Fixed-Logout Area



134 4868

138 4872

13C 4876

131 488

1314 4884

1318 4888 Store-Status Prefix Save Area

131C 4892 Store-Status FP-Ctl-Reg Save Area; or MC FP-Ctl-Reg Save Area

132 4896

1324 49 Store-Status TOD Prog Reg Save Area; or MC TOD Prog Reg S A

1328 494 Store-Status CPU-Timer Save Area; or Machine-Check CPU-Timer


Save Area
132C 498

133 4912 Store-Status Clock-Comparator Bits -55 Save Area; or


Machine-Check Clock-Comparator Bits -55 Save Area
1334 4916

1338 492

133C 4924

134 4928 Store-Status Access-Register Save Area; or Machine-Check


Access-Register Save Area
/ / (64 bytes) /

137C 4988

138 4992 Store-Status Control-Register Save Area; or Machine-Check


Control-Register Save Area
1384 4996

/ / (128 bytes) /

13F8 5112

13FC 5116

Figure 3-11 (Part 6 of 6). Assigned Storage Locations

Chapter 3. Storage 3-63


3-64 z/Architecture Principles of Operation
Chapter 4. Control
Stopped, Operating, Load, and Check-Stop Time-of-Day Clock . . . . . . . . . . . . . . 4-35
States . . . . . . . . . . . . . . . . . . . . . . 4-1 Format . . . . . . . . . . . . . . . . . . . 4-35
Stopped State . . . . . . . . . . . . . . . . 4-2 States . . . . . . . . . . . . . . . . . . . . 4-35
Operating State . . . . . . . . . . . . . . . . 4-2 Changes in Clock State . . . . . . . . . 4-36
Load State . . . . . . . . . . . . . . . . . . 4-2 Setting and Inspecting the Clock . . . . 4-36
Check-Stop State . . . . . . . . . . . . . . 4-3 TOD Programmable Register . . . . . . 4-37
Program-Status Word . . . . . . . . . . . . . . 4-3 TOD-Clock Synchronization . . . . . . . . . 4-39
Program-Status-Word Format . . . . . . . 4-5 Clock Comparator . . . . . . . . . . . . . . 4-39
Control Registers . . . . . . . . . . . . . . . . 4-7 CPU Timer . . . . . . . . . . . . . . . . . . 4-40
Tracing . . . . . . . . . . . . . . . . . . . . . . 4-10 Externally Initiated Functions . . . . . . . . . 4-41
Control-Register Allocation . . . . . . . . . 4-13 Resets . . . . . . . . . . . . . . . . . . . . . 4-41
Trace Entries . . . . . . . . . . . . . . . . . 4-13 CPU Reset . . . . . . . . . . . . . . . . . 4-45
Operation . . . . . . . . . . . . . . . . . . . 4-23 Initial CPU Reset . . . . . . . . . . . . . 4-46
Program-Event Recording . . . . . . . . . . . 4-24 Subsystem Reset . . . . . . . . . . . . . 4-46
Control-Register Allocation and Clear Reset . . . . . . . . . . . . . . . . 4-46
Address-Space-Control Element . . . . 4-24 Power-On Reset . . . . . . . . . . . . . 4-47
Operation . . . . . . . . . . . . . . . . . . . 4-25 Initial Program Loading . . . . . . . . . . . 4-47
Identification of Cause . . . . . . . . . . 4-26 Store Status . . . . . . . . . . . . . . . . . . 4-48
Priority of Indication . . . . . . . . . . . . 4-28 Multiprocessing . . . . . . . . . . . . . . . . . 4-49
Storage-Area Designation . . . . . . . . . . 4-29 Shared Main Storage . . . . . . . . . . . . 4-49
PER Events . . . . . . . . . . . . . . . . . . 4-30 CPU-Address Identification . . . . . . . . . 4-49
Successful Branching . . . . . . . . . . . 4-30 CPU Signaling and Response . . . . . . . . . 4-49
Instruction Fetching . . . . . . . . . . . . 4-31 Signal-Processor Orders . . . . . . . . . . 4-49
Storage Alteration . . . . . . . . . . . . . 4-31 Conditions Determining Response . . . . . 4-53
Store Using Real Address . . . . . . . . 4-32 Conditions Precluding Interpretation of
Indication of PER Events Concurrently the Order Code . . . . . . . . . . . . 4-53
with Other Interruption Conditions . . . 4-32 Status Bits . . . . . . . . . . . . . . . . . 4-54
Timing . . . . . . . . . . . . . . . . . . . . . . . 4-34

This chapter describes in detail the facilities for load state during the initial-program-loading opera-
controlling, measuring, and recording the opera- tion. The CPU enters the check-stop state only as
tion of one or more CPUs. the result of machine malfunctions.

A change between these four CPU states can be


Stopped, Operating, Load, and effected by use of the operator facilities or by
Check-Stop States acceptance of certain SIGNAL PROCESSOR
orders addressed to that CPU. The states are not
The stopped, operating, load, and check-stop controlled or identified by bits in the PSW. The
states are four mutually exclusive states of the stopped, load, and check-stop states are indicated
CPU. When the CPU is in the stopped state, to the operator by means of the manual indicator,
instructions and interruptions, other than the load indicator, and check-stop indicator, respec-
restart interruption, are not executed. In the oper- tively. These three indicators are off when the
ating state, the CPU executes instructions and CPU is in the operating state.
takes interruptions, subject to the control of the
program-status word (PSW) and control registers, The CPU timer is updated when the CPU is in the
and in the manner specified by the setting of the operating state or the load state. The TOD clock
operator-facility rate control. The CPU is in the is not affected by the state of any CPU.

Copyright IBM Corp. 1990, 2000 4-1


Stopped State cuted on another CPU in the configuration, the
clearing of TLB entries is completed before the
The CPU changes from the operating state to the CPU leaves the stopped state.
stopped state by means of the stop function. The
stop function is performed when: Operating State
The stop key is activated while the CPU is in
The CPU changes from the stopped state to the
the operating state.
operating state by means of the start function or
The CPU accepts a stop or stop-and-store- when a restart interruption (see Chapter 6,
status order specified by a SIGNAL Interruptions) occurs.
PROCESSOR instruction addressed to this
CPU while it is in the operating state. The start function is performed if the CPU is in the
stopped state and (1) the start key associated
The CPU has finished the execution of a unit
with that CPU is activated or (2) that CPU accepts
of operation initiated by performing the start
the start order specified by a SIGNAL
function with the rate control set to the
PROCESSOR instruction addressed to that CPU.
instruction-step position.
The effect of performing the start function is
When the stop function is performed, the transition unpredictable when the stopped state has been
from the operating to the stopped state occurs at entered by means of a reset.
the end of the current unit of operation. When the
wait-state bit of the PSW is one, the transition When the rate control is set to the process posi-
takes place immediately, provided no interruptions tion and the start function is performed, the CPU
are pending for which the CPU is enabled. In the starts operating at normal speed. When the rate
case of interruptible instructions, the amount of control is set to the instruction-step position and
data processed in a unit of operation depends on the wait-state bit is zero, one instruction or, for
the particular instruction and may depend on the interruptible instructions, one unit of operation is
model. executed, and all pending allowed interruptions
occur before the CPU returns to the stopped state.
Before entering the stopped state by means of the When the rate control is set to the instruction-step
stop function, all pending allowed interruptions position and the wait-state bit is one, the start
occur while the CPU is still in the operating state. function does not cause an instruction to be exe-
They cause the old PSW to be stored and the cuted, but all pending allowed interruptions occur
new PSW to be fetched before the stopped state before the CPU returns to the stopped state.
is entered. While the CPU is in the stopped state,
interruption conditions remain pending.
Load State
The CPU is also placed in the stopped state
The CPU enters the load state when the load-
when:
normal or load-clear key is activated. (See Initial
The CPU reset is completed. However, when Program Loading on page 4-47. See also Initial
the reset operation is performed as part of Program Loading on page 17-15.) This sets the
initial program loading for this CPU, then the architectural mode to the ESA/390 mode. For
CPU is placed in the load state and does not ease of reference, the additional elements of the
necessarily enter the stopped state. description of the ESA/390 load state are given
below.
An address comparison indicates equality and
stopping on the match is specified.
If the initial-program-loading operation is com-
The execution of resets is described in Resets pleted successfully, the CPU changes from the
on page 4-41, and address comparison is load state to the operating state, provided the rate
described in Address-Compare Controls on control is set to the process position; if the rate
page 12-1. control is set to the instruction-step position, the
CPU changes from the load state to the stopped
If the CPU is in the stopped state when an INVAL- state.
IDATE PAGE TABLE ENTRY instruction is exe-

4-2 z/Architecture Principles of Operation


Check-Stop State sequencing and to hold and indicate much of the
status of the CPU in relation to the program cur-
The check-stop state, which the CPU enters on rently being executed. Additional control and
certain types of machine malfunction, is described status information is contained in control registers
in Chapter 11, Machine-Check Handling. The and permanently assigned storage locations.
CPU leaves the check-stop state when CPU reset
The status of the CPU can be changed by loading
is performed.
a new PSW or part of a PSW.
Programming Notes:
Control is switched during an interruption of the
1. Except for the relationship between execution CPU by storing the current PSW, so as to pre-
time and real time, the execution of a program serve the status of the CPU, and then loading a
is not affected by stopping the CPU. new PSW.
2. When, because of a machine malfunction, the
Execution of LOAD PSW or LOAD PSW
CPU is unable to end the execution of an
EXTENDED, or the successful conclusion of the
instruction, the stop function is ineffective, and
initial-program-loading sequence, introduces a
a reset function has to be invoked instead. A
new PSW. The instruction address is updated by
similar situation occurs when an unending
sequential instruction execution and replaced by
string of interruptions results from a PSW with
successful branches. Other instructions are pro-
a PSW-format error of the type that is recog-
vided which operate on a portion of the PSW.
nized early, or from a persistent interruption
Figure 4-1 on page 4-4 summarizes these
condition, such as one due to the CPU timer.
instructions.
3. Pending I/O operations may be initiated, and
active I/O operations continue to suspension A new or modified PSW becomes active (that is,
or completion, after the CPU enters the the information introduced into the current PSW
stopped state. The interruption conditions due assumes control over the CPU) when the inter-
to suspension or completion of I/O operations ruption or the execution of an instruction that
remain pending when the CPU is in the changes the PSW is completed. The interruption
stopped state. for PER associated with an instruction that
changes the PSW occurs under control of the
PER mask that is effective at the beginning of the
Program-Status Word operation.
The current program-status word (PSW) in the
Bits 0-7 of the PSW are collectively referred to as
CPU contains information required for the exe-
the system mask.
cution of the currently active program. The PSW
is 128 bits in length and includes the instruction
address, condition code, and other control fields.
In general, the PSW is used to control instruction

Chapter 4. Control 4-3



Condition
Address- Code and Basic Extended
System Problem Space Program AddressingAddressing
Mask PSW Key State Control Mask Mode Mode
(PSW Bits (PSW Bits (PSW (PSW Bits (PSW Bits (PSW (PSW
-7) 8-11) Bit 15) 16-17) 18-23) Bit 32) Bit 31)

Instruction SavedSet SavedSet SavedSet SavedSet SavedSet SavedSet SavedSet

BRANCH AND LINK - - - - - - - - 24AM - 31AM - - -


BRANCH AND SAVE - - - - - - - - - - BAM - - -
BRANCH AND SAVE AND SET - - - - - - - - - - BAM Yes Yes Yes
MODE
BRANCH AND SET AUTHORITY - - Yes Yes Yes Yes - - - - BAMBAM - -
BRANCH AND SET MODE - - - - - - - - - - BAMYes YesYes

BRANCH AND STACK Yes - Yes - Yes - Yes - Yes - BAM - Yes -
BRANCH IN SUBSPACE GROUP - - - - - - - - - - BAMBAM - -
INSERT PROGRAM MASK - - - - - - - - Yes - - - - -
INSERT PSW KEY - - Yes - - - - - - - - - - -
INSERT ADDRESS SPACE - - - - - - Yes - - - - - - -
CONTROL

Basic PROGRAM CALL - - - - Yes Yes - - - - BAM BAM - -


Stacking PROGRAM CALL Yes - Yes PKC Yes Yes Yes Yes Yes - Yes Yes Yes Yes
PROGRAM RETURN - Yes - Yes - Yes - Yes - Yes - Yes - Yes
PROGRAM TRANSFER - - - - - Yes - - - - - BAM - -
RESUME PROGRAM - - - - - - - Yes - Yes - Yes - Yes

SET ADDRESS SPACE CONTROL - - - - - - - Yes - - - - - -


SET ADDRESSING MODE - - - - - - - - - - - Yes - Yes
SET PROGRAM MASK - - - - - - - - - Yes - - - -
SET PSW KEY FROM ADDRESS - - - Yes - - - - - - - - - -
SET SYSTEM MASK - Yes - - - - - - - - - - - -

STORE THEN AND SYSTEM MASK Yes ANDs - - - - - - - - - - - -


STORE THEN OR SYSTEM MASK Yes ORs - - - - - - - - - - - -

Explanation:

- No.

The action takes place only if the associated R field in the instruction is nonzero.

In the reduced-authority state, the action takes place only if the R field in the instruction
is nonzero.

The action also takes place in the 64-bit addressing mode if the R field in the instruction is
zero.

PROGRAM RETURN does not change the PER mask.

PROGRAM TRANSFER does not change the problem-state bit from one to zero.

Figure 4-1 (Part 1 of 2). Operations on PSW Fields

4-4 z/Architecture Principles of Operation



BAM The basic-addressing-mode bit is saved or set in the 24-bit or 31-bit addressing mode.

ANDs The logical AND of the immediate field in the instruction and the current system mask
replaces the current system mask.

ORs The logical OR of the immediate field in the instruction and the current system mask
replaces the current system mask.

PKC When the PSW-key-control bit, bit 131 of the entry-table entry, is zero, the PSW key remains
unchanged. When the PSW-key-control bit is one, the PSW key is set with the entry key, bits
136-139 of the entry-table entry.

24AM The condition code and program mask are saved in the 24-bit addressing mode.

31AM The basic-addressing-mode bit is saved in the 31-bit addressing mode.

Figure 4-1 (Part 2 of 2). Operations on PSW Fields

Programming Note: A summary of the oper- logical and instruction addresses are treated as
ations which save or set the problem state, real addresses. When the bit is one, DAT is on,
addressing mode, and instruction address is con- and the dynamic-address-translation mechanism is
tained in Subroutine Linkage without the Linkage invoked.
Stack on page 5-10.
I/O Mask (IO): Bit 6 controls whether the CPU is
enabled for I/O interruptions. When the bit is
Program-Status-Word Format zero, an I/O interruption cannot occur. When the
bit is one, I/O interruptions are subject to the
IE Prog E
RTOX Key MWPA SC C Mask A I/O-interruption subclass-mask bits in control reg-

5 8 12 16 18 2 24 31
ister 6. When an I/O-interruption subclass-mask
bit is zero, an I/O interruption for that

B I/O-interruption subclass cannot occur; when the


A I/O-interruption subclass-mask bit is one, an I/O

32 63 interruption for that I/O-interruption subclass can


occur.

Instruction Address
External Mask (EX): Bit 7 controls whether the
64 95
CPU is enabled for interruption by conditions
included in the external class. When the bit is

Instruction Address (Continued) zero, an external interruption cannot occur. When

96 127 the bit is one, an external interruption is subject to


Figure 4-2. PSW Format the corresponding external subclass-mask bits in
control register 0; when the subclass-mask bit is
The following is a summary of the functions of the zero, conditions associated with the subclass
PSW fields. (See Figure 4-2.) cannot cause an interruption; when the subclass-
mask bit is one, an interruption in that subclass
PER Mask (R): Bit 1 controls whether the CPU is can occur.
enabled for interruptions associated with program-
event recording (PER). When the bit is zero, no PSW Key: Bits 8-11 form the access key for
PER event can cause an interruption. When the storage references by the CPU. If the reference is
bit is one, interruptions are permitted, subject to subject to key-controlled protection, the PSW key
the PER-event-mask bits in control register 9. is matched with a storage key when information is
stored or when information is fetched from a
DAT Mode (T): Bit 5 controls whether implicit location that is protected against fetching.
dynamic address translation of logical and instruc- However, for one of the operands of each of
tion addresses used to access storage takes MOVE TO PRIMARY, MOVE TO SECONDARY,
place. When the bit is zero, DAT is off, and MOVE WITH KEY, MOVE WITH SOURCE KEY,
and MOVE WITH DESTINATION KEY, an access

Chapter 4. Control 4-5


key specified as an operand is used instead of the any selection of the condition-code values as a
PSW key. criterion for branching. A table in Appendix C
summarizes the condition-code values that may
Machine-Check Mask (M): Bit 13 controls be set for all instructions which set the condition
whether the CPU is enabled for interruption by code of the PSW.
machine-check conditions. When the bit is zero, a
machine-check interruption cannot occur. When Program Mask: Bits 20-23 are the four program-
the bit is one, machine-check interruptions due to mask bits. Each bit is associated with a program
system damage and instruction-processing exception, as follows:
damage are permitted, but interruptions due to
other machine-check-subclass conditions are Program-
subject to the subclass-mask bits in control reg- Mask Bit Program Exception
ister 14.
2 Fixed-point overflow
Wait State (W): When bit 14 is one, the CPU is 21 Decimal overflow
22 HFP exponent underflow
waiting; that is, no instructions are processed by 23 HFP significance
the CPU, but interruptions may take place. When
bit 14 is zero, instruction fetching and execution
occur in the normal manner. The wait indicator is When the mask bit is one, the exception results in
on when the bit is one. an interruption. When the mask bit is zero, no
interruption occurs. The setting of the
Problem State (P): When bit 15 is one, the CPU HFP-exponent-underflow-mask bit or the
is in the problem state. When bit 15 is zero, the HFP-significance-mask bit also determines the
CPU is in the supervisor state. In the supervisor manner in which the operation is completed when
state, all instructions are valid. In the problem the corresponding exception occurs.
state, only those instructions are valid that provide
meaningful information to the problem program Extended Addressing Mode (EA): Bit 31 con-
and that cannot affect system integrity; such trols the size of effective addresses and effective-
instructions are called unprivileged instructions. address generation in conjunction with bit 32, the
The instructions that are never valid in the basic-addressing-mode bit. When bit 31 is zero,
problem state are called privileged instructions. the addressing mode is controlled by bit 32. When
When a CPU in the problem state attempts to bits 31 and 32 are both one, 64-bit addressing is
execute a privileged instruction, a privileged- specified.
operation exception is recognized. Another group
Basic Addressing Mode (BA): Bits 31 and 32
of instructions, called semiprivileged instructions,
control the size of effective addresses and
are executed by a CPU in the problem state only
effective-address generation. When bits 31 and
if specific authority tests are met; otherwise, a
32 are both zero, 24-bit addressing is specified.
privileged-operation exception or a special-
When bit 31 is zero and bit 32 is one, 31-bit
operation exception is recognized.
addressing is specified. When bits 31 and 32 are
Address-Space Control (AS): Bits 16 and 17, in both one, 64-bit addressing is specified. Bit 31
conjunction with PSW bit 5, control the translation one and bit 32 zero is an invalid combination that
mode. See Translation Modes on page 3-28. causes a specification exception to be recognized.
The addressing mode does not control the size of
Condition Code (CC): Bits 18 and 19 are the PER addresses or of addresses used to access
two bits of the condition code. The condition code DAT, ASN, dispatchable-unit-control, linkage,
is set to 0, 1, 2, or 3, depending on the result entry, and trace tables or access lists or the
obtained in executing certain instructions. Most linkage stack. See Address Generation on
arithmetic and logical operations, as well as some page 5-7 and Address Size and Wraparound on
other operations, set the condition code. The page 3-5. The control of the addressing mode by
instruction BRANCH ON CONDITION can specify bits 31 and 32 of the PSW is summarized as
follows:

4-6 z/Architecture Principles of Operation


the current PSW, and it sets bits 33-96 of the
PSW.31 PSW.32 Addressing Mode current PSW to zeros.

24-bit
1 31-bit
1 1 64-bit Control Registers

The control registers provide for maintaining and


manipulating control information outside the PSW.
Instruction Address: Bits 64-127 of the PSW
There are sixteen 64-bit control registers.
are the instruction address. This address desig-
nates the location of the leftmost byte of the next
The LOAD CONTROL (LCTLG) instruction causes
instruction to be executed, unless the CPU is in
all control-register bit positions within those regis-
the wait state (bit 14 of the PSW is one).
ters designated by the instruction to be loaded
from storage. The LOAD CONTROL (LCTL)
Bit positions 0, 2-3, 24-31, and 33-63 are unas-
instruction loads only bit positions 32-63 of the
signed and must contain zeros. A specification
control registers, and bits 0-31 of the registers
exception is recognized when these bit positions
remain unchanged. The instructions BRANCH
do not contain zeros.
AND SET AUTHORITY, BRANCH IN SUBSPACE
When bits 31 and 32 of the PSW specify the GROUP, LOAD ADDRESS SPACE PARAME-
24-bit addressing mode, bits 64-103 of the instruc- TERS, SET SECONDARY ASN, BRANCH AND
tion address must be zeros, or, when bits 31 and STACK, PROGRAM CALL, PROGRAM RETURN,
32 specify the 31-bit mode, bits 64-96 must be and PROGRAM TRANSFER provide specialized
zeros. Otherwise, a specification exception is functions to place information into certain control-
recognized. A specification exception is also register bit positions.
recognized when bit 31 is one and bit 32 is zero
Information loaded into the control registers
or when bit position 12 does not contain a zero.
becomes active (that is, assumes control over the
LOAD PSW EXTENDED has a 16-byte second system) at the completion of the instruction that
operand. The instruction loads the operand causes the information to be loaded.
unchanged and without examination as the current
At the time the registers are loaded, the informa-
PSW.
tion is not checked for exceptions, such as an
LOAD PSW has an eight-byte second operand. address designating an unavailable or protected
The operand is treated as an ESA/390 PSW, location. The validity of the information is checked
except that bit 31 (the z/Architecture extended- and the exceptions, if any, are indicated at the
addressing-mode bit) may be one. time the information is used.

IE Prog E The STORE CONTROL (STCTG) instruction


RTOX Key 1MWPA SC C Mask A causes the contents of all control-register bit posi-

5 8 12 16 18 2 24 31 tions, within those registers designated by the


instruction, to be placed in storage. The STORE
B CONTROL (STCTL) instruction places the con-
A Instruction Address
tents of bit positions 32-63 of the control registers
32 63
in storage, and bits 0-31 of the registers are
Figure 4-3. ESA/390 PSW Format, Except Bit 31 ignored. The instructions EXTRACT PRIMARY
Shown as EA ASN, EXTRACT SECONDARY ASN, and
PROGRAM CALL provide specialized functions to
Depending on the model, either LOAD PSW obtain information from certain control-register bit
recognizes a specification exception if bit 12 of its positions.
second operand is not one or this error is indi-
cated by an early specification exception after the Only the general structure of the control registers
completion of the execution of LOAD PSW. is described here; the definition of a particular
LOAD PSW loads bits 0-32 of its second operand, control-register bit position appears in the
except with bit 12 inverted, and bits 33-63 of the description of the facility with which the position is
operand as bits 0-32 and 97-127, respectively, of associated. Figure 4-4 on page 4-8 shows the

Chapter 4. Control 4-7


control-register bit positions which are assigned Programming Notes:
and the initial values of the positions upon exe-
1. The detailed definition of a particular control-
cution of initial CPU reset. All control-register bit
register bit position can be located by referring
positions not listed in the figure are initialized to
to the entry control-register assignment in
zero.
the Index.
2. To ensure that existing programs operate cor-
rectly if and when new facilities using addi-
tional control-register bit positions are
installed, the program should load zeros in
unassigned positions.

Ctrl Initial
Reg Bits Name of Field Associated with Value

33 SSM-suppression control SET SYSTEM MASK


34 TOD-clock-sync control TOD clock
35 Low-address-protection control Low-address protection
36 Extraction-authority control Instruction authorization
37 Secondary-space control Instruction authorization
38 Fetch-protection-override control Key-controlled protection
39 Storage-protection-override controlKey-controlled protection
45 AFP-register control Floating point
48 Malfunction-alert subclass mask External interruptions
49 Emergency-signal subclass mask External interruptions
5 External-call subclass mask External interruptions
52 Clock-comparator subclass mask External interruptions
53 CPU-timer subclass mask External interruptions
54 Service-signal subclass mask External interruptions
56 Unused 1
57 Interrupt-key subclass mask External interruptions 1
58 Unused 1
59 ETR subclass mask External interruptions
61 Crypto control Cryptography

1 -51 Primary region-table origin Dynamic address translation


1 -51 Primary segment-table origin Dynamic address translation
1 -51 Primary real-space token origin Dynamic address translation
1 54 Primary subspace-group control Subspace groups
1 55 Primary private-space control Dynamic address translation
1 56 Primary storage-alteration-event Program-event recording
control
1 57 Primary space-switch-event control Program interruptions
1 58 Primary real-space control Dynamic address translation
1 6-61Primary designation-type control Dynamic address translation
1 62-63Primary table length Dynamic address translation

2 33-57Dispatchable-unit-control-table Access-register translation


origin

3 32-47PSW-key mask Instruction authorization


3 48-63Secondary ASN Address spaces

4 32-47Authorization index Instruction authorization


4 48-63Primary ASN Address spaces

Figure 4-4 (Part 1 of 3). Assignment of Control-Register Fields

4-8 z/Architecture Principles of Operation



Ctrl Initial
Reg Bits Name of Field Associated with Value

5 33-57Primary-ASN-second-table-entry Access-register translation


origin

6 32-39I/O-interruption subclass mask I/O interruptions

7 -51 Secondary segment-table origin Dynamic address translation


7 -51 Secondary region-table origin Dynamic address translation
7 -51 Secondary real-space token origin Dynamic address translation
7 54 Secondary subspace-group control Subspace groups
7 55 Secondary private-space control Dynamic address translation
7 56 Secondary storage-alteration-event Program-event recording
control
7 58 Secondary real-space control Dynamic address translation
7 6-61Secondary designation-type controlDynamic address translation
7 62-63Secondary table length Dynamic address translation

8 32-47Extended authorization index Access-register translation


8 48-63Monitor masks MONITOR CALL

9 32 Successful-branching-event mask Program-event recording


9 33 Instruction-fetching-event mask Program-event recording
9 34 Storage-alteration-event mask Program-event recording
9 36 Store-using-real-address-event maskProgram-event recording
9 4 Branch-address control Program-event recording
9 42 Storage-alteration-space control Program-event recording

1 -63PER starting address Program-event recording

11 -63PER ending address Program-event recording

12 Branch-trace control Tracing


12 1 Mode-trace control Tracing
12 2-61Trace-entry address Tracing
12 62 ASN-trace control Tracing
12 63 Explicit-trace control Tracing

13 -51 Home segment-table origin Dynamic address translation


13 -51 Home region-table origin Dynamic address translation
13 -51 Home real-space token origin Dynamic address translation
13 55 Home private-space control Dynamic address translation
13 56 Home storage-alteration-event Program-event recording
control
13 57 Home space-switch-event control Program interruptions
13 58 Home real-space control Dynamic address translation
13 6-61Home designation-type control Dynamic address translation
13 62-63Home table length Dynamic address translation

Figure 4-4 (Part 2 of 3). Assignment of Control-Register Fields

Chapter 4. Control 4-9



Ctrl Initial
Reg Bits Name of Field Associated with Value

14 32 Unused 1
14 33 Unused 1
14 35 Channel-report-pending subclass I/O machine-check handling
mask
14 36 Recovery subclass mask Machine-check handling
14 37 Degradation subclass mask Machine-check handling
14 38 External-damage subclass mask Machine-check handling 1
14 39 Warning subclass mask Machine-check handling
14 42 TOD-clock-control-override control TOD clock
14 44 ASN-translation control Instruction authorization
14 45-63ASN-first-table origin ASN translation

15 -6Linkage-stack-entry address Linkage-stack operations

Explanation:

The fields not listed are unassigned. The initial value for all unlisted
control-register bit positions is zero.

This bit is not used but is initialized to one for consistency with the
System/37 definition.

The address-space-control element (ASCE) in the control register has one of
three formats, depending on bit 58 of the register, the real-space control,
and bits 6 and 61 of the register, the designation-type control. When bit
58 is zero, the ASCE is a region-table designation if bits 6 and 61 are 11,
1, or 1 binary, or it is a segment-table designation if bits 6 and 61 are
binary. When bit 58 is one, the ASCE is a real-space designation. Bits
-51 are the region-table origin, the segment-table origin or the real-space
token origin, depending on whether the ASCE is a region-table designation, a
segment-table designation, or a real-space designation, respectively.

Bits 6-63 are assigned when the ASCE in the control register is a region-
table designation or a segment-table designation.

Figure 4-4 (Part 3 of 3). Assignment of Control-Register Fields

lowing about the addressing mode in effect after


Tracing branching and the branch address: (1) the CPU
Tracing assists in the determination of system is in the 24-bit addressing mode, (2) the CPU
problems by providing an ongoing record in either is in the 31-bit addressing mode or is in the
storage of significant events. Tracing consists of 64-bit addressing mode and bits 0-32 of the
four separately controllable functions which cause branch address are all zeros, or (3) the CPU is in
entries to be made in a trace table: branch the 64-bit addressing mode and bits 0-32 of the
tracing, ASN tracing, mode tracing, and explicit branch address are not all zeros. The branch
tracing. Branch tracing, ASN tracing, and mode instructions that are traced are:
tracing together are referred to as implicit tracing.
BRANCH AND LINK (BALR only) when the
R field is not zero
When branch tracing is on, a branch trace entry is
BRANCH AND SAVE (BASR only) when the
made in the trace table for each execution of
R field is not zero
certain branch instructions when they cause
BRANCH AND SAVE AND SET MODE when
branching. The branch address is placed in the
the R field is not zero
trace entry. The trace entry also indicates the fol-
BRANCH AND SET AUTHORITY

4-10 z/Architecture Principles of Operation


BRANCH AND STACK when the R field is (64-bit) addressing mode or from the extended
not zero mode to a basic mode.
BRANCH IN SUBSPACE GROUP
RESUME PROGRAM When mode tracing is on, a mode-switch trace
TRAP entry is made in the trace table for each execution
of the following instructions if the execution
However, a branch trace entry is made for changes PSW bit 31:
BRANCH IN SUBSPACE GROUP only if ASN
BRANCH AND SAVE AND SET MODE
tracing is not on.
BRANCH AND SET MODE
PROGRAM CALL
If both branch tracing and mode tracing are on
PROGRAM RETURN
and BRANCH AND SAVE AND SET MODE or
RESUME PROGRAM
RESUME PROGRAM changes the extended-
SET ADDRESSING MODE
addressing-mode bit, PSW bit 31, a mode-
switching-branch trace entry is made instead of a However, a mode-switch trace entry is not made
branch trace entry. for PROGRAM RETURN if ASN tracing is on and
PROGRAM RETURN unstacks a state entry
When ASN tracing is on, an entry named the formed by PROGRAM CALL; a PROGRAM
same as the instruction is made in the trace table RETURN trace entry is made instead, and it con-
for each execution of the following instructions: tains information about PSW bit 31.
BRANCH IN SUBSPACE GROUP
BRANCH AND SAVE AND SET MODE and
PROGRAM CALL
RESUME PROGRAM cause trace entries to be
PROGRAM RETURN
made as follows: a branch trace entry if only
PROGRAM TRANSFER
branch tracing is on, a mode-switching-branch
SET SECONDARY ASN
trace entry if both branch tracing and mode tracing
However, the entry for PROGRAM RETURN is are on, or a mode-switch trace entry if only mode
made only when PROGRAM RETURN unstacks a tracing is on.
linkage-stack state entry that was formed by
PROGRAM CALL, not when PROGRAM RETURN The trace entries produced by implicit tracing are
unstacks an entry formed by BRANCH AND summarized in Figure 4-5 on page 4-12.
STACK.
When explicit tracing is on, execution of TRACE
If both ASN tracing and mode tracing are on and (TRACE or TRACG) causes an entry to be made
PROGRAM CALL changes PSW bit 31, first a in the trace table. The entry for TRACE (TRACE)
PROGRAM CALL trace entry is made, and then a includes bits 16-63 from the TOD clock, the
mode-switch trace entry is made. second operand of the TRACE instruction, and
bits 32-63 of a range of general registers. The
Mode tracing records a switch from a basic (24-bit entry for TRACE (TRACG) is the same except that
or 31-bit) addressing mode to the extended it includes bits 0-79 from the TOD clock and bits
0-63 of a range of general registers.

Chapter 4. Control 4-11



Implicit Tracing Enabled

Branch Branch ASN
and and and
Branch ASN Mode ASN Mode Mode All
Instruc-
tion Trace Entries Made

BAKR B - - B B - B

BALR B - - B B - B

BASR B - - B B - B

BASSM B - MS B B | MSB MS B | MSB

BSA B - - B B - B

BSG B BSG - BSG B BSG BSG

BSM - - MS - MS - MS

PC - PC MS PC MS PC & MSPC & MS

PR-b - - MS - MS MS MS

PR-pc - PR MS PR MS PR PR

PT - PT - PT - PT PT

RP B - MS B B | MSB MS B | MSB

SASN - SASN - SASN - SASN SASN

SAM24/ - - MS - MS MS MS
31/64

TRAP2/4 B - - B B - B

Explanation:

- None.

-b The case when PROGRAM RETURN unstacks a branch state
entry.

-pc The case when PROGRAM RETURN unstacks a program-call state
entry.

| OR.

& AND.

Figure 4-5 (Part 1 of 2). Summary of Implicit Tracing

4-12 z/Architecture Principles of Operation



Explanation (Continued):

B Branch trace entry. Made only if the branch is taken and
a mode-switching-branch trace entry is not made.

MS Mode-switch trace entry. Made only if PSW bit 31 is
changed.

MSB Mode-switching-branch trace entry. Made only if PSW bit
31 is changed (which can occur only if the branch is
taken).

Figure 4-5 (Part 2 of 2). Summary of Implicit Tracing

Control-Register Allocation entry in the trace table, except that no entry is


made when bit 0 of the second operand of the
The information to control tracing is contained in TRACE instruction is one.
control register 12 and has the following format:
Trace Entries
BM Trace-Entry Address AE
Trace entries are of nine types, with most types
1 2 62 63 having more than one detailed format. The types
and numbers of formats are as follows:
Branch-Trace-Control Bit (B): Bit 0 of control
register 12 controls whether branch tracing is Branch (three formats)
turned on or off. If the bit is zero, branch tracing BRANCH IN SUBSPACE GROUP (two
is off; if the bit is one, branch tracing is on. formats)

Mode-Trace-Control Bit (M): Bit 1 of control Mode switch (three formats)


register 12 controls whether mode tracing is Mode-switching branch (three formats)
turned on or off. If the bit is zero, mode tracing is
off; if the bit is one, mode tracing is on. PROGRAM CALL (two formats)
PROGRAM RETURN (nine formats)
Trace-Entry Address: Bits 2-61 of control reg-
ister 12, with two zero bits appended on the left PROGRAM TRANSFER (three formats)
and two on the right, form the real address of the SET SECONDARY ASN (one format)
next trace entry to be made.
TRACE (two formats)
ASN-Trace-Control Bit (A): Bit 62 of control The entries are shown in Figure 4-6 on
register 12 controls whether ASN tracing is turned page 4-14. In that figure, each entry is labeled
on or off. If the bit is zero, ASN tracing is off; if with Fn, indicating a format number, to allow ref-
the bit is one, ASN tracing is on. erences to each format within a trace-entry type.
Also, Branch, referring to the mnemonic of an
Explicit-Trace-Control Bit (E): Bit 63 of control instruction that causes a branch trace entry, refers
register 12 controls whether explicit tracing is to BAKR, BALR, BASR, BASSM, BSA, or BSG.
turned on or off. If the bit is zero, explicit tracing
is off, which causes the TRACE instruction to be Figure 4-7 on page 4-20 lists the trace entries in
executed as a no-operation; if the bit is one, the ascending order of values in bit fields that identify
execution of the TRACE instruction creates an the entries.

Chapter 4. Control 4-13


F1 Branch (Branch, RP, or TRAP2/4 when Resulting Mode Is 24-Bit)

Bits 4-63 of Branch Adr.

8 31

F2 Branch (Branch, RP, or TRAP2/4 when Resulting Mode Is 31-Bit, or when


Resulting PSW Bit 31 Is One (See Note) and Bits -32 of Branch Address
Are All Zeros)

1 Bits 33-63 of Branch Address

1 31

F3 Branch (Branch, RP, or TRAP2/4 when Resulting PSW Bit 31 Is One (See
Note) and Bits -32 of Branch Address Are Not All Zeros)

11111 All Zeros Bits -31 of Branch Address

8 12 32 63

Bits 32-63 of Branch Address

64 95

F1 BRANCH IN SUBSPACE GROUP (if ASN Tracing On, in 24-Bit or 31-Bit Mode)

11P Bits 9-31 of ALET A Bits 33-63 of Branch Address

8 32 63

F2 BRANCH IN SUBSPACE GROUP (if ASN Tracing On, in 64-Bit Mode)

11P Bits 9-31 of ALET Bits -31 of Branch Address

8 32 63

Bits 32-63 of Branch Address

64 95

F1 Mode Switch (BASSM, BSM, PC, PR, RP, or SAM64 from 24-Bit or 31-Bit
Mode when Resulting PSW Bit 31 Is One (See Note))

11111 All Zeros A Updated Instruction Address

8 12 32 63
Figure 4-6 (Part 1 of 7). Trace Entries

4-14 z/Architecture Principles of Operation


F2 Mode Switch (BASSM, BSM, PC, PR, RP, SAM24, or SAM31 from 64-Bit Mode
to 24-Bit or 31-Bit Mode when Bits -31 of Updated Instruction Address
Are All Zeros)

1111 All Zeros Bits 32-63 of Updated Inst. Adr.

8 12 32 63

F3 Mode Switch (BASSM, BSM, PC, PR, RP, SAM24, or SAM31 from 64-Bit Mode
to 24-Bit or 31-Bit Mode when Bits -31 of Updated Instruction Address
Are Not All Zeros)

11111 All Zeros Bits -31 of Updated Inst. Adr.

8 12 32 63

Bits 32-63 of Updated Inst. Adr.

64 95

F1 Mode-Switching Branch (BASSM or RP from 64-Bit Mode to 24-Bit or


31-Bit Mode)

11111 All Zeros A Branch Address

8 12 32 63

F2 Mode-Switching Branch (BASSM or RP from 24-Bit or 31-Bit Mode when


Resulting PSW Bit 31 Is One (See Note) and Bits -31 of Branch Address
Are All Zeros)

111111 All Zeros Bits 32-63 of Branch Address

8 12 32 63

F3 Mode-Switching Branch (BASSM or RP from 24-Bit or 31-Bit Mode when


Resulting PSW Bit 31 Is One (See Note) and Bits -31 of Branch Address
Are Not All Zeros

1111111 All Zeros Bits -31 of Branch Address

8 12 32 63

Bits 32-63 of Branch Address

64 95
Figure 4-6 (Part 2 of 7). Trace Entries

Chapter 4. Control 4-15


F1 PROGRAM CALL (in 24-Bit or 31-Bit Mode, Regardless of Resulting Mode)

PSW
11Key PC Number ABits 33-62 of Return AddressP

8 12 32 63

F2 PROGRAM CALL (in 64-Bit Mode, Regardless of Resulting Mode)

PSW
11Key PC Number Bits -31 of Return Address

8 12 32 63

Bits 32-62 of Return Address P

64 95

F1 PROGRAM RETURN (in 24-Bit or 31-Bit Mode when Resulting Mode Is


24-Bit or 31-Bit)

PSW
111Key New PASN ABits 33-62 of Return AddressP

8 12 16 32 63

ABits 33-63 of Updated Inst. Adr.

64 95

F2 PROGRAM RETURN (in 64-Bit Mode when Bits -31 of Updated Instruction
Address Are All Zeros and Resulting Mode Is 24-Bit or 31-Bit)

PSW
111Key 1 New PASN ABits 33-62 of Return AddressP

8 12 16 32 63

Bits 32-63 of Updated Inst. Adr.

64 95
Figure 4-6 (Part 3 of 7). Trace Entries

4-16 z/Architecture Principles of Operation


F3 PROGRAM RETURN (in 64-Bit Mode when Bits -31 of Updated Instruction
Address Are Not All Zeros and Resulting Mode Is 24-Bit or 31-Bit)

PSW
1111Key 11 New PASN ABits 33-62 of Return AddressP

8 12 16 32 63

Updated Instruction Address

64 127

F4 PROGRAM RETURN (in 24-Bit or 31-Bit Mode when Resulting PSW Bit 31
Is One (See Note) and Bits -31 of Return Address Are All Zeros)

PSW
111Key 1 New PASN Bits 32-62 of Return Address P

8 12 16 32 63

ABits 33-63 of Updated Inst. Adr.

64 95

F5 PROGRAM RETURN (in 64-Bit Mode when Bits -31 of Updated Instruction
Address Are All Zeros, Resulting PSW Bit 31 Is One (See Note), and Bits
-31 of Return Address Are All Zeros)

PSW
111Key 11 New PASN Bits 32-62 of Return Address P

8 12 16 32 63

Bits 32-63 of Updated Inst. Adr.

64 95

F6 PROGRAM RETURN (in 64-Bit Mode when Bits -31 of Updated Instruction
Address Are Not All Zeros, Resulting PSW Bit 31 Is One (See Note), and
Bits -31 of Return Address Are All Zeros)

PSW
1111Key 111 New PASN Bits 32-62 of Return Address P

8 12 16 32 63

Updated Instruction Address

64 127
Figure 4-6 (Part 4 of 7). Trace Entries

Chapter 4. Control 4-17


F7 PROGRAM RETURN (in 24-Bit or 31-Bit Mode when Resulting PSW Bit 31
Is One (See Note) and Bits -31 of Return Address Are Not All Zeros)

PSW
1111Key 11 New PASN Bits -31 of Return Address

8 12 16 32 63

Bits 32-62 of Return Address PA Updated Instruction Address

64 96 127

F8 PROGRAM RETURN (in 64-Bit Mode when Bits -31 of Updated Instruction
Address Are All Zeros, Resulting PSW Bit 31 Is One (See Note), and Bits
-31 of Return Address Are Not All Zeros)

PSW
1111Key 111 New PASN Bits -31 of Return Address

8 12 16 32 63

Bits 32-62 of Return Address PBits 32-63 of Updated Inst. Adr.

64 96 127

F9 PROGRAM RETURN (in 64-Bit Mode when Bits -31 of Updated Instruction
Address Are Not All Zeros, Resulting PSW Bit 31 Is One (See Note), and
Bits -31 of Return Address Are Not All Zeros)

PSW
111Key 1111 New PASN Bits -31 of Return Address

8 12 16 32 63

Bits 32-62 of Return Address PBits -31 of Updated Inst. Adr.

64 96 127

Bits 32-63 of Updated Inst. Adr.

128 159

F1 PROGRAM TRANSFER (in 24-Bit or 31-Bit Mode)

PSW
111Key New PASN Bits 32-63 of R Before

8 12 16 32 63
Figure 4-6 (Part 5 of 7). Trace Entries

4-18 z/Architecture Principles of Operation


F2 PROGRAM TRANSFER (in 64-Bit Mode when Bits -31 of R Are All Zeros)

PSW
111Key 1 New PASN Bits 32-63 of R Before

8 12 16 32 63

F3 PROGRAM TRANSFER (in 64-Bit Mode when Bits -31 of R Are Not All
Zeros)

PSW
111Key 11 New PASN Bits -31 of R Before

8 12 16 32 63

Bits 32-63 of R Before

64 95

F1 SET SECONDARY ASN

1 New SASN

8 16 31

F1 TRACE (TRACE)

111 N TOD-Clock Bits 16-63

4 8 16 63

/
TRACE Operand (R) - (R)
/
64 96 95 + 32(N+1)

F2 TRACE (TRACG)

111 N 1 TOD-Clock Bits -47

4 8 16 63

TOD-Clock Bits 48-79 TRACE Operand

64 96 127

/
(R) - (R)
/
128 127 + 64(N+1)
Figure 4-6 (Part 6 of 7). Trace Entries

Chapter 4. Control 4-19


Note: The terminology when Resulting PSW Bit 31 Is One is used
instead of when Resulting Mode Is 64-Bit because, if the
resulting PSW bit 32 is zero, an early specification exception will be
recognized. PROGRAM
RETURN
can set PSW bit 31 to one and bit 32 to zero.
Figure 4-6 (Part 7 of 7). Trace Entries

Trace Entry
Trace-Entry Bits
For-
-7 8-1112-15 Type mat

Branch 1
1 SET SECONDARY ASN 1
11 PROGRAM CALL 1
11 PROGRAM CALL 2
111 PROGRAM TRANSFER 1

111 1 PROGRAM TRANSFER 2


111 PROGRAM RETURN 1
111 1 PROGRAM RETURN 2
111 1 PROGRAM RETURN 4
111 11 PROGRAM RETURN 5

111 11 PROGRAM TRANSFER 3


1111 11 PROGRAM RETURN 3
1111 111 PROGRAM RETURN 6
1111 11 PROGRAM RETURN 7
1111 111 PROGRAM RETURN 8

111 1111 PROGRAM RETURN 9


11 BRANCH IN SUBSPACE GROUP 1
11 BRANCH IN SUBSPACE GROUP 2
1111 Mode Switch 2
11111 Mode Switch 1

11111 Mode-Switching Branch 1


111111 Mode-Switching Branch 2
11111 Mode Switch 3
11111 Branch 3
1111111 Mode-Switching Branch 3

111 TRACE 1
111 1 TRACE 2
1 Branch 2

Figure 4-7. Trace Entries Arranged by Identifying Bits

The fields in the trace entries are defined as after branching (a format-1 entry), bit positions
follows. The fields are described in the order in 8-31 contain bits 40-63 of the branch address.
which they first appear in Figure 4-6 on When the 31-bit addressing mode is in effect after
page 4-14. branching or PSW bit 31 is one after branching
and bits 0-32 of the branch address are all zeros,
Branch Address: The branch address is the bit positions 1-31 of the trace entry (format 2)
address of the next instruction to be executed contain bits 33-63 of the branch address. When
when the branch is taken. In a branch trace entry PSW bit 31 is one after branching and bits 0-32 of
made when the 24-bit addressing mode is in effect the branch address are not all zeros, bit positions

4-20 z/Architecture Principles of Operation


32-95 of the trace entry (format 3), contain bits basic-addressing-mode bit, bit 32, from the current
0-63 of the branch address. PSW.

In a BRANCH IN SUBSPACE GROUP trace entry Bit position 32 of a PROGRAM RETURN trace
made on execution in the 24-bit or 31-bit entry made when the resulting addressing mode is
addressing mode, bit positions 33-63 of the trace the 24-bit or 31-bit mode (a format-1, format-2, or
entry (format 1) contain bits 33-63 of the branch format-3 entry) contains the basic-addressing-
address, or, in the 64-bit addressing mode, bit mode bit that replaces bit 32 of the PSW.
positions 32-95 of the trace entry (format 2)
contain bits 0-63 of the branch address. Bit position 64 of a PROGRAM RETURN trace
entry made in the 24-bit or 31-bit addressing
In a mode-switching-branch trace entry made on a mode when the return address occupies only one
switch from the 64-bit addressing mode to the word in the entry, (a format-1 or format-4 entry),
24-bit or 31-bit addressing mode, bit positions contains the value of PSW bit 32 that existed
33-63 of the entry (format 1) contain bits 33-63 of before the PROGRAM RETURN operation. When
the branch address; or, on a switch from PSW bit the return address occupies two words (a format-7
31 being off to the bit being on, bit positions 32-63 entry), bit position 96 contains that value of PSW
of the entry (format 2) contain bits 32-63 of the bit 32.
branch address if bits 0-31 of the branch address
are zeros, or bits 32-95 of the entry (format 3) Updated Instruction Address: Bit positions
contain bits 0-63 of the branch address if bits 0-31 33-63 of a mode-switch trace entry that indicates
of the branch address are not all zeros. a switch from PSW bit 31 being off to the bit being
on (a format-1 entry) contains bits 33-63 of the
Primary-List Bit (P) and Bits 9-31 of ALET: Bit updated instruction address in the PSW (bits
position 8 of a BRANCH IN SUBSPACE GROUP 97-127 of the PSW) before that address is
trace entry contains bit 7 of the access-list-entry replaced, if it is replaced, by the mode-switch
token (ALET) in the access register designated by operation. Bit positions 32-63 of a mode-switch
the R field of the instruction. Bit positions 9-31 of trace entry (format 2) that indicates a switch from
the trace entry contain bits 9-31 of the ALET. the 64-bit addressing mode to the 24-bit or 31-bit
addressing mode contains bits 32-63 of the
Basic-Addressing-Mode Bit (A): Bit position 32 updated instruction address in the PSW (bits
of a BRANCH IN SUBSPACE GROUP trace entry 96-127 of the PSW) before that address is
made on execution in the 24-bit or 31-bit replaced, if it is replaced, by the mode-switch
addressing mode (a format-1 entry) contains the operation, if bits 0-31 of the updated instruction
basic-addressing-mode bit that replaces bit 32 of address are zeros; or bit positions 32-95 of the
the PSW. trace entry (format 3) contain bits 0-63 of that
updated instruction address (bits 64-127 of the
Bit position 32 of a mode-switch trace entry that PSW) if bits 0-31 of the address are not all zeros.
indicates a switch from PSW bit 31 being off to
the bit being on (a format-1 entry) contains the The following description of a PROGRAM
value of PSW bit 32 that existed before the mode- RETURN trace entry applies when the return
switch operation. address in the entry occupies only one word in the
entry. Bit positions 65-95 of the trace entry made
Bit position 32 of a mode-switching-branch trace on execution in the 24-bit or 31-bit addressing
entry that indicates a switch from the 64-bit mode (a format-1 or format-4 entry) contain bits
addressing mode to the 24-bit or 31-bit addressing 33-63 of the updated instruction address in the
mode (a format-1 entry) contains the value that PSW (bits 97-127 of the PSW) before that
replaces PSW bit 32. address is replaced from the linkage-stack state
entry; or, when the execution is in the 64-bit
Bit position 32 of a PROGRAM CALL trace entry addressing mode, bit positions 64-95 of the trace
made on execution in the 24-bit or 31-bit entry (format 2 or 5) contain bits 32-63 of that
addressing mode (regardless of the resulting updated instruction address (bits 96-127 of the
addressing mode) (a format-1 entry) contains the PSW) if bits 0-31 of the address are zeros, or bit
positions 64-127 of the trace entry (format 3 or 6)

Chapter 4. Control 4-21


contain bits 0-63 of that updated instruction the 24-bit or 31-bit mode (a format-1, format-2, or
address (bits 64-127 of the PSW) if bits 0-31 of format-3 entry) or when the resulting PSW bit 31
the address are not all zeros. If the return is one and bits 0-31 of the return address are
address in the PROGRAM RETURN trace entry zeros (formats 4-6) contains the problem-state bit
occupies two words, the updated instruction that replaces bit 15 of the PSW. Bit position 95 of
address in the entry is moved one word to the a PROGRAM RETURN trace entry made when
right in the entry (formats 7-9). the resulting PSW bit 31 is one and bits 0-31 of
the return address are not all zeros (formats 7-9)
PSW Key: Bit positions 8-11 of a PROGRAM contains that problem-state bit.
CALL, PROGRAM TRANSFER, or PROGRAM
RETURN trace entry contain the PSW key from New PASN: Bit positions 16-31 a PROGRAM
the current PSW. TRANSFER trace entry contain the new PASN
(which may be zero) specified in bit positions
PC Number: Bit positions 12-31 of a 48-63 of general register R.
PROGRAM CALL trace entry contain the value of
the rightmost 20 bits of the second-operand Bit positions 16-31 of a PROGRAM RETURN
address. trace entry contain the new PASN that is restored
from the linkage-stack state entry.
Return Address: Bit positions 33-62 of a
PROGRAM CALL trace entry made on execution Bits 32-63 of R Before: Bit positions 32-63 of a
in the 24-bit or 31-bit addressing mode (a format-1 PROGRAM TRANSFER trace entry made on exe-
entry) contain bits 33-62 of the updated instruction cution in the 24-bit or 31-bit addressing mode (a
address in the PSW (bits 97-126 of the PSW) format-1 entry) contain bits 32-63 of the general
before that address is replaced from the entry- register designated by the R field of the instruc-
table entry; or, when the execution is in the 64-bit tion. (Bits 32 and 33-62 of that register replace
addressing mode, bit positions 32-94 of the trace bits 32 and 97-126, respectively, of the PSW. Bit
entry (format 2) contain bits 0-62 of that updated 63 of the register replaces the problem-state bit in
instruction address (bits 64-126 of the PSW). the PSW.) When PROGRAM TRANSFER is exe-
cuted in the 64-bit addressing mode, bit positions
Bit positions 33-62 of a PROGRAM RETURN 32-63 of the trace entry (format 2) contain bits
trace entry made when the resulting addressing 32-63 of the R general register if bits 0-31 of the
mode is the 24-bit or 31-bit mode (a format-1, register are zeros, or bit positions 32-95 of the
format-2, or format-3 entry) contain bits 33-62 of trace entry (format 3) contain bits 0-63 of the reg-
the instruction address that replaces bits 64-127 of ister if bits 0-31 of the register are not all zeros.
the PSW; or, when the resulting PSW bit 31 is
one (which causes the addressing mode be the New SASN: Bit positions 16-31 of a SET SEC-
64-bit mode unless the resulting PSW bit 32 is ONDARY ASN trace entry contain the ASN value
zero), bit positions 32-62 of the trace entry loaded into control register 3 by the instruction.
(formats 4-6) contain bits 32-62 of that instruction
address if bits 0-31 of the address are zeros, or Number of Registers (N): Bits 4-7 of the trace
bit positions 32-94 of the trace entry (formats 7-9) entry for TRACE contain a value which is one less
contain bits 0-62 of that instruction address if bits than the number of general registers which have
0-31 of the address are not all zeros. been provided in the trace entry. The value of N
ranges from zero, meaning the contents of one
Problem-State Bit (P): Bit position 63 of a general register are provided in the trace entry, to
PROGRAM CALL trace entry made on execution 15, meaning the contents of all 16 general regis-
in the 24-bit or 31-bit addressing mode (regardless ters are provided.
of the resulting mode) (a format-1 entry), or bit 95
of the entry (format 2) made on execution in the TOD-Clock Bits 16-63 or 0-79: Bits 16-63 of the
64-bit addressing mode, contains the problem- trace entry for TRACE (TRACE) are obtained from
state bit from the current PSW. bit positions 16-63 of the TOD clock, as would be
provided by a STORE CLOCK instruction exe-
Bit position 63 of a PROGRAM RETURN trace cuted at the time the TRACE instruction was exe-
entry made when the resulting addressing mode is cuted. Bits 16-95 of the trace entry for TRACE

4-22 z/Architecture Principles of Operation


(TRACG) are obtained from bit positions 0-79 of Operation
the TOD clock, as would be provided by a STORE
CLOCK EXTENDED instruction executed at the When an instruction which is subject to tracing is
time the TRACE instruction was executed. See executed and the corresponding tracing function is
programming note 2 for information about a carry turned on, a trace entry of the appropriate type
from bit position 0 of the TOD clock. and format is made. The real address of the trace
entry is formed by appending two zero bits on the
TRACE Operand: Bit positions 64-95 of the
left and two on the right to the value in bit posi-
trace entry for TRACE (TRACE) contain a copy of
tions 2-61 of control register 12. The address in
the 32 bits of the second operand of the TRACE
control register 12 is subsequently increased by
instruction for which the entry is made. Bit posi-
the size of the entry created.
tions 96-127 of the trace entry for TRACE
(TRACG) contain a copy of those bits. No trace entry is stored if the incrementing of the
address in control register 12 would cause a carry
(R)-(R): The four-byte fields starting with bit 96
to be propagated into bit position 51 (that is, if the
of the trace entry for TRACE (TRACE) contain the
trace-entry address would be in the next 4K-byte
contents of bit positions 32-63 of the general reg-
block). If this would be the case for the entry to
isters whose range is specified by the R and R
be made, a trace-table exception is recognized.
fields of the TRACE instruction. The general reg-
When PROGRAM CALL is to form both a
isters are stored in ascending order of register
PROGRAM CALL trace entry and a mode-switch
numbers, starting with general register R and
trace entry, neither entry is stored, and a trace-
continuing up to and including general register R,
table exception is recognized, if either entry would
with general register 0 following general register
cause a carry into bit position 51. For the purpose
15. The eight-byte fields starting with bit 128 of
of recognizing the trace-table exception in the
the trace entry for TRACE (TRACG) similarly
case of a TRACE instruction, the maximum length
contain the contents of bit positions 0-63 of those
of 76 (TRACE) or 144 (TRACG) bytes is used
registers.
instead of the actual length.
Programming Notes:
The storing of a trace entry is not subject to key-
1. The size of the trace entry for TRACE controlled protection (nor, since the trace-entry
(TRACE) in units of words is 3 + (N + 1). address is real, is it subject to page protection),
The maximum size of an entry is 19 words, or but it is subject to low-address protection; that is,
76 bytes. For TRACE (TRACG), the size in if the address of the trace entry due to be created
units of words is 4 + 2(N + 1), and the is in the range 0-511 or 4096-4607 and bit 35 of
maximum size is 36 words, or 144 bytes. control register 0 is one, a protection exception is
recognized, and instruction execution is sup-
2. At some time in the future, the TOD clock on
pressed. If the address of a trace entry is invalid,
new models will have a leftmost extension so
an addressing exception is recognized, and
that there can be a carry from bit position 0 of
instruction execution is suppressed.
the clock into the extension; see programming
note 13 on page 4-39. On these models, the
The three exceptions associated with storing a
rightmost bit of the extension will be stored in
trace entry (addressing, protection, and trace
bit position 15 of the TRACE (TRACG) trace
table) are collectively referred to as trace
entry. It may be desired to have programs
exceptions.
that process TRACE (TRACG) trace entries
take this future development into account. If a program interruption takes place for a condi-
tion which is not a trace-exception condition and
for which execution of an instruction is not com-
pleted, it is unpredictable whether part or all of
any trace entry due to be made for such an inter-
rupted instruction is stored in the trace table.
Thus, for a condition which would ordinarily cause
nullification or suppression of instruction exe-
cution, storage locations may have been altered

Chapter 4. Control 4-23


beginning at the location designated by control Control-Register Allocation and
register 12 and extending up to the length of the
entry that would have been created.
Address-Space-Control Element

When PROGRAM RETURN unstacks a linkage- The information for controlling PER resides in
stack state entry that was formed by BRANCH control registers 9, 10, and 11 and the address-
AND STACK and ASN tracing is on, trace space-control element. The information in the
exceptions may be recognized, even though a control registers has the following format:
trace entry is not made and no part of a trace
Control Register 9
entry is stored. /
EM B S
The order in which information is placed in a trace /
entry is unpredictable. Furthermore, as observed 32 37 4 42 63
by other CPUs and by channel programs, the con-
tents of a byte of a trace entry may appear to Control Register 10
change more than once before completion of the /
instruction for which the entry is made. Starting Address
/
The trace-entry address in control register 12 is 63
updated only on completion of execution of an
instruction for which a trace entry is made. Control Register 11
/
A serialization and checkpoint-synchronization Ending Address
function is performed before the operation begins /
and again after the operation is completed. 63

PER-Event Masks (EM): Bits 32-34 and 36


Program-Event Recording specify which types of events are recognized.
The bits are assigned as follows:
The purpose of PER is to assist in debugging
programs. It permits the program to be alerted to Bit 32: Successful-branching event
the following types of events: Bit 33: Instruction-fetching event
Bit 34: Storage-alteration event
Execution of a successful branch instruction.
Bit 36: Store-using-real-address event (bit 34
The option is provided of having an event
must be one also)
occur only when the branch-target location is
within the designated storage area. Bits 32-34 and bit 36, when ones, specify that the
Fetching of an instruction from the designated corresponding types of events be recognized.
storage area. However, bit 36 is effective for this purpose only
Alteration of the contents of the designated when bit 34 is also one. When bit 34 is one, the
storage area. The option is provided of storage-alteration event is recognized. When bits
having an event occur only when the storage 34 and 36 are ones, both the storage-alteration
area is within designated address spaces. event and the store-using-real-address event are
Execution of the STORE USING REAL recognized. When a bit is zero, the corresponding
ADDRESS instruction. type of event is not recognized. When bit 34 is
zero, both the storage-alteration event and the
The program can selectively specify that one or
store-using-real-address event are not recognized.
more of the above types of events be recognized,
except that the event for STORE USING REAL
Branch-Address Control (B): Bit 40 of control
ADDRESS can be specified only along with the
register 9 specifies, when one, that successful-
storage-alteration event. The information con-
branching events occur only for branches that are
cerning a PER event is provided to the program
to a location within the designated storage area.
by means of a program interruption, with the
When bit 40 is zero, successful branching events
cause of the interruption being identified in the
occur regardless of the branch-target address.
interruption code.

4-24 z/Architecture Principles of Operation


Storage-Alteration-Space Control (S): Bit 42 buffer (ALB). Bit 56 is ignored when the storage-
of control register 9 specifies, when one, that alteration-space control is zero.
storage-alteration events occur as a result of refer-
ences to the designated storage area only within Programming Notes:
designated address spaces. An address space is 1. Models may operate at reduced performance
designated as one for which storage-alteration while the CPU is enabled for PER events. In
events occur by means of the storage-alteration- order to ensure that CPU performance is not
event bit in the address-space-control element that degraded because of the operation of the
is used to translate references to the address PER facility, programs that do not use it
space. Bit 42 is ignored when DAT is off. When should disable the CPU for PER events by
DAT is off or bit 42 is zero, storage-alteration setting either the PER mask in the PSW to
events are not restricted to occurring for only par- zero or the PER-event masks in control reg-
ticular address spaces. ister 9 to zero, or both. No degradation due
to PER occurs when either of these fields is
PER Starting Address: Bits 0-63 of control reg-
zero.
ister 10 are the address of the beginning of the
designated storage area. 2. Some degradation may be experienced on
some models every time control registers 9,
PER Ending Address: Bits 0-63 of control reg- 10, and 11 are loaded, even when the CPU is
ister 11 are the address of the end of the desig- disabled for PER events (see the program-
nated storage area. ming note under Storage-Area Designation).

The address-space-control element has one of the


following formats:
Operation

Region-Table or Segment-Table Designation (R=) PER is under control of bit 1 of the PSW, the PER
/ mask. When the PER mask and a particular
Region-Table or PER-event mask bit are all ones, the CPU is
Segment-Table Origin GPSXR DTTL enabled for the corresponding type of event; oth-
/ erwise, it is disabled. However, the CPU is
52 54 58 6 63
enabled for the store-using-real-address event
Real-Space Designation (R=1)
/ only when the storage-alteration mask bit and the
Real-Space store-using-real-address mask bit are both one.
Token Origin GPSXR
/ An interruption due to a PER event normally
52 54 58 63 occurs after the execution of the instruction
responsible for the event. The occurrence of the
Storage-Alteration-Event Bit (S): When the event does not affect the execution of the instruc-
storage-alteration-space control in control register tion, which may be completed, partially completed,
9 is one, bit 56 of the address-space control terminated, suppressed, or nullified. However,
element specifies, when one, that the address recognition of a storage-alteration event causes no
space defined by the address-space-control more than 4K bytes to be stored beginning with
element is one for which storage-alteration events the byte that caused the event, and this may
can occur. Bit 56 is examined when the address- result in partial completion of an interruptible
space-control element is used to perform dynamic- instruction.
address translation for a storage-operand store
reference. The address-space-control element When the CPU is disabled for a particular PER
may be the PASCE, SASCE, or HASCE in control event at the time it occurs, either by the PER
register 1, 7, or 13, respectively, or it may be mask in the PSW or by the masks in control reg-
obtained from an ASN-second-table entry during ister 9, the event is not recognized.
access-register translation. Instead of being
obtained from an ASN-second-table entry in main A change to the PER mask in the PSW or to the
storage, bit 56 may be obtained from an PER control fields in control registers 9, 10, and
ASN-second-table entry in the ART-lookaside 11 affects PER starting with the execution of the
immediately following instruction.

Chapter 4. Control 4-25


A change to the storage-alteration-event bit in an Location 161:
address-space-control element in control register
1, 7, or 13 also affects PER starting with the exe- PAID

cution of the immediately following instruction. A 4 7
change to the storage-alteration-event bit in an
address-space-control element that may be
obtained, during access-register translation, from PER Code (PERC): The occurrence of PER
an ASN-second-table entry in either main storage events is indicated by ones in bit positions 0-2 and
or the ALB does not necessarily have an imme- 4. The bit position in the PER code for a partic-
diate, if any, effect on PER. However, PER is ular type of event is 32 less than the bit position
affected immediately after PURGE ALB is exe- for that event in the PER-event-mask field in
cuted. control register 9, except that a one in bit position
2 and a zero in bit position 4 of location 150 indi-
If a PER event occurs during the execution of an cate a storage-alteration event, while ones in bit
instruction which changes the CPU from being positions 2 and 4 indicate a store-using-real-
enabled to being disabled for that type of event, address event. When a program interruption
that PER event is recognized. occurs, more than one type of PER event can be
concurrently indicated. Additionally, if another
PER events may be recognized in a trial execution program-interruption condition exists, the inter-
of an instruction, and subsequently the instruction, ruption code for the program interruption may indi-
DAT-table entries, and operands may be refetched cate both the PER events and the other condition.
for the actual execution. If any refetched field was
modified by another CPU or by a channel program Addressing-and-Translation-Mode Identifica-
between the trial execution and the actual exe- tion (ATMID): During a program interruption
cution, it is unpredictable whether the PER events when a PER event is indicated, bits 31, 32, 5, 16,
indicated are for the trial or the actual execution. and 17 of the PSW at the beginning of the exe-
cution of the instruction that caused the event may
For special-purpose instructions that are not be stored in bit positions 8 and 10-13, respec-
described in this publication, the operation of PER tively, of real locations 150-151. If bits 31, 32, 5,
may not be exactly as described in this section. 16, and 17 are stored, then a one bit is stored in
bit position 9 of locations 150-151. If bits 31, 32,
Identification of Cause 5, 16, and 17 are not stored, then zero bits are
A program interruption for PER sets bit 8 of the stored in bit positions 8-13 of locations 150-151.
interruption code to one and places identifying
information in real storage locations 150-159 and Bits 8-13 of real locations 150-151 are named the
in location 161 if the PER event is a storage- addressing-and-translation-mode identification
alteration event. Additional information is provided (ATMID). Bit 9 is named the ATMID-validity bit.
by means of the instruction address in the When bit 9 is zero, it indicates that an invalid
program old PSW and the ILC. The information ATMID (all zeros) was stored.
stored in real locations 150-159 and 161 has the
following format: The meanings of the bits of a valid ATMID are as
follows:
Locations 150-151:
Bit Meaning
PERC ATMID AI
8 PSW bit 31

5 8 13 15 9 ATMID-validity bit
10 PSW bit 32
11 PSW bit 5
Locations 152-159: 12 PSW bit 16
/
PER Address 13 PSW bit 17
/
63 A valid ATMID is necessarily stored only if the
PER event was caused by one of the following
instructions:

4-26 z/Architecture Principles of Operation


BRANCH AND SAVE AND SET MODE If a storage-alteration event is not indicated in the
(BASSM) PER code (bit 2 is zero or bit 4 is one) or DAT
BRANCH AND SET AUTHORITY (BSA) was off, zeros are stored in bit positions 14 and
BRANCH AND SET MODE (BSM) 15.
BRANCH IN SUBSPACE GROUP (BSG)
LOAD PSW (LPSW) Zeros are stored in bit positions 3 and 5-7 of
LOAD PSW EXTENDED (LPSWE) locations 150-151.
PROGRAM CALL (PC)
PROGRAM RETURN (PR) PER Address: The PER-address field at
PROGRAM TRANSFER (PT) locations 152-159 contains the instruction address
RESUME PROGRAM (RP) used to fetch the instruction in execution when
SET ADDRESS SPACE CONTROL (SAC) one or more PER events were recognized. When
SET ADDRESS SPACE CONTROL FAST the instruction is the target of EXECUTE, the
(SACF) instruction address used to fetch the EXECUTE
SET ADDRESSING MODE (SAM24, SAM31, instruction is placed in the PER-address field.
SAM64)
SET SYSTEM MASK (SSM) PER Access Identification (PAID): If a storage-
STORE THEN AND SYSTEM MASK alteration event is indicated in the PER code, an
(STNSM) indication of the address space to which the event
STORE THEN OR SYSTEM MASK (STOSM) applies may be stored at location 161. If the
SUPERVISOR CALL (SVC) access used an AR-specified address-space-
TRAP (TRAP2, TRAP4) control element, the number of the access register
used is stored in bit positions 4-7 of location 161,
It is unpredictable whether a valid ATMID is stored and zeros are stored in bit positions 0-3. The
if the PER event was caused by any other instruc- contents of location 161 are unpredictable if
tion. (1) the CPU was in the access-register mode but
the access was an implicit reference to the linkage
PER ASCE Identification (AI): If a storage- stack or (2) the CPU was not in the access-
alteration event is indicated in the PER code (bit 2 register mode.
is one and bit 4 is zero) and this event occurred
when DAT was on, bits 14 and 15 of locations Instruction Address: The instruction address in
150-151 are set to identify the address-space- the program old PSW is the address of the
control element (ASCE) that was used to translate instruction which would have been executed next,
the reference that caused the event, as follows: unless another program condition is also indi-
Bits cated, in which case the instruction address is that
14-15 Meaning determined by the instruction ending due to that
00 Primary ASCE was used. condition.
01 An AR-specified ASCE was used. The
PER access id, real location 161, can be ILC: The ILC indicates the length of the instruc-
examined to determine the ASCE used. tion designated by the PER address, except when
However, if the primary, secondary, or a concurrent specification exception for the PSW
home ASCE was used, bits 14 and 15 introduced by LOAD PSW, LOAD PSW
may be set to 00, 10, or 11, respectively, EXTENDED, PROGRAM RETURN, or a
instead of to 01. supervisor-call interruption sets an ILC of 0.
10 Secondary ASCE was used.
Programming Notes:
11 Home ASCE was used.
1. PSW bit 31 is the extended-addressing-mode
The CPU may avoid setting bits 14 and 15 to 01
bit, and PSW bit 32 is the basic-addressing-
by recognizing that access-list-entry token (ALET)
mode bit. When PSW bit 31 and 32 are both
00000000 or 00000001 hex was used or that the
one, they specify the 64-bit addressing mode.
ALET designated, through an access-list entry, an
When PSW bit 31 is zero, PSW 32 specifies
ASN-second-table entry containing an ASCE
the 24-bit addressing mode if the bit is zero or
equal to the primary ASCE, secondary ASCE, or
the 31-bit addressing mode if the bit is one.
home ASCE.

Chapter 4. Control 4-27


PSW bit 5 is the DAT-mode bit, and PSW bits and operands. Note that the address of the
16 and 17 are the address-space-control bits. instruction is not necessarily provided without
For the handling of instruction and logical error by the PER address in real locations
addresses in the different translation modes, 152-159 because that address may be the
see Translation Modes on page 3-28. address of an EXECUTE instruction, with the
address of the target instruction still to be
2. A valid ATMID allows the program handling
determined from the fields that specify the
the PER event to determine the address
second-operand address of the EXECUTE
space from which the instruction that caused
instruction. Also note that another possible
the event was fetched and also to determine
source of error is that, in the 24-bit or 31-bit
which translation mode applied to the storage-
addressing mode, an instruction or operand
operand references of the instruction, if any.
may wrap around in storage by beginning just
Each of the instructions for which a valid
below the 16M-byte or 2G-byte boundary,
ATMID is necessarily stored can change one
respectively.
or more of PSW bits 5, 16, and 17, with the
result that the values of those bits in the 5. A valid ATMID is necessarily stored for all
program old PSW that is stored because of instructions that can change the addressing-
the PER event are not necessarily the values mode bits. However, the ATMID mechanism
that existed at the beginning of the execution does not provide complete assurance that the
of the instruction that caused the event. The instruction causing a PER event and the
instructions for which a valid ATMID is neces- instruction's operands can be located accu-
sarily stored are the only instructions that can rately because LOAD CONTROL and LOAD
change any of PSW bits 5, 16, and 17. ADDRESS SPACE PARAMETERS can
change the address-space-control element
3. If a storage-alteration PER event is indicated
that was used to fetch the instruction.
and DAT was on when the event occurred, an
indication of the address-space-control
element that was used to translate the refer- Priority of Indication
ence that caused the event is given by the When a program interruption occurs and more
PER ASCE identification, bits 14 and 15 of than one PER event has been recognized, all
real locations 150-151. If bits 14 and 15 indi- recognized PER events are concurrently indicated
cate that an AR-specified address-space- in the PER code. Additionally, if another program-
control element was used, the PER access interruption condition concurrently exists, the inter-
identification in real location 161 can be used ruption code for the program interruption indicates
to determine the address space that was ref- both the PER condition and the other condition.
erenced. To determine if DAT was on, the
In the case of an instruction-fetching event for
program handling the PER event should first
SUPERVISOR CALL, the program interruption
examine the ATMID-validity bit to determine
occurs immediately after the supervisor-call inter-
whether a valid ATMID was stored and, if it
ruption.
was stored, then examine the DAT-mode bit in
the ATMID. If a valid ATMID was not stored,
If a PER event is recognized during the execution
the program should examine the DAT-mode
of an instruction which also introduces a new
bit in the program old PSW.
PSW with the type of PSW-format error which is
4. If a valid ATMID is stored, it also allows the recognized early (see Exceptions Associated with
program handling the PER event to determine the PSW on page 6-9), both the specification
the addressing mode (24-bit, 31-bit, or 64-bit) exception and PER are indicated concurrently in
that existed for the instruction that caused the the interruption code of the program interruption.
PER event. This knowledge of the addressing However, for a PSW-format error of the type
mode allows the program to determine, which is recognized late, only PER is indicated in
without any chance of error, the meaning of the interruption code. In both cases, the invalid
one bits in bit positions 0-39 of the addresses PSW is stored as the program old PSW.
of the instruction and of the storage operands,
if any, of the instruction and, thus, to deter- Recognition of a PER event does not normally
mine accurately the locations of the instruction affect the ending of instruction execution.

4-28 z/Architecture Principles of Operation


However, in the following cases, execution of an old PSW associated with the program
interruptible instruction is not completed normally: interruption for the PER event may indi-
cate that the CPU was disabled for PER
1. When the instruction is due to be interrupted
events.
for an asynchronous condition (I/O, external,
restart, or repressible machine-check condi- b. An instruction-fetching event may be
tion), a program interruption for the PER event recognized during execution of a LOAD
occurs first, and the other interruptions occur CONTROL instruction that changes the
subsequently (subject to the mask bits in the value of the PER-event masks in control
new PSW) in the normal priority order. register 9 or the addresses in control reg-
isters 10 and 11 controlling indication of
2. When the stop function is performed, a
instruction-fetching events.
program interruption indicating the PER event
occurs before the CPU enters the stopped c. In the access-register mode, a storage-
state. alteration event that is permitted by a one
value of the storage-alteration-event bit in
3. When any program exception is recognized,
an address-space-control element in an
PER events recognized for that instruction
ASN-second-table entry (designated by an
execution are indicated concurrently.
access-list entry) may be caused by any
4. Depending on the model, in certain situations, store-type instruction that changes the
recognition of a PER event may appear to value of the bit from one to zero.
cause the instruction to be interrupted prema-
2. When a PER interruption occurs during the
turely without concurrent indication of a
execution of an interruptible instruction, the
program exception, without an interruption for
ILC indicates the length of that instruction or
any asynchronous condition, and without the
EXECUTE, as appropriate. When a PER
CPU entering the stopped state. In particular,
interruption occurs as a result of LOAD PSW,
recognition of a storage-alteration event
LOAD PSW EXTENDED, PROGRAM
causes no more than 4K bytes to be stored
RETURN, or SUPERVISOR CALL, the ILC
beginning with the byte that caused the event.
indicates the length of these instructions or
In cases 1 and 2 above, if the only PER event that EXECUTE, as appropriate, unless a concur-
has been recognized is an instruction-fetching rent specification exception on LOAD PSW,
event and another unit of operation of the instruc- LOAD PSW EXTENDED, or PROGRAM
tion remains to be executed, the event may be RETURN calls for an ILC of 0.
discarded, with the result that a program inter-
3. When a PER interruption is caused by
ruption does not occur. Whether the event is dis-
branching, the PER address identifies the
carded is unpredictable.
branch instruction (or EXECUTE, as appro-
Programming Notes: priate), whereas the old PSW points to the
next instruction to be executed. When the
1. In the following cases, an instruction can both interruption occurs during the execution of an
cause a program interruption for a PER event interruptible instruction, the PER address and
and change the value of fields controlling an the instruction address in the old PSW are the
interruption for PER events. The original field same.
values determine whether a program inter-
ruption takes place for the PER event.
Storage-Area Designation
a. The instructions LOAD PSW, LOAD PSW
EXTENDED, SET SYSTEM MASK, Two types of PER events instruction fetching
STORE THEN AND SYSTEM MASK, and and storage alteration always involve the desig-
SUPERVISOR CALL can cause an nation of an area in storage. Successful-
instruction-fetching event and disable the branching events may involve this designation.
CPU for PER interruptions. Additionally, The storage area starts at the location designated
STORE THEN AND SYSTEM MASK can by the starting address in control register 10 and
cause a storage-alteration event to be extends up to and including the location desig-
indicated. In all these cases, the program nated by the ending address in control register 11.

Chapter 4. Control 4-29


The area extends to the right of the starting the TLB to be cleared of entries. This degradation
address. may be experienced even when the CPU is disa-
bled for PER events. Thus, when possible, the
An instruction-fetching event occurs whenever the program should avoid loading control registers 9,
first byte of an instruction or the first byte of the 10, or 11.
target of an EXECUTE instruction is fetched from
the designated area. A storage-alteration event
occurs when a store access is made to the desig-
PER Events
nated area by using an operand address that is
defined to be a logical or a virtual address.
Successful Branching
When the branch-address control in control reg-
However, when DAT is on and the storage-
ister 9 is zero, a successful-branching event
alteration-space control in control register 9 is one,
occurs independent of the branch-target address.
a storage-alteration event occurs only when the
When the branch-address control is one, a
storage area is within an address space for which
successful-branching event occurs only when the
the storage-alteration-event bit in the address-
first byte of the branch-target instruction is fetched
space-control element is one. A storage-alteration
from the storage area designated by control regis-
event does not occur for a store access made with
ters 10 and 11.
an operand address defined to be a real address.
When the branch-address control in control reg-
Subject to the effect of the branch-address control,
ister 9 is one, a successful-branching event occurs
a successful-branching event occurs whenever
when the first byte of the branch-target instruction
one of the following instructions causes branching:
is within the designated area.
BRANCH AND LINK (BAL, BALR)
The set of addresses designated for successful- BRANCH AND SAVE (BAS, BASR)
branching, instruction-fetching, and storage- BRANCH AND SAVE AND SET MODE
alteration events wraps around at address (BASSM)
2 - 1; that is, address 0 is considered to follow BRANCH AND SET AUTHORITY (BSA)
address 2 - 1. When the starting address is BRANCH AND SET MODE (BSM)
less than the ending address, the area is contig- BRANCH AND STACK (BAKR)
uous. When the starting address is greater than BRANCH IN SUBSPACE GROUP (BSG)
the ending address, the set of locations desig- BRANCH ON CONDITION (BC, BCR)
nated includes the area from the starting address BRANCH ON COUNT (BCT, BCTR, BCTG,
to address 2 - 1 and the area from address 0 BCTGR)
to, and including, the ending address. When the BRANCH ON INDEX HIGH (BXH, BXHG)
starting address is equal to the ending address, BRANCH ON INDEX LOW OR EQUAL
only that one location is designated. (BXLE, BXLEG)
BRANCH RELATIVE AND SAVE (BRAS)
Address comparison for successful-branching, BRANCH RELATIVE AND SAVE LONG
instruction-fetching, and storage-alteration events (BRASL)
is always performed using 64-bit addresses. This BRANCH RELATIVE ON CONDITION (BRC)
is accomplished in the 24-bit or 31-bit addressing BRANCH RELATIVE ON CONDITION LONG
mode by extending the virtual, logical, or instruc- (BRCL)
tion address on the left with 39 or 33 zeros, BRANCH RELATIVE ON COUNT (BRCT,
respectively, before comparing it with the starting BRCTG)
and ending addresses. BRANCH RELATIVE ON INDEX HIGH
Programming Note: In some models, perform- (BRXH, BRXHG)
ance of address-range checking is assisted by BRANCH RELATIVE ON INDEX LOW OR
means of an extension to each page-table entry in EQUAL (BRXLE, BRXLG)
the TLB. In such an implementation, changing the RESUME PROGRAM (RP)
contents of control registers 10 and 11 when the TRAP (TRAP2, TRAP4)
successful-branching, instruction-fetching, or Subject to the effect of the branch-address control,
storage-alteration-event mask is one, or setting a successful-branching event also occurs when-
any of these PER-event masks to one, may cause

4-30 z/Architecture Principles of Operation


ever one of the following instructions causes 9 is one, the event occurs only if the storage-
branching: alteration-event bit is one in the address-space-
control element that is used by DAT to translate
PROGRAM CALL (PC)
the reference to the storage location.
PROGRAM RETURN (PR)
PROGRAM TRANSFER (PT)
The contents of storage are considered to have
For PROGRAM CALL, PROGRAM RETURN, and been altered whenever the CPU executes an
PROGRAM TRANSFER, the branch-target instruction that causes all or part of an operand to
address is considered to be the new instruction be stored within the designated storage area.
address that is placed in the PSW by the instruc- Alteration is considered to take place whenever
tion. storing is considered to take place for purposes of
indicating protection exceptions, except that recog-
A successful-branching event causes a PER nition does not occur for the storing of data by a
successful-branching event to be recognized if bit channel program. (See Recognition of Access
32 of the PER-event masks is one and the PER Exceptions on page 6-35.) Storing constitutes
mask in the PSW is one. alteration for PER purposes even if the value
stored is the same as the original value.
A PER successful-branching event is indicated by
setting bit 0 of the PER code to one. Implied locations that are referred to by the CPU
in the process of performing an interruption are
Instruction Fetching not monitored. Such locations include PSW and
An instruction-fetching event occurs if the first byte interruption-code locations. These locations,
of the instruction is within the storage area desig- however, are monitored when information is stored
nated by control registers 10 and 11. An there explicitly by an instruction. Similarly, moni-
instruction-fetching event also occurs if the first toring does not apply to the storing of data by a
byte of the target of EXECUTE is within the desig- channel program. Implied locations in the linkage
nated storage area. stack, which are stored in by instructions that
operate on the linkage stack, are monitored.
An instruction-fetching event causes a PER
instruction-fetching event to be recognized if bit 33 The I/O instructions are considered to alter the
of the PER-event masks is one and the PER second-operand location only when storing actu-
mask in the PSW is one. ally occurs.

If an instruction-fetching event is the only PER Storage alteration does not apply to instructions
event recognized for an interruptible instruction whose operands are specified to be real
that is to be interrupted because of an asynchro- addresses. Thus, storage alteration does not
nous condition (I/O, external, restart, or apply to INVALIDATE PAGE TABLE ENTRY,
repressible machine-check condition) or the per- RESET REFERENCE BIT EXTENDED, SET
formance of the stop function, and if a unit of STORAGE KEY EXTENDED, STORE USING
operation of the instruction remains to be exe- REAL ADDRESS, TEST BLOCK, and TEST
cuted, the instruction-fetching event may be dis- PENDING INTERRUPTION (when the effective
carded, and whether it is discarded is address is zero).
unpredictable.
A storage-alteration event causes a PER storage-
The PER instruction-fetching event is indicated by alteration event to be recognized if bit 34 of the
setting bit 1 of the PER code to one. PER-event masks is one and the PER mask in the
PSW is one. Bit 36 of the PER-event masks is
Storage Alteration ignored when determining whether a PER storage-
A storage-alteration event occurs whenever a alteration event is to be recognized.
CPU, by using a logical or virtual address, makes
a store access without an access exception to the PER storage-alteration event is indicated by
storage area designated by control registers 10 setting bit 2 of the PER code to one and bit 4 of
and 11. However, when DAT is on and the the PER code to zero.
storage-alteration-space control in control register

Chapter 4. Control 4-31


Store Using Real Address occurred had the execution of the instruction
A store-using-real-address event occurs whenever been completed, even if altering the contents
the STORE USING REAL ADDRESS instruction is of the result field is contingent on operand
executed. values. For purposes of this definition, the
occurrence of those exceptions which permit
There is no relationship between the store-using- termination (addressing, protection, and data)
real-address event and the designated storage is considered to cause termination, even if no
area. result area is changed.
5. When LOAD PSW, LOAD PSW EXTENDED,
A store-using-real-address event causes a PER
PROGRAM RETURN, RESUME PROGRAM,
store-using-real-address event to be recognized if
SET SYSTEM MASK, STORE THEN OR
bits 34 and 36 of the PER-event mask are ones
SYSTEM MASK, or SUPERVISOR CALL
and the PER mask in the PSW is one.
causes a PER condition and at the same time
introduces a new PSW with the type of
PER store-using-real-address event is indicated by
PSW-format error that is recognized imme-
setting bits 2 and 4 of the PER code to one.
diately after the PSW becomes active, the
interruption code identifies both the PER con-
Indication of PER Events dition and the specification exception. When
Concurrently with Other LOAD PSW, LOAD PSW EXTENDED,
Interruption Conditions PROGRAM RETURN, RESUME PROGRAM,
or SUPERVISOR CALL introduces a
The following rules govern the indication of PER PSW-format error of the type that is recog-
events caused by an instruction that also causes a nized as part of the execution of the following
program exception, a monitor event, a space- instruction, the PSW is stored as the old PSW
switch event, or a supervisor-call interruption. without the specification exception being
recognized.
1. The indication of an instruction-fetching event
does not depend on whether the execution of The indication of PER events concurrently with
the instruction was completed, terminated, other program-interruption conditions is summa-
suppressed, or nullified. However, when an rized in Figure 4-8 on page 4-34.
access exception applies to the first, second,
or third halfword of the instruction, it is unpre- Programming Notes:
dictable whether the instruction-fetching event 1. The execution of the interruptible instructions
is indicated. Similarly, when an access MOVE LONG, TEST BLOCK, and COMPARE
exception prohibits access to all or a portion LOGICAL LONG can cause events for instruc-
of the target of EXECUTE, it is unpredictable tion fetching. Additionally, MOVE LONG can
whether the instruction-fetching events for cause the storage-alteration event.
EXECUTE and the target are indicated.
Interruption of such an instruction may cause
2. When the operation is completed or partially a PER event to be indicated more than once.
completed, the event is indicated, regardless It may be necessary, therefore, for a program
of whether any program exception, space- to remove the redundant event indications
switch event, or monitor event is also recog- from the PER data. The following rules
nized. govern the indication of the applicable events
3. Successful branching, storage alteration, and during execution of these instructions:
store using real address are not indicated for a. The instruction-fetching event is indicated
an operation or, in case the instruction is inter- whenever the instruction is fetched for
ruptible, for a unit of operation that is sup- execution, regardless of whether it is the
pressed or nullified. initial execution or a resumption, except
4. When the execution of the instruction is termi- that the event may be discarded (not indi-
nated, storage alteration is indicated whenever cated) if it is the only PER event to be
the event has occurred, and a model may indicated, the interruption is due to an
indicate the event if the event would have asynchronous interruption condition or the

4-32 z/Architecture Principles of Operation


performance of the stop function, and a 2. The following is an outline of the general
unit of operation of the instruction remains action a program must take to delete multiple
to be executed. entries in the PER data for an interruptible
instruction so that only one entry for each
b. The storage-alteration event is indicated
complete execution of the instruction is
only when data has been stored in the
obtained:
designated storage area by the portion of
the operation starting with the last initi- a. Check to see if the PER address is equal
ation and ending with the last byte trans- to the instruction address in the old PSW
ferred before the interruption. No special and if the last instruction executed was
indication is provided on premature inter- interruptible.
ruptions as to whether the event will occur
b. If both conditions are met, delete
again upon the resumption of the opera-
instruction-fetching events.
tion. When the designated storage area is
a single byte location, a storage-alteration c. If both conditions are met and the event is
event can be recognized only once in the storage alteration, delete the event if
execution of MOVE LONG. some part of the remaining destination
operand is within the designated storage
area.

Chapter 4. Control 4-33



PER Event
Type
of Instr Storage
Concurrent Condition EndingBranchFetch Alter. STURA

Specification
Odd instruction address in the PSW S No No No No
Instruction access N or S No U No No
Specification
EXECUTE target address odd S No U No -
EXECUTE target access N or S No U No -
Other nullifying N No Yes No -
Other suppressing S No Yes No No
All terminating T No Yes Yes -
All completing C Yes Yes Yes -

Explanation:

- The condition does not apply.

Although PER events of this type are not indicated for the cur-
rent unit of operation of an interruptible instruction, PER
events of this type that were recognized on completed units of
operation of the interruptible instruction are indicated.

This event may be indicated, depending on the model, if the
event has not occurred but would have been indicated if execu-
tion had been completed.

C The operation or, in the case of the interruptible instructions,
the unit of operation is completed.

N The operation or, in the case of the interruptible instructions,
the unit of operation is nullified.

S The operation or, in the case of the interruptible instructions,
the unit of operation is suppressed.

T The execution of the instruction is terminated.

Yes The PER event is indicated with the other program interruption
condition if the event has occurred; that is, the contents of
the designated storage location were altered, or an attempt was
made to execute an instruction whose first byte is located in
the designated storage area.

No The PER event is not indicated.

U It is unpredictable whether the PER event is indicated.

Figure 4-8. Indication of PER Events with Other Concurrent Conditions

clock is shared by all CPUs. Each CPU has its


Timing own clock comparator, CPU timer, and TOD pro-
The timing facilities include three facilities for grammable register.
measuring time: the TOD clock, the clock
comparator, and the CPU timer. A TOD program-
mable register is associated with the TOD clock.

In a multiprocessing configuration, a single TOD

4-34 z/Architecture Principles of Operation


Time-of-Day Clock States
The following states are distinguished for the TOD
The time-of-day (TOD) clock provides a high- clock: set, not set, stopped, error, and not opera-
resolution measure of real time suitable for the tional. The state determines the condition code
indication of date and time of day. The cycle of set by execution of STORE CLOCK and STORE
the clock is approximately 143 years. A single CLOCK EXTENDED. The clock is incremented,
TOD clock is shared by all CPUs in the configura- and is said to be running, when it is in either the
tion. set state or the not-set state.

Format Not-Set State: When the power for the clock is


The TOD clock is a 104-bit register. It is a binary turned on, the clock is set to zero, and the clock
counter with the format shown in the following enters the not-set state. The clock is incremented
illustration. when in the not-set state.

1 microsecond When the clock is in the not-set state, execution of


6
STORE CLOCK or STORE CLOCK EXTENDED

causes condition code 1 to be set and the current


value of the running clock to be stored.

51 64 13 Stopped State: The clock enters the stopped


The TOD clock nominally is incremented by state when SET CLOCK is executed and the exe-
adding a one in bit position 51 every microsecond. cution results in the clock being set. This occurs
In models having a higher or lower resolution, a when SET CLOCK is executed without encount-
different bit position is incremented at such a fre- ering any exceptions and either any manual
quency that the rate of advancing the clock is the TOD-clock control in the configuration is set to the
same as if a one were added in bit position 51 enable-set position or the
every microsecond. The resolution of the TOD TOD-clock-control-override control, bit 42 of
clock is such that the incrementing rate is compa- control register 14, is one. The clock can be
rable to the instruction-execution rate of the placed in the stopped state from the set, not-set,
model. and error states. The clock is not incremented
while in the stopped state.
When incrementing of the clock causes a carry to
be propagated out of bit position 0, the carry is When the clock is in the stopped state, execution
ignored, and counting continues from zero. The of STORE CLOCK or STORE CLOCK
program is not alerted, and no interruption condi- EXTENDED causes condition code 3 to be set
tion is generated as a result of the overflow. and the value of the stopped clock to be stored.

The operation of the clock is not affected by any Set State: The clock enters the set state only
normal activity or event in the system. Incre- from the stopped state. The change of state is
menting of the clock does not depend on whether under control of the TOD-clock-sync-control bit, bit
the wait-state bit of the PSW is one or whether the 34 of control register 0, of the CPU which most
CPU is in the operating, load, stopped, or check- recently caused the clock to enter the stopped
stop state. Its operation is not affected by CPU, state. If the bit is zero, the clock enters the set
initial-CPU, or clear resets or by initial program state at the completion of execution of SET
loading. Operation of the clock is also not CLOCK. If the bit is one, the clock remains in the
affected by the setting of the rate control or by an stopped state until the bit is set to zero on that
initial-machine-loading operation. Depending on CPU or until another CPU executes a SET
the model and the configuration, the TOD clock CLOCK instruction affecting the clock. If an
may or may not be powered independent of the external time reference (ETR) is installed, a signal
CPU. from the ETR may be used to set the set state
from the stopped state.

Incrementing of the clock begins with the first


stepping pulse after the clock enters the set state.

Chapter 4. Control 4-35


When the clock is in the set state, execution of Setting the clock replaces the values in all bit
STORE CLOCK or STORE CLOCK EXTENDED positions from bit position 0 through the rightmost
causes condition code 0 to be set and the current position that is incremented when the clock is
value of the running clock to be stored. running. However, on some models, the rightmost
bits starting at or to the right of bit 52 of the speci-
Error State: The clock enters the error state fied value are ignored, and zeros are placed in the
when a malfunction is detected that is likely to corresponding positions of the clock. Zeros are
have affected the validity of the clock value. It also placed in positions to the right of bit position
depends on the model whether the clock can be 63 of the clock.
placed in this state. A timing-facility-damage
machine-check-interruption condition is generated The TOD clock can be inspected by executing
on each CPU in the configuration whenever the STORE CLOCK, which causes bits 0-63 of the
clock enters the error state. clock to be stored in an eight-byte operand in
storage, or by executing STORE CLOCK
When STORE CLOCK or STORE CLOCK EXTENDED, which causes bits 0-103 of the clock
EXTENDED is executed and the clock is in the to be stored in bytes 1-13 of a 16-byte operand in
error state, condition code 2 is set, and the value storage. STORE CLOCK EXTENDED stores
stored is zero. zeros in the leftmost byte, byte 0, of its storage
operand, and it obtains the TOD programmable
Not-Operational State: The clock is in the not- field from bit positions 16-31 of the TOD program-
operational state when its power is off or when it mable register and stores it in byte positions 14
is disabled for maintenance. It depends on the and 15 of the storage operand. The operand
model whether the clock can be placed in this stored by STORE CLOCK EXTENDED has the
state. Whenever the clock enters the not- following format:
operational state, a timing-facility-damage

machine-check-interruption condition is generated Programm-
on each CPU in the configuration. Zeros TOD Clock able Field

When the clock is in the not-operational state, 8 112 127
execution of STORE CLOCK or STORE CLOCK
EXTENDED causes condition code 3 to be set, At some time in the future, STORE CLOCK
and zero is stored. EXTENDED on new models will store a leftmost
extension of the TOD clock in byte position 0 of its
Changes in Clock State storage operand; see programming note 13 on
When the TOD clock changes value because of page 4-39.
the execution of SET CLOCK or changes state,
interruption conditions pending for the clock Two executions of STORE CLOCK or STORE
comparator and CPU timer may or may not be CLOCK EXTENDED, possibly on different CPUs
recognized for up to 1.048576 seconds (2 in the same configuration, always store different
microseconds) after the change. values of the clock if the clock is running. If the
clock is stopped, zeros are stored in the clock
The results of channel-subsystem-monitoring- value, bits 8-111 of the storage operand, in posi-
facility operations may be unpredictable as a tions to the right of the rightmost bit position that
result of changes to the TOD clock. is incremented when the clock is running. The
programmable field continues to be stored even
Setting and Inspecting the Clock when the clock is stopped.
The clock can be set to a specified value by exe-
The values stored for a running clock by STORE
cution of SET CLOCK if the manual TOD-clock
CLOCK or STORE CLOCK EXTENDED always
control of any CPU in the configuration is in the
correctly imply the sequence of execution of these
enable-set position or the TOD-clock-control-
instructions by one or more CPUs for all cases
override control, bit 42 of control register 14, is
where the sequence can be discovered by the
one. SET CLOCK sets bits of the clock with the
program. To ensure that unique values are
contents of corresponding bit positions of a
doubleword operand in storage.

4-36 z/Architecture Principles of Operation


obtained when the value of a running clock is
stored, nonzero values may be stored in positions Programmable
to the right of the rightmost incremented bit posi- Field

tion. When the value of a running clock is stored 16 31
by STORE CLOCK EXTENDED, the value in bit
positions 64-103 of the clock (bit positions 72-111 The register is loaded by SET CLOCK PRO-
of the storage operand) is always nonzero; this GRAMMABLE FIELD. The contents of the reg-
ensures that values stored by STORE CLOCK ister are reset to a value of all zeros by initial CPU
EXTENDED are always unique when compared reset.
with values stored by STORE CLOCK and
extended on the right with zeros. Programming Notes:

For the purpose of establishing uniqueness and 1. Bit position 31 of the clock is incremented
sequence of occurrence of the results of STORE every 1.048576 seconds; for some applica-
CLOCK and STORE CLOCK EXTENDED, the tions, reference to the leftmost 32 bits of the
64-bit value provided by STORE CLOCK may be clock may provide sufficient resolution.
considered to be extended to 104 bits by 2. Communication between systems is facilitated
appending 40 zeros on the right, with the STORE by establishing a standard time origin that is
CLOCK value and STORE CLOCK EXTENDED the calendar date and time to which a clock
bits 8-111 then both being treated as 104-bit value of zero corresponds. January 1, 1900,
unsigned binary integers. 0 a.m. Coordinated Universal Time (UTC) is
recommended as this origin, and it is said to
In a configuration where more than one CPU begin the standard epoch for the clock. This
accesses the clock, SET CLOCK is interlocked is also the epoch used when the TOD clock is
such that the entire contents appear to be updated synchronized to the external time reference
concurrently; that is, if SET CLOCK instructions (ETR). Note that the former term, Greenwich
are executed simultaneously by two CPUs, the Mean Time (GMT), is now obsolete and has
final result is either one or the other value. If SET been replaced with the more precise UTC.
CLOCK is executed by one CPU and STORE
CLOCK or STORE CLOCK EXTENDED by the 3. A program using the clock value as a
other, the result obtained by STORE CLOCK or time-of-day and calendar indication must be
STORE CLOCK EXTENDED is either the entire consistent with the programming support
old value or the entire new value. When SET under which the program is to be executed. If
CLOCK is executed by one CPU, a STORE the programming support uses the standard
CLOCK or STORE CLOCK EXTENDED instruc- epoch, bit 0 of the clock remains one through
tion executed by another CPU may find the clock the years 1972-2041. (Bit 0 turned on at
in the stopped state even when the 11:56:53.685248 (UTC) May 11, 1971.) Ordi-
TOD-clock-sync-control bit, bit 34 of control reg- narily, testing bit 0 for a one is sufficient to
ister 0, of each CPU is zero. Since the clock determine if the clock value is in the standard
enters the set state before incrementing, the first epoch.
STORE CLOCK or STORE CLOCK EXTENDED 4. In converting to or from the current date or
instruction executed after the clock enters the set time, the programming support must take into
state may still find the original value introduced by account that leap seconds have been
SET CLOCK. inserted or deleted because of time-correction
standards. When the TOD clock has been set
TOD Programmable Register correctly to a time within the standard epoch,
Each CPU has a TOD programmable register. the sum of the accumulated leap seconds
Bits 16-31 of the register contain the program- must be subtracted from the clock time to
mable field that is appended on the right to the determine UTC time.
TOD-clock value by STORE CLOCK EXTENDED.
5. Because of the limited accuracy of manually
The register has the following format:
setting the clock value, the rightmost bit posi-
tions of the clock, expressing fractions of a
second, are normally not valid as indications

Chapter 4. Control 4-37


of the time of day. However, they permit
elapsed-time measurements of high resol- Leap
ution. Year MthDaySec. Clock Setting (Hex)

6. The following chart shows the time interval 19 1 1
between instants at which various bit positions 1972 1 1 8126 D6E 46
1972 7 1 1 82B A981 1E24
of the TOD clock are stepped. This time 1973 1 1 2 82F3 AE E248
value may also be considered as the weighted 1974 1 1 3 84BD E971 146C
time value that the bit, when one, represents. 1975 1 1 4 8688 D233 469
1976 1 1 5 8853 BAF5 78B4
TOD- Stepping Interval 1977 1 1 6 8A1F E595 2D8
Clock 1978 1 1 7 8BEA CE57 52FC
Bit DaysHoursMin. Seconds 1979 1 1 8 8DB5 B719 852
198 1 1 9 8F8 9FDB B744
51 . 1 1981 7 1 1 923 5CF CD68
47 . 16 1982 7 1 11 93FB 44D1 FF8C
43 . 256 1983 7 1 12 95C6 2D94 31B
1985 7 1 13 995D 4F5 17D4
39 .4 96 1988 1 1 14 9DDA 69A5 57F8
35 .65 536 199 1 1 15 A171 7D6 3E1C
31 1.48 576 1991 1 1 16 A33C 65C8 74
1992 7 1 17 A5EC 21FC 8664
27 16.777 216 1993 7 1 18 A7B7 ABE B888
23 4 28.435 456 1994 7 1 19 A981 F38 EAAC
19 1 11 34.967 296 1996 1 1 2 AC34 336F ECD
1997 7 1 21 AEE3 EFA4 2F4
15 19 5 19.476 736 1999 1 1 22 B196 2F93 518
11 12 17 25 11.627 776
7 23 14 43 6.44 416 8. The stepping value of TOD-clock bit position
3 3257 19 29 36.71 656 63, if implemented, is 2- microseconds, or

approximately 244 picoseconds. This value is
7. The following chart shows the TOD clock called a clock unit.
setting for 00:00:00 (0 am), UTC time, for
The following chart shows various time inter-
several dates: January 1, 1900, January 1,
vals in clock units expressed in hexadecimal
1972, and for that instant in time just after
notation.
each of the 22 leap seconds that have
occurred through November, 2000. Each of
these leap seconds was inserted in the UTC Interval Clock Units (Hex)

time scale beginning at 23:59:60 UTC of the 1 microsecond 1
day previous to the one listed and ending at 1 millisecond 3E 8
00:00:00 UTC of the day listed. 1 second F424
1 minute 39 387
1 hour D69 3A4
1 day 1 41DD 76
365 days 1CA E8C1 3E
366 days 1CC 2A9E B4
1,461 days\ 72C E4E2 6E

\ Number of days in four years,
including a leap year. Note
that the year 19 was not a
leap year. Thus, the four-
year span starting in 19
has only 1,46 days.

9. The charts in notes 6-8 are useful when
examining the value stored by STORE
CLOCK. Similar charts for use when exam-

4-38 z/Architecture Principles of Operation


ining the value stored by STORE CLOCK The stepping rates for the TOD clock and the
EXTENDED are in programming notes at the ETR are synchronized.
end of the definition of that instruction.
Bits 32 through the rightmost incremented bit
10. In a multiprocessing configuration, after the of a clock in the set state are compared with
TOD clock is set and begins running, the the same bits of the ETR. An unequal condi-
program should delay activity for 2 micro- tion is signaled by an external-damage
seconds (1.048576 seconds) to ensure that machine-check-interruption condition. The
the CPU-timer, clock-comparator, and machine-check-interruption condition may not
TOD-clock-sync-check interruption conditions be recognized for up to 1.048576 seconds
are recognized by the CPU. (2 microseconds) after the unequal condi-
tion occurs.
11. Due to the sequencing rules for the results of
STORE CLOCK and STORE CLOCK
Programming Notes:
EXTENDED, the execution of STORE CLOCK
may be considerably slower than that of 1. TOD-clock synchronization provides for syn-
STORE CLOCK EXTENDED on models that chronizing and checking only bits 32 through
increment a bit position of the TOD clock to the rightmost incremented bit of the TOD
the right of position 63. clock. Bits 0-31 of the TOD clock may be dif-
ferent from those of the ETR.
12. Uniqueness of TOD-clock values can be
extended to apply to processors in separate 2. If an ETR is installed, SET CLOCK must place
configurations by including a configuration all zeros in bit positions 32 through the right-
identification in the TOD programmable field. most incremented bit position of the TOD
clock; otherwise, an external-damage
13. At some time in the future, new models will
machine-check-interruption condition will be
use a carry from bit position 0 of the TOD
recognized.
clock to increment an additional eight-bit
binary counter. STORE CLOCK EXTENDED
will store the contents of this counter in byte Clock Comparator
position 0 of its storage operand. A variation
of SET CLOCK will set the counter, as well as The clock comparator provides a means of
the TOD clock. Variations of SET CLOCK causing an interruption when the TOD-clock value
COMPARATOR and STORE CLOCK exceeds a value specified by the program.
COMPARATOR will manipulate a comparable
byte at the left of the clock comparator. In a configuration with more than one CPU, each
These actions will allow the TOD clock to con- CPU has a separate clock comparator.
tinue to measure time within the standard
The clock comparator has the same format as bits
epoch after the current 143-year limit caused
0-63 of the TOD clock. The clock comparator
by a carry from bit position 0 has been
nominally consists of bits 0-47, which are com-
exceeded, and they will allow continued use of
pared with the corresponding bits of the TOD
the clock comparator. It may be desired to
clock. In some models, higher resolution is
have programs that process 16-byte STORE
obtained by providing more than 48 bits. The bits
CLOCK EXTENDED operands take these
in positions provided in the clock comparator are
future developments into account.
compared with the corresponding bits of the clock.
When the resolution of the clock is less than that
TOD-Clock Synchronization of the clock comparator, the contents of the clock
comparator are compared with the clock value as
The following functions are provided if an external this value would be stored by executing STORE
time reference (ETR) is installed: CLOCK.
A clock in the stopped state, with the
TOD-clock-sync-control bit (bit 34 of control The clock comparator causes an external inter-
register 0) set to one, is placed in the set ruption with the interruption code 1004 hex. A
state and starts incrementing when an ETR request for a clock-comparator interruption exists
signal occurs. whenever either of the following conditions exists:

Chapter 4. Control 4-39


1. The TOD clock is running and the value of the CPU Timer
clock comparator is less than the value in the
compared portion of the clock, both values The CPU timer provides a means for measuring
being considered unsigned binary integers. elapsed CPU time and for causing an interruption
Comparison follows the rules of unsigned when a specified amount of time has elapsed.
binary arithmetic.
2. The TOD clock is in the error state or the not- In a configuration with more than one CPU, each
operational state. CPU has a separate CPU timer.

A request for a clock-comparator interruption does The CPU timer is a binary counter with a format
not remain pending when the value of the clock which is the same as that of bits 0-63 of the TOD
comparator is made equal to or greater than that clock, except that bit 0 is considered a sign. The
of the TOD clock or when the value of the TOD CPU timer nominally is decremented by sub-
clock is made less than the clock-comparator tracting a one in bit position 51 every micro-
value. The latter may occur as a result of the second. In models having a higher or lower
TOD clock either being set or wrapping to zero. resolution, a different bit position is decremented
at such a frequency that the rate of decrementing
The clock comparator can be inspected by exe- the CPU timer is the same as if a one were sub-
cuting the instruction STORE CLOCK tracted in bit position 51 every microsecond. The
COMPARATOR and can be set to a specified resolution of the CPU timer is such that the step-
value by executing the SET CLOCK ping rate is comparable to the instruction-
COMPARATOR instruction. execution rate of the model.
The contents of the clock comparator are initial- The CPU timer requests an external interruption
ized to zero by initial CPU reset. with the interruption code 1005 hex whenever the
CPU-timer value is negative (bit 0 of the CPU
Programming Notes:
timer is one). The request does not remain
1. An interruption request for the clock pending when the CPU-timer value is changed to
comparator persists as long as the clock- a nonnegative value.
comparator value is less than that of the TOD
clock or as long as the TOD clock is in the When both the CPU timer and the TOD clock are
error state or the not-operational state. There- running, the stepping rates are synchronized such
fore, one of the following actions must be that both are stepped at the same rate. Normally,
taken after an external interruption for the decrementing the CPU timer is not affected by
clock comparator has occurred and before the concurrent I/O activity. However, in some models
CPU is again enabled for external inter- the CPU timer may stop during extreme I/O
ruptions: the value of the clock comparator activity and other similar interference situations.
must be replaced, the TOD clock must be set, In these cases, the time recorded by the CPU
the TOD clock must wrap to zero, or the timer provides a more accurate measure of the
clock-comparator-subclass mask must be set CPU time used by the program than would have
to zero. Otherwise, loops of external inter- been recorded had the CPU timer continued to
ruptions are formed. step.
2. The instruction STORE CLOCK or STORE The CPU timer is decremented when the CPU is
CLOCK EXTENDED may store a value which in the operating state or the load state. When the
is greater than that in the clock comparator, manual rate control is set to instruction step, the
even though the CPU is enabled for the clock- CPU timer is decremented only during the time in
comparator interruption. This is because the which the CPU is actually performing a unit of
TOD clock may be incremented one or more operation. However, depending on the model, the
times between when instruction execution is CPU timer may or may not be decremented when
begun and when the clock value is accessed. the TOD clock is in the error, stopped, or not-
In this situation, the interruption occurs when operational state.
the execution of STORE CLOCK or STORE
CLOCK EXTENDED is completed.

4-40 z/Architecture Principles of Operation


Depending on the model, the CPU timer may or after external interruptions are again enabled
may not be decremented when the CPU is in the if the saved value was negative.
check-stop state.
The persistence of the CPU-timer-interruption
request means, however, that after an
The CPU timer can be inspected by executing the
external interruption for the CPU timer has
instruction STORE CPU TIMER and can be set to
occurred, the value of the CPU timer must be
a specified value by executing the SET CPU
replaced, the value in the CPU timer must
TIMER instruction.
wrap to a positive value, or the
The CPU timer is set to zero by initial CPU reset. CPU-timer-subclass mask must be set to zero
before the CPU is again enabled for external
Programming Notes: interruptions. Otherwise, loops of external
interruptions are formed.
1. The CPU timer in association with a program
may be used both to measure CPU-execution 5. The instruction STORE CPU TIMER may
time and to signal the end of a time interval store a negative value even though the CPU
on the CPU. is enabled for the interruption. This is
because the CPU-timer value may be decre-
2. The time measured for the execution of a mented one or more times between when
sequence of instructions may depend on the instruction execution is begun and when the
effects of such things as I/O interference, the CPU timer is accessed. In this situation, the
availability of pages, and instruction retry. interruption occurs when the execution of
Therefore, repeated measurements of the STORE CPU TIMER is completed.
same sequence on the same installation may
differ.
3. The fact that a CPU-timer interruption does Externally Initiated Functions
not remain pending when the CPU timer is set
to a positive value eliminates the problem of Resets
an undesired interruption. This would occur if,
between the time when the old value is stored Five reset functions are provided:
and a new value is set, the CPU is disabled
for CPU-timer interruptions and the CPU timer CPU reset
value goes from positive to negative. Initial CPU reset
Subsystem reset
4. The fact that CPU-timer interruptions are Clear reset
requested whenever the CPU timer is nega- Power-on reset
tive (rather than just when the CPU timer goes
from positive to negative) eliminates the CPU reset provides a means of clearing
requirement for testing a value to ensure that equipment-check indications and any resultant
it is positive before setting the CPU timer to unpredictability in the CPU state with the least
that value. amount of information destroyed. In particular, it
is used to clear check conditions when the CPU
As an example, assume that a program being state is to be preserved for analysis or resumption
timed by the CPU timer is interrupted for a of the operation. CPU reset sets the architectural
cause other than the CPU timer, external mode to the ESA/390 mode if it is caused by acti-
interruptions are disallowed by the new PSW, vation of the load-normal key.
and the CPU-timer value is then saved by
STORE CPU TIMER. This value could be Initial CPU reset provides the functions of CPU
negative if the CPU timer went from positive reset together with initialization of the current
to negative since the interruption. Subse- PSW, CPU timer, clock comparator, prefix, and
quently, when the program being timed is to control, floating-point-control, and TOD program-
continue, the CPU timer may be set to the mable registers. Initial CPU reset sets the archi-
saved value by SET CPU TIMER. A tectural mode to the ESA/390 mode if it is caused
CPU-timer interruption occurs immediately by activation of the load-normal key.

Chapter 4. Control 4-41


Subsystem reset provides a means for clearing they are held by a CPU already powered on. The
floating interruption conditions as well as for power-on-reset sequences for the TOD clock,
invoking I/O-system reset. main storage, and the channel subsystem may be
included as part of the CPU power-on sequence,
Clear reset causes initial CPU reset and sub- or the power-on sequence for these units may be
system reset to be performed and, additionally, initiated separately. If CPU power-on reset estab-
clears or initializes all storage locations and regis- lishes the configuration, it sets the architectural
ters in all CPUs in the configuration, with the mode to the ESA/390 mode; otherwise, it sets the
exception of the TOD clock. Such clearing is architectural mode to that of the CPUs already in
useful in debugging programs and in ensuring the configuration.
user privacy. Clear reset also releases all locks
used by the PERFORM LOCKED OPERATION CPU reset, initial CPU reset, subsystem reset, and
instruction. Clear reset sets the architectural clear reset may be initiated manually by using the
mode to the ESA/390 mode. Clearing does not operator facilities (see Chapter 12, Operator
affect external storage, such as direct-access Facilities). Initial CPU reset is part of the initial-
storage devices used by the control program to program-loading function. Figure 4-9 summarizes
hold the contents of unaddressable pages. how these four resets are manually initiated.
Power-on reset is performed as part of turning
CPU power-on reset causes initial CPU reset to power on. The reset actions are tabulated in
be performed and clears the contents of general Figure 4-10 on page 4-43. For information con-
registers, access registers, and floating-point reg- cerning which resets can be performed by the
isters to zeros with valid checking-block code. SIGNAL PROCESSOR instruction, see Signal-
Locks used by PERFORM LOCKED OPERATION Processor Orders on page 4-49.
and associated with the CPU are released unless

Function Performed on

CPU on Which Key Other CPUs Remainder of
Key Activated Was Activated in Config Configuration

System-reset-normalCPU reset CPU reset Subsystem reset


key

System-reset-clear Clear reset Clear resetClear reset
key

Load-normal key Initial CPU reset,CPU reset Subsystem reset
followed by IPL

Load-clear key Clear reset, Clear resetClear reset
followed by IPL

Explanation:

Activation of a system-reset or load key may change the config-
uration, including the connection with I/O, storage units, and
other CPUs.

Only the CPU elements of this reset apply.

Only the non-CPU elements of this reset apply.

Figure 4-9. Manual Initiation of Resets

4-42 z/Architecture Principles of Operation



Reset Function

Sub- Initial Power
system CPU CPU Clear -On
Area Affected Reset Reset Reset Reset Reset

CPU U S S S S
PSW U U/V# C\ C\ C\
Prefix U U/V C C C
CPU timer U U/V C C C
Clock comparator U U/V C C C
TOD programmable register U U/V C C C
Control registers U U/V I I I
Floating-point-control U U/V C C C
register
Access registers U U/V U/V C C
General registers U U/V U/V C C
Floating-point registers U U/V U/V C C
Storage keys U U U C C
Volatile main storage U U U C C
Nonvolatile main storage U U U C U
Expanded storage U U U U C
TOD clock U U U U T
Floating interruption C U U C C
conditions
I/O system R U U R R
PERFORM LOCKED OPERATION U U U RC RP
locks

Explanation:

# If the architectural mode is changed from the z/Architecture mode
to the ESA/39 mode, the PSW does not remain unchanged.
Instead, the PSW is changed from 16 bytes to eight bytes,
and the bits of the eight-byte PSW are set as follows:
bits -11 and 13-32 are set equal to the same bits of the
16-byte PSW, bit 12 is set to one, and bits 33-63 are set
equal to bits 97-127 of the 16-byte PSW. The PSW is
invalid in the ESA/39 mode if PSW bit 31 is one.

\ Clearing the contents of the PSW to zero causes the PSW
to be invalid if the architectural mode is ESA/39.

When the IPL sequence follows the reset function on that
CPU, the CPU does not necessarily enter the stopped
state, and the PSW is not necessarily cleared to zeros.

When these units are separately powered, the action is
performed only when the power for the unit is turned on.

Figure 4-10 (Part 1 of 3). Summary of Reset Actions

Chapter 4. Control 4-43



Explanation (Continued):

Access to change expanded storage at the time a reset
function is performed may cause the contents of the 4K-
byte block in expanded storage to be unpredictable.
Access to examine expanded storage does not affect the
contents of the expanded storage.

Access to the TOD clock by means of STORE CLOCK at the
time a reset function is performed does not cause the
value of the TOD clock to be affected.

When the channel subsystem is separately powered or con-
sists of multiple elements which are separately powered,
the reset action is applied only to those subchannels,
channel paths, and I/O control units and devices on those
paths associated with the element which is being powered
on.

C The condition or contents are cleared. If the area
affected is a field, the contents are set to zero with
valid checking-block code.

I The state or contents are initialized. If the area af-
fected is a field, the contents are set to the initial
value with valid checking-block code.

R I/O-system reset is performed in the channel subsystem.
As part of this reset, system reset is signaled to all
I/O control units and devices attached to the channel
subsystem.

RC All locks in the configuration are released.

RP All locks in the configuration are released except for
ones held by CPUs already powered on.

S The CPU is reset; current operations, if any, are term-
inated; the ALB and TLB are cleared of entries; inter-
ruption conditions in the CPU are cleared; and the CPU
is placed in the stopped state. The effect of perform-
ing the start function is unpredictable when the stopped
state has been entered by means of a reset. If the reset
is initiated by the system-reset-clear, load-normal, or
load-clear key or by a CPU power-on reset that
establishes the configuration, the architectural mode is
set to the ESA/39 mode; otherwise, the architectural
mode is unchanged, except that power-on reset sets the
mode to that of the CPUs already in the configuration.

Figure 4-10 (Part 2 of 3). Summary of Reset Actions

4-44 z/Architecture Principles of Operation



Explanation (Continued):

T The TOD clock is initialized to zero and validated; it
enters the not-set state.

U The state, condition, or contents of the field remain
unchanged. However, the result is unpredictable if an
operation is in progress that changes the state, con-
dition, or contents of the field at the time of reset.

U/V The contents remain unchanged, provided the field is not
being changed at the time the reset function is per-
formed. However, on some models the checking-block code
of the contents may be made valid. The result is un-
predictable if an operation is in progress that changes
the contents of the field at the time of reset.

Figure 4-10 (Part 3 of 3). Summary of Reset Actions

CPU Reset ESA/390 mode. If this changes the mode


CPU reset causes the following actions: from the z/Architecture mode to the ESA/390
mode, the current PSW is changed from 16
1. The execution of the current instruction or
bytes to eight bytes, and the bits of the eight-
other processing sequence, such as an inter-
byte PSW are set as follows: bits 0-11 and
ruption, is terminated, and all program-
13-32 are set equal to the same bits of the
interruption and supervisor-call-interruption
16-byte PSW, bit 12 is set to one, and bits
conditions are cleared.
33-63 are set equal to bits 97-127 of the
2. Any pending external-interruption conditions 16-byte PSW.
which are local to the CPU are cleared.
7. The CPU is placed in the stopped state after
Floating external-interruption conditions are
actions 1-6 have been completed. When the
not cleared.
IPL sequence follows the reset function on
3. Any pending machine-check-interruption con- that CPU, the CPU enters the load state at
ditions and error indications which are local to the completion of the reset function and does
the CPU and any check-stop states are not necessarily enter the stopped state during
cleared. Floating machine-check-interruption the execution of the reset operation.
conditions are not cleared. Any machine-
Registers, storage contents, and the state of con-
check condition which is reported to all CPUs
ditions external to the CPU remain unchanged by
in the configuration and which has been made
CPU reset. However, the subsequent contents of
pending to a CPU is said to be local to the
the register, location, or state are unpredictable if
CPU.
an operation is in progress that changes the con-
4. All copies of prefetched instructions or oper- tents at the time of the reset. A lock held by the
ands are cleared. Additionally, any results to CPU when executing PERFORM LOCKED OPER-
be stored because of the execution of ATION is not released by CPU reset.
instructions in the current checkpoint interval
are cleared. When the reset function in the CPU is initiated at
the time the CPU is executing an I/O instruction or
5. The ART-lookaside buffer and translation-
is performing an I/O interruption, the current oper-
lookaside buffer are cleared of entries.
ation between the CPU and the channel sub-
6. If the reset is caused by activation of the load- system may or may not be completed, and the
normal key on any CPU in the configuration, resultant state of the associated channel-
the architectural mode of the CPU (and of all subsystem facility may be unpredictable.
other CPUs in the configuration) is set to the

Chapter 4. Control 4-45


Programming Notes: Subsystem Reset
1. Most operations which would change a state, Subsystem reset operates only on those elements
a condition, or the contents of a field cannot in the configuration which are not CPUs. It per-
occur when the CPU is in the stopped state. forms the following actions:
However, some signal-processor functions 1. I/O-system reset is performed by the channel
and some operator functions may change subsystem (see I/O-System Reset on
these fields. To eliminate the possibility of page 17-10).
losing a field when CPU reset is issued, the
CPU should be stopped, and no operator 2. All floating interruption conditions in the con-
functions should be in progress. figuration are cleared.

2. If the architectural mode is changed to the As part of I/O-system reset, pending


ESA/390 mode and bit 31 of the current PSW I/O-interruption conditions are cleared, and system
is one, the PSW is invalid. reset is signaled to all control units and devices
attached to the channel subsystem (see
I/O-System Reset on page 17-10). The effect of
Initial CPU Reset
system reset on I/O control units and devices and
Initial CPU reset combines the CPU reset func-
the resultant control-unit and device state are
tions with the following clearing and initializing
described in the appropriate System Library publi-
functions:
cation for the control unit or device. A system
1. If the reset is caused by activation of the load- reset, in general, resets only those functions in a
normal key, the architectural mode of the CPU shared control unit or device that are associated
(and of all other CPUs in the configuration) is with the particular channel path signaling the
set to the ESA/390 mode. reset.
2. The contents of the current PSW, prefix, CPU
timer, clock comparator, and TOD program- Clear Reset
mable register are set to zero. When the IPL Clear reset combines the initial-CPU-reset function
sequence follows the reset function on that with an initializing function which causes the fol-
CPU, the contents of the PSW are not neces- lowing actions:
sarily set to zero. 1. The architectural mode of all CPUs in the con-
3. The contents of control registers are set to figuration is set to the ESA/390 mode.
their initial z/Architecture values. All 64 bits of 2. The access, general, and floating-point regis-
the control registers are set regardless of ters of all CPUs in the configuration are set to
whether the CPU is in the ESA/390 or zero. All 64 bits of the general registers are
z/Architecture architectural mode. set even though the CPUs are in the ESA/390
4. The contents of the floating-point-control reg- architectural mode at the end of the reset
ister are set to zero. operation.

These clearing and initializing functions include 3. The contents of the main storage in the con-
validation. figuration and the associated storage keys are
set to zero with valid checking-block code.
Setting the current PSW to zero when the CPU is 4. The locks used by any CPU in the configura-
in the ESA/390 architectural mode at the end of tion when executing the PERFORM LOCKED
the operation causes the PSW to be invalid, since OPERATION instruction are released.
PSW bit 12 must be one in that mode. Thus, in
this case if the CPU is placed in the operating 5. A subsystem reset is performed.
state after a reset without first introducing a new Validation is included in setting registers and in
PSW, a specification exception is recognized. clearing storage and storage keys.

4-46 z/Architecture Principles of Operation


Programming Notes: storage, and channel subsystem. See also
Chapter 17, I/O Support Functions, and the
1. The architectural mode is not changed by acti-
appropriate System Library publication for the
vation of the system-reset-normal key or by
channel subsystem, control units, and I/O devices.
execution of a SIGNAL PROCESSOR
CPU-reset or initial-CPU-reset order. All
CPU Power-On Reset: The power-on reset
CPUs in the configuration are always in the
causes initial CPU reset to be performed and may
same architectural mode.
or may not cause I/O-system reset to be per-
2. For the CPU-reset operation not to affect the formed in the channel subsystem. The contents
contents of fields that are to be left of general registers, access registers, and floating-
unchanged, the CPU must not be executing point registers are cleared to zeros with valid
instructions and must be disabled for all inter- checking-block code. Locks used by PERFORM
ruptions at the time of the reset. Except for LOCKED OPERATION and associated with the
the operation of the CPU timer and for the CPU are released unless they are held by a CPU
possibility of a machine-check interruption already powered on. If the reset is associated
occurring, all CPU activity can be stopped by with establishing a configuration, the CPU is
placing the CPU in the wait state and by disa- placed in the ESA/390 mode; otherwise, the CPU
bling it for I/O and external interruptions. To is placed in the architectural mode of the CPUs
avoid the possibility of causing a reset at the already in the configuration.
time that the CPU timer is being updated or a
machine-check interruption occurs, the CPU TOD-Clock Power-On Reset: The power-on
must be in the stopped state. reset causes the value of the TOD clock to be set
to zero with valid checking-block code and causes
3. CPU reset, initial CPU reset, subsystem reset,
the clock to enter the not-set state.
and clear reset do not affect the value and
state of the TOD clock. Main-Storage Power-On Reset: For volatile
4. The conditions under which the CPU enters main storage (one that does not preserve its con-
the check-stop state are model-dependent and tents when power is off) and for storage keys,
include malfunctions that preclude the com- power-on reset causes zeros with valid checking-
pletion of the current operation. Hence, if block code to be placed in these fields. The con-
CPU reset or initial CPU reset is executed tents of nonvolatile main storage, including the
while the CPU is in the check-stop state, the checking-block code, remain unchanged.
contents of the PSW, registers, and storage
locations, including the storage keys and the Expanded-Storage Power-On Reset: The con-
storage location accessed at the time of the tents of expanded storage are cleared to zeros
error, may have unpredictable values, and, in with valid checking-block code.
some cases, the contents may still be in error
after the check-stop state is cleared by these Channel-Subsystem Power-On Reset: The
resets. In this situation, a clear reset is channel-subsystem power-on reset causes
required to clear the error. I/O-system reset to be performed in the channel
subsystem. (See I/O-System Reset on
Power-On Reset page 17-10.)
The power-on-reset function for a component of
the machine is performed as part of the power-on Initial Program Loading
sequence for that component.
Initial program loading (IPL) provides a manual
The power-on sequences for the TOD clock, main means for causing a program to be read from a
storage, expanded storage, and channel sub- designated device and for initiating execution of
system may be included as part of the CPU that program.
power-on sequence, or the power-on sequence for
these units may be initiated separately. The fol- Some models may provide additional controls and
lowing sections describe the power-on resets for indications relating to IPL; this additional informa-
the CPU, TOD clock, main storage, expanded tion is specified in the System Library publication
for the model.

Chapter 4. Control 4-47


IPL is initiated manually by setting the load-unit- control is set to the process position, the CPU
address controls to a four-digit number to desig- enters the operating state, and the CPU operation
nate an input device and by subsequently proceeds under control of the new PSW. If the
activating the load-clear or load-normal key for a rate control is set to the instruction-step position,
particular CPU. In the description which follows, the CPU enters the stopped state, with the manual
the term this CPU refers to the CPU in the con- indicator on, after the new PSW is loaded.
figuration for which the load-clear or load-normal
key was activated. If the IPL I/O operation or the PSW loading is not
completed successfully, the CPU remains in the
Activating the load-clear key causes a clear reset load state, and the load indicator remains on. The
to be performed on the configuration. contents of absolute storage locations 0-7 are
unpredictable.
Activating the load-normal key causes an initial
CPU reset to be performed on this CPU, CPU
reset to be propagated to all other CPUs in the
Store Status
configuration, and a subsystem reset to be per-
The store-status operation places an architectural-
formed on the remainder of the configuration.
mode identification and the contents of the CPU
registers, except for the TOD clock, in assigned
Activating the load-clear key or the load-normal
storage locations.
key sets the architectural mode to the ESA/390
mode. For ease of reference, the additional ele-
Figure 4-11 lists the fields that are stored, their
ments of the description of ESA/390 initial
length, and their location in main storage.
program loading are given below.

In the loading part of the operation, after the Length Absolute
resets have been performed, this CPU then enters Field in Bytes Address
the load state. This CPU does not necessarily
enter the stopped state during the execution of the Architectural-mode id 1 163
Fl-pt registers -15 128 468
reset operations. The load indicator is on while General registers -15 128 4736
the CPU is in the load state. Current PSW 16 4864
Prefix 4 4888
Subsequently, a channel-program read operation Fl-pt control register 4 4892
is initiated from the I/O device designated by the TOD programmable register 4 49
load-unit-address controls. The effect of executing CPU timer 8 494
Zeros 1 4912
the channel program is as if a format-0 CCW in Bits -55 of clock 7 4913
absolute storage location 0 specified a read comparator
command with the modifier bits zeros, a data Access registers -15 64 4928
address of zero, a byte count of 24, the chain- Control registers -15 128 4992
command and SLI flags ones, and all other flags
zeros. Figure 4-11. Assigned Storage Locations for Store
Status
The details of the channel-subsystem portion of
the IPL operation are defined in Initial Program During the execution of the store-status operation,
Loading on page 17-15. zeros are stored in bit positions 0-6, and a one is
stored in bit position 7, of absolute location 163,
When the IPL I/O operation is completed success- the store-status architectural-mode identification.
fully, the subsystem-identification word of the IPL
device is stored in absolute storage locations When the CPU is in the ESA/390 architectural
184-187, zeros are stored in absolute storage mode, the store-status operation stores all zeros
locations 188-191, and a new PSW is loaded from at absolute location 163.
absolute storage locations 0-7. If the PSW
loading is successful and if no machine malfunc- When bits 0-55 of the clock comparator are stored
tions are detected, this CPU leaves the load state, beginning at absolute location 4913, zeros are
and the load indicator is turned off. If the rate stored at absolute location 4912.

4-48 z/Architecture Principles of Operation


The contents of the registers are not changed. If Shared Main Storage
an error is encountered during the operation, the
CPU enters the check-stop state. The shared-main-storage facility permits more
than one CPU to have access to common main-
The store-status operation can be initiated manu-
storage locations. All CPUs having access to a
ally by use of the store-status key (see
common main-storage location have access to the
Chapter 12, Operator Facilities). The store-
entire 4K-byte block containing that location and to
status operation can also be initiated at the
the associated storage key. The channel sub-
addressed CPU by executing SIGNAL
system and all CPUs in the configuration refer to a
PROCESSOR, specifying the stop-and-store-
shared main-storage location using the same
status order. Execution of SIGNAL PROCESSOR
absolute address.
specifying the store-status-at-address order
permits the same status information, except for
the store-status architectural-mode identification, CPU-Address Identification
to be stored at a designated address (see Signal-
Processor Orders). Each CPU has a number assigned, called its CPU
address. A CPU address uniquely identifies one
CPU within a configuration. The CPU is desig-
Multiprocessing nated by specifying this address in the
CPU-address field of SIGNAL PROCESSOR. The
The multiprocessing facility provides for the inter- CPU signaling a malfunction alert, emergency
connection of CPUs, via a common main storage, signal, or external call is identified by storing this
in order to enhance system availability and to address in the CPU-address field with the inter-
share data and resources. The multiprocessing ruption. The CPU address is assigned during
facility includes the following facilities: system installation and is not changed as a result
Shared main storage of reconfiguration changes. The program can
CPU-to-CPU interconnection determine the address of the CPU by using
TOD-clock synchronization STORE CPU ADDRESS.

Associated with these facilities are two external-


interruption conditions (TOD-clock-sync check and CPU Signaling and Response
malfunction alert), which are described in The CPU-signaling-and-response facility consists
Chapter 6, Interruptions; and control-register of SIGNAL PROCESSOR and a mechanism to
positions for the TOD-clock-sync-control bit and interpret and act on several order codes. The
for the masks for the external-interruption condi- facility provides for communications among CPUs,
tions, which are listed in Control Registers on including transmitting, receiving, and decoding a
page 4-7. set of assigned order codes; initiating the specified
operation; and responding to the signaling CPU.
The channel subsystem, including all subchannels,
A CPU can address SIGNAL PROCESSOR to
in a multiprocessing configuration can be
itself. SIGNAL PROCESSOR is described in
accessed by all CPUs in the configuration.
Chapter 10, Control Instructions.
I/O-interruption conditions are floating and can be
accepted by any CPU in the configuration.
Signal-Processor Orders
The signal-processor orders are specified in bit
positions 56-63 of the second-operand address of
SIGNAL PROCESSOR and are encoded as
shown in Figure 4-12 on page 4-50.

Chapter 4. Control 4-49


when the CPU is enabled for that condition and
Code does not necessarily occur during the execution of
(Hex) Order SIGNAL PROCESSOR. The address of the CPU

Unassigned sending the signal is provided with the interruption


1 Sense code when the interruption occurs. At any one
2 External call time the receiving CPU can keep pending one
3 Emergency signal emergency-signal condition for each CPU in the
4 Start configuration, including the receiving CPU itself.
5 Stop
6 Restart The order is effective only when the addressed
7 Unassigned CPU is in the stopped or the operating state.
8 Unassigned
9 Stop and store status Start: The addressed CPU performs the start
A Unassigned function (see Stopped, Operating, Load, and
B Initial CPU reset Check-Stop States on page 4-1). The CPU does
C CPU reset
D Set prefix not necessarily enter the operating state during
E Store status at address the execution of SIGNAL PROCESSOR. The
F-11 Unassigned order is effective only when the addressed CPU is
12 Set architecture in the stopped state. The effect of performing the
13-FF Unassigned start function is unpredictable when the stopped
state has been entered by reset.
Figure 4-12. Encoding of Orders
Stop: The addressed CPU performs the stop
The orders are defined as follows: function (see Stopped, Operating, Load, and
Check-Stop States on page 4-1). The CPU does
Sense: The addressed CPU presents its status not necessarily enter the stopped state during the
to the issuing CPU (see Status Bits on execution of SIGNAL PROCESSOR. The order is
page 4-54 for a definition of the bits). No other effective only when the CPU is in the operating
action is caused at the addressed CPU. The state.
status, if not all zeros, is stored in the general reg-
ister designated by the R field of the SIGNAL Restart: The addressed CPU performs the
PROCESSOR instruction, and condition code 1 is restart operation (see Restart Interruption on
set; if all status bits are zeros, condition code 0 is page 6-46). The CPU does not necessarily
set. perform the operation during the execution of
SIGNAL PROCESSOR. The order is effective
External Call: An external-call external- only when the addressed CPU is in the stopped or
interruption condition is generated at the the operating state.
addressed CPU. The interruption condition
becomes pending during the execution of SIGNAL Stop and Store Status: The addressed CPU
PROCESSOR. The associated interruption occurs performs the stop function, followed by the store-
when the CPU is enabled for that condition and status operation (see Store Status on
does not necessarily occur during the execution of page 4-48). The CPU does not necessarily com-
SIGNAL PROCESSOR. The address of the CPU plete the operation, or even enter the stopped
sending the signal is provided with the interruption state, during the execution of SIGNAL
code when the interruption occurs. Only one PROCESSOR. The order is effective only when
external-call condition can be kept pending in a the addressed CPU is in the stopped or the oper-
CPU at a time. The order is effective only when ating state.
the addressed CPU is in the stopped or the oper-
ating state. Initial CPU Reset: The addressed CPU performs
initial CPU reset (see Resets on page 4-41).
Emergency Signal: An emergency-signal The execution of the reset does not affect the
external-interruption condition is generated at the architectural mode or other CPUs and does not
addressed CPU. The interruption condition cause I/O to be reset. The reset operation is not
becomes pending during the execution of SIGNAL necessarily completed during the execution of
PROCESSOR. The associated interruption occurs SIGNAL PROCESSOR.

4-50 z/Architecture Principles of Operation


CPU Reset: The addressed CPU performs CPU by the addressed CPU, bit 55 (invalid param-
reset (see Resets on page 4-41). The execution eter) of the general register designated by the
of the reset does not affect the architectural mode R field of the SIGNAL PROCESSOR instruc-
or other CPUs and does not cause I/O to be reset. tion is set to one, and condition code 1 is set.
The reset operation is not necessarily completed
The value is placed in the prefix register of the
during the execution of SIGNAL PROCESSOR.
addressed CPU.
Set Prefix: The contents of bit positions 33-50 of The ALB and TLB of the addressed CPU are
the parameter register of the SIGNAL cleared of their contents.
PROCESSOR instruction are treated as a prefix
A serializing and checkpoint-synchronizing
value, which replaces bits 33-50 of the prefix reg-
function is performed on the addressed CPU
ister of the addressed CPU. Bits 0-32 and 51-63
following insertion of the new prefix value.
of the parameter register are ignored. The order
is accepted only if the addressed CPU is in the Store Status at Address: The contents of bit
stopped state, the value to be placed in the prefix positions 33-54 of the parameter register of the
register designates an 8K block which is available SIGNAL PROCESSOR instruction are used as the
in the configuration, and no other condition pre- origin of a 512-byte area on a 512-byte boundary
cludes accepting the order. Verification of the in absolute storage into which the status of the
stopped state of the addressed CPU and of the addressed CPU is stored. Bits 0-32 and 55-63 of
availability of the designated storage is performed the parameter register are ignored.
during execution of SIGNAL PROCESSOR. If
accepted, the order is not necessarily completed The order is accepted only if the addressed CPU
during the execution of SIGNAL PROCESSOR. is in the stopped state, the status-area origin des-
ignates a location which is available in the config-
The parameter register has the following format: uration, and no other condition precludes
/
//// Prefix Value //////// accepting the order. Verification of the stopped
/ state of the addressed CPU and of the availability
33 52 63 of the designated storage is performed during exe-
cution of SIGNAL PROCESSOR. If accepted, the
The set-prefix order is completed as follows: order is not necessarily completed during the exe-
cution of SIGNAL PROCESSOR.
If the addressed CPU is not in the stopped
state, the order is not accepted. Instead, bit The parameter register has the following format:
54 (incorrect state) of the general register des- /
ignated by the R field of the SIGNAL //// Status-Area Origin ///////
PROCESSOR instruction is set to one, and /
33 55 63
condition code 1 is set.
The value to be placed in the prefix register of The store-status-at-address order is completed as
the addressed CPU is tested for the avail- follows:
ability of the designated storage. The abso-
lute address of an 8K-byte area of storage is If the addressed CPU is not in the stopped
formed by appending 13 zeros to the right and state, the order is not accepted. Instead, bit
33 zeros to the left of bits 33-50 of the param- 54 (incorrect state) of the general register des-
eter value. This address is treated as a 64-bit ignated by the R field of the SIGNAL
absolute address regardless of whether the PROCESSOR instruction is set to one, and
sending and receiving CPUs are in the 24-bit, condition code 1 is set.
31-bit, or 64-bit addressing mode. The two The address of the area into which status is to
4K-byte blocks of storage within the new be stored is tested for availability. The abso-
prefix area are accessed. The accesses to lute address of a 512-byte area of storage is
the blocks are not subject to protection, and formed by appending 9 zeros to the right and
the associated reference bits may or may not 33 zeros to the left of bits 33-54 of the param-
be set to one. If either block is not available eter value. This address is treated as a 64-bit
in the configuration, the order is not accepted absolute address regardless of whether the

Chapter 4. Control 4-51


sending and receiving CPUs are in the 24-bit, The store-status-at-address order does not store
31-bit, or 64-bit addressing mode. The the architectural-mode identification that is stored
512-byte block of storage at this address is at absolute location 163 by the store-status opera-
accessed. The access is not subject to pro- tion and the stop-and-store-status order.
tection, and the associated reference bit may
or may not be set to one. If the block is not Set Architecture: The contents of bit positions
available in the configuration, the order is not 56-63 of the parameter register are used as a
accepted by the addressed CPU, bit 55 code specifying an architectural mode to which all
(invalid parameter) of the general register des- CPUs in the configuration are to be set: code 0
ignated by the R field of the SIGNAL specifies the ESA/390 mode, and code 1 specifies
PROCESSOR instruction is set to one, and the z/Architecture mode. Bits 0-55 of the param-
condition code 1 is set. eter register are ignored. The contents of the
CPU-address register of the SIGNAL
The status of the addressed CPU is placed in
PROCESSOR instruction are ignored; all other
the designated area. The information stored,
CPUs in the configuration are considered to be
and the format of the area receiving the infor-
addressed. The order is accepted only if the code
mation, are the same as for the stop-and-
is zero or one, the CPU is not already in the mode
store-status order, except that each field,
specified by the code, each of all other CPUs is in
rather than being stored at an offset from the
either the stopped or the check-stop state, and no
beginning of absolute storage, is stored in the
other condition precludes accepting the order. If
designated area at the offsets listed in
accepted, the order is completed by all CPUs
Figure 4-13, and except that an architectural-
during the execution of SIGNAL PROCESSOR. In
mode identification is not stored. Bytes
no case can different CPUs be in different archi-
288-291 and 312-319 of the designated area
tectural modes.
remain unchanged.
A serialization and checkpoint-synchronization The set-architecture order is completed as follows:
function is performed on the addressed CPU If the code in the parameter register is not
following storing of the status. zero or one, or if the CPU is already in the
architectural mode specified by the code, the
Length Offset order is not accepted. Instead, bit 55 (invalid
Field in Bytes in Bytes parameter) of the general register designated
by the R field of the SIGNAL PROCESSOR
Fl-pt registers -15 128 instruction is set to one, and condition code 1
General registers -15 128 128 is set.
Current PSW 16 256
Prefix 4 28 If it is not true that all other CPUs in the con-
Fl-pt-control register 4 284 figuration are in the stopped or check-stop
TOD programmable register 4 292
CPU timer 8 296 state, the order is not accepted. Instead, bit
Zeros 1 34 54 (incorrect state) of the general register des-
Bits -55 of clock 7 35 ignated by the R field of the SIGNAL
comparator PROCESSOR instruction is set to one, and
Access registers -15 64 32 condition code 1 is set.
Control registers -15 128 384
The architectural mode of all CPUs in the con-
Figure 4-13. Location of Status Fields in Designated
figuration is set as specified by the code.
Area If the order changes the architectural mode
from ESA/390 to z/Architecture, then, for each
Programming Note: The architectural mode of CPU in the configuration, the eight-byte
the CPU that stored status in a designated area current PSW is changed to a 16-byte PSW,
normally is indicated by bit 12 of the PSW stored and the bits of the 16-byte PSW are set as
at offset 256 in the area. The PSW is stored at follows: bits 0-11 and 13-32 are set equal to
the same offset, 256, in both the ESA/390 mode the same bits of the eight-byte PSW, bit 12
and the z/Architecture mode. Bit 12 is one in an and bits 33-96 are set to zero, and bits 97-127
ESA/390 PSW and zero in an z/Architecture PSW. are set equal to bits 33-63 of the eight-byte

4-52 z/Architecture Principles of Operation


PSW. Also, bit 19 of the ESA/390 prefix, instruction can be any CPU in the configura-
which becomes bit 51 of the z/Architecture tion other than this CPU, and the CPU
prefix, is set to zero. address can be any address, including that of
this CPU or an invalid address. The order is
If the order changes the architectural mode
rejected. Condition code 2 is set.
from z/Architecture to ESA/390, then, for each
CPU in the configuration, the 16-byte current 2. The addressed CPU is not operational; that is,
PSW is changed to an eight-byte PSW, and it is not provided in the installation, it is not in
the bits of the eight-byte PSW are set as the configuration, it is in any of certain
follows: bits 0-11 and 13-32 are set equal to customer-engineer test modes, or its power is
the same bits of the 16-byte PSW, bit 12 is off. The order is rejected. Condition code 3
set to one, and bits 33-63 are set equal to bits is set. This condition cannot arise as a result
97-127 of the 16-byte PSW. of a SIGNAL PROCESSOR instruction exe-
cuted by a CPU addressing itself.
The ALBs and TLBs of all CPUs in the config-
uration are cleared of their contents. 3. One of the following conditions exists at the
addressed CPU:
A serializing and checkpoint-synchronizing
function is performed on all CPUs in the con- a. A previously issued start, stop, restart,
figuration. stop-and-store-status, set-prefix, or store-
status-at-address order has been
If the order changes the architectural mode from
accepted by the addressed CPU, and exe-
z/Architecture to ESA/390 and the SIGNAL
cution of the function requested by the
PROCESSOR instruction causes occurrence of an
order has not yet been completed.
instruction-fetching PER event, only the rightmost
31 bits of the address of the instruction are stored b. A manual start, stop, restart, or store-
in the ESA/390 PER-address field. status function has been initiated at the
addressed CPU, and the function has not
Programming Notes: yet been completed. This condition
1. If the set-architecture order changes the archi- cannot arise as a result of a SIGNAL
tectural mode from z/Architecture to ESA/390 PROCESSOR instruction executed by a
and bit 31 of the PSW is one, the PSW is CPU addressing itself.
invalid. If the currently specified order is sense,
2. For a discussion on the relative performance external call, emergency signal, start, stop,
of the SIGNAL PROCESSOR orders, see the restart, stop and store status, set prefix, store
programming note following the instruction status at address, or set architecture, then the
SIGNAL PROCESSOR in Chapter 10, order is rejected, and condition code 2 is set.
Control Instructions. If the currently specified order is one of the
reset orders, or an unassigned or not-
implemented order, the order code is inter-
Conditions Determining preted as described in Status Bits on
Response page 4-54.
4. One of the following conditions exists at the
Conditions Precluding Interpretation of addressed CPU:
the Order Code
The following situations preclude the initiation of a. A previously issued initial-CPU-reset or
the order. The sequence in which the situations CPU-reset order has been accepted by
are listed is the order of priority for indicating con- the addressed CPU, and execution of the
currently existing situations: function requested by the order has not
yet been completed.
1. The access path to the addressed CPU is
busy because a concurrently executed b. A manual-reset function has been initiated
SIGNAL PROCESSOR is using the at the addressed CPU, and the function
CPU-signaling-and-response facility. The has not yet been completed. This condi-
CPU which is concurrently executing the tion cannot arise as a result of a SIGNAL
PROCESSOR by a CPU addressing itself.

Chapter 4. Control 4-53


If the currently specified order is sense,
external call, emergency signal, start, stop, Bit
restart, stop and store status, set prefix, store Position Status Condition

status at address, or set architecture, then the 32 Equipment check
order is rejected, and condition code 2 is set. 33-53 Unassigned; zeros stored
If the currently specified order is one of the 54 Incorrect state
reset orders, or an unassigned or not- 55 Invalid parameter
implemented order, either the order is rejected 56 External-call pending
57 Stopped
and condition code 2 is set or the order code 58 Operator intervening
is interpreted as described in Status Bits. 59 Check stop
When any of the conditions described in items 3 6 Unassigned; zero stored
61 Inoperative
and 4 exists, the addressed CPU is referred to as 62 Invalid order
busy. Busy is not indicated if the addressed CPU 63 Receiver check
is in the check-stop state or when the operator-
intervening condition exists. A CPU-busy condi- Figure 4-14. Status Conditions
tion is normally of short duration; however, the
conditions described in item 3 may last indefinitely The status condition assigned to bit position 32,
because of a string of interruptions. In this situ- and to bit position 55 when the order is set archi-
ation, however, the CPU does not appear busy to tecture, are generated by the CPU executing
any of the reset orders. SIGNAL PROCESSOR. The remaining status
conditions are generated by the addressed CPU.
When the conditions described in items 1 and 2
above do not apply and operator-intervening and When the invalid-parameter condition exists for
receiver-check status conditions do not exist at the the set-architecture order, bit 55 of the general
addressed CPU, reset orders may be accepted register designated by the R field of the SIGNAL
regardless of whether the addressed CPU has PROCESSOR instruction is set to one, all other
completed a previously accepted order. This may bits in bit positions 32-63 are set to zeros, bits
cause the previous order to be lost when it is only 0-31 of the register remain unchanged, and condi-
partially completed, making unpredictable whether tion code 1 is set. No other action is taken.
the results defined for the lost order are obtained.
When the equipment-check condition exists,
Status Bits except when the invalid-parameter condition exists
Various status conditions are defined whereby the for the set-architecture order, bit 32 of the general
issuing and addressed CPUs can indicate their register designated by the R field of the SIGNAL
responses to the specified order. The status con- PROCESSOR instruction is set to one, unas-
ditions and their bit positions in the general reg- signed bits in bit positions 32-63 of the status reg-
ister designated by the R field of the SIGNAL ister are set to zeros, the other status bits are
PROCESSOR instruction are shown in unpredictable, and bits 0-31 of the register remain
Figure 4-14. unchanged. In this case, condition code 1 is set
independent of whether the access path to the
addressed CPU is busy and independent of
whether the addressed CPU is not operational, is
busy, or has presented zero status.

When the access path to the addressed CPU is


not busy and the addressed CPU is operational
and does not indicate busy to the currently speci-
fied order, the addressed CPU presents its status
to the issuing CPU. These status bits are of two
types:
1. Status bits 54, 55 when the order is not set
architecture, 56-59, and 61 indicate the pres-
ence of the corresponding conditions in the

4-54 z/Architecture Principles of Operation


addressed CPU at the time the order code is architecture order has been rejected because not
received. Except in response to the sense all other CPUs are stopped or in the check-stop
order, each condition is indicated only when state. When applicable, this status is generated
the condition precludes the successful exe- during execution of SIGNAL PROCESSOR and is
cution of the specified order, although invalid indicated concurrently with other indications of
parameter is not necessarily indicated when conditions which preclude execution of the order,
any other precluding condition exists. In the except that this status is not generated if an
case of sense, all existing status conditions invalid-parameter condition exists for a set-
are indicated; the operator-intervening condi- architecture order.
tion is indicated if it precludes the execution of
any installed order. Invalid Parameter: This condition exists in two
cases:
2. Status bits 62 and 63 indicate that the corre-
sponding conditions were detected by the 1. The parameter value supplied with a set-prefix
addressed CPU during reception of the order. or store-status-at-address order designates a
storage location which is not available in the
If the presented status is all zeros, the addressed
configuration. When applicable, this status is
CPU has accepted the order, and condition code
generated during execution of SIGNAL
0 is set at the issuing CPU; if the presented status
PROCESSOR, except that it is not necessarily
is not all zeros, the order has been rejected, the
generated when another condition precluding
status is stored at the issuing CPU in the general
execution of the order also exists.
register designated by the R field of the SIGNAL
PROCESSOR instruction, zeros are stored in the 2. The parameter value supplied with a set-
unassigned positions in bit positions 32-63 of the architecture order either is not zero or one or
register, bits 0-31 of the register remain specifies the current architectural mode.
unchanged, and condition code 1 is set. When applicable, this status is generated
during execution of SIGNAL PROCESSOR,
When the order is set architecture, the addressed and no other status is generated.
CPU refers to each of the other CPUs in the con-
figuration. Those CPUs, in an unpredictable External Call Pending: This condition exists
order, are tested for a condition that causes when an external-call interruption condition is
setting of condition code 1, 2, or 3. Conditions pending in the addressed CPU because of a pre-
are prioritized for a single CPU as if it were the viously issued SIGNAL PROCESSOR order. The
only CPU addressed, but there is no prioritization condition exists from the time an external-call
across CPUs. If a condition is recognized, no order is accepted until the resultant external inter-
further CPUs are tested, the condition code corre- ruption has been completed or a CPU reset
sponding to the condition is set, and the execution occurs. The condition may be due to the issuing
of SIGNAL PROCESSOR is completed. CPU or another CPU. The condition, when
present, is indicated only in response to sense
The status conditions are defined as follows: and to external call.

Equipment Check: This condition exists when Stopped: This condition exists when the
the CPU executing the instruction detects equip- addressed CPU is in the stopped state. The con-
ment malfunctioning that has affected only the dition, when present, is indicated only in response
execution of this instruction and the associated to sense. This condition cannot be reported as a
order. The order code may or may not have been result of a SIGNAL PROCESSOR by a CPU
transmitted and may or may not have been addressing itself.
accepted, and the status bits provided by the
addressed CPU may be in error. This condition is Operator Intervening: This condition exists
not detected if the invalid-parameter condition for when the addressed CPU is executing certain
the set-architecture order is detected. operations initiated from local or remote operator
facilities. The particular manually initiated oper-
Incorrect State: A set-prefix or store-status-at- ations that cause this condition to be present
address order has been rejected because the depend on the model and on the order specified.
addressed CPU is not stopped, or a set- The operator-intervening condition may exist when

Chapter 4. Control 4-55


the addressed CPU uses reloadable control The following chart summarizes which status con-
storage to perform an order and the required ditions are presented to the issuing CPU in
licensed internal code has not been loaded by the response to each order code.
IML function. The operator-intervening condition, Status Condition
when present, can be indicated in response to all
orders. Operator intervening is indicated in 63 Receiver check
response to sense if the condition is present and 62 Invalid order
precludes the acceptance of any of the installed 61 Inoperative
59 Check stop
orders. The condition may also be indicated in 58 Operator intervening#
response to unassigned or uninstalled orders. 57 Stopped
This condition cannot arise as a result of a 56 External call pending
SIGNAL PROCESSOR by a CPU addressing 55 Invalid parameter
itself. 54 Incorrect state


Check Stop: This condition exists when the Order
addressed CPU is in the check-stop state. The 6 6 6 6 6 6 6 6 6
condition, when present, is indicated only in Sense X X X X X
response to sense, external call, emergency External call X X X X
signal, start, stop, restart, set prefix, store status Emergency signal X X X
at address, and stop and store status. The condi- Start X X X X
Stop X X X X
tion may also be indicated in response to unas- Restart X X X X
signed or uninstalled orders. This condition Stop and store status X X X X
cannot be reported as a result of a SIGNAL Initial CPU reset X X X
PROCESSOR instruction executed by a CPU CPU reset X X X
addressing itself. Set prefix X X X X X X
Store status at addr. X X X X X X
Set architecture X X X X X
Inoperative: This condition indicates that the Unassigned order X E X 1 X
execution of the operation specified by the order
code requires the use of a service processor Explanation:
which is inoperative. The failure of the service
processor may have been previously reported by # The current state of the operator-intervening
a service-processor-damage machine-check con- condition may depend on the order code that
dition. The inoperative condition cannot occur for is being interpreted.
the sense, external-call, or emergency-signal order If a one is presented in the receiver-check bit
code. position, the values presented in the other bit
positions are not necessarily valid.
Invalid Order: This condition exists during the
communications associated with the execution of 0 A zero is presented in this bit position regard-
SIGNAL PROCESSOR when an unassigned or less of the current state of this condition.
uninstalled order code is decoded. 1 A one is presented in this bit position.

Receiver Check: This condition exists when the X A zero or a one is presented in this bit posi-
addressed CPU detects malfunctioning of equip- tion, reflecting the current state of the corre-
ment during the communications associated with sponding condition.
the execution of SIGNAL PROCESSOR. When E Either a zero or the current state of the corre-
this condition is indicated, the order has not been sponding condition is indicated.
initiated, and, since the malfunction may have
If the presented status bits are all zeros, the order
affected the generation of the remaining receiver
has been accepted, and the issuing CPU sets
status bits, these bits are not necessarily valid. A
condition code 0. If one or more ones are pre-
machine-check condition may or may not have
sented, the order has been rejected, and the
been generated at the addressed CPU.
issuing CPU stores the status in the general reg-
ister designated by the R field of the SIGNAL

4-56 z/Architecture Principles of Operation


PROCESSOR instruction and sets condition code e. Restart provides a means to store the
1. current PSW.
f. Stop and store status causes the machine
Programming Notes:
to stop and store all current status.
1. All SIGNAL PROCESSOR orders except set
2. Two CPUs can simultaneously execute
architecture (which in effect is addressed to all
SIGNAL PROCESSOR, with each CPU
other CPUs and affects all CPUs) can be
addressing the other. When this occurs, one
addressed to this same CPU. The following
CPU, but not both, can find the access path
are examples of functions obtained by a CPU
busy because of the transmission of the order
addressing SIGNAL PROCESSOR to itself:
code or status bits associated with SIGNAL
a. Sense indicates whether an external-call PROCESSOR that is being executed by the
condition is pending. other CPU. Alternatively, both CPUs can find
b. External call and emergency signal cause the access path available and transmit the
the corresponding interruption conditions order codes to each other. In particular, two
to be generated. External call can be CPUs can simultaneously stop, restart, or
rejected because of a previously gener- reset each other.
ated external-call condition. 3. To obtain status from another CPU which is in
c. Start sets condition code 0 and has no the check-stop state by means of the store-
other effect. status-at-address order, a CPU reset opera-
tion should first be used to bring the CPU to
d. Stop causes the CPU to set condition the stopped state. This reset order does not
code 0, take pending interruptions for alter the status, and, depending on the nature
which it is enabled, and enter the stopped of the malfunction, provides the best chance
state. of establishing conditions in the addressed
CPU which allow status to be obtained.

Chapter 4. Control 4-57


4-58 z/Architecture Principles of Operation
Chapter 5. Program Execution
Instructions . . . . . . . . . . . . . . . . . . . . 5-2 PC-Number Translation Control . . . . . . 5-29
Operands . . . . . . . . . . . . . . . . . . . 5-2 Control Register 5 . . . . . . . . . . . . . 5-29
Instruction Formats . . . . . . . . . . . . . . 5-3 PC-Number Translation Tables . . . . . . . 5-29
Register Operands . . . . . . . . . . . . 5-6 Linkage-Table Entries . . . . . . . . . . 5-29
Immediate Operands . . . . . . . . . . . 5-6 Entry-Table Entries . . . . . . . . . . . . 5-30
Storage Operands . . . . . . . . . . . . 5-6 PC-Number-Translation Process . . . . . . 5-31
Address Generation . . . . . . . . . . . . . . . 5-7 Obtaining the Linkage-Table
Trimodal Addressing . . . . . . . . . . . . . 5-7 Designation . . . . . . . . . . . . . . 5-32
Sequential Instruction-Address Generation . 5-7 Linkage-Table Lookup . . . . . . . . . . 5-33
Operand-Address Generation . . . . . . . 5-7 Entry-Table Lookup . . . . . . . . . . . . 5-33
Formation of the Intermediate Value . . 5-7 Recognition of Exceptions during
Formation of the Operand Address . . . 5-8 PC-Number Translation . . . . . . . 5-33
Branch-Address Generation . . . . . . . . 5-8 Home Address Space . . . . . . . . . . . . . 5-34
Formation of the Intermediate Value . . 5-8 Access-Register Introduction . . . . . . . . . . 5-34
Formation of the Branch Address . . . . 5-9 Summary . . . . . . . . . . . . . . . . . . . 5-35
Instruction Execution and Sequencing . . . . 5-9 Access-Register Functions . . . . . . . . . 5-35
Decision Making . . . . . . . . . . . . . . . 5-10 Access-Register-Specified Address
Loop Control . . . . . . . . . . . . . . . . . 5-10 Spaces . . . . . . . . . . . . . . . . . 5-35
Subroutine Linkage without the Linkage Access-Register Instructions . . . . . . 5-42
Stack . . . . . . . . . . . . . . . . . . . 5-10 Access-Register Translation . . . . . . . . . . 5-43
Simple Branch Instructions . . . . . . . 5-10 Access-Register-Translation Control . . . . 5-43
Other Linkage Instructions . . . . . . . . 5-14 Control Register 2 . . . . . . . . . . . . . 5-43
Interruptions . . . . . . . . . . . . . . . . . . 5-19 Control Register 5 . . . . . . . . . . . . . 5-43
Types of Instruction Ending . . . . . . . . . 5-19 Control Register 8 . . . . . . . . . . . . . 5-43
Completion . . . . . . . . . . . . . . . . . 5-19 Access Registers . . . . . . . . . . . . . . . 5-44
Suppression . . . . . . . . . . . . . . . . 5-19 Access-Register-Translation Tables . . . . 5-44
Nullification . . . . . . . . . . . . . . . . . 5-20 Dispatchable-Unit Control Table and
Termination . . . . . . . . . . . . . . . . 5-20 Access-List Designations . . . . . . 5-45
Interruptible Instructions . . . . . . . . . . . 5-20 Access-List Entries . . . . . . . . . . . . 5-46
Point of Interruption . . . . . . . . . . . . 5-20 ASN-Second-Table Entries . . . . . . . 5-47
Unit of Operation . . . . . . . . . . . . . 5-20 Access-Register-Translation Process . . . 5-48
Execution of Interruptible Instructions . 5-20 Selecting the Access-List-Entry Token . 5-51
Condition-Code Alternative to Obtaining the Primary or Secondary
Interruptibility . . . . . . . . . . . . . 5-21 Address-Space-Control Element . . 5-51
Exceptions to Nullification and Checking the First Byte of the ALET . . 5-51
Suppression . . . . . . . . . . . . . . . 5-22 Obtaining the Effective Access-List
Storage Change and Restoration for Designation . . . . . . . . . . . . . . 5-51
DAT-Associated Access Exceptions 5-22 Access-List Lookup . . . . . . . . . . . . 5-51
Modification of DAT-Table Entries . . . 5-23 Locating the ASN-Second-Table Entry . 5-52
Trial Execution for Editing Instructions Authorizing the Use of the Access-List
and Translate Instruction . . . . . . 5-23 Entry . . . . . . . . . . . . . . . . . . 5-52
Authorization Mechanisms . . . . . . . . . . . 5-23 Checking for Access-List-Controlled
Mode Requirements . . . . . . . . . . . 5-24 Protection . . . . . . . . . . . . . . . 5-53
Extraction-Authority Control . . . . . . . 5-24 Obtaining the Address-Space-Control
PSW-Key Mask . . . . . . . . . . . . . . 5-24 Element from the ASN-Second-Table
Secondary-Space Control . . . . . . . . 5-25 Entry . . . . . . . . . . . . . . . . . . 5-53
Subsystem-Linkage Control . . . . . . . 5-25 Recognition of Exceptions during
ASN-Translation Control . . . . . . . . . 5-25 Access-Register Translation . . . . 5-53
Authorization Index . . . . . . . . . . . . 5-25 ART-Lookaside Buffer . . . . . . . . . . . . 5-53
PC-Number Translation . . . . . . . . . . . . . 5-29 ALB Structure . . . . . . . . . . . . . . . 5-53

Copyright IBM Corp. 1990, 2000 5-1


Formation of ALB Entries . . . . . . . . 5-54 Unstacking Process . . . . . . . . . . . . . 5-75
Use of ALB Entries . . . . . . . . . . . . 5-54 Locating the Current Entry and
Modification of ART Tables . . . . . . . 5-55 Processing a Header Entry . . . . . 5-75
Subspace Groups . . . . . . . . . . . . . . . . 5-55 Checking for a State Entry . . . . . . . . 5-76
Subspace-Group Tables . . . . . . . . . . 5-55 Restoring Information . . . . . . . . . . . 5-76
Subspace-Group Dispatchable-Unit Updating the Preceding Entry . . . . . . 5-77
Control Table . . . . . . . . . . . . . 5-55 Updating Control Register 15 . . . . . . 5-77
Subspace-Group ASN-Second-Table Recognition of Exceptions during the
Entries . . . . . . . . . . . . . . . . . 5-57 Unstacking Process . . . . . . . . . 5-77
Subspace-Replacement Operations . . . . 5-59 Sequence of Storage References . . . . . . . 5-77
Linkage-Stack Introduction . . . . . . . . . . . 5-60 Conceptual Sequence . . . . . . . . . . 5-77
Summary . . . . . . . . . . . . . . . . . . . 5-60 Overlapped Operation of Instruction
Linkage-Stack Functions . . . . . . . . . . 5-60 Execution . . . . . . . . . . . . . . . 5-78
Transferring Program Control . . . . . . 5-60 Divisible Instruction Execution . . . . . . 5-78
Branching Using the Linkage Stack . . 5-62 Interlocks for Virtual-Storage References . 5-79
Adding and Retrieving Information . . . 5-63 Interlocks between Instructions . . . . . 5-79
Testing Authorization . . . . . . . . . . . 5-63 Interlocks within a Single Instruction . . 5-80
Program-Problem Analysis . . . . . . . . 5-64 Instruction Fetching . . . . . . . . . . . . . 5-81
Linkage-Stack Entry-Table Entries . . . . . . 5-64 ART-Table and DAT-Table Fetches . . . . 5-83
Linkage-Stack Operations . . . . . . . . . . . 5-65 Storage-Key Accesses . . . . . . . . . . . 5-83
Linkage-Stack-Operations Control . . . . . 5-67 Storage-Operand References . . . . . . . 5-84
Control Register 15 . . . . . . . . . . . . 5-67 Storage-Operand Fetch References . . 5-84
Linkage Stack . . . . . . . . . . . . . . . . . 5-67 Storage-Operand Store References . . 5-84
Entry Descriptors . . . . . . . . . . . . . 5-67 Storage-Operand Update References . 5-85
Header Entries . . . . . . . . . . . . . . 5-69 Storage-Operand Consistency . . . . . . . 5-86
Trailer Entries . . . . . . . . . . . . . . . 5-69 Single-Access References . . . . . . . . 5-86
State Entries . . . . . . . . . . . . . . . . 5-70 Multiple-Access References . . . . . . . 5-86
Stacking Process . . . . . . . . . . . . . . . 5-72 Block-Concurrent References . . . . . . 5-87
Locating Space for a New Entry . . . . 5-72 Consistency Specification . . . . . . . . 5-87
Forming the New Entry . . . . . . . . . . 5-73 Relation between Operand Accesses . . . 5-88
Updating the Current Entry . . . . . . . 5-74 Other Storage References . . . . . . . . . 5-89
Updating Control Register 15 . . . . . . 5-74 Serialization . . . . . . . . . . . . . . . . . . . 5-89
Recognition of Exceptions during the CPU Serialization . . . . . . . . . . . . . . 5-89
Stacking Process . . . . . . . . . . . 5-74 Channel-Program Serialization . . . . . . . 5-91

Normally, operation of the CPU is controlled by Operands


instructions in storage that are executed sequen-
tially, one at a time, left to right in an ascending Operands can be grouped in three classes: oper-
sequence of storage addresses. A change in the ands located in registers, immediate operands,
sequential operation may be caused by branching, and operands in storage. Operands may be either
LOAD PSW, interruptions, SIGNAL PROCESSOR explicitly or implicitly designated.
orders, or manual intervention.
Register operands can be located in general,
floating-point, access, or control registers, with the
Instructions type of register identified by the op code. The
Each instruction consists of two major parts: register containing the operand is specified by
identifying the register in a four-bit field, called the
An operation code (op code), which specifies R field, in the instruction. For some instructions,
the operation to be performed an operand is located in an implicitly designated
The designation of the operands that partic- register, the register being implied by the op code.
ipate

5-2 z/Architecture Principles of Operation


Immediate operands are contained within the When the CPU is in the access-register mode, a B
instruction, and the 8-bit, 16-bit, or 32-bit field con- or R field may designate an access register in
taining the immediate operand is called the I field. addition to being used to specify an address.

Operands in storage may have an implied length; To describe the execution of instructions, oper-
be specified by a bit mask; be specified by a ands are designated as first and second operands
four-bit or eight-bit length specification, called the and, in some cases, third operands.
L field, in the instruction; or have a length speci-
fied by the contents of a general register. The In general, two operands participate in an instruc-
addresses of operands in storage are specified by tion execution, and the result replaces the first
means of a format that uses the contents of a operand. However, CONVERT TO DECIMAL,
general register as part of the address. This TEST BLOCK, and instructions with store in the
makes it possible to: instruction name (other than STORE THEN AND
SYSTEM MASK and STORE THEN OR SYSTEM
1. Specify a complete address by using an
MASK) use the second-operand address to desig-
abbreviated notation
nate a location in which to store. TEST AND
2. Perform address manipulation using SET, COMPARE AND SWAP, and COMPARE
instructions which employ general registers for DOUBLE AND SWAP may perform an update on
operands the second operand. Except when otherwise
stated, the contents of all registers and storage
3. Modify addresses by program means without
locations participating in the addressing or exe-
alteration of the instruction stream
cution part of an operation remain unchanged.
4. Operate independent of the location of data
areas by directly using addresses received
from other programs
Instruction Formats
The address used to refer to storage either is con- An instruction is one, two, or three halfwords in
tained in a register designated by the R field in the length and must be located in storage on a
instruction or is calculated from a base address, halfword boundary. Each instruction is in one of
index, and displacement, specified by the B, X, 17 basic formats: E, RR, RRE, RRF, RX, RXE,
and D fields, respectively, in the instruction. RXF, RS, RSE, RSI, RI, RIE, RIL, SI, S, SSE, and
SS, with three variations of RRF, two of RS and
RSE, and four of SS. (See Figure 5-1 on
page 5-4.)

Chapter 5. Program Execution 5-3


RS Format (Continued)
E Format
Op Code R M B D
Op Code
8 12 16 2 31
15
RSE Format
RR Format /
Op Code R R B D ////////Op Code
Op Code R R /
8 12 16 2 32 4 47
8 12 15
/
RRE Format Op Code R M B D ////////Op Code
/
Op Code //////// R R 8 12 16 2 32 4 47

16 24 28 31 RSI Format

RRF Format Op Code R R I

Op Code R //// R R 8 12 16 31

16 2 24 28 31 RI Format

Op Code R OpCd I
Op Code M //// R R
8 12 16 31
16 2 24 28 31
RIE Format
/
Op Code R M R R Op Code R R I ////////Op Code
/
16 2 24 28 31 8 12 16 32 4 47

RX Format RIL Format


/
Op Code R X B D Op Code R OpCd I
/
8 12 16 2 31 8 12 16 47

RXE Format SI Format


/
Op Code R X B D ////////Op Code Op Code I B D
/
8 12 16 2 32 4 47 8 16 2 31

RXF Format S Format


/
Op Code R X B D R ////Op Code Op Code B D
/
8 12 16 2 32 36 4 47 16 2 31

RS Format SS Format
//
Op Code R R B D Op Code L B D B D
//
8 12 16 2 31 8 16 2 32 36 47
Figure 5-1 (Part 1 of 3). Basic Instruction Formats Figure 5-1 (Part 2 of 3). Basic Instruction Formats

5-4 z/Architecture Principles of Operation


SS Format (Continued) RI denotes a register-and-immediate operation
// having an extended op-code field.
Op Code L L B D B D RIE denotes a register-and-immediate opera-
//
8 12 16 2 32 36 47 tion having a longer extended op-code field.
RIL denotes a register-and-immediate opera-
// tion having an extended op-code field and a
Op Code R R B D B D longer immediate field.
// SI denotes a storage-and-immediate opera-
8 12 16 2 32 36 47
tion.
// S denotes an operation using an implied
Op Code R R B D B D operand and storage.
// SS denotes a storage-and-storage operation.
8 12 16 2 32 36 47 SSE denotes a storage-and-storage operation
having an extended op-code field.
SSE Format
// In the RR, RX, RS, RSI, SI, and SS formats, the
Op Code B D B D first byte of an instruction contains the op code.
//
16 2 32 36 47 In the E, RRE, RRF, S, and SSE formats, the first
two bytes of an instruction contain the op code,
Figure 5-1 (Part 3 of 3). Basic Instruction Formats except that for some instructions in the S format,
all or a portion of the second byte is ignored. In
Some instructions contain fields that vary slightly the RI and RIL formats, the op code is in the first
from the basic format, and in some instructions byte and bits 12-15 of an instruction. In the RXE,
the operation performed does not follow the RXF, RSE, and RIE formats, the op code is in the
general rules stated in this section. All of these first byte and bits 40-47 of an instruction.
exceptions are explicitly identified in the individual
instruction descriptions. The first two bits of the first or only byte of the op
code specify the length and format of the instruc-
The format names indicate, in general terms, the tion, as follows:
classes of operands which participate in the oper-
ation:
Bit Instruction
E denotes an operation using implied oper- Positions Length (in Instruction
ands and having an extended op-code field. -1 Halfwords) Format

RR denotes a register-and-register operation.
One E/RR
RRE denotes a register-and-register operation 1 Two RX
having an extended op-code field. 1 Two RRE/RRF/RX/RS/RSI/RI/
RRF denotes a register-and-register operation SI/S
having an extended op-code field and an addi- 11 Three RXE/RXF/RSE/RIE/RIL/
tional R field, M field, or both. SS/SSE

RX denotes a register-and-indexed-storage
operation. In the format illustration for each individual instruc-
RXE denotes a register-and-indexed-storage tion description, the op-code field or fields show
operation having an extended op-code field. the op code as hexadecimal digits within single
RXF denotes a register-and-indexed-storage quotes. The hexadecimal representation uses 0-9
operation having an extended op-code field for the binary codes 0000-1001 and A-F for the
and an additonal R field. binary codes 1010-1111.
RS denotes a register-and-storage operation.
RSE denotes a register-and-storage operation The remaining fields in the format illustration for
having an extended op-code field. each instruction are designated by code names,
RSI denotes a register-and-immediate opera- consisting of a letter and possibly a subscript
tion. number. The subscript number denotes the
operand to which the field applies.

Chapter 5. Program Execution 5-5


Register Operands operand, which is 32 or 64 bits in length,
In the RR, RRE, RRF, RX, RXE, RXF, RS, RSE, depending on the instruction. For the instruction
RSI, RI, RIE, and RIL formats, the contents of the TEST UNDER MASK (TMHH, TMHL, TMLH,
register designated by the R field are called the TMLL), the contents of the I field are used as a
first operand. The register containing the first mask, and the R field specifies the first operand,
operand is sometimes referred to as the first- which is 64 bits in length. For the instructions
operand location, and sometimes as register R. INSERT IMMEDIATE, AND IMMEDIATE, OR
In the RR, RRE, and RRF formats, the R field IMMEDIATE, and LOAD LOGICAL IMMEDIATE,
designates the register containing the second the contents of the I field are used as an
operand, and the R field may designate the same unsigned binary integer or a logical value, and the
register as R. In the RRF, RXF, RS, RSE, RSI, R field specifies the first operand, which is 64
and RIE formats, the use of the R field depends bits in length.
on the instruction. In the RS and RSE formats,
the R field may instead be an M field specifying For the relative-branch instructions in the RI and
a mask. RSI formats, the contents of the 16-bit I field are
used as a signed binary integer designating a
The R field designates a general or access reg- number of halfwords. This number, when added
ister in the general instructions, a general register to the address of the branch instruction, specifies
in the control instructions, and a floating-point reg- the branch address. In the RIL format, the I field
ister in the floating-point instructions. However, in is 32 bits and is used in the same way.
the instructions EXTRACT STACKED REGIS-
TERS and LOAD ADDRESS EXTENDED, the R Storage Operands
field designates both a general register and an The use of B and R fields to designate access
access register, and, in the instructions LOAD registers to refer to storage operands is described
CONTROL and STORE CONTROL, the R field in Access-Register-Specified Address Spaces on
designates a control register. (This paragraph page 5-35.
refers only to register operands, not to the use of
access registers in addressing storage operands.) In the SI, SS, and SSE formats, the contents of
the general register designated by the B field are
For access and floating-point registers, unless oth- added to the contents of the D field to form the
erwise indicated in the individual instruction first-operand address. In the RS, RSE, S, SS,
description, the register operand is one register in and SSE formats, the contents of the general reg-
length (32 bits for an access register and 64 bits ister designated by the B field are added to the
for a floating-point register), and the second contents of the D field to form the second-
operand is the same length as the first. For operand address. In the RX, RXE, and RXF
general and control registers, the register operand formats, the contents of the general registers des-
is in bit positions 32-63 of the 64-bit register or ignated by the X and B fields are added to the
occupies the entire register, depending on the contents of the D field to form the second-
instruction. operand address.

Immediate Operands When a general register contains a 24-bit or 32-bit


In the SI format, the contents of the eight-bit length of a storage operand, the length is an
immediate-data field, the I field of the instruction, unsigned binary integer, except that it is signed for
are used directly as the second operand. The B COMPARE UNTIL SUBSTRING EQUAL, with a
and D fields specify the first operand, which is negative value treated as zero. Similarly, the con-
one byte in length. tents of an L, L, or L field of an instruction are
an unsigned binary integer.
In the RI format for the instructions ADD
HALFWORD IMMEDIATE, COMPARE In the SS format with a single, eight-bit length
HALFWORD IMMEDIATE, LOAD HALFWORD field, L specifies the number of additional operand
IMMEDIATE, and MULTIPLY HALFWORD IMME- bytes to the right of the byte designated by the
DIATE, the contents of the 16-bit I field of the first-operand address. Therefore, the length in
instruction are used directly as a signed binary bytes of the first operand is 1-256, corresponding
integer, and the R field specifies the first to a length code in L of 0-255. Storage results

5-6 z/Architecture Principles of Operation


replace the first operand and are never stored addressing mode, and 24-bit instruction and
outside the field specified by the address and operand effective addresses are generated.
length. In this format, the second operand has the When bit 31 of the current PSW is zero and bit 32
same length as the first operand, except for the is one, the CPU is in the 31-bit addressing mode,
following instructions: EDIT, EDIT AND MARK, and 31-bit instruction and operand effective
TRANSLATE, and TRANSLATE AND TEST. addresses are generated. When bits 31 and 32 of
the current PSW are both one, the CPU is in the
In the SS format with two length fields, L speci- 64-bit addressing mode, and 64-bit instruction and
fies the number of additional operand bytes to the operand effective addresses are generated.
right of the byte designated by the first-operand
address. Therefore, the length in bytes of the first Execution of instructions by the CPU involves gen-
operand is 1-16, corresponding to a length code in eration of the addresses of instructions and oper-
L of 0-15. Similarly, L specifies the number of ands. This section describes address generation
additional operand bytes to the right of the as it applies to most instructions. In some
location designated by the second-operand instructions, the operation performed does not
address. Results replace the first operand and follow the general rules stated in this section. All
are never stored outside the field specified by the of these exceptions are explicitly identified in the
address and length. If the first operand is longer individual instruction descriptions.
than the second, the second operand is extended
on the left with zeros up to the length of the first Sequential Instruction-Address
operand. This extension does not modify the
second operand in storage.
Generation

In the SS format with two R fields, as used by the When an instruction is fetched from the location
MOVE TO PRIMARY, MOVE TO SECONDARY, designated by the current PSW, the instruction
and MOVE WITH KEY instructions, the contents address is increased by the number of bytes in
of the general register specified by the R field are the instruction, and the instruction is executed.
a 32-bit unsigned value called the true length. The same steps are then repeated by using the
The operands are of the same length, called the new value of the instruction address to fetch the
effective length. The effective length is equal to next instruction in the sequence.
the true length or 256, whichever is less. The
In the 24-bit addressing mode, instruction
instructions set the condition code to facilitate pro-
addresses wrap around, with the halfword at
gramming a loop to move the total number of
instruction address 2 - 2 being followed by the
bytes specified by the true length. The SS format
halfword at instruction address 0. Thus, in the
with two R fields is also used to specify a range of
24-bit addressing mode, any carry out of PSW bit
registers and two storage operands by the LOAD
position 104, as a result of updating the instruction
MULTIPLE DISJOINT instruction and to specify
address, is lost. In the 31-bit or 64-bit addressing
one or two registers and one or two storage oper-
mode, instruction addresses similarly wrap around,
ands by the PERFORM LOCKED OPERATION
with the halfword at instruction address 2 - 2 or
instruction.
2 - 2, respectively, followed by the halfword at
instruction address 0. A carry out of PSW bit
position 97 or 64, respectively, is lost.
Address Generation
Operand-Address Generation
Trimodal Addressing
Bits 31 and 32 of the current PSW are the
Formation of the Intermediate Value
An operand address that refers to storage is
addressing-mode bits. Bit 31 is the extended-
derived from an intermediate value, which either is
addressing-mode bit, and bit 32 is the basic-
contained in a register designated by an R field in
addressing-mode bit. These bits control the size
the instruction or is calculated from the sum of
of the effective address produced by address gen-
three binary numbers: base address, index, and
eration. When bits 31 and 32 of the current PSW
displacement.
both are zeros, the CPU is in the 24-bit

Chapter 5. Program Execution 5-7


The base address (B) is a 64-bit number con- the register contents are used as the 64-bit inter-
tained in a general register specified by the mediate value.
program in a four-bit field, called the B field, in the
instruction. Base addresses can be used as a An instruction can designate the same general
means of independently addressing each program register both for address computation and as the
and data area. In array-type calculations, it can location of an operand. Address computation is
designate the location of an array, and, in record- completed before registers, if any, are changed by
type processing, it can identify the record. The the operation.
base address provides for addressing the entire
storage. The base address may also be used for Unless otherwise indicated in an individual instruc-
indexing. tion definition, the generated operand address
designates the leftmost byte of an operand in
The index (X) is a 64-bit number contained in a storage.
general register designated by the program in a
four-bit field, called the X field, in the instruction. Formation of the Operand Address
It is included only in the address specified by the The generated operand address is always 64 bits
RX-, RXE-, and RXF-format instructions. The long, and the bits are numbered 0-63. The
RX-, RXE-, and RXF-format instructions permit manner in which the generated address is
double indexing; that is, the index can be used to obtained from the intermediate value depends on
provide the address of an element within an array. the current addressing mode. In the 24-bit
addressing mode, bits 0-39 of the intermediate
The displacement (D) is a 12-bit number con- value are ignored, bits 0-39 of the generated
tained in a field, called the D field, in the instruc- address are forced to be zeros, and bits 40-63 of
tion. The displacement provides for relative the intermediate value become bits 40-63 of the
addressing of up to 4,095 bytes beyond the generated address. In the 31-bit addressing
location designated by the base address. In mode, bits 0-32 of the intermediate value are
array-type calculations, the displacement can be ignored, bits 0-32 of the generated address are
used to specify one of many items associated with forced to be zero, and bits 33-63 of the interme-
an element. In the processing of records, the dis- diate value become bits 33-63 of the generated
placement can be used to identify items within a address. In the 64-bit addressing mode, bits 0-63
record. of the intermediate value become bits 0-63 of the
generated address.
In forming the intermediate sum, the base address
and index are treated as 64-bit binary integers. Programming Note: Negative values may be
The displacement is similarly treated as a 12-bit used in index and base-address registers. Bits
unsigned binary integer, and 42 zero bits are 0-32 of these values are ignored in the 31-bit
appended on the left. The three are added as addressing mode, and bits 0-39 are ignored in the
64-bit binary numbers, ignoring overflow. The 24-bit addressing mode.
sum is always 64 bits long and is used as an
intermediate value to form the generated address. Branch-Address Generation
The bits of the intermediate value are numbered
0-63. Formation of the Intermediate Value
For branch instructions, the address of the next
A zero in any of the B, B, or X fields indicates instruction to be executed when the branch is
the absence of the corresponding address compo- taken is called the branch address. Depending on
nent. For the absent component, a zero is used the branch instruction, the instruction format may
in forming the intermediate sum, regardless of the be RR, RRE, RX, RXE, RS, RSE, RSI, RI, RIE, or
contents of general register 0. A displacement of RIL.
zero has no special significance.
In the RS, RSE, RX, and RXE formats, the branch
When an instruction description specifies that the address is specified by a base address, a dis-
contents of a general register designated by an R placement, and, in the RX and RXE formats, an
field are used to address an operand in storage, index. In these formats, the generation of the
intermediate value follows the same rules as for

5-8 z/Architecture Principles of Operation


the generation of the operand-address interme- the new addressing mode is used. In the 24-bit
diate value. addressing mode, bits 0-39 of the intermediate
value are ignored, bits 0-39 of the branch address
In the RR and RRE formats, the contents of the are made zeros, and bits 40-63 of the interme-
general register designated by the R field are diate value become bits 40-63 of the branch
used as the intermediate value from which the address. In the 31-bit addressing mode, bits 0-32
branch address is formed. General register 0 of the intermediate value are ignored, bits 0-32 of
cannot be designated as containing a branch the branch address are made zeros, and bits
address. A value of zero in the R field causes 33-63 of the intermediate value become bits 33-63
the instruction to be executed without branching. of the branch address. In the 64-bit addressing
mode, bits 0-63 of the intermediate value become
The relative-branch instructions are in the RSI, RI, bits 0-63 of the branch address.
RIE, and RIL formats. In the RSI, RI, and RIE
formats for the relative-branch instructions, the For several branch instructions, branching
contents of the I field are treated as a 16-bit depends on satisfying a specified condition.
signed binary integer designating a number of When the condition is not satisfied, the branch is
halfwords. In the RIL format, the contents of the not taken, normal sequential instruction execution
I field are treated as a 32-bit signed binary continues, and the branch address is not used.
integer designating a number of halfwords. The When a branch is taken, bits 0-63 of the branch
branch address is the number of halfwords desig- address replace bits 64-127 of the current PSW.
nated by the I field added to the address of the The branch address is not used to access storage
relative-branch instruction. as part of the branch operation.

The 64-bit intermediate value for a relative branch A specification exception due to an odd branch
instruction in the RSI, RI, RIE, or RIL format is the address and access exceptions due to fetching of
sum of two addends, with overflow from bit posi- the instruction at the branch location are not
tion 0 ignored. In the RSI, RI, or RIE format, the recognized as part of the branch operation but
first addend is the contents of the I field with one instead are recognized as exceptions associated
zero bit appended on the right and 47 bits equal with the execution of the instruction at the branch
to the sign bit of the contents appended on the location.
left. In the RIL format, the first addend is the con-
tents of the I field with one zero bit appended on A branch instruction, such as BRANCH AND
the right and 31 bits equal to the sign bit of the SAVE, can designate the same general register
contents appended on the left. In all formats, the for branch-address computation and as the
second addend is the 64-bit address of the branch location of an operand. Branch-address computa-
instruction. The address of the branch instruction tion is completed before the remainder of the
is the instruction address in the PSW before that operation is performed.
address is updated to address the next sequential
instruction, or it is the address of the target of the
EXECUTE instruction if EXECUTE is used. If Instruction Execution and
EXECUTE is used in the 24-bit or 31-bit Sequencing
addressing mode, the address of the branch
instruction is the target address with 40 or 33 The program-status word (PSW), described in
zeros, respectively, appended on the left. Chapter 4, Control contains information required
for proper program execution. The PSW is used
to control instruction sequencing and to hold and
Formation of the Branch Address
indicate the status of the CPU in relation to the
The branch address is always 64 bits long, with
program currently being executed. The active or
the bits numbered 0-63. The branch addresss
controlling PSW is called the current PSW.
replaces bits 64-127 of the current PSW.
Branch instructions perform the functions of deci-
The manner in which the branch address is
sion making, loop control, and subroutine linkage.
obtained from the intermediate value depends on
A branch instruction affects instruction sequencing
the addressing mode. For those branch
by introducing a new instruction address into the
instructions which change the addressing mode,

Chapter 5. Program Execution 5-9


current PSW. The relative-branch instructions Subroutine Linkage without the
with a 16-bit I field allow branching to a location
at an offset of up to plus 64K - 2 bytes or minus
Linkage Stack
64K bytes relative to the location of the branch
This section describes only the methods for sub-
instruction, without the use of a base register.
routine linkage that do not use the linkage stack.
The relative-branch instructions with a 32-bit I
For the linkage extensions provided by the linkage
field allow branching to a location at an offset of
stack, see Linkage-Stack Introduction on
up to plus 4G - 2 bytes or minus 4G bytes rela-
page 5-60. (Those extensions include a different
tive to the location of the branch instruction,
method of operation of the PROGRAM CALL
without the use of a base register.
instruction and also the BRANCH AND STACK
and PROGRAM RETURN instructions.)
Decision Making
Simple Branch Instructions
Facilities for decision making are provided by the Subroutine linkage when a change of the
BRANCH ON CONDITION, BRANCH RELATIVE addressing mode is not required is provided by
ON CONDITION, and BRANCH RELATIVE ON the BRANCH AND LINK and BRANCH AND
CONDITION LONG instructions. These SAVE instructions. (This discussion of BRANCH
instructions inspect a condition code that reflects AND SAVE applies also to BRANCH RELATIVE
the result of a majority of the arithmetic, logical, AND SAVE and BRANCH RELATIVE AND SAVE
and I/O operations. The condition code, which LONG.) Both of these instructions permit not only
consists of two bits, provides for four possible the introduction of a new instruction address but
condition-code settings: 0, 1, 2, and 3. also the preservation of a return address and
associated information. The return address is the
The specific meaning of any setting depends on
address of the instruction following the branch
the operation that sets the condition code. For
instruction in storage, except that it is the address
example, the condition code reflects such condi-
of the instruction following an EXECUTE instruc-
tions as zero, nonzero, first operand high, equal,
tion that has the branch instruction as its target.
overflow, and subchannel busy. Once set, the
condition code remains unchanged until modified Both BRANCH AND LINK and BRANCH AND
by an instruction that causes a different condition SAVE have an R field. They form a branch
code to be set. See Appendix C, Condition-Code address by means of fields that depend on the
Settings on page C-1 for a summary of the instruction. The operations of the instructions are
instructions which set the condition code. summarized as follows:
In the 24-bit addressing mode, both
Loop Control instructions place the return address in bit
positions 40-63 of general register R and
Loop control can be performed by the use of
leave bits 0-31 of that register unchanged.
BRANCH ON CONDITION, BRANCH RELATIVE
BRANCH AND LINK places the instruction-
ON CONDITION, and BRANCH RELATIVE ON
length code for the instruction and also the
CONDITION LONG to test the outcome of
condition code and program mask from the
address arithmetic and counting operations. For
current PSW in bit positions 32-39 of general
some particularly frequent combinations of arith-
register R. BRANCH AND SAVE places
metic and tests, BRANCH ON COUNT, BRANCH
zeros in those bit positions.
ON INDEX HIGH, and BRANCH ON INDEX LOW
OR EQUAL are provided, and relative-branch In the 31-bit addressing mode, both
equivalents of these instructions are also provided. instructions place the return address in bit
These branches, being specialized, provide positions 33-63 and a one in bit position 32 of
increased performance for these tasks. general register R, and they leave bits 0-31
of the register unchanged.
In the 64-bit addressing mode, both
instructions place the return address in bit
positions 0-63 of general register R.

5-10 z/Architecture Principles of Operation


In any addressing mode, both instructions entry to the called program. If R is the same
generate the branch address under the control as R, the results in the designated general
of the current addressing mode. The register are as specified for the R register.
instructions place bits 0-63 of the branch
The operations of the simple branch instructions
address in bit positions 64-127 of the PSW.
are summarized in Figure 5-2 on page 5-12. For
In the RR format, both instructions do not
contrast, the figure also shows the BRANCH AND
perform branching if the R field of the instruc-
COUNT instruction, which is not for use in linkage,
tion is zero.
and the LOAD ADDRESS and LOAD ADDRESS
It can be seen that, in the 24-bit or 31-bit EXTENDED instructions.
addressing mode, BRANCH AND SAVE places
the basic-addressing-mode bit, bit 32 of the PSW, Programming Notes:
in bit position 32 of general register R. BRANCH 1. A called program that is entered in the 64-bit
AND LINK does so in the 31-bit addressing mode. addressing mode can use bit 63 of the entry-
point register to determine the instruction used
The instructions BRANCH AND SAVE AND SET
to perform the call and, thus, the instruction
MODE and BRANCH AND SET MODE are for
that must be used to perform the return
use when a change of the addressing mode is
linkage. If bit 63 is zero, BRANCH AND
required during linkage. These instructions have
SAVE (BAS or BASR) (or possibly BAL,
R and R fields. The operations of the
BALR, BRAS, or BRASL) was used, the
instructions are summarized as follows:
addressing mode of the caller is not indicated
BRANCH AND SAVE AND SET MODE sets in the return register, and BRANCH ON CON-
the contents of general register R the same DITION (BCR) must be used to return without
as BRANCH AND SAVE. In addition, the changing the addressing mode during the
instruction places the extended-addressing- return. If bit 63 of the entry-point register is
mode bit, bit 31 of the PSW, in bit position 63 one, BASSM or BSM was used, the
of the register. addressing mode of the caller is indicated in
the return register (or at least can be, in the
BRANCH AND SET MODE, if R is nonzero,
case of BSM), and BSM must be used to
performs as follows. In the 24- or 31-bit
return and restore the addressing mode of the
mode, it places bit 32 of the PSW in bit posi-
caller.
tion 32 of general register R, and it leaves
bits 0-31 and 33-63 of the register unchanged. 2. When BSM is executed in the 24-bit or 31-bit
Note that bit 63 of the register should be zero addressing mode and used in a forward
if the register contains an instruction address. linkage to set the 64-bit mode, and the R and
In the 64-bit mode, the instruction places bit R of the instruction are the same value, bit
31 of the PSW (a one) in bit position 63 of 63 of the designated general register does
general register R, and it leaves bits 0-62 of not, upon entry to the called program, cor-
the register unchanged. rectly indicate the mode of the calling
program. (The bit is one, instead of zero,
When R is nonzero, both instructions set the
because the program set bit 63 of the R reg-
addressing mode and perform branching as
ister to one and the instruction does not
follows. Bit 63 of general register R is
change bit 63 of the R register in the 24- or
placed in bit position 31 of the PSW. If bit 63
31-bit mode.) BASSM always correctly indi-
is zero, bit 32 of the register is placed in bit
cates the addressing mode of the calling
position 32 of the PSW. If bit 63 is one, PSW
program.
bit 32 is set to one. Then the branch address
is generated from the contents of the register, 3. If an entry point can be branched to in the
except with bit 63 of the register treated as a 64-bit addressing mode either by BAS or
zero, under the control of the new addressing BASR or by BASSM or BSM, one must be
mode. The instructions place bits 0-63 of the subtracted from the entry-point register in the
branch address in bit positions 64-127 of the BASSM or BSM case if the register is to be
PSW. Bit 63 of general register R remains named in a USING statement that provides
unchanged and, therefore, may be one upon addressability.

Chapter 5. Program Execution 5-11



Address Branch or
Placed in GR R 2nd-Op Adr.
R PSW PSW
In Bits Bit Bits Bit Bits Bits Bit Bit 31 Bit 32
Instruction Format Mode -31 32 33-62 63 -32 33-63 63 Set to Set to

BALR\/BAL RR/RX 24 U \\\ \\\ IA SIA SIA LSExc U U



31 U BAM IA IA SIA SIA LSExc U U

64 IA IA IA IA SIA SIA LSExc U U

BASR\/BAS/ RR/RX/ 24/31 U BAM IA IA SIA SIA LSExc U U
BRAS/BRASL RI/RIL
64 IA IA IA IA SIA SIA LSExc U U

BASSM\ RR 24/31 U BAM IA IA SIA SIA R232

24/31 U BAM IA IA SIA SIA 1G 1 1

64 IA IA IA 1 SIA SIA R232

64 IA IA IA 1 SIA SIA 1G 1 1

BSM\\ RR 24/31 U BAM U U SIA SIA R232

24/31 U BAM U U SIA SIA 1G 1 1

64 U U U 1 SIA SIA R232

64 U U U 1 SIA SIA 1G 1 1

BCTR\/BCT/ RR/RX/ 24/31 NLA NLA NLA NLA SIA SIA LSExc U U
BCTGR\/BCTG RRE/RXE
64 NLA NLA NLA NLA SIA SIA LSExc U U

LA/LAE RX/RX 24/31 U Op2AdOp2Ad FZ SR1 /1 U U

64 Op2AdOp2AdOp2AdOp2Ad SR1 SR1 /1 U U

Figure 5-2 (Part 1 of 2). Summary of Simple Branch Linkage Instructions and Other Instructions

5-12 z/Architecture Principles of Operation



Explanation:

- The address does not exist, or the bit has no special effect.

\ The action associated with the R field is not performed if the
field is zero.

\\ The action associated with the R or R field is not performed
if the field is zero.

\\\ The instruction-length code, condition code, and program mask
are saved in bit positions 32-39 of the link address, and bits
4-63 of the updated instruction address are saved in bit
positions 4-63.

/1 Bit 63 can be zero or one.

1G Bit 63 is one and is left one, but the branch address is
generated as if the bit is zero.

BAM Bit 32 of the link address is set with the basic-addressing-mode
bit, bit 32 of the PSW.

FZ Bits -32 of the second-operand address are forced to zeros in
the 24-bit or 31-bit addressing mode.

IA Bits of the link address are set with the updated instruction
address as shown.

LSExc A late specification exception is recognized if the bit is one.

NLA The instruction does not produce a link address. (The
instruction is shown simply as an example of a non-linkage
branch instruction.)

Op2Ad Bits of the address in general register R are set with the
corresponding bits of the second-operand address as shown.

R232 The basic-addressing-mode bit, bit 32 of the PSW, is set with
bit 32 of general register R.

SIA Bits -63 of the branch address are used to set the instruction
address in the PSW. Bits -39 of the branch address are forced
to zeros in the 24-bit addressing mode. Bits -32 are forced to
zeros in the 31-bit addressing mode.

SR1 Bits of the second-operand address are used to set the
corresponding bits of the address in the R general register as
shown. Bits -39 of the second-operand address are forced to
zeros in the 24-bit addressing mode. Bits -32 are forced to
zeros in the 31-bit addressing mode.

U Unchanged.

Figure 5-2 (Part 2 of 2). Summary of Simple Branch Linkage Instructions and Other Instructions

Chapter 5. Program Execution 5-13


Other Linkage Instructions PROGRAM TRANSFER specifies the address
Linkage between a problem-state program and the space which is to become the new primary
supervisor or monitoring program is provided by address space. When the primary address space
means of the SUPERVISOR CALL and MONITOR is changed, the operation is called PROGRAM
CALL instructions. TRANSFER with space switching (PT-ss). When
the primary address space is not changed, the
The instructions PROGRAM CALL and operation is called PROGRAM TRANSFER to
PROGRAM TRANSFER provide the facility for current primary (PT-cp).
linkage between programs of different authority
and in different address spaces. PROGRAM Basic PROGRAM CALL, and PROGRAM
CALL permits linkage to a number of preassigned TRANSFER, can be executed successfully in
programs that may be in either the problem or the either a basic (24-bit or 31-bit) addressing mode
supervisor state and may be in either the same or the extended (64-bit) addressing mode. They
address space or an address space different from do not provide a change between a basic
that of the caller. It permits a change between the addressing mode and the extended addressing
24-bit and 31-bit addressing modes, and it permits mode.
an increase of PSW-key-mask authority, which
authorizes the execution of the SET PSW KEY The BRANCH AND SET AUTHORITY instruction
FROM ADDRESS instruction and also other func- can improve performance by replacing a PT-cp
tions. In general, PROGRAM CALL is used to instruction used to perform a calling linkage in
transfer control to a program of higher authority. which PSW-key-mask authority is reduced, and by
PROGRAM TRANSFER permits a change of the replacing a PC-cp instruction used to perform the
instruction address and address space and a associated return linkage in which PSW-key-mask
change between the 24-bit and 31-bit addressing authority is restored. BRANCH AND SET
modes. PROGRAM TRANSFER also permits a AUTHORITY also permits changes between the
reduction of PSW-key-mask authority and a supervisor and problem states, and it can replace
change from the supervisor to the problem state. SET PSW KEY FROM ADDRESS by changing
In general, it is used to transfer control from one the PSW key during the linkage. The calling-
program to another of equal or lower authority. linkage operation is called BRANCH AND SET
AUTHORITY in the base-authority state (BSA-ba),
When a calling linkage is to increase authority, the and the return-linkage operation is called
calling linkage can be performed by PROGRAM BRANCH AND SET AUTHORITY in the reduced-
CALL and the return linkage by PROGRAM authority state (BSA-ra).
TRANSFER. Alternatively, when the calling
linkage is to decrease authority, the calling linkage The BRANCH IN SUBSPACE GROUP instruction
can be performed by PROGRAM TRANSFER and allows linkage within a group of address spaces
the return linkage by PROGRAM CALL. called a subspace group, where one address
space in the group is called the base space and
The operation of PROGRAM CALL is controlled the others are called subspaces. It is intended
by means of an entry-table entry, which is located that each subspace contain a different subset of
as part of a table-lookup process during the exe- the storage in the base space, that the base
cution of the instruction. The entry-table entry space and each subspace contain a subsystem
specifies either a basic (nonstacking) operation or control program, such as CICS, and application
the stacking operation described in Linkage-Stack programs, and that each subspace contain the
Introduction on page 5-60. The instruction data for a single transaction being processed
causes the primary address space to be changed under the subsystem control program. The place-
only when the ASN in the entry-table entry is ment of the data for each transaction in a different
nonzero. When the primary address space is subspace prevents a program that is being exe-
changed, the operation is called PROGRAM CALL cuted to process one particular transaction from
with space switching (PC-ss). When the primary erroneously damaging the data of other trans-
address space is not changed, the operation is actions. It is intended that the primary address
called PROGRAM CALL to current primary space be the base space when the control
(PC-cp). program is being executed, and that it be the sub-
space for a transaction when an application

5-14 z/Architecture Principles of Operation


program is being executed to process that trans- The SET ADDRESSING MODE (SAM24, SAM31,
action. BRANCH IN SUBSPACE GROUP SAM64) instruction can assist in linkage by setting
changes not only the instruction address in the the 24-bit, 31-bit, or 64-bit addressing mode either
PSW but also the primary address-space-control before or after a linkage operation.
element in control register 1. BRANCH IN SUB-
SPACE GROUP does not change the primary The RESUME PROGRAM instruction is intended
ASN in control register 4 or the for use by a problem-state interruption-handling
primary-ASN-second-table-entry origin in control program to return to the interrupted program. The
register 5, and, therefore, the base space and the interruption-handling program can use LOAD
subspaces all are associated with the same ASN, ACCESS MULTIPLE and LOAD MULTIPLE
and the programs in those address spaces all are instructions to restore the contents of the inter-
of equal authority. rupted program's access and general registers
from a save area, except for the contents of one
Although a subspace is intended to be a subset of access-and-general register pair. The interruption-
the base space as described above, BRANCH IN handling program then can use RESUME
SUBSPACE GROUP does not require this, and PROGRAM to restore the contents of certain PSW
the instruction may be useful in ways other than fields, including the instruction address, and also
as described above. the contents of the remaining access-and-general
pair from the save area, with that pair first being
BRANCH IN SUBSPACE GROUP uses an used by RESUME PROGRAM to address the
access-list-entry token (ALET) in an access reg- save area.
ister as an identifier of the address space that is
to receive control. The instruction saves the The TRAP instruction (TRAP2, TRAP4) can
updated instruction address to permit a return overlay instructions in an application program and
linkage, but it does not save an identifier of the give control to a trap program for performing
address space from which control was transferred. fix-ups of data used by the application program.
However, an ALET equal to 00000000 hex, called The RESUME PROGRAM instruction can be used
ALET 0, can be used to return from a subspace to to return control from the trap program to the
the base space, and an ALET equal to 00000001 application program.
hex, called ALET 1, can be used to return from
the base space to the subspace that last had The linkage instructions provided and the func-
control. tions performed by each are summarized in
Figure 5-3 on page 5-16.

Chapter 5. Program Execution 5-15



Instruction Basic Extended Problem PASN
Address Adr. Mode Adr. Mode State CR4 PSW-Key
PSW Bits 64-127PSW Bit 32 PSW Bit 31 PSW Bit 15 Bits 48-63 Mask
Changed
InstructionFormat Save Set Save Set Save Set Save Set Save Set in CR3 Trace

BALR RR Yes\ R BAM31 - - - - - - - - R



BAL RX Yes\ Yes BAM31 - - - - - - - - -

BASR RR Yes R BAM - - - - - - - - R

BAS RX Yes Yes BAM - - - - - - - - -

BASSM RR Yes R BAM R Yes R - - - - - -

BRAS RI Yes Yes BAM - - - - - - - - -

BRASL RIL Yes Yes BAM - - - - - - - - -

BSA-ba RRE Yes Yes BAM BAM - - Yes Yes - - "AND" R Yes

BSA-ra RRE R Yes R BAM - Yes - - Yes Yes
BAM

BSG RRE Yes Yes R BAM - - - - - - - Yes
BAM

BSM RR - R R R R R - - - - - -
BAM EAM64

MC# SI Yes Yes Yes Yes Yes Yes Yes Yes - - - -

PC-cp S Yes Yes BAM BAM - - Yes Yes - - "OR" EKM Yes

PC-ss S Yes Yes BAM BAM - - Yes Yes Yes Yes "OR" EKM Yes

PT-cp RRE - R - R - - - R\\ - - "AND" R Yes
BAM

PT-ss RRE - R - R - - - R\\ - Yes "AND" R Yes
BAM

RP S - Yes - Yes - Yes - - - - - Yes

SAM24 E - - - Yes - Yes - - - - - Yes

SAM31 E - - - Yes 1 - Yes - - - - - Yes

SAM64 E - - - Yes 1 - Yes 1 - - - - - Yes

SVC RR Yes Yes Yes Yes Yes Yes Yes Yes - - - -

TRAP2 E Yes Yes Yes Yes Yes - Yes - - - - Yes

TRAP4 S Yes Yes Yes Yes Yes - Yes - - - - Yes

Explanation:

- No

\ In the 24-bit addressing mode, the instruction-length code, condition code, and program mask
are saved in bit positions 32-39 of the R general register.

Figure 5-3 (Part 1 of 2). Summary of Linkage Instructions without the Linkage Stack

5-16 z/Architecture Principles of Operation



Explanation (Continued):

\\ A change from the supervisor to the problem state is allowed; a privileged-operation excep-
tion is recognized when a change from the problem to the supervisor state is specified.

# Monitor-mask bits provide a means of disallowing linkage, or enabling linkage, for selected
classes of events.

The action takes place only if the associated R field in the instruction is nonzero.

MC and SVC, as part of the interruption, save the entire current PSW and load a new PSW.

The primary address-space-control element is set even though the PASN is not set.

The problem state is set.

The PSW key also is set from general register R.

BAM The basic-addressing-mode bit is saved or set only in the 24-bit or 31-bit addressing mode.

BAM31 The basic-addressing-mode bit is saved only in the 31-bit addressing mode.

EAM64 The extended-addressing-mode bit is saved only in the 64-bit addressing mode.

R The field or bit is saved in general register R.

R The field or bit is set from general register R.

Figure 5-3 (Part 2 of 2). Summary of Linkage Instructions without the Linkage Stack

Programming Note: This note describes the mode but may have called programs which
simple branch-type linkage instructions that were operate in either the 24-bit or 31-bit addressing
included in 370-XA and carried forward to mode. They and also modified 370-XA, ESA/370,
ESA/370, ESA/390, and z/Architecture. To give and ESA/390 programs now may call programs
the reader a better understanding of the utility and that operate in the 24-bit, 31-bit, or 64-bit
intended usage of these linkage instructions, the addressing mode. New programs may be written
following paragraphs in this note describe various to operate in any addressing mode, and, in some
program linkages and conventions and the use of cases, a program may be written such that it can
the linkage instructions in these situations. be invoked in any addressing mode.

The linkage instructions were originally provided to BRANCH AND SAVE AND SET MODE (BASSM)
permit System/370 programs to operate with no is intended to be the principal calling instruction to
modification or only slight modification on 370/XA subroutines outside of an assembler/linkage-editor
(and successor) systems and also to provide addi- control section (CSECT), for use by all new pro-
tional function for those programs which were grams and particularly by programs that must
designed to take advantage of the 31-bit change the addressing mode during the linkage.
addressing of 370/XA. The instructions provided BRANCH AND SET MODE (BSM) is intended to
the capability for both old and new programs to be the return instruction used after a BASSM.
coexist in storage and to communicate with each BASSM uses a V-type address constant (VCON),
other. The instructions now have been enhanced which has been a four-byte field containing a
to permit usage of the 64-bit addressing of 31-bit entry-point address and a leftmost bit indi-
z/Architecture. cating whether the entry is in the 24-bit or 31-bit
addressing mode. The calling sequence normally
With respect to System/370 programs, it is is:
assumed that old, unmodified programs operate in L 15,VCON
the 24-bit addressing mode and call, or directly BASSM 14,15
communicate with, other programs operating in
the 24-bit addressing mode only. Modified pro- The return from such a routine normally is:
grams normally operate in the 24-bit addressing BSM ,14

Chapter 5. Program Execution 5-17


It is assumed that the VCON will be extended so it known to be in the same addressing mode.
may be an eight-byte field containing a 64-bit BASR with the R field 0 is also useful for
entry-point address, with bit 63 of the address obtaining addressability to the instruction stream
indicating, when one, that the entry is in the 64-bit by getting a 31-bit address, uncluttered by leftmost
addressing mode. This extended VCON is shown fields, in the 24-bit addressing mode.
here as VCONE. The calling sequence would
normally be: The instruction for returning from a routine called
LG 15,VCONE in the 24-bit or 31-bit addressing mode by
BASSM 14,15 BRANCH AND SAVE (BAS or BASR) may be
either:
The return from such a routine would normally be:
BCR 15,14
BSM ,14
or:
When a change of the addressing mode is not
required, BRANCH AND LINK or BRANCH AND BSM ,14
SAVE should be used instead of BASSM. The instruction for returning from a routine called
in the 64-bit addressing mode by BAS or BASR
The BRANCH AND LINK (BAL, BALR) instruction must be BCR; BSM would set the 24-bit or 31-bit
is provided primarily for compatibility with addressing mode, depending on bit 32 of the link
System/370. It is defined to operate in the 31-bit register (an address bit), because bit 63 of the link
and 64-bit addressing modes to increase the prob- register (the rightmost bit of an instruction
ability that an old, straightforward program can be address) is zero. BSM can always be used as the
modified to operate in those addressing modes return instruction if BASSM is used as the calling
with minimal or no change. It is recommended, instruction.
however, that BRANCH AND SAVE (BAS and
BASR) be used instead and that BRANCH AND In some cases, it may be desirable to rewrite a
LINK be avoided since it places nonzero informa- program that is called by an old program which
tion in bit positions 32-39 of the general register in has not been rewritten. In such a case, the old
the 24-bit addressing mode, which may lead to program, which operates in the 24-bit or 31-bit
problems and may decrease performance. addressing mode, will be given the address of an
BRANCH RELATIVE AND SAVE and BRANCH intermediate program that will set up the correct
RELATIVE AND SAVE LONG may be used entry and return modes and then call the rewritten
instead of BRANCH AND SAVE. program. Such an intermediate program is some-
times referred to as a glue module. The instruc-
It is assumed that the normal return from a sub- tion BRANCH AND SET MODE (BSM) with a
routine called in the 24-bit or 31-bit addressing nonzero R field provides the function necessary
mode by BRANCH AND LINK (BAL or BALR) will to perform this operation efficiently. This is shown
be: in Figure 5-4 on page 5-19 for a linkage from a
BCR 15,14 24-bit-mode program to a 31-bit-mode program.
However, the standard return instruction: Note that the BSM 14,15 in the glue module
BSM ,14 causes either an indication of the 64-bit
addressing mode to be saved in bit position 63 of
operates correctly for all cases except for a calling
general register 14 or an indication of one of the
BAL executed in the 24-bit addressing mode. In
24-bit and 31-bit addressing modes to be saved in
the 24-bit addressing mode, BAL causes an ILC of
bit position 32 of the register, and that the other
10 to be placed in bit positions 32 and 33 of the
bits of the register are unchanged. Thus, when
link register. Thus, a BSM would return in the
BSM 0,14 is executed in the new program,
31-bit addressing mode. Note that an EXECUTE
control passes directly back to the old program
of BALR in the 24-bit addressing mode also
without passing through the glue module again.
causes the same ILC effect.
The glue module could give control to a program
The BRANCH AND SAVE (BAS, BASR) instruc- in the 64-bit addressing mode and possibly above
tion is provided to be used for subroutine linkage the 2G-byte boundary by loading an eight-byte
to any program either within the same CSECT or VCONE instead of a four-byte VCON.

5-18 z/Architecture Principles of Operation




Old Program Glue Module New Program

L 15,OLDVCON
BALR 14,15



OLDVCON DC V(GLUE)
GLUE CSECT
USING \,15
L 15,NEWVCON
BSM 14,15
NEWVCON DC V(NEW)
NEW CSECT
USING \,15



BSM ,14

Figure 5-4. Glue Module for Linkage from the 24-Bit Mode to the 31-Bit Mode

Interruptions Types of Instruction Ending


Interruptions permit the CPU to change state as a Instruction execution ends in one of five ways:
result of conditions external to the system, in sub- completion, nullification, suppression, termination,
channels or input/output (I/O) devices, in other and partial completion.
CPUs, or in the CPU itself. Details are to be
found in Chapter 6, Interruptions. Partial completion of instruction execution occurs
only for interruptible instructions; it is described in
Six classes of interruption conditions are provided: Interruptible Instructions on page 5-20.
external, I/O, machine check, program, restart,
and supervisor call. Each class has two related Completion
PSWs, called old and new, in permanently Completion of instruction execution provides
assigned real storage locations. In all classes, an results as called for in the definition of the instruc-
interruption involves storing information identifying tion. When an interruption occurs after the com-
the cause of the interruption, storing the current pletion of the execution of an instruction, the
PSW at the old-PSW location, and fetching the instruction address in the old PSW designates the
PSW at the new-PSW location, which becomes next sequential instruction.
the current PSW.
Suppression
The old PSW contains CPU-status information Suppression of instruction execution causes the
necessary for resumption of the interrupted instruction to be executed as if it specified no
program. At the conclusion of the program operation. The contents of any result fields,
invoked by the interruption, the instruction LOAD including the condition code, are not changed.
PSW EXTENDED may be used to restore the The instruction address in the old PSW on an
current PSW to the value of the old PSW. interruption after suppression designates the next
sequential instruction.

Chapter 5. Program Execution 5-19


Nullification Unit of Operation
Nullification of instruction execution has the same Whenever points of interruption that include those
effect as suppression, except that when an inter- occurring within the execution of an interruptible
ruption occurs after the execution of an instruction instruction are discussed, the term unit of
has been nullified, the instruction address in the operation is used. For a noninterruptible instruc-
old PSW designates the instruction whose exe- tion, the entire execution consists, in effect, in the
cution was nullified (or an EXECUTE instruction, execution of one unit of operation.
as appropriate) instead of the next sequential
instruction. The execution of an interruptible instruction is con-
sidered to consist in the execution of a number of
Termination units of operation, and an interruption is permitted
Termination of instruction execution causes the between units of operation. The amount of data
contents of any fields due to be changed by the processed in a unit of operation depends on the
instruction to be unpredictable. The operation particular instruction and may depend on the
may replace all, part, or none of the contents of model and on the particular condition that causes
the designated result fields and may change the the execution of the instruction to be interrupted.
condition code if such change is called for by the
instruction. Unless the interruption is caused by a When an instruction execution consists of a
machine-check condition, the validity of the number of units of operation and an interruption
instruction address in the PSW, the interruption occurs after some, but not all, units of operation
code, and the ILC are not affected, and the state have been completed, the instruction is said to be
or the operation of the machine is not affected in partially completed. In this case, the type of
any other way. The instruction address in the old ending (completion, nullification, or suppression) is
PSW on an interruption after termination desig- associated with the unit of operation. In the case
nates the next sequential instruction. of termination, the entire instruction is terminated,
not just the unit of operation.
Programming Note: Although the execution of
an instruction is treated as a no-operation when An exception may exist that causes the first unit of
suppression or nullification occurs, stores may be operation of an interruptible instruction not to be
performed as the result of the implicit tracing completed. In this case when the ending is
action associated with some instructions. See nullification or suppression, all operand parame-
Tracing on page 4-10. ters and result locations remain unchanged,
except that the condition code is unpredictable if
Interruptible Instructions the instruction is defined to set the condition code.

Point of Interruption When a storage-alteration PER event is recog-


For most instructions, the entire execution of an nized, fewer than 4K additional bytes are stored
instruction is one operation. An interruption is per- before the event is indicated by an interruption.
mitted between operations; that is, an interruption
can occur after the performance of one operation Execution of Interruptible Instructions
and before the start of a subsequent operation. The execution of an interruptible instruction is
completed when all units of operation associated
For the following instructions, referred to as inter- with that instruction are completed. When an
ruptible instructions, an interruption is permitted interruption occurs after completion, nullification,
also after partial completion of the instruction: or suppression of a unit of operation, all preceding
units of operation have been completed, and sub-
COMPARE AND FORM CODEWORD sequent units of operation and instructions have
COMPARE LOGICAL LONG not been started. The main difference between
COMPARE UNTIL SUBSTRING EQUAL these types of ending is the handling of the
MOVE LONG current unit of operation and whether the instruc-
TEST BLOCK tion address stored in the old PSW identifies the
UPDATE TREE current instruction or the next sequential instruc-
tion.

5-20 z/Architecture Principles of Operation


At the time of an interruption, changes to storage
Unit of Instruction Operand Current Result
locations or register contents which are due to be Operation Is Address Parameters Location
made by instructions following the interrupted
Completed
instruction have not yet been made. Last unit Next instruc-Depends on Changed
of oper- tion the instruc-
ation tion
Completion: On completion of the last unit of Any other Current in- Next unit of Changed
operation of an interruptible instruction, the unit of struction operation
operation
instruction address in the old PSW designates the
next sequential instruction. The result location for Nullified Current in- Current unit Unchanged
struction of operation
the current unit of operation has been updated. It
depends on the particular instruction how the Suppressed Next instruc-Current unit Unchanged
tion of operation
operand parameters are adjusted. On completion
of a unit of operation other than the last one, the Terminated Next instruc-UnpredictableUnpredictable
instruction address in the old PSW designates the tion

interrupted instruction or an EXECUTE instruction,
as appropriate. The result location for the current Figure 5-5. Types of Ending for a Unit of Operation
unit of operation has been updated. The operand
If an instruction is defined to set the condition
parameters are adjusted such that the execution
code, the execution of the instruction makes the
of the interrupted instruction is resumed from the
condition code unpredictable except when the last
point of interruption when the old PSW stored
unit of operation has been completed.
during the interruption is made the current PSW.

Nullification: When a unit of operation is nulli- Condition-Code Alternative to


fied, the instruction address in the old PSW desig- Interruptibility
nates the interrupted instruction or an EXECUTE The following instructions are not interruptible
instruction, as appropriate. The result location for instructions but instead may be completed after
the current unit of operation remains unchanged. performing a CPU-determined subportion of the
The operand parameters are adjusted such that, if processing specified by the parameters of the
the instruction is reexecuted, execution of the instructions:
interrupted instruction is resumed with the current CHECKSUM
unit of operation. COMPARE LOGICAL LONG EXTENDED
COMPARE LOGICAL LONG UNICODE
Suppression: When a unit of operation is sup- COMPARE LOGICAL STRING
pressed, the instruction address in the old PSW CONVERT UNICODE TO UTF-8
designates the next sequential instruction. The CONVERT UTF-8 TO UNICODE
operand parameters, however, are adjusted so as MOVE LONG EXTENDED
to indicate the extent to which instruction exe- MOVE LONG UNICODE
cution has been completed. If the instruction is MOVE STRING
reexecuted after the conditions causing the sup- SEARCH STRING
pression have been removed, the execution is TRANSLATE EXTENDED
resumed with the current unit of operation. TRANSLATE ONE TO ONE
TRANSLATE ONE TO TWO
Termination: When an exception which causes
TRANSLATE TWO TO ONE
termination occurs as part of a unit of operation of
TRANSLATE TWO TO TWO
an interruptible instruction, the entire operation is
terminated, and the contents, in general, of any When any of the above instructions is completed
fields due to be changed by the instruction are after performing only a CPU-determined amount of
unpredictable. On such an interruption, the processing instead of all specified processing, the
instruction address in the old PSW designates the instruction sets condition code 3. On such com-
next sequential instruction. pletion, the instruction address in the PSW desig-
nates the next sequential instruction, and the
The differences among the four types of ending
operand parameters of the instruction have been
for a unit of operation are summarized in
adjusted so that the processing of the instruction
Figure 5-5.

Chapter 5. Program Execution 5-21


can be resumed simply by branching back to the single unit of operation is performed, but the
instruction to execute it again. When the instruc- unit of operation for the various cases of stop-
tion has performed all specified processing, it sets ping may be different.
a condition code other than 3.

The points at which any of the above instructions


Exceptions to Nullification and
may set condition code 3 are comparable to the Suppression
points of interruption of an interruptible instruction,
and the amount of processing between adjacent In certain unusual situations, the result fields of an
points is comparable to a unit of operation of an instruction having a store-type operand are
interruptible instruction. However, since the changed in spite of the occurrence of an exception
instruction is not interruptible, each execution is which would normally result in nullification or sup-
considered the execution of one unit of operation. pression. These situations are exceptions to the
general rule that the operation is treated as a no-
Completion with the setting of condition code 3 operation when an exception requiring nullification
permits interruptions to occur. Depending on the or suppression is recognized. Each of these situ-
model and the instruction, condition code 3 may or ations may result in the turning on of the change
may not be set when there is not a need for an bit associated with the store-type operand, even
interruption. though the final result in storage may appear
unchanged. Depending on the particular situation,
When a storage-alteration PER event is recog- additional effects may be observable. The extent
nized, fewer than 4K additional bytes are stored of these effects is described along with each of
before the event is indicated by an interruption. the situations.

The COMPARE UNTIL SUBSTRING EQUAL and All of these situations are limited to the extent that
COMPRESSION CALL instructions both are inter- a store access does not occur and the change bit
ruptible instructions and ones that may set condi- is not set when the store access is prohibited. For
tion code 3 after performing a CPU-determined the CPU, a store access is prohibited whenever
amount of processing. an access exception exists for that access, or
whenever an exception exists which is of higher
Programming Notes: priority than the priority of an access exception for
that access.
1. Any interruption, other than supervisor call
and some program interruptions, can occur When, in these situations, an interruption for an
after a partial execution of an interruptible exception requiring suppression occurs, the
instruction. In particular, interruptions for instruction address in the old PSW designates the
external, I/O, machine-check, restart, and next sequential instruction. When an interruption
program interruptions for access exceptions for an exception requiring nullification occurs, the
and PER events can occur between units of instruction address in the old PSW designates the
operation. instruction causing the exception even though
2. The amount of data processed in a unit of partial results may have been stored.
operation of an interruptible instruction
depends on the model and may depend on Storage Change and Restoration for
the type of condition which causes the exe- DAT-Associated Access Exceptions
cution of the instruction to be interrupted or In this section, the term DAT-associated access
stopped. Thus, when an interruption occurs at exceptions is used to refer to those exceptions
the end of the current unit of operation, the which may occur as part of the dynamic-address-
length of the unit of operation may be different translation process. These exceptions are
for different types of interruptions. Also, when ASCE-type, region-first translation, region-second
the stop function is requested during the exe- translation, region-third translation, segment trans-
cution of an interruptible instruction, the CPU lation, page translation, translation specification,
enters the stopped state at the completion of and addressing due to a DAT-table entry being
the execution of the current unit of operation. designated at a location that is not available in the
Similarly, in the instruction-step mode, only a configuration. The first six of these exceptions

5-22 z/Architecture Principles of Operation


normally cause nullification, and the last two b. Perform preliminary testing to ensure that
normally cause suppression. Protection no exceptions occur for any of the
exceptions, including those due to page pro- required pages
tection, are not considered to be DAT-associated
c. Operate with DAT off
access exceptions.

For DAT-associated access exceptions, on some Modification of DAT-Table Entries


models, channel programs may observe the When a valid and attached DAT-table entry is
effects on storage as described in the following changed to a value which would cause an excep-
case. tion, and when, before the TLB is cleared of
entries which qualify for substitution for that entry,
When, for an instruction having a store-type an attempt is made to refer to storage by using a
operand, a DAT-associated access exception is virtual address requiring that entry for translation,
recognized for any operand of the instruction, that the contents of any fields due to be changed by
portion, if any, of the store-type operand which the instruction are unpredictable. Results, if any,
would not cause an exception may be changed to associated with the virtual address whose
an intermediate value but is then restored to the DAT-table entry was changed may be placed in
original value. those real locations originally associated with the
address. Furthermore, it is unpredictable whether
The accesses associated with storage change and or not an interruption occurs for an access excep-
restoration for DAT-associated access exceptions tion that was not initially applicable. On some
are only observable by channel programs and are machines, this situation may be reported by
not observable by other CPUs in a multiproc- means of an instruction-processing-damage
essing configuration. Except for instructions which machine check with the delayed-access-exception
are defined to have multiple-access operands, the bit also indicated.
intermediate value, if any, is always equal to what
would have been the final value if the Trial Execution for Editing Instructions
DAT-associated access exception had not and Translate Instruction
occurred. For the instructions EDIT, EDIT AND MARK, and
TRANSLATE, the portions of the operands that
Programming Notes: are actually used in the operation may be estab-
1. Storage change and restoration for lished in a trial execution for operand accessibility
DAT-associated access exceptions occur in that is performed before the execution of the
two main situations: instruction is started. This trial execution consists
in an execution of the instruction in which results
a. The exception is recognized for a portion are not stored. If the first operand of TRANS-
of a store-type operand which crosses a LATE or either operand of EDIT or EDIT AND
page boundary, and the other portion has MARK is changed by another CPU or by a
no access exception. channel program, after the initial trial execution but
b. The exception is recognized for one before completion of execution, the contents of
operand of an instruction having two any fields due to be changed by the instruction
storage operands (for example, an are unpredictable. Furthermore, it is unpredictable
SS-format instruction or MOVE LONG), whether or not an interruption occurs for an
and the other operand, which is a store- access exception that was not initially applicable.
type operand, has no access exception.
2. To avoid letting a channel program observe Authorization Mechanisms
intermediate operand values due to storage
change and restoration for DAT-associated The authorization mechanisms which are
access exceptions (especially when a CCW described in this section permit the control
chain is modified), the CPU program should program to establish the degree of function which
do one of the following: is provided to a particular semiprivileged program.
(A summary of the authorization mechanisms is
a. Operate on one storage page at a time given in Figure 5-6 on page 5-27.) The authori-

Chapter 5. Program Execution 5-23


zation mechanisms are intended for use by pro- modes. BRANCH AND STACK, stacking
grams considered to be semiprivileged, that is, PROGRAM CALL, and PROGRAM RETURN are
programs which are executed in the problem state valid only in the primary-space and access-
but which may be authorized to use additional register modes. EXTRACT STACKED REGIS-
capabilities. With these authorization controls, a TERS, EXTRACT STACKED STATE, and
hierarchy of programs may be established, with MODIFY STACKED STATE are valid only in the
programs at a higher level having a greater primary-space, access-register, and home-space
degree of privilege or authority than programs at a modes. When a semiprivileged instruction is exe-
lower level. The range of functions available at cuted in an invalid translation mode, a special-
each level, and the ability to transfer control from operation exception is recognized.
a lower to a higher level, are specified in tables
which are managed by the control program. PROGRAM TRANSFER specifies a new value for
When the linkage stack is used, a nonhierarchical the problem-state bit in the PSW. If a program in
transfer of control also can be specified. the problem state attempts to execute PROGRAM
TRANSFER and set the supervisor state, a
A semiprivileged instruction is one which can be privileged-operation exception is recognized. A
executed in the problem state, but which is subject privileged-operation exception is also recognized
to the control of one or more of the authorization on an attempt to use RESUME PROGRAM, SET
mechanisms described in this section. There are ADDRESS SPACE CONTROL, or SET ADDRESS
28 semiprivileged instructions and also the privi- SPACE CONTROL FAST to set the home-space
leged LOAD ADDRESS SPACE PARAMETERS mode in the problem state.
instruction that are controlled by the authorization
mechanisms. All of these semiprivileged and priv- Extraction-Authority Control
ileged instructions are described in Chapter 10, The extraction-authority-control bit is located in bit
Control Instructions. position 36 of control register 0. In the problem
state, bit 36 must be one to allow completion of
The instructions controlled by the authorization these instructions:
mechanisms are listed in Figure 5-6 on
page 5-27. The figure also shows additional EXTRACT PRIMARY ASN
authorization mechanisms that do not control spe- EXTRACT SECONDARY ASN
cifically semiprivileged instructions; they control INSERT ADDRESS SPACE CONTROL
implicit access-register translation (access-register INSERT PSW KEY
translation as part of an instruction making a INSERT VIRTUAL STORAGE KEY
storage reference) and also access-register trans- Otherwise, a privileged-operation exception is
lation in the LOAD REAL ADDRESS, STORE recognized. The extraction-authority control is not
REAL ADDRESS, TEST ACCESS, and TEST examined in the supervisor state.
PROTECTION instructions. These additional
mechanisms (the extended authorization index, PSW-Key Mask
ALE sequence number, and ASTE sequence The PSW-key mask consists of bits 32-47 in
number) are described in Access-Register- control register 3, with the bits corresponding to
Specified Address Spaces on page 5-35. the values 0-15, respectively, of the PSW key.
These bits are used in the problem state to control
Mode Requirements which keys and entry points are authorized for the
Most of the semiprivileged instructions can be program. The PSW-key mask is modified by
executed only with DAT on. Basic PROGRAM PROGRAM TRANSFER, is modified or loaded by
CALL, and PROGRAM TRANSFER, are valid only BRANCH AND SET AUTHORITY and PROGRAM
in the primary-space mode. (Basic PROGRAM CALL, and is loaded by LOAD ADDRESS SPACE
CALL is the PROGRAM CALL operation when the PARAMETERS and PROGRAM RETURN. The
linkage stack is not used. When the linkage stack PSW-key mask is used in the problem state to
is used, the PROGRAM CALL operation is called control the following:
stacking PROGRAM CALL). MOVE TO
The PSW-key values that can be set by
PRIMARY and MOVE TO SECONDARY are valid
means of the instruction SET PSW KEY
only in the primary-space and secondary-space
FROM ADDRESS.

5-24 z/Architecture Principles of Operation


The PSW-key values that are valid for the six ASN-Translation Control
move instructions that specify a second Bit 44 of control register 14 is the
access key: MOVE PAGE, MOVE TO ASN-translation-control bit. This bit provides a
PRIMARY, MOVE TO SECONDARY, MOVE mechanism whereby the control program can indi-
WITH KEY, MOVE WITH SOURCE KEY, and cate whether ASN translation may occur while a
MOVE WITH DESTINATION KEY. particular program is being executed. Bit 44 must
The entry points which can be called by be one to allow completion of these instructions:
means of PROGRAM CALL. In this case, the LOAD ADDRESS SPACE PARAMETERS
PSW-key mask is ANDed with the authori- SET SECONDARY ASN
zation key mask in the entry-table entry, and, PROGRAM CALL with space switching
if the result is zero, the program is not author- PROGRAM RETURN with space switching
ized. and also when the restored secondary ASN is
When an instruction in the problem state attempts not equal to the restored primary ASN
to use a key not authorized by the PSW-key PROGRAM TRANSFER with space switching
mask, a privileged-operation exception is recog- Otherwise, a special-operation exception is recog-
nized. The same action is taken when an instruc- nized. The ASN-translation control is examined in
tion in the problem state attempts to call an entry both the problem and supervisor states. The
not authorized by the PSW-key mask. The ASN-translation control is examined by
PSW-key mask is not examined in the supervisor PROGRAM CALL even though PROGRAM CALL
state, all keys and entry points being valid. obtains the address of the ASN-second-table entry
directly from the entry-table entry, instead of by
Secondary-Space Control performing ASN translation.
Bit 37 of control register 0 is the secondary-space-
control bit. This bit provides a mechanism Authorization Index
whereby the control program can indicate whether The authorization index is contained in bit posi-
or not the secondary region-first table, region- tions 32-47 of control register 4. The authorization
second table, region-third table or segment table index is associated with the primary address
has been established. Bit 37 may be required to space and is loaded along with the PASN when
be one to allow completion of SET ADDRESS PROGRAM CALL with space switching,
SPACE CONTROL FAST and must be one to PROGRAM RETURN with space switching,
allow completion of these instructions: PROGRAM TRANSFER with space switching, or
MOVE TO PRIMARY LOAD ADDRESS SPACE PARAMETERS is exe-
MOVE TO SECONDARY cuted. The authorization index is used to deter-
SET ADDRESS SPACE CONTROL mine whether a program is authorized to establish
a particular address space. A program may be
Otherwise, a special-operation exception is recog- authorized to establish the address space as a
nized. The secondary-space control is examined secondary-address space, as a primary-address
in both the problem and supervisor states. space, or both. The authorization index is exam-
ined in both the problem and supervisor states.
Subsystem-Linkage Control
Bit 192 of the primary ASN-second-table entry is Associated with each address space is an
the subsystem-linkage-control bit. The authority table. The authorization index is used to
subsystem-linkage control must be one to allow select an entry in the authority table. Each entry
completion of these instructions: contains two bits, which indicate whether the
PROGRAM CALL program with that authorization index is permitted
PROGRAM TRANSFER to establish the address space as a primary
address space, as a secondary address space, or
Otherwise, a special-operation exception is recog- both.
nized. The subsystem-linkage control is examined
in both the problem and supervisor states and The instruction SET SECONDARY ASN with
controls both the space-switching and current- space switching, and the instruction PROGRAM
primary versions of the instructions. RETURN when the restored secondary ASN is not
equal to the restored primary ASN, use the

Chapter 5. Program Execution 5-25


authorization index to test the secondary-authority loaded from the ASN-second-table entry. This
bit in the authority-table entry to determine if the permits the program which is called to be given an
address space can be established as a secondary authorization index which authorizes it to access
address space. The tested bit must be one; oth- more or different address spaces than those
erwise, a secondary-authority exception is recog- authorized for the calling program. The
nized. instructions PROGRAM RETURN with space
switching and PROGRAM TRANSFER with space
The instruction PROGRAM TRANSFER with switching restore the authorization index that is
space switching uses the authorization index to associated with the returned-to address space.
test the primary-authority bit in the authority-table
entry to determine if the address space can be The secondary-authority bit in the authority-table
established as a primary address space. The entry may also be used, along with the extended
tested bit must be one; otherwise, a primary- authorization index, to determine if the program is
authority exception is recognized. authorized to use an access-list entry in access-
register translation. This is described in Access-
The instruction PROGRAM CALL with space Register-Specified Address Spaces on
switching causes a new authorization index to be page 5-35.

5-26 z/Architecture Principles of Operation



Authorization Mechanism
Space
Mode PSW- Ext.- Sw.-
Requirement Sec.-ASN- Extr.Key Auth. Auth. Event
Function Subs.SpaceTrans. Auth.Mask Index Index ALE ASTECtl.
or Pr.Trans. Link.Ctl.(Ctl. Ctl.((3.32-(4.32-(8.32-Seq.Seq.(1.57,
Instruction Op.Mode Ctl..37)(14.44).36)3.47) 4.47) 8.47) No.No.13.57)

Implicit A EA ALQ ASQ


AR transl.
BAKR SO-PA
BSA-ba Q
BSA-ra
BSG SO-PSAH ASQ
EPAR SO-PSAH Q

EREG SO-PAH
EREGG SO-PAH
ESAR SO-PSAH Q
ESTA SO-PAH
IAC SO-PSAH Q
IPK Q

IVSK SO-PSAH Q
LASP P SO CC CC
LRA P CCA CCA CCA
LRAG P CCA CCA CCA
MSTA SO-PAH
MVCDK Q

MVCP SO-PS SO Q
MVCS SO-PS SO Q
MVCSK Q
bPC-cp SO-P SO Q
sPC-cp SO-PA SO Q
bPC-ss SO-P SO SO Q X1

sPC-ss SO-PA SO SO Q X1
PR-cp SO-PA SO SA
PR-ss SO-PA SO PASA X1
PT-cp QSO-P SO
PT-ss QSO-P SO SO PA X1
RP X2

SAC QSO-PSAH SO X2
SACF QSO-PSAH SO X2
SPKA Q
SSAR-cp SO-PSAH SO
SSAR-ss SO-PSAH SO SA
STRAG P EA ALQ ASQ

TAR CC CC CC
TPROT P CC CC CC

Figure 5-6. Summary of Authorization Mechanisms

Chapter 5. Program Execution 5-27


Explanation for Summary of Authorization P Privileged-operation exception for privi-
Mechanisms: leged instruction.
The PSW-key mask is ANDed with the PA Primary-authority exception.
authorization key mask in the entry-
PASA Primary-authority exception or
table entry.
secondary-authority exception.
The exception is recognized on an
Q Privileged-operation exception for semi-
attempt to set the supervisor state
privileged instruction. Authority
when in the problem state.
checked only in the problem state.
The exception is recognized on an
SA Secondary-authority exception.
attempt to set the home-space mode
when in the problem state. SO Special-operation exception.
ASN translation is performed for the SO-P CPU must be in the primary-space
new SASN, and the exception may be mode; special-operation exception if the
recognized, only when the new SASN CPU is in the secondary-space,
is not equal to the new PASN. access-register, home-space, or real
mode.
Secondary authority is checked for the
new SASN, and the exception may be SO-PA CPU must be in the primary-space or
recognized, only when the new SASN access-register mode; special-operation
is not equal to the new PASN. exception if the CPU is in the
secondary-space, home-space, or real
Subsystem-linkage control is bit 192 of
mode.
the primary ASN-second-table entry.
SO-PAH CPU must be in the primary-space,
ALE sequence number is bits 8-15 of
access-register, or home-space mode;
the access-list-entry token and bits 8-15
special-operation exception if the CPU
of the access-list entry.
is in the secondary-space or real mode.
ASTE sequence number is bits 96-127
SO-PS CPU must be in the primary-space or
of the access-list entry and bits
secondary-space mode; special-
160-191 of the ASN-second-table entry.
operation exception if the CPU is in the
Whether the exception is recognized is home-space, access-register, or real
unpredictable. mode.
A Access-register translation occurs only SO-PSAH CPU must be in the primary-space,
in the access-register mode. secondary-space, access-register, or
home-space mode; special-operation
ALQ ALE-sequence exception.
exception if the CPU is in the real
ASQ ASTE-sequence exception. mode.
bPC Basic (nonstacking) PROGRAM CALL. sPC Stacking PROGRAM CALL.
CC Test results in setting a condition code. X1 When bit 57 of control register 1 is one,
CCA Test results in setting a condition code. a space-switch event is recognized.
The test occurs only in the access- The operation is completed.
register mode. X2 When bit 57 of control register 1 or 13
CRx.y Control register x, bit position y. is one and the instruction space is
changed to or from the home address
EA Extended-authority exception. space, a space-switch event is recog-
nized. The operation is completed.

5-28 z/Architecture Principles of Operation


Subsystem-Linkage Control (V): Bit 0 of the
PC-Number Translation linkage-table designation is the subsystem-
PC-number translation is the process of translating linkage-control bit. Bit 0 must be one to allow
the 20-bit PC number to locate an entry-table completion of these instructions:
entry as part of the execution of the PROGRAM PROGRAM CALL
CALL instruction. To perform this translation, the PROGRAM TRANSFER
20-bit PC number is divided into two fields. The
leftmost 12 bits are the linkage index (LX), and the Otherwise, a special-operation exception is recog-
rightmost eight bits are the entry index (EX). The nized. The subsystem-linkage control is examined
effective address, from which the PC-number is in both the problem and the supervisor states and
taken, has the following format: controls both the space-switching and current-
primary versions of the instructions.
/
LX EX
/ Linkage-Table Origin: Bits 1-24 of the linkage-
44 56 63 table designation, with seven zeros appended on
the right, form a 31-bit real address that desig-
The translation is performed by means of two nates the beginning of the linkage table.
tables: a linkage table and an entry table. Both
of these tables reside in real storage. The Linkage-Table Length (LTL): Bits 25-31 of the
linkage-table designation resides in a third area in linkage-table designation specify the length of the
storage, called the primary ASN-second-table linkage table in units of 128 bytes, thus making
entry (primary ASTE), whose origin is in control the length of the linkage table variable in multiples
register 5. The entry table is designated by of 32 four-byte entries. The length of the linkage
means of a linkage-table entry. table, in units of 128 bytes, is one more than the
value in bit positions 25-31. The linkage-table
PC-Number Translation Control length is compared against the leftmost seven bits
of the linkage-index portion of the PC number to
PC-number translation is controlled by means of a determine whether the linkage index designates
linkage-table designation in the primary an entry within the linkage table.
ASN-second-table entry designated by the con-
tents of control register 5. PC-Number Translation Tables
Control Register 5 The PC-number translation process consists in a
Control register 5 specifies the location of the two-level lookup using two tables: a linkage table
primary ASN-second-table entry. The register has and an entry table. These tables reside in real
the following format: storage.
/
PASTEO Linkage-Table Entries
/ The entry fetched from the linkage table has the
33 58 63
following format:
Primary-ASTE Origin (PASTEO): Bits 33-57 of
control register 5, with six zeros appended on the I Entry-Table Origin ETL

right, form a 31-bit real address that designates 1 26 31
the beginning of the primary ASTE. The linkage-
table designation is in bytes 24-27 of the primary The fields in the linkage-table entry are allocated
ASTE. as follows:

The linkage-table designation has the following LX Invalid Bit (I): Bit 0 controls whether the
format: entry table associated with the linkage-table entry
is available.

V Linkage-Table Origin LTL


When the bit is zero, PC-number translation pro-
1 25 31 ceeds by using the linkage-table entry. When the

Chapter 5. Program Execution 5-29


bit is one, an LX-translation exception is recog- If Bit 129 is Zero
nized.


Entry-Table Origin: Bits 1-25, with six zeros 31
appended on the right, form a 31-bit real address
that designates the beginning of the entry table.
A Entry Instruction Address P

Entry-Table Length (ETL): Bits 26-31 specify 32 63
the length of the entry table in units of 128 bytes,
thus making the table variable in multiples of four
If Bit 129 is One
32-byte entries. The length of the entry table, in
units of 128 bytes, is one more than the value in Entry Instruction Address (Part 1)
bit positions 26-31. The entry-table length is com-
pared against the leftmost six bits of the entry 31
index to determine whether the entry index desig-
nates an entry within the entry table. Entry Instruction Address (Part 2) P

32 63
Entry-Table Entries
The format of bits 0-63 of the entry-table entry
depends on whether the addressing-mode in
Authorization Key Mask ASN
effect after the PROGRAM CALL operation is the

extended (64-bit) addressing mode or a basic 64 8 95
(24-bit or 31-bit) addressing mode. This in turn

depends on bits 128 and 129 of the entry-table
Entry Key Mask
entry.
96 112 127
Bit 128 of the entry-table entry (T) is the PC-type

bit. When bit 128 is zero, PROGRAM CALL is to TG Linkage-Stack Fields
perform the basic (nonstacking) operation. When
bit 128 is one, PROGRAM CALL is to perform the 128 13 159
stacking operation.
ASTE Address
Bit 129 of the entry-table entry (G) is the entry-
extended-addressing-mode bit. In the basic 16 186 191
PROGRAM CALL operation, bit 31 of the current
PSW, the extended-addressing-mode bit, must Entry Parameter (Part 1)
equal bit 129; otherwise, a special-operation
exception is recognized. In the stacking operation 192 223
when bit 129 is zero, bit 31 of the current PSW is
set to zero, and bit 32 of the PSW, the basic- Entry Parameter (Part 2)
addressing-mode bit, is set with the value of bit 32
of the entry-table entry (A), the entry-basic- 224 255
addressing-mode bit. In the stacking operation The fields in the entry-table entry are allocated as
when bit 129 is one, bits 31 and 32 of the current follows:
PSW both are set to one. Thus, the basic
PROGRAM CALL operation does not switch Entry Basic Addressing Mode (A): When bit
between the extended and a basic addressing 129 is zero, bit 32 replaces the basic-addressing-
mode but can switch between the 24-bit and 31-bit mode bit, bit 32 of the current PSW, as part of the
modes, and the stacking operation can set any PROGRAM CALL operation. In this case if bit 32
addressing mode. is zero, bits 33-39 must also be zeros; otherwise,
a PC-translation-specification exception is recog-
The 32-byte entry-table entry has the following nized. When bit 129 is one, bit 32 is a bit of the
format: entry instruction address, and bit 32 of the PSW
remains or is set to one.

5-30 z/Architecture Principles of Operation


Entry Instruction Address: When bit 129 is ASN-second-table-entry address that should result
zero, bits 33-62, with 33 zeros appended on the from applying the ASN-translation process to bits
left and a zero appended on the right, form the 80-95.
instruction address which replaces the instruction
address in the PSW as part of the PROGRAM Entry Parameter: When bit 129 is zero, bits
CALL operation. When bit 129 is one, bits 0-62, 224-255 are placed in bit positions 32-63 of
with a zero appended on the right, form the general register 4, and bits 0-31 of the register
instruction address. remain unchanged. When bit 129 is one, bits
192-255 are placed in general register 4.
Entry Problem State (P): Bit 63 replaces the
problem-state bit, bit 15 of the current PSW, as Bits 130-159 are used in connection with the
part of the PROGRAM CALL operation. linkage stack and are described in Linkage-Stack
Entry-Table Entries on page 5-64.
Authorization Key Mask: Bits 64-79 are used
to verify whether the program issuing the Bits 112-127, 160, and 186-191 are reserved for
PROGRAM CALL instruction, when in the problem possible future extensions and should be zeros.
state, is authorized to call this entry point. The Programming Note: The entry parameter is
authorization key mask and the current PSW-key intended to provide the called program with an
mask in control register 3 are ANDed, and the address which can be depended upon and used
result is checked for all zeros. If the result is all as the basis of addressability in locating neces-
zeros, a privileged-operation exception is recog- sary information which may be environment
nized. The test is not performed in the supervisor dependent. The parameter may be appropriately
state. changed for each environment by setting up dif-
ferent entry tables. The alternative -- obtaining
ASN: Bits 80-95 specify whether a space-
this information from the calling program -- may
switching (PC-ss) operation or a to-current-primary
require extensive validity checking or may present
(PC-cp) operation is to occur. When bits 80-95
an integrity exposure.
are zeros, PC-cp is specified. When bits 80-95
are not all zeros, PC-ss is specified, and the bits
are the ASN that replaces the primary ASN. PC-Number-Translation Process
Entry Key Mask: Bits 96-111 are ORed into the The translation of the PC number is performed by
PSW-key mask in control register 3 as part of the means of a linkage table and entry table both of
basic PROGRAM CALL operation. During the which reside in real storage. The translation also
stacking operation, bits 96-111 are ORed into the requires the use of the primary ASN-second-table
PSW-key mask if bit 132 is zero or they replace it entry, which also resides in real storage.
if bit 132 is one.
For the purposes of PC-number translation, the
PC-Type Bit (T): Bit 128 specifies the basic 20-bit PC number is divided into two parts: the
PROGRAM CALL operation when the bit is zero leftmost 12 bits are called the linkage index (LX),
or the stacking PROGRAM CALL operation when and the rightmost eight bits are called the entry
the bit is one. index (EX). The LX is used to select an entry
from the linkage table, the starting address and
Entry Extended Addressing Mode (G): In the length of which are specified by the linkage-table
basic PROGRAM CALL operation, bit 129 must designation in the primary ASTE. This entry des-
match the extended-addressing-mode bit, bit 31 of ignates the entry table to be used. The EX field of
the current PSW; otherwise, a special-operation the PC number is then used to select an entry
exception is recognized. In the stacking opera- from the entry table.
tion, bit 129 replaces bit 31 of the PSW.
When, for the purposes of PC-number translation,
ASTE Address: When bits 80-95 are not all accesses are made to main storage to fetch
zeros, bits 161-185, with six zeros appended on entries from the primary ASTE, linkage table, and
the right, form the 31-bit real entry table, key-controlled protection does not
apply.

Chapter 5. Program Execution 5-31


The PC-number-translation process is shown in
Figure 5-7 on page 5-32.

Linkage-Table Designation
in Primary ASTE

V LTO LTL
PC Number
(x128)
LX EX

(x4) (x32)


6
Linkage Table
5+



5
R I ETO ETL

(x64)







6
Entry Table
5+


5
R \\ A EIA P AKM ASN EKM

TGL.-S. Fields ASTE Address EP



R: Address is real
\\: First word and A of ETE are bits -32 of EIA if G is one.
Figure 5-7. PC-Number Translation

Obtaining the Linkage-Table control register 5, and adding 24. The addition
Designation cannot cause a carry into bit position 0. The
The linkage-table designation is obtained from 31-bit address is formed and used regardless of
bytes 24-27 of the primary ASN-second-table whether the current PSW specifies the 24-bit,
entry, the starting address of which is specified by 31-bit, or 64-bit addressing mode.
the contents of control register 5.
All four bytes of the linkage-table designation are
The 31-bit real address of the linkage-table desig- fetched concurrently from the primary ASTE. The
nation is obtained by appending six zeros on the fetch access is not subject to protection. When
right to the primary-ASTE origin, bits 33-57 of the storage address which is generated for
fetching the linkage-table designation designates a

5-32 z/Architecture Principles of Operation


location which is not available in the configuration, Entry-Table Lookup
an addressing exception is recognized, and the The entry-index (EX) portion of the PC number, in
operation is suppressed. Besides the linkage- conjunction with the entry-table origin contained in
table designation, no other field in the primary the linkage-table entry, is used to select an entry
ASTE is examined. from the entry table.

Linkage-Table Lookup The 31-bit real address of the entry-table entry is


The linkage-index (LX) portion of the PC number, obtained by appending six zeros on the right to
in conjunction with the linkage-table origin, is used the entry-table origin and adding the entry index,
to select an entry from the linkage table. with five rightmost and 18 leftmost zeros
appended. When a carry into bit position 0 occurs
The 31-bit real address of the linkage-table entry during the addition, an addressing exception may
is obtained by appending seven zeros on the right be recognized, or the carry may be ignored,
to the contents of bit positions 1-24 of the linkage- causing the table to wrap from 2 - 1 to 0. The
table designation and adding the linkage index, 31-bit address is formed and used regardless of
with two rightmost and 17 leftmost zeros whether the current PSW specifies the 24-bit,
appended. When a carry into bit position 0 occurs 31-bit, or 64-bit addressing mode.
during the addition, an addressing exception may
be recognized, or the carry may be ignored, As part of the entry-table-lookup process, the six
causing the table to wrap from 2 - 1 to 0. The leftmost bits of the entry index are compared
31-bit address is formed and used regardless of against the entry-table length, bits 26-31 of the
whether the current PSW specifies the 24-bit, linkage-table entry, to establish whether the
31-bit, or 64-bit addressing mode. addressed entry is within the table. If the value in
the entry-table length field is less than the value in
As part of the linkage-table-lookup process, the the six leftmost bits of the entry index, an
leftmost seven bits of the linkage index are com- EX-translation exception is recognized.
pared against the linkage-table length, bits 25-31
of the linkage-table designation, to establish The 32-byte entry-table entry is fetched by using
whether the addressed entry is within the linkage the real address. The fetch of the entry appears
table. If the value in the linkage-table-length field to be word-concurrent as observed by other
is less than the value in the seven leftmost bits of CPUs, with the leftmost word fetched first. The
the linkage index, an LX-translation exception is order in which the remaining seven words are
recognized. fetched is unpredictable. The fetch access is not
subject to protection. When the storage address
All four bytes of the linkage-table entry appear to which is generated for fetching the entry-table
be fetched concurrently as observed by other entry designates a location which is not available
CPUs. The fetch access is not subject to pro- in the configuration, an addressing exception is
tection. When the storage address which is gen- recognized, and the operation is suppressed.
erated for fetching the linkage-table entry
designates a location which is not available in the The use that is made of the information fetched
configuration, an addressing exception is recog- from the entry-table entry is described in the defi-
nized, and the operation is suppressed. nition of the PROGRAM CALL instruction.

Bit 0 of the linkage-table entry specifies whether Recognition of Exceptions during


the entry table corresponding to the linkage index PC-Number Translation
is available. This bit is inspected, and, if it is one, The exceptions which can be encountered during
an LX-translation exception is recognized. the PC-number-translation process and their pri-
ority are described in the definition of the
When no exceptions are recognized in the PROGRAM CALL instruction.
process of linkage-table lookup, the entry fetched
from the linkage table designates the origin and Programming Note: The linkage-table desig-
length of the corresponding entry table. nation is fetched successfully from the primary
ASN-second-table entry regardless of the value of
bit 0, the ASX-invalid bit, in the primary ASTE. A

Chapter 5. Program Execution 5-33


one value of this bit may cause an exception to be The ability of the RESUME PROGRAM, SET
recognized in other circumstances. ADDRESS SPACE CONTROL, and SET
ADDRESS SPACE CONTROL FAST
instructions to set the home-space mode in
Home Address Space the supervisor state, and the ability of the
INSERT ADDRESS SPACE CONTROL
Facilities are provided which a privileged program,
instruction to return an indication of the home-
such as the control program, can use to obtain
space mode.
control in and access the home address space of
a dispatchable unit (for example, a task). The home space-switch-event control, bit 57
of control register 13.
Each dispatchable unit normally has an address
Recognition of a space-switch event upon
space associated with it in which the control
completion of a RESUME PROGRAM, SET
program keeps the principal control blocks that
ADDRESS SPACE CONTROL, or SET
represent the dispatchable unit. This address
ADDRESS SPACE CONTROL FAST instruc-
space is called the home address space of the
tion if the CPU was in the home-space mode
dispatchable unit. Different dispatchable units
before or after the operation but not both
may have the same or different home address
before and after the operation, if any of the
spaces. When the control program initiates a
following is true: (1) the primary space-
dispatchable unit, it may set the primary and sec-
switch-event control, bit 57 of control register
ondary address spaces equal to the home
1, is one, (2) the home space-switch-event
address space of the dispatchable unit. There-
control is one, or (3) a PER event is to be
after, because of the dispatchable unit's possible
indicated.
use of the PROGRAM CALL, PROGRAM
RETURN, PROGRAM TRANSFER, or SET SEC- The space-switch event can be used to enable or
ONDARY ASN instruction, the control program disable PER or tracing when fetching of
normally cannot depend on either the primary instructions begins or ends in particular address
address space or the secondary address space spaces.
being the home address space when the home
address space must be accessed, for example,
during the processing by the control program of an Access-Register Introduction
interruption. Therefore, the control program
Many of the functions related to access registers
normally must take some special action to ensure
are described in this section and in Subroutine
that the home address space is addressed when it
Linkage without the Linkage Stack on page 5-10,
must be accessed. The home-address-space
Access-Register Translation on page 5-43, and
facilities provide an efficient means to take this
Sequence of Storage References on page 5-77.
action.
Additionally, translation modes and access-list-
controlled protection are described in Chapter 3,
The home-address-space facilities include:
Storage; the PER means of restricting storage-
The home address-space-control element alteration events to designated address spaces
(HASCE) in control register 13. The HASCE and the handling of access registers during resets
is used by DAT in the same way as the and during the store-status operation are
primary address-space-control element described in Chapter 4, Control; interruptions are
(PASCE) in control register 1 and the sec- described in Chapter 6, Interruptions;
ondary address-space-control element instructions are described in Chapter 7, General
(SASCE) in control register 7. Instructions, and Chapter 10, Control
Home-space mode, which results when DAT Instructions; the handling of access registers
is on and the address-space control, PSW bits during a machine-check interruption and the pro-
16 and 17, has the value 11 binary. When grammed validation of the access registers are
the CPU is in the home-space mode, instruc- described in Chapter 11, Machine-Check
tion and logical addresses are home virtual Handling; and the alter-and-display controls for
addresses and are translated by DAT by access registers are described in Chapter 12,
means of the HASCE. Operator Facilities.

5-34 z/Architecture Principles of Operation


Summary mode. The stacking PROGRAM CALL,
PROGRAM RETURN, and RESUME PROGRAM
These major functions are provided: instructions also allow setting of the access-
register mode. All of these instructions are
A maximum of 16 address spaces, including described in Chapter 10, Control Instructions.
the instruction space, for immediate and
simultaneous use by a semiprivileged Access registers are used in a special way by the
program; the address spaces are specified by BRANCH IN SUBSPACE GROUP instruction.
16 registers called access registers. The use of access registers by that instruction is
Instructions for examining and changing the described in detail only in the definition of the
contents of the access registers. instruction in Chapter 10, Control Instructions.
However, Subspace-Group Tables on page 5-55
In addition, control and authority mechanisms are describes the use of the dispatchable-unit control
incorporated to control these functions. table and the extended ASN-second-table entry by
BRANCH IN SUBSPACE GROUP.
Access registers allow a sequence of instructions,
or even a single instruction such as MOVE (MVC)
or MOVE LONG (MVCL), to operate on storage Access-Register Functions
operands in multiple address spaces, without the
requirement of changing either the translation Access-Register-Specified Address
mode or other control information. Thus, a Spaces
program residing in one address space can use The CPU includes sixteen 32-bit access registers
the complete instruction set to operate on data in numbered 0-15. In the access-register mode,
that address space and in up to 15 other address which results when DAT is on and PSW bits 16
spaces, and it can move data between any and all and 17 are 01 binary, an instruction B or R field
pairs of these address spaces. Furthermore, the that is used to specify the logical address of a
program can change the contents of the access storage operand designates not only a general
registers in order to access still other address register but also an access register. The desig-
spaces. nated general register is used in the ordinary way
to form the logical address of the storage operand.
The instructions for examining and changing The designated access register is used to specify
access-register contents are unprivileged and are the address space to which the logical address is
described in Chapter 7, General Instructions. relative. The access register specifies the
They are: address space by specifying an address-space-
control element for the address space, and this
COPY ACCESS
address-space-control element is used by DAT to
EXTRACT ACCESS
translate the logical address. An access register
LOAD ACCESS MULTIPLE
specifies an address-space-control element in an
LOAD ADDRESS EXTENDED
indirect way, not by containing the address-space-
SET ACCESS
control element.
STORE ACCESS MULTIPLE
The privileged PURGE ALB instruction and An access register may specify the primary or
COMPARE AND SWAP AND PURGE instruction secondary address-space-control element in
are used in connection with access registers and control register 1 or 7, respectively, or it may
are described in Chapter 10, Control specify an address-space-control element con-
Instructions. tained in an ASN-second-table entry. In the latter
case, the access register designates an entry in a
Access registers specify address spaces when the table called an access list, and the designated
CPU is in the access-register mode. The SET access-list entry in turn designates the
ADDRESS SPACE CONTROL and SET ASN-second-table entry.
ADDRESS SPACE CONTROL FAST instructions
allow setting of the access-register mode, and the The process of using the contents of an access
INSERT ADDRESS SPACE CONTROL instruction register to obtain an address-space-control
provides an indication of the access-register element for use by DAT is called access-register

Chapter 5. Program Execution 5-35


translation (ART). This is depicted in Figure 5-8 containing the first-operand location by access
on page 5-36. register 1. These two address spaces may be dif-
Instruction ferent address spaces, and each may be different
Displacement from the current instruction address space (the
B D
primary address space).

General Register
In Access-Register Mode When PSW bits 16 and 17 are 01, the B field of
5 Base Address
the LOAD REAL ADDRESS and STORE REAL

Access Register 6 ADDRESS instructions designates an access reg-
ister, for use in access-register translation, regard-
5 + %
less of whether DAT is on or off.

Logical Address
6 6 The COMPARE AND FORM CODEWORD and

UPDATE TREE instructions specify storage oper-
ART ASCE 5 DAT
ands by means of implicitly designated general
registers and access registers.

6
Real Address The MOVE TO PRIMARY and MOVE TO SEC-
Figure 5-8. Use of Access Registers ONDARY instructions specify storage operands by
means of primary virtual and secondary virtual
An access register is said to specify an addresses, and access registers do not apply to
AR-specified address space by means of an these instructions. An exception is recognized
AR-specified address-space-control element. The when either of these instructions is executed in
virtual addresses in an AR-specified address the access-register mode. The MOVE WITH KEY
space are called AR-specified virtual addresses. instruction can be used in place of MOVE TO
PRIMARY and MOVE TO SECONDARY in the
In the access-register mode, whereas all storage- access-register mode. The MOVE WITH
operand addresses are AR-specified virtual, SOURCE KEY and MOVE WITH DESTINATION
instruction addresses are primary virtual. KEY instructions also can be used.

Designating Access Registers: In the access- An instruction R field may designate an access
register mode, an instruction B or R field desig- register for other than the purpose of access-
nates an access register, for use in register translation.
access-register translation, under the following
conditions: The fields which may designate access registers,
The field is a B field which designates a whether or not for access-register translation, are
general register containing a base address. indicated in the summary figure at the beginning
The base address is used, along with a dis- of each instruction chapter.
placement (D) and possibly an index (X), to
form the logical address of a storage operand. Obtaining the Address-Space-Control
Element: This section and the following ones
The field is an R field which designates a introduce the access-register-translation process
general register containing the logical address and present the concepts related to access lists.
of a storage operand.
For example, consider the following instruction: The address-space-control element specified by
an access register is obtained by access-register
MVC (L,1),(2) translation as follows:
The second operand, of length L, is to be moved If the access register contains 00000000 hex,
to the first-operand location. The logical address the specified address-space-control element is
of the second operand is in general register 2, and the primary address-space-control element
that of the first-operand location in general register (PASCE), obtained from control register 1.
1. The address space containing the second
operand is specified by access register 2, and that If the access register contains 00000001 hex,
the specified address-space-control element is

5-36 z/Architecture Principles of Operation


the secondary address-space-control element ASN-second-table entry, bit 0 of the entry, the
(SASCE), obtained from control register 7. ASX-invalid bit, must be zero; otherwise, an
exception is recognized.
If the access register contains any other
value, the specified address-space-control
Access Lists: The access-list entry that is desig-
element is obtained from an
nated by the contents of an access register can
ASN-second-table entry. The contents of the
be located in either one of two access lists, the
access register designate an access-list entry
dispatchable-unit access list or the primary-space
that contains the real origin of the
access list. A bit in the access register specifies
ASN-second-table entry.
which of the two access lists contains the desig-
Access register 0 is treated in a special way by nated entry. Both of the access lists reside in real
access-register translation; it is treated as con- or absolute storage. The locations of the access
taining 00000000 hex, and its actual contents are lists are specified by means of control registers 2
not examined. Thus, a logical address specified and 5.
by means of a zero B or R field in the access-
register mode is always relative to the primary Control register 2 contains the origin of a real-
address space, regardless of the contents of storage area called the dispatchable-unit control
access register 0. However, there is one excep- table. The dispatchable-unit control table contains
tion to how access register 0 is treated: the TEST the designation -- the real or absolute origin, and
ACCESS instruction uses the actual contents of length -- of the dispatchable-unit access list.
access register 0, instead of treating access reg-
ister 0 as containing 00000000 hex. Control register 5 contains the origin of a real-
storage area called the primary ASN-second-table
The treatment of an access register containing the entry. The primary ASN-second-table entry con-
value 00000000 hex as designating the current tains the designation of the primary-space access
primary address space allows that address space list.
to be addressed, in the access-register mode,
without requiring the use of an access-list entry. An access list, either the dispatchable-unit access
This is useful when the primary address space is list or the primary-space access list, contains
changed by a space-switching PROGRAM CALL some multiple of eight 16-byte entries, up to a
(PC-ss), PROGRAM RETURN (PR-ss), or maximum of 1,024 entries.
PROGRAM TRANSFER (PT-ss) instruction. Simi-
larly, the treatment of an access register con- Programs and Dispatchable Units: When dis-
taining the value 00000001 hex as designating the cussing access lists, it is necessary to distinguish
secondary address space allows that space to be between the terms program and dispatchable
addressed after a space-switching operation, unit. A program is a sequence of instructions and
again without requiring the use of an access-list may be referred to as a program module. A
entry. program may be a sequence of calling and called
programs. A dispatchable unit, which is some-
The contents of the access registers are not times called a process or a task, is a unit of work
changed by the PROGRAM CALL and PROGRAM that is performed through the execution of a
TRANSFER instructions. Therefore, an access program by one CPU at a time.
register containing 00000000 or 00000001 hex
may specify a different address space after the The dispatchable-unit access list is intended to be
execution of PROGRAM CALL or PROGRAM associated with a dispatchable unit; that is, it is
TRANSFER than before the execution. For intended that a dispatchable unit have the same
example, if a space-switching PROGRAM CALL dispatchable-unit access list regardless of which
instruction is executed, an access register con- program is currently being executed to perform the
taining 00000000 hex specifies the old primary dispatchable unit. There is no mechanism, except
address space before the execution and the new for the LOAD CONTROL instruction, that changes
primary address space after the execution. the dispatchable-unit-control-table origin in control
register 2.
When access-register translation obtains an
address-space-control element from an

Chapter 5. Program Execution 5-37


The primary-space access list is associated with The access-list-entry sequence number (ALESN)
the primary address space that is specified by the in the ALET is described in the next section.
primary ASN in control register 4 and the primary
address-space-control element in control register The above format of the ALET does not apply
1. The primary-space access list that is available when the ALET is 00000000 or 00000001 hex.
for use by a dispatchable unit changes as the
primary address space of the dispatchable unit An ALET can exist in an access register, in a
changes, that is, whenever a program in a dif- general register, or in storage, and it has no
ferent primary address space begins to be exe- special protection from manipulation by the
cuted to perform the dispatchable unit. Whenever problem program. Any program can transfer
a LOAD ADDRESS SPACE PARAMETERS, ALETs back and forth among access registers,
PROGRAM CALL, PROGRAM RETURN, or general registers, and storage. A called program
PROGRAM TRANSFER instruction replaces the can save the contents of the access registers in
primary ASN in control register 4 and the primary any storage area available to it, load and use the
address-space-control element in control register access registers for its own purposes, and then
1, it also replaces the primary-ASN-second-table- restore the original contents of the access regis-
entry origin in control register 5. ters before returning to its caller.

Thus, for a dispatchable unit, the dispatchable-unit Allocating and Invalidating Access-List
access list is intended to be constant (although its Entries: It is intended that access lists be pro-
entries may be changed, as will be described), vided by the control program and that they be pro-
and the primary-space access list is a function of tected from direct manipulation by any problem
which program is being executed, through being a program. This protection may be obtained by
function of the primary address space of the means of key-controlled protection or by placing
program. Also, all dispatchable units and pro- the access lists in real storage not accessible by
grams in the same primary address space have any problem program by means of DAT.
the same primary-space access list.
As determined by a bit in the entry, an access-list
Access-List-Entry Token: The contents of an entry is either valid or invalid. A valid access-list
access register are called an access-list-entry entry specifies an address space and can be used
token (ALET) since, in the general case, they des- by a suitably authorized program to access that
ignate an entry in an access list. An ALET has space. An invalid access-list entry is available for
the following format: allocation as a valid entry. It is intended that the
control program provide services that allocate

P ALESN ALEN valid access-list entries and that invalidate previ-


ously allocated entries.
7 8 16 31
Allocation of an access-list entry may consist in
The ALET contains a primary-list bit (P) that speci-
the following steps. A problem program passes
fies which access list contains the designated
some kind of identification of an address space to
access-list entry: the dispatchable-unit access list
the control program, and it passes a specification
if the bit is zero, or the primary-space access list if
of either the dispatchable-unit access list or the
the bit is one. The specified access list is called
primary-space access list. The control program
the effective access list.
checks, by some means, the authority of the
problem program to access the address space. If
The ALET also contains an access-list-entry
the problem program is authorized, the control
number (ALEN) which, when multiplied by 16, is
program selects an invalid entry in the specified
the number of bytes from the beginning of the
access list, changes it to a valid entry specifying
effective access list to the designated access-list
the subject address space, and returns to the
entry. During access-register translation, an
problem program an access-list-entry token
exception is recognized if the ALEN designates an
(ALET) that designates the allocated entry. The
entry that is outside the effective access list or if
problem program can subsequently place the
the leftmost seven bits in the ALET are not all
ALET in an access register in order to access the
zeros.
address space. Later, through the use of the

5-38 z/Architecture Principles of Operation


invalidation service of the control program, the Other elements used in the related authorization
access-list entry that was allocated may be made mechanism are: (1) a private bit in the access-list
invalid. An exception is recognized during access- entry, (2) an access-list-entry authorization index
register translation if an ALET is used that desig- (ALEAX) in the access-list entry, and (3) the
nates an invalid access-list entry. authority table.

It may be that a particular access-list entry is allo- A program is authorized to use an access-list
cated, then invalidated, and then allocated again, entry, in access-register translation, if any of the
this time specifying a different address space than following conditions is met:
the first time. To guard against erroneous use of
1. The private bit in the access-list entry is zero.
an ALET that designates a conceptually wrong
This condition provides a high-performance
address space, an access-list-entry sequence
means to authorize any and all programs that
number (ALESN) is provided in both the ALET
are executed to perform the dispatchable unit.
and the access-list entry. When the control
program allocates an access-list entry, it should 2. The ALEAX in the access-list entry is equal to
place the same ALESN in the entry and in the the EAX in control register 8. This condition
designating ALET that it returns to the problem provides a high-performance means to
program. When the control program reallocates authorize only particular programs.
an access-list entry, it should change the value of 3. The EAX selects a secondary bit that is one in
the ALESN. An exception is recognized during the authority table associated with the address
access-register translation if the ALESN in the space that is specified by the access-list entry.
ALET used is not equal to the ALESN in the des- The authority table is locatable in that the
ignated access-list entry. access-list entry contains the real origin of the
ASN-second-table entry (ASTE) for the
The ALESN check is a reliability mechanism, not
address space, and the ASTE contains the
an authority mechanism, because the ALET is not
real origin of the authority table. This condi-
protected from the problem program, and the
tion provides another means, less well-
problem program can change the ALESN in the
performing than condition 2, for authorizing
ALET to any value. Also, this is not a fail-proof
only particular programs. However, providing
reliability mechanism because the ALESN is one
for condition 3 to be met instead of condition 2
byte and its value wraps around after 256 reallo-
can be advantageous because it permits
cations, assuming that the value is incremented by
several programs, each executed with a dif-
one for each reallocation.
ferent EAX, all to use a single access-list
entry to access a particular address space.
Authorizing the Use of Access-List Entries:
Although an access list is intended to be associ- Access-register translation tests for the three con-
ated with either a dispatchable unit or a primary ditions in the order indicated by their numbers,
address space, the valid entries in the list are and a higher-numbered condition is not tested for
intended to be associated with the different pro- if a lower-numbered condition is met. An excep-
grams that are executed, in some order, to tion is recognized if none of the conditions is met.
perform the work of the dispatchable unit. It is
intended that each program be able to have a par- Figure 5-9 on page 5-40 shows an example of
ticular authority that permits the use of only those how the authorization mechanism can be used. In
access-list entries that are associated with the the figure, PBZ means that the private bit is
program. The authority being referred to here is zero, and PBO means that the private bit is one.
represented by a 16-bit extended authorization
index (EAX) in control register 8.

Chapter 5. Program Execution 5-39


Access List

/ / ASTE for Space 36

4 PBZ 5

/ / ASTE for Space 25

7 PBO, ALEAX = 5 5

/ / ASTE for Space 62

9 PBO, ALEAX = 1 5

/ / ASTE for Space 17 Authority Table

12 PBO, ALEAX = 5 5 5S bit selected by
EAX 1 is one.
/ /

Program A Program B Program C



EAX = %5 EAX = 5 %5 EAX = 1

Figure 5-9. Example of Authorizing the Use of Access-List Entries

The figure shows an access listassume it is a use ALE 7 to access space 25 because the
dispatchable-unit access listin which the entries ALEAX in the ALE equals the EAX for the
of interest are entries 4, 7, 9, and 12. Each program, and no other program can use this ALE.
access-list entry contains a private bit, an ALEAX, Similarly, only program C can use ALE 9.
and the real origin of the ASTE for an address Program B can use ALE 12 because the ALEAX
space. The private bit in entry 4 is zero, and, and EAX are equal, and program C can use it
therefore, the value of the ALEAX in entry 4 is because C's EAX selects a secondary bit that is
immaterial and is not shown. The private bits in one in the authority table for space 17.
entries 7, 9, and 12 are ones, and the ALEAX
values in these entries are as shown. The The example would be the same if programs A, B,
numbers used to identify the address spaces (36, and C were all in the same address space and the
25, 62, and 17) are arbitrary. They may be the access list were the primary-space access list for
ASNs of the address spaces; however, ASNs are that space.
in no way used in access-register translation.
Only the authority table for address space 17 is An ALE in which the private bit is zero may be
shown. In it, the secondary bit selected by EAX called public because the ALE can be used by
10 is one. Assume that no secondary bits are any program, regardless of the value of the
ones in the authority tables for the other spaces. current EAX. An ALE in which the private bit is
one may be called private because the ability of a
The figure also shows a sequence of three pro- program to use the ALE depends on the current
grams, named A, B, and C, that is executed to EAX.
perform the work of the dispatchable unit associ-
ated with the access list. These programs may be Notes on the Authorization Mechanism: An
in the same or different address spaces. The access list is a kind of capability list, in the sense
EAX in control register 8 when each of these pro- in which the word capability is used in computer
grams is executed is 0, 5, and 10, respectively. science. It is up to the control program to formu-
late the policies that are used to allocate entries in
Each of programs A, B, and C can use access-list an access list, and the programmed authorization
entry (ALE) 4 to access address space 36 since checking required during allocation may be very
the private bit in ALE 4 is zero. Program B can complex and lengthy. After a valid entry has been

5-40 z/Architecture Principles of Operation


made in an access list, the access-register- ASTESN in the ALE must equal the ASTESN in
translation process enforces the control-program the designated ASTE; otherwise, an exception is
policies in a well-performing way by means of the recognized.
authorization mechanism described above.
When the control program allocates an ALE, it
Using access lists has an advantage over using should copy the ASTESN from the designated
only ASNs and authority tables. For example, ASTE into the ALE. Subsequently, the control
assume that an access register could contain an program can, in effect, revoke the addressing
ASN and that access-register translation would do capability represented by the ALE by changing the
ASN translation of the ASN and then use the EAX ASTESN in the ASTE. Changing the ASTESN in
to test the authority table. This would make the the ASTE makes all previously usable ALEs that
EAX relevant to all existing address spaces, and, designate the ASTE unusable.
therefore, it would make the management of EAXs
and their assignment to programs more difficult. Making an ALE unusable may be required in
With the actual definitions of the ALET and either of two cases:
access-register translation, an EAX is relevant to 1. Some element of the control-program policy
only the address spaces that are represented in for determining the authority of a program to
the current dispatchable-unit and primary-space have access to the address space specified
access lists. Also, since ASN translation is not by the ASTE has changed. This may mean
done as a part of access-register translation, the that some or all of the programs that were
number of concurrently existing address spaces, authorized to the address space, and for
as represented by ASN-second-table entries, can which ALEs have been allocated, are no
be greater than the number of available ASNs longer authorized.
(64K).
Changing the ASTESN in the ASTE ends the
The entry-table entry and linkage stack can be usability of all ALEs that designate the ASTE.
used to assign EAXs to programs and to change If this revocation of capability is to be selec-
the EAX in control register 8 during program link- tive, then, when an exception is recognized
ages. These components are introduced in because of unequal ASTESNs, the control
Linkage-Stack Introduction on page 5-60. The program can reapply its programmed proce-
privileged EXTRACT AND SET EXTENDED dures for determining authorization, and an
AUTHORITY instruction also is available for ALE which should have remained usable can
saving and changing the EAX in control register 8. be made usable again by copying the new
ASTESN into it. When the usability of an ALE
The SET SECONDARY ASN instruction and the is restored, the control program normally
authorization index (AX), bits 32-47 of control reg- should cause reexecution of the instruction
ister 4, can play a role in the use of access regis- that encountered the exception.
ters. The space-switching form of SET
2. The ASTE has been reassigned to specify a
SECONDARY ASN (SSAR-ss) establishes a new
conceptually different address space, and
secondary address space if the secondary bit
ALEs which specified the old address space
selected by the AX is one in the authority table
must not be allowed to specify the new one.
associated with the new secondary space. The
(Bit 0 of the ASTE, the ASX-invalid bit, can be
secondary space can be addressed by means of
set to one to delete the assignment of the
an ALET having the value 00000001 hex.
ASTE to an address space, and this prevents
the use of the ASTE in access-register trans-
Revoking Accessing Capability: Another mech-
lation. But after reassignment, bit 0 normally
anism, which is a combined authority and integrity
is set back to zero.)
mechanism, is part of access-register translation,
and it is described in this section. The ASTESN mechanism may be regarded as an
authority mechanism in the first case above and
An access-list entry (ALE) contains an as an integrity mechanism in the second.
ASN-second-table-entry sequence number
(ASTESN), and so does the ASTE designated by The ASTESN mechanism is especially valuable
the ALE. During access-register translation, the because it avoids the need of the control program

Chapter 5. Program Execution 5-41


to keep track of the access lists that contain the Access-Register Instructions
ALEs that designate each ASTE. Furthermore, it The following instructions are provided for exam-
avoids the need of searching through these ining and changing the contents of access regis-
access lists in order to find the ALEs and set them ters:
invalid, to prevent the use of the ALEs in access-
register translation. The latter activity could be COPY ACCESS
particularly time-consuming, or could present a EXTRACT ACCESS
particularly difficult management problem, because LOAD ACCESS MULTIPLE
the access lists could be in auxiliary storage, such LOAD ADDRESS EXTENDED
as a direct-access storage device, when the need SET ACCESS
arises to invalidate the ALEs. STORE ACCESS MULTIPLE
The SET ACCESS instruction replaces the con-
The ASTESN is a four-byte field. Assuming a rea- tents of a specified access register with the con-
sonable frequency of authorization-policy changes tents of a specified general register. Conversely,
or address-space reassignments, the approxi- the EXTRACT ACCESS instruction moves the
mately four billion possible values of the ASTESN contents of an access register to a general reg-
provide a fail-proof authority or integrity mech- ister. The COPY ACCESS instruction moves the
anism over the lifetime of the system. contents of one access register to another.

Preventing Store References: The access-list The LOAD ACCESS MULTIPLE instruction loads
entry contains a fetch-only bit which, when one, a specified set of consecutively numbered access
specifies that the access-list entry cannot be used registers from a specified storage location whose
to perform storage-operand store references. The length in words equals the number of access reg-
principal description of the effect of the fetch-only isters loaded. Conversely, the STORE ACCESS
bit is in Access-List-Controlled Protection on MULTIPLE instruction function stores the contents
page 3-11. of a set of access registers at a storage location.

Improving Translation Performance: Access- The LOAD ADDRESS EXTENDED instruction is


register translation (ART) conceptually occurs similar to the LOAD ADDRESS instruction in that
each time a logical address is used to reference a it loads a specified general register with an effec-
storage operand in the access-register mode. To tive address specified by means of the B, X, and
improve performance, ART normally is imple- D fields of the instruction. In addition, LOAD
mented such that some or all of the information ADDRESS EXTENDED operates on the access
contained in the ART tables (access-list- register having the same number as the general
designation sources, access lists, ASN second register loaded. When the address-space control,
tables, and authority tables) is maintained in a PSW bits 16 and 17, is 00, 10, or 11 binary,
special buffer referred to as the ART-lookaside LOAD ADDRESS EXTENDED loads the access
buffer (ALB). The CPU necessarily refers to an register with 00000000, 00000001, or 00000002
ART-table entry in real storage only for the initial hex, respectively. When the address space
access to that entry. The information in the entry control is 01 binary, LOAD ADDRESS
may be placed in the ALB, and subsequent trans- EXTENDED loads the target access register with
lations may be performed using the information in a value that depends on the B field of the instruc-
the ALB. tion. If the B field is zero, LOAD ADDRESS
EXTENDED loads the target access register with
The PURGE ALB instruction and the COMPARE 00000000 hex. If the B field is nonzero, LOAD
AND SWAP AND PURGE instruction can be used ADDRESS EXTENDED loads the target access
to clear all information from the ALB after a register with the contents of the access register
change has been made to an ART-table entry in designated by the B field. However, in the last
real storage. case when bits 0-6 of the access register desig-
nated by the B field are not all zeros, the results in
the target general register and access register are
unpredictable.

5-42 z/Architecture Principles of Operation


The address-space-control values 00, 01, 10, and translation may obtain the dispatchable-unit
11 binary specify primary-space, access-register, access-list designation from the dispatchable-unit
secondary-space, and home-space mode, respec- control table.
tively, when DAT is on. LOAD ADDRESS
EXTENDED functions the same regardless of Control Register 5
whether DAT is on or off. The location of the primary ASN-second-table
entry is specified in control register 5. The reg-
When used in access-register translation, the ister has the following format:
access-register values 00000000 and 00000001
/
hex specify the primary and secondary address PASTEO
spaces, respectively, and the value 00000002 hex /
designates entry 2 in the dispatchable-unit access 33 58 63
list. Loading the target access register with
00000002 hex when the address-space control is Primary-ASTE Origin (PASTEO): Bits 33-57 of
11 binary is intended to support assignment, by control register 5, with six zeros appended on the
the control program, of entry 2 in the dispatchable- right, form a 31-bit real address that designates
unit access list as specifying the home address the beginning of the primary ASN-second-table
space. entry. Access-register translation may obtain the
primary-space access-list designation from the
primary ASTE. The primary-ASTE origin is set by
Access-Register Translation LOAD ADDRESS SPACE PARAMETERS when it
performs PASN translation and by the space-
Access-register translation is introduced in
switching forms of PROGRAM CALL, PROGRAM
Access-Register-Specified Address Spaces on
RETURN, and PROGRAM TRANSFER. When
page 5-35.
any of these instructions places the primary-ASTE
origin in control register 5, it also places zeros in
Access-Register-Translation bit positions 32 and 58-63 of the register and
Control leaves bits 0-31 of the register unchanged. Bits
0-32 and 58-63 of control register 5 are subject to
Access-register translation is controlled by an possible future assignment, and they should not
address-space control and by controls in control be depended upon to be zeros.
registers 2, 5, and 8. The address-space control,
PSW bits 16 and 17, is described in Translation Control Register 8
Modes on page 3-28. The other controls are The extended authorization index is in control reg-
described below. ister 8. The register has the following format:
/
Additional controls are located in the access- EAX Monitor Masks
register-translation tables. /
32 48 63
Control Register 2
The location of the dispatchable-unit control table Extended Authorization Index (EAX): Bits
is specified in control register 2. The register has 32-47 of control register 8 are the extended
the following format: authorization index. During access-register trans-
lation, the EAX may be compared against the
/
DUCTO access-list-entry authorization index (ALEAX) in an
/ access-list entry, and it may be used as an index
33 58 63 to locate a secondary bit in an authority table.
The EAX may be set by a stacking PROGRAM
Dispatchable-Unit-Control-Table Origin CALL operation, and it is restored by PROGRAM
(DUCTO): Bits 33-57 of control register 2, with RETURN. The EAX can also be saved and set by
six zeros appended on the right, form a 31-bit real the privileged instruction EXTRACT AND SET
address that designates the beginning of the EXTENDED AUTHORITY.
dispatchable-unit control table. Access-register

Chapter 5. Program Execution 5-43


Access Registers effective access-list length to determine whether
the designated access-list entry is within the list,
There are sixteen 32-bit access registers num- and an ALEN-translation exception is recognized if
bered 0-15. The contents of an access register the entry is outside the list. Although the largest
are called an access-list-entry token (ALET). An possible value of the ALEN is 65,535, an access
ALET has the following format: list can contain at most 1,024 entries.

Bits 0-6 must be zeros during access-register


P ALESN ALEN
translation; otherwise, an ALET-specification
7 8 16 31 exception is recognized.

The fields in the ALET are allocated as follows: When the ALET is 00000000 or 00000001 hex, it
specifies the primary or secondary address space,
Primary-List Bit (P): When the ALET is not respectively, and the above format does not apply.
00000000 or 00000001 hex, bit 7 specifies the
access list to be used by access-register trans- Access register 0 usually is treated in access-
lation. When bit 7 is zero, the dispatchable-unit register translation as containing 00000000 hex,
access list is used; this is specified by the and its actual contents are not examined; the
dispatchable-unit access-list designation in the access-register translation done as part of TEST
dispatchable-unit control table designated by the ACCESS is the only exception. Access register 0
contents of control register 2. When bit 7 is one, is also treated as containing 00000000 hex when
the primary-space access list is used; this is spec- it is designated by the B field of LOAD ADDRESS
ified by the primary-space access-list designation EXTENDED when PSW bits 16 and 17 are 01
in the primary ASTE designated by the contents of binary. When access register 0 is specified for
control register 5. TEST ACCESS or as a source for COPY
ACCESS, EXTRACT ACCESS, or STORE
Access-List-Entry Sequence Number ACCESS MULTIPLE, the actual contents of the
(ALESN): Bits 8-15 may be used as a check on access register are used. Access register 0, like
whether the access-list entry designated by the any other access register, can be loaded by
ALET has been invalidated and reallocated since COPY ACCESS, LOAD ACCESS MULTIPLE,
the ALET was obtained. During access-register LOAD ADDRESS EXTENDED, and SET
translation when the ALET is not 00000000 or ACCESS.
00000001 hex, bits 8-15 of the ALET are com-
pared against the access-list-entry sequence Another definition of ALETs 00000000 and
number (ALESN) in the designated access-list 00000001 hex is given in BRANCH IN SUB-
entry. SPACE GROUP on page 10-13.

Access-List-Entry Number (ALEN): When the


ALET is not 00000000 or 00000001 hex, bits Access-Register-Translation
16-31 of the ALET designate an entry in either the Tables
dispatchable-unit access list or the primary-space
access list, as determined by bit 7. The access- When the ALET being translated is not 00000000
list designation that is used is called the effective or 00000001 hex, access-register translation per-
access-list designation; it consists of the effective forms a two-level lookup to locate first the effec-
access-list origin and the effective access-list tive access-list designation and then an entry in
length. the effective access list. The effective access-list
designation resides in real storage. The effective
During access-register translation, the ALEN, with access list resides in real or absolute storage.
four zeros appended on the right, is added to the
31-bit real or absolute address specified by the Access-register translation uses an origin in the
effective access-list origin, and the result is the access-list entry to locate an ASN-second-table
real or absolute address of the designated access- entry, and it may perform a one-level lookup to
list entry. The ALEN is compared against the locate an entry in an authority table. The
ASN-second-table entry resides in real storage.

5-44 z/Architecture Principles of Operation


The authority table resides in real or absolute In the 64-Bit Addressing Mode
storage.
2 32 Bits -31 of
Return Address
Authority-table entries are described in Authority-

Table Entries on page 3-24. Access-list desig- 24 36 Bits 33-63 of
nations, access-list entries, and ASN-second-table Return Address
entries are described in the following sections.

Dispatchable-Unit Control Table and


Access-List Designations 28 4
When the ALET being translated is not 00000000
2C 44 Trap-Control-
or 00000001 hex, access-register translation Block Address E
obtains the dispatchable-unit access-list desig-
nation if bit 7 of the ALET is zero, or it obtains the 3 48
primary-space access-list designation if bit 7 is / /
one. The obtained access-list designation is 3C 6

called the effective access-list designation.

The dispatchable-unit access-list designation Bytes 0-7 (BASTEO, SA, and SSASTEO) and
(DUALD) is located in bytes 16-19 of a 64-byte 12-15 (SSASTESN) of the DUCT are described in
area called the dispatchable-unit control table Subspace-Group Dispatchable-Unit Control
(DUCT). The DUCT resides in real storage, and Table on page 5-55. Bytes 20-23 (PSW key
its location is specified by the DUCT origin in mask, PSW key, RA, and P) and 32-39 (BA and
control register 2. return address) are described in BRANCH AND
SET AUTHORITY on page 10-6. Bytes 44-47
The dispatchable-unit control table has the fol- (trap-control-block address and E) are described
lowing format: in TRAP on page 10-116. Bytes 8-11, 24-27,
40-43, and 48-63 are reserved for possible future
Hex Dec extensions and should contain all zeros. Bytes

BASTEO 28-31 are available for use by programming.

S The primary-space access-list designation


4 4 A SSASTEO (PSALD) is located in bytes 16-19 of a 64-byte
area called the primary ASN-second-table entry.
8 8 The primary ASTE resides in real storage, and its

C 12 SSASTESN location is specified by the primary-ASTE origin in


control register 5. The format of the primary
1 16 DUALD ASTE is described in ASN-Second-Table Entries
on page 5-47.
PSW-Key PSWR
14 2 Mask KeyA P The dispatchable-unit and primary-space access-

18 24 list designations both have the same format, which


is as follows:
1C 28 ///////////////////
Access-List Designation

Access-List Origin ALL
In the 24-Bit or 31-Bit
Addressing Mode 1 25 31

2 32
The fields in the access-list designation are allo-
24 36 B Bits 33-63 of cated as follows:
A Return Address

Chapter 5. Program Execution 5-45


Access-List Origin: Bits 1-24 of the access-list
designation, with seven zeros appended on the ASTESN
right, form a 31-bit address that designates the
96 127
beginning of the access list. This address is
treated unpredictably as either a real address or
an absolute address. The fields in the access-list entry are allocated as
follows:
Access-List Length (ALL): Bits 25-31 of the
access-list designation specify the length of the ALEN-Invalid Bit (I): Bit 0, when zero, indicates
access list in units of 128 bytes, thus making the that the access-list entry specifies an address
length of the access list variable in multiples of space. When bit 0 is one during access-register
eight 16-byte entries. The length of the access translation, an ALEN-translation exception is
list, in units of 128 bytes, is one more than the recognized.
value in bit positions 25-31. The access-list
length, with six zeros appended on the left, is Fetch-Only Bit (FO): Bit 6 controls which types
compared against bits 0-12 of an access-list-entry of operand references are permitted to the
number (bits 16-28 of an access-list-entry token) address space specified by the access-list entry.
to determine whether the access-list-entry number When bit 6 is zero, both fetch-type and store-type
designates an entry in the access list. references are permitted. When bit 6 is one, only
fetch-type references are permitted, and an
Bit 0 is reserved for a possible future extension attempt to store causes a protection exception for
and should be zero. access-list-controlled protection to be recognized
and the operation to be suppressed.
Programming Note: The maximum number of
access-list entries allowed by an access-list desig- Private Bit (P): Bit 7, when zero, specifies that
nation is 1,024. There are two access lists avail- any program is authorized to use the access-list
able for use at any time. Therefore, a maximum entry in access-register translation. When bit 7 is
of 2,048 16E-byte address spaces can be one, authorization is determined as described for
addressable without control-program intervention, bits 16-31.
which is a total of 2 bytes.
Access-List-Entry Sequence Number
Access-List Entries (ALESN): Bits 8-15 are compared against the
The effective access list is the dispatchable-unit ALESN in the ALET during access-register trans-
access list if bit 7 of the ALET being translated is lation. Inequality causes an ALE-sequence excep-
zero, or it is the primary-space access list if bit 7 tion to be recognized. It is intended that the
is one. The entry fetched from the effective control program change bits 8-15 each time it real-
access list is 16 bytes in length and has the fol- locates the access-list entry.
lowing format:
Access-List-Entry Authorization Index
(ALEAX): Bits 16-31 may be used to determine
F whether the program for which access-register
I OP ALESN ALEAX
translation is being performed is authorized to use
1 6 7 8 16 31 the access-list entry. The program is authorized if
any of the following conditions is met:
1. Bit 7 is zero.

2. Bits 16-31 are equal to the extended authori-
32 63 zation index (EAX) in control register 8.
3. The EAX selects a secondary bit that is one in
the authority table for the specified address
ASTEO
space.

64 9 95 An extended-authority exception is recognized if


none of the conditions is met.

5-46 z/Architecture Principles of Operation


ASN-Second-Table-Entry Origin (ASTEO): Bits RSD Part 2
65-89, with six zeros appended on the right, form
the 31-bit real address of the ASTE for the speci- RSTKO (Cont.) GPSXR R=1

fied address space. Access-register translation 96 115 118 122 127
obtains the address-space-control element for the
address space from the ASTE.
ALD

ASTE Sequence Number (ASTESN): Bits ALO ALL
96-127 may be used to revoke the addressing
capability represented by the access-list entry. 128 153 159
Bits 96-127 are compared against an ASTE
sequence number (ASTESN) in the designated
ASTE during access-register translation. ASTESN

Bits 1-5, 32-64, and 90-95 are reserved for pos- 16 191
sible future extensions and should be zeros.
LTD
In both the dispatchable-unit access list and the
primary-space access list, access-list entries 0 V LTO LTL
and 1 are intended not to be used in access-
192 217 223
register translation. Bits 1-127 of access-list entry
0 and bits 1-63 of access-list entry 1 are reserved
for possible future extensions and should be
/////////////////////////////////
zeros. Bit 0 of access-list entries 0 and 1, and
bits 64-127 of access-list entry 1, are available for 224 255
use by programming. The control program should
set bit 0 of access-list entries 0 and 1 to one in
The fields in bytes 0-31 of the ASN-second-table
order to prevent the use of these entries by
entry (ASTE) are defined with respect to certain
means of ALETs in which the ALEN is 0 or 1.
mechanisms and instructions in
ASN-Second-Table Entries on page 3-19. The
ASN-Second-Table Entries fields in the ASTE are defined with respect to the
The first 32 bytes of the 64-byte
BRANCH IN SUBSPACE GROUP instruction in
ASN-second-table entry have the following format:
Subspace-Group ASN-Second-Table Entries on
page 5-57. With respect to access-register trans-
I ATO B lation only, and only for an instruction other than
BRANCH IN SUBSPACE GROUP, the fields in
1 3 31 the ASTE are allocated as follows:

ASX-Invalid Bit (I): Bit 0 controls whether the


AX ATL address space associated with the ASTE is avail-
able. When bit 0 is zero, access-register trans-
32 48 6 63 lation proceeds. When the bit is one, an
ASTE-validity exception is recognized.
ASCE (RTD, STD, or RSD) Part 1
Authority-Table Origin (ATO): Bits 1-29, with
RTO, STO, or RSTKO two zeros appended on the right, form a 31-bit

64 95 address that designates the beginning of the


authority table. This address is treated unpredict-
ably as either a real address or an absolute
RTD or STD Part 2
address, although it is treated as a real address
RTO/STO (Cont.) GPSXR DTTL R= for ASN authorization. The authority table is
accessed in access-register translation only if the
96 115 118 122 124 127 private bit in the access-list entry is one and the
access-list-entry authorization index (ALEAX) in

Chapter 5. Program Execution 5-47


the access-list entry is not equal to the extended ASN-Second-Table-Entry Sequence Number
authorization index (EAX) in control register 8. (ASTESN): Bits 160-191 are used to control
revocation of the accessing capability represented
Base-Space Bit (B): Bit 31 is ignored during by access-list entries that designate the ASTE.
access-register translation. Bit 31 is further During access-register translation, bits 160-191
described in Subspace-Group ASN-Second-Table are compared against the ASTESN in the access-
Entries on page 5-57. list entry, and inequality causes an
ASTE-sequence exception to be recognized. It is
Authorization Index (AX): Bits 32-47 are not intended that the control program change the
used in access-register translation. value of bits 160-191 when the authorization poli-
cies for the address space specified by the ASTE
Authority-Table Length (ATL): Bits 48-59 change or when the ASTE is reassigned to specify
specify the length of the authority table in units of another address space.
four bytes, thus making the authority table variable
in multiples of 16 entries. The length of the Bits 224-255 in the ASTE are available for use by
authority table, in units of four bytes, is one more programming.
than the ATL value. The contents of the ATL field
are used to establish whether the entry designated Programming Note: All unused fields in the
by a particular EAX is within the authority table. ASTE, including the unused fields in bytes 0-31
An extended-authority exception is recognized if and all of bytes 32-63, should be set to zeros.
the entry is not within the table. These fields are reserved for future extensions,
and programs which place nonzero values in
Address-Space-Control Element (ASCE): Bits these fields may not operate compatibly on future
64-127 are an eight-byte address-space-control machines.
element (ASCE) that may be a segment-table des-
ignation (STD), a region-table designation (RTD),
or a real-space designation (RSD). (The term
Access-Register-Translation
region-table designation is used to mean a Process
region-first-table designation, region-second-table
designation, or region-third-table designation.) This section describes the access-register-
The ASCE field is obtained as the result of translation process as it is performed during a
access-register translation and is used by DAT to storage-operand reference in the access-register
translate the logical address for the storage- mode. LOAD REAL ADDRESS and STORE
operand reference being made. Bit 121, the REAL ADDRESS when PSW bits 16 and 17 are
space-switch-event control, is not used in or as a 01 binary, TEST ACCESS in any translation
result of access-register translation. The other mode, and TEST PROTECTION in the access-
fields in the ASCE (RTO, STO, RSTKO, G, P, S, register mode, perform access-register translation
R, DT, and TL) are described in Control Register the same as described here, except that, for
1 on page 3-29. LOAD REAL ADDRESS, TEST ACCESS, and
TEST PROTECTION, the following exceptions
Linkage-Table Designation (LTD): Bits cause a setting of the condition code instead of
192-223 are not used in access-register trans- being treated as program-interruption conditions:
lation. ALET specification
ALEN translation
Access-List Designation (ALD): When this ALE sequence
ASTE is designated by the primary-ASTE origin in ASTE validity
control register 5, bits 128-159 are the primary- ASTE sequence
space access-list designation (PSALD). During Extended authority
access-register translation when the primary-list
bit, bit 7, in the ALET being translated is one, the BRANCH IN SUBSPACE GROUP performs
PSALD is the effective access-list designation. access-register translation as described in
BRANCH IN SUBSPACE GROUP on
page 10-13.

5-48 z/Architecture Principles of Operation


Access-register translation operates on the access one or more of: (1) the private bit and access-list-
register designated in a storage-operand reference entry authorization index (ALEAX) in the access-
in order to obtain an address-space-control list entry, (2) the extended authorization index
element for use by DAT. When one of access- (EAX) in control register 8, and (3) an entry in the
registers 1-15 is designated, the access-list-entry authority table addressed by the
token (ALET) that is in the access register is used ASN-second-table entry.
to obtain the address-space-control element.
When access register 0 is designated, an ALET If a store-type reference is to be performed, the
having the value 00000000 hex is used, except fetch-only bit in the access-list entry is checked for
that TEST ACCESS uses the actual contents of being zero.
access register 0.
When no exceptions are recognized, the address-
When the ALET is 00000000 or 00000001 hex, space-control element in the ASN-second-table
the primary or secondary address-space-control entry is obtained.
element, respectively, is obtained.
In order to avoid the delay associated with refer-
When the ALET is other than 00000000 or ences to real or absolute storage, the information
00000001 hex, the leftmost seven bits of the fetched from real or absolute storage normally is
ALET are checked for zeros, the primary-list bit in also placed in a special buffer, the ART-lookaside
the ALET and the contents of control register 2 or buffer (ALB), and subsequent translations
5 are used to obtain the effective access-list des- involving the same information may be performed
ignation, and the access-list entry number (ALEN) by using the contents of the ALB. The operation
in the ALET is used to select an entry in the effec- of the ALB is described in ART-Lookaside Buffer
tive access list. on page 5-53.

The access-list entry is checked for validity and for Whenever access to real or absolute storage is
containing the correct access-list-entry sequence made during access-register translation for the
number (ALESN). purpose of fetching an entry from an access-list-
designation source, access list, ASN second table,
The ASN-second-table entry (ASTE) addressed by or authority table, key-controlled protection does
the access-list entry is checked for validity and for not apply.
containing the correct ASN-second-table-entry
sequence number (ASTESN). The principal features of access-register trans-
lation, including the effect of the ALB, are shown
Whether the program is authorized to use the in Figure 5-10 on page 5-50.
access-list entry is determined through the use of

Chapter 5. Program Execution 5-49


Access-List Designation ALET in Access Register Control Register 1

ALO ALL %1 PALESN ALEN PASCE




Control Register 7
6
Access List SASCE
5+



F
5IOPALESNALEAX ASTEO ASTESN



6 6

= if =?5 =? %
store?

CR 8
/
EAX
/


5 =? % 5 =? %




ASN-Second-Table Entry
/
5 I ATO ATL ASCE ASTESN
/

(x 4)
6 6 6
(x 1/4)
6 25 ALB 5 3
Authority Table
5+
6

5PS Obtained ASCE


Explanation:

The appropriate ALD is obtained:


1 When P in the ALET is zero (and the ALET is not zero or one), the DUALD in the DUCT is obtained.
When P in the ALET is one, the PSALD in the primary ASTE is obtained.

Information, which may include the ALD-source origin, ALET, ALO, and EAX, is used to search
2 the ALB. This information, along with information from the ALE, ASTE, and ATE, may be
placed in the ALB.

The appropriate ASCE is obtained:


3 When the ALET is zero, the PASCE in CR 1 is obtained.
When the ALET is one, the SASCE in CR 7 is obtained.
When the ALET is larger than one:
If a match exists, the ASCE from the ALB is used.
If no match exists, tables from real or absolute storage are fetched. The resulting ASCE from
the ASTE is obtained, and entries may be formed in the ALB.
Figure 5-10. Access-Register Translation

5-50 z/Architecture Principles of Operation


Selecting the Access-List-Entry Token The obtained 31-bit real address is used to fetch
When one of access registers 1-15 is designated, the effective ALDeither the dispatchable-unit
or for the access register designated by the R ALD or the primary-space ALD, depending on bit
field of TEST ACCESS, access-register translation 7 of the ALET. The fetch of the effective ALD
uses the access-list-entry token (ALET) that is in appears to be word-concurrent, as observed by
the access register. When access register 0 is other CPUs, and is not subject to protection.
designated, except for TEST ACCESS, an ALET When the storage address that is generated for
having the value 00000000 hex is used, and the fetching the effective ALD refers to a location
contents of access register 0 are not examined. which is not available in the configuration, an
addressing exception is recognized, and the oper-
Obtaining the Primary or Secondary ation is suppressed. When the primary-space
Address-Space-Control Element ALD is fetched, bit 0, the ASX-invalid bit, in the
primary ASTE is ignored.
When the ALET being translated is 00000000 hex,
the primary address-space-control element in Access-List Lookup
control register 1 is obtained. When the ALET is A lookup in the effective access list is performed.
00000001 hex, the secondary address-space- The effective access list is the dispatchable-unit
control element in control register 7 is obtained. access list if bit 7 of the ALET is zero, or it is the
In each of these two cases, access-register trans- primary-space access list if bit 7 is one. The
lation is completed. effective access list is treated unpredictably as
being in either real or absolute storage.
Checking the First Byte of the ALET
When the ALET being translated is other than The access-list-entry-number (ALEN) portion of
00000000 or 00000001 hex, bits 0-6 of the ALET the ALET is used to select an entry in the effective
are checked for being all zeros. If bits 0-6 are not access list. The 31-bit real or absolute address of
all zeros, an ALET-specification exception is the access-list entry is obtained by appending
recognized, and the operation is suppressed. seven zeros on the right to bits 1-24 of the effec-
tive ALD and adding the ALEN, with four rightmost
and 11 leftmost zeros appended. When a carry
Obtaining the Effective Access-List
into bit position 0 occurs during the addition, an
Designation
addressing exception may be recognized, or the
The primary-list bit, bit 7, in the ALET is used to
carry may be ignored, causing the access list to
perform a lookup to obtain the effective access-list
wrap from 2 - 1 to 0. The 31-bit address is
designation. When bit 7 is zero, the effective ALD
formed and used regardless of whether the
is the dispatchable-unit ALD located in bytes
current PSW specifies the 24-bit, 31-bit, or 64-bit
16-19 of the dispatchable-unit control table
addressing mode.
(DUCT). When bit 7 is one, the effective ALD is
the primary-space ALD located in bytes 16-19 of
As part of the access-list-lookup process, the left-
the primary ASN-second-table entry (primary
most 13 bits of the ALEN are compared against
ASTE).
the effective access-list length, bits 25-31 of the
effective ALD, to establish whether the addressed
When bit 7 is zero, the 31-bit real address of the
entry is within the access list. For this compar-
dispatchable-unit ALD is obtained by appending
ison, the access-list length is extended with six
six zeros on the right to the DUCT origin, bits
leftmost zeros. If the value formed from the
33-57 of control register 2, and adding 16. The
access-list length is less than the value in the 13
addition cannot cause a carry into bit position 0.
leftmost bits of the ALEN, an ALEN-translation
When bit 7 is one, the 31-bit real address of the exception is recognized, and the operation is nulli-
primary-space ALD is obtained by appending six fied.
zeros on the right to the primary-ASTE origin, bits
The 16-byte access-list entry is fetched by using
33-57 of control register 5, and adding 16. The
the real or absolute address. The fetch of the
addition cannot cause a carry into bit position 0.
entry appears to be word-concurrent as observed
by other CPUs, with the leftmost word fetched
first. The order in which the remaining three

Chapter 5. Program Execution 5-51


words are fetched is unpredictable. The fetch causes an ASTE-sequence exception to be recog-
access is not subject to protection. When the nized and the operation to be nullified.
storage address that is generated for fetching the
access-list entry refers to a location which is not Authorizing the Use of the Access-List
available in the configuration, an addressing Entry
exception is recognized, and the operation is sup- The private bit, bit 7, in the access-list entry is
pressed. used to determine whether the program is author-
ized to use the access-list entry. The access-list-
Bit 0 of the access-list entry indicates whether the entry authorization index (ALEAX) in bit positions
access-list entry specifies an address space by 16-31 of the access-list entry, the extended
designating an ASN-second-table entry. This bit authorization index (EAX) in bit positions 32-47 of
is inspected, and, if it is one, an ALEN-translation control register 8, and the authority table desig-
exception is recognized, and the operation is nulli- nated by the ASTE may also be used.
fied.
When the private bit is zero, the program is
When bit 0 is zero, the access-list-entry sequence authorized, and the authorization step of access-
number (ALESN) in bit positions 8-15 of the register translation is completed.
access-list entry is compared against the ALESN
in the ALET to determine whether the ALET desig- When the private bit is one but the ALEAX is
nates the conceptually correct access-list entry. equal to the EAX, the program is authorized, and
Inequality causes an ALE-sequence exception to the authorization step of access-register trans-
be recognized and the operation to be nullified. lation is completed.

Locating the ASN-Second-Table Entry When the private bit is one and the ALEAX is not
The ASN-second-table-entry (ASTE) origin in the equal to the EAX, a process called the extended-
access-list entry is used to locate the ASTE. Bits authorization process is performed. Extended
65-89 of the access-list entry, with six zeros authorization uses the EAX to select an entry in
appended on the right, form the 31-bit real the authority table designated by the ASTE, and it
address of the ASTE. tests the secondary-authority bit in the selected
entry for being one. The program is authorized if
The 64-byte ASTE is fetched by using the real the tested bit is one.
address. The fetch of the entry appears to be
word-concurrent as observed by other CPUs, with Extended authorization is the same as the
the leftmost word fetched first. The order in which secondary-ASN-authorization process described in
the remaining words are fetched is unpredictable. ASN Authorization on page 3-23, except as
The fetch access is not subject to protection. follows:
When the storage address that is generated for
The authority-table origin is treated as a real
fetching the ASTE refers to a location which is not
or absolute address instead of as a real
available in the configuration, an addressing
address.
exception is recognized, and the operation is sup-
pressed. The EAX in control register 8 is used instead
of the authorization index (AX) in control reg-
Bit 0 of the ASTE indicates whether the ASTE ister 4.
specifies an address space. This bit is inspected,
When the value in bit positions 0-11 of the
and, if it is one, an ASTE-validity exception is
EAX is greater than the authority-table length
recognized, and the operation is nullified.
(ATL) in the ASTE, an extended-authority
exception is recognized instead of a
When bit 0 is zero, the ASTE sequence number
secondary-authority exception. The operation
(ASTESN) in bit positions 160-191 of the ASTE is
is nullified if the extended-authority exception
compared against the ASTESN in bit positions
is recognized.
96-127 of the access-list entry to determine
whether the addressing capability represented by When the private bit is one, the ALEAX is not
the access-list entry has been revoked. Inequality equal to the EAX, and the secondary bit in the
authority-table entry selected by the EAX is not

5-52 z/Architecture Principles of Operation


one, an extended-authority exception is recog- in the entry may be placed in the ALB, and subse-
nized, and the operation is nullified. quent ART operations may be performed using
the information in the ALB. The presence of the
Checking for Access-List-Controlled ALB affects the ART process to the extent that
Protection (1) a modification of an ART-table entry in real or
If a store-type reference is to be performed and absolute storage does not necessarily have an
the fetch-only bit, bit 6, in the access-list entry is immediate effect, if any, on the translation, (2) the
one, a protection exception is recognized, and the comparison against the access-list length in an
operation is suppressed. access-list designation that is in storage and used
in a translation may be omitted if an ALB access-
Obtaining the Address-Space-Control list entry is used, and (3) the comparison against
Element from the ASN-Second-Table the authority-table length in an ASN-second-table
Entry entry that is in storage and used in a translation
may be omitted if an ALB authority-table entry is
When the ALET being translated is other than used. In a multiple-CPU configuration, each CPU
00000000 or 00000001 hex and no exception is has its own ALB.
recognized in the steps described above, access-
register translation obtains the address-space- Entries within the ALB are not explicitly address-
control element from bit positions 64-127 of the able by the program.
ASTE.
Information is not necessarily retained in the ALB
under all conditions for which such retention is
Recognition of Exceptions during possible. Furthermore, information in the ALB
Access-Register Translation may be cleared under conditions additional to
The exceptions which can be encountered during those for which clearing is mandatory.
the access-register-translation process and their
priority are shown in the section Access
ALB Structure
Exceptions in Chapter 6, Interruptions.
The description of the logical structure of the ALB
Programming Note: When updating an access- covers the implementation by all systems oper-
list entry or ASN-second-table entry, the program ating as defined by z/Architecture. The ALB
should change the entry from invalid to valid (set entries are considered as being of four types:
bit 0 of the entry to zero) as the last step of the ALB access-list designations (ALB ALDs), ALB
updating. This ensures, because the leftmost access-list entries (ALB ALEs), ALB
word is fetched first, that words of a partially ASN-second-table entries (ALB ASTEs), and ALB
updated entry will not be fetched. authority-table entries (ALB ATEs). An ALB entry
is considered as containing within it both the infor-
ART-Lookaside Buffer mation obtained from the ART-table entry in real
or absolute storage and the attributes used to
To enhance performance, the access-register- fetch the ART-table entry from real or absolute
translation (ART) mechanism normally is imple- storage. There is not an indication in an ALB ALD
mented such that access-list designations and of whether the ALD-source origin used to select
information specified in access lists, ASN second the ALD in real storage was the dispatchable-unit-
tables, and authority tables are maintained in a control-table origin or the primary-ASTE origin.
special buffer, referred to as the ART-lookaside Note: The following sections describe the condi-
buffer (ALB). Access-list designations, access-list tions under which information may be placed in
entries, ASN-second-table entries, and authority- the ALB, the conditions under which information
table entries are collectively referred to as from the ALB may be used for access-register
ART-table entries. The CPU necessarily refers to translation, and how changes to the tables affect
an ART-table entry in real or absolute storage only the ART process.
for the initial access to that entry. The information

Chapter 5. Program Execution 5-53


Formation of ALB Entries Use of ALB Entries
The formation of ALB entries and the effect of any The usable state of an ALB entry denotes that the
manipulation of the contents of an ART-table entry CPU can attempt to use the ALB entry for access-
in real or absolute storage by the program depend register translation. A usable ALB entry attaches
on whether the entry is attached to a particular the next-lower-level table, if any, and may be
CPU and on whether the entry is valid. usable for a particular instance of access-register
translation.
The attached state of an ART-table entry denotes
that the CPU to which the entry is attached can An ALB ALD is in the usable state when the
attempt to use the entry for access-register trans- ALDSO field in the ALB ALD matches the current
lation. The ART-table entry may be attached to dispatchable-unit-control-table origin or the current
more than one CPU at a time. primary-ASTE origin.

An access-list entry or ASN-second-table entry is An ALB ALD may be used for a particular instance
valid when the invalid bit associated with the entry of access-register translation when either of the
is zero. Access-list designations and authority- following conditions is met:
table entries have no invalid bit and are always
1. The primary-list bit in the ALET to be trans-
valid. The primary-space access-list designation
lated is zero, and the ALDSO field in the ALB
is valid regardless of the value of the invalid bit in
ALD matches the current dispatchable-unit-
the primary ASTE.
control-table origin.
An ART-table entry may be placed in the ALB 2. The primary-list bit in the ALET to be trans-
whenever the entry is attached and valid. lated is one, and the ALDSO field in the ALB
ALD matches the current primary-ASTE origin.
An access-list designation is attached to a CPU
An ALB ALE is in the usable state when the ALO
when the designation is within the dispatchable-
field in the ALB ALE matches the ALO field in an
unit control table designated by the dispatchable-
attached ALD or a usable ALB ALD.
unit-control-table origin in control register 2 or is
within the primary ASTE designated by the
An ALB ALE may be used for a particular instance
primary-ASTE origin in control register 5.
of access-register translation when all of the fol-
lowing conditions are met:
An access-list entry is attached to a CPU when
the entry is within the access list specified by 1. The ALET to be translated has a value larger
either an attached access-list designation (ALD) or than 1. (If the ALET is 0 or 1, the contents of
a usable ALB ALD. A usable ALB ALD is CR 1 or CR 7 are used.)
explained in the next section.
2. The ALO field in the ALB ALE matches the
ALO field in the ALD or ALB ALD being used
An ASN-second-table entry is attached to a CPU
in the translation.
when it is designated by the ASTE origin in either
an attached and valid access-list entry (ALE) or a 3. The ALEN field in the ALB ALE matches the
usable ALB ALE. A usable ALB ALE is explained ALEN field in the ALET to be translated.
in the next section.
An ALB ASTE is in the usable state when the
ASTEO field in the ALB ASTE matches the
An authority-table entry is attached to a CPU
ASTEO field in an attached and valid ALE or a
when it is within the authority table designated by
usable ALB ALE.
either an attached and valid ASN-second-table
entry (ASTE) or a usable ALB ASTE. A usable
An ALB ASTE may be used for a particular
ALB ASTE is explained in the next section.
instance of access-register translation when the
ASTEO field in the ALB ASTE matches the
ASTEO field in the ALE or ALB ALE being used in
the translation.

5-54 z/Architecture Principles of Operation


An ALB ATE may be used for a particular instance
of access-register translation when both of the fol- Subspace Groups
lowing conditions are met: The subspace-group facility includes the BRANCH
1. The ATO field in the ALB ATE matches the IN SUBSPACE GROUP instruction, allocations of
ATO field in the ASTE or ALB ASTE being fields in the address-space-control element,
used in the translation. dispatchable-unit control table, and
ASN-second-table entry, and subspace-
2. The EAX field in the ALB ATE matches the replacement operations of the PROGRAM CALL,
current EAX. PROGRAM RETURN, PROGRAM TRANSFER,
SET SECONDARY ASN, and LOAD ADDRESS
Modification of ART Tables SPACE PARAMETERS instructions. BRANCH IN
When an attached but invalid ART-table entry is SUBSPACE GROUP is introduced in Subroutine
made valid, or when an unattached but valid Linkage without the Linkage Stack on page 5-10
ART-table entry is made attached, and no entry and described in detail in BRANCH IN SUB-
formed from the ART-table entry is already in the SPACE GROUP on page 10-13.
ALB, the change takes effect no later than the end
of the current instruction.
Subspace-Group Tables
When an attached and valid ART-table entry is
This section describes the use of the
changed, and when, before the ALB is cleared of
dispatchable-unit control table and
copies of that entry, an attempt is made to
ASN-second-table entry by the subspace-group
perform ART requiring that entry, unpredictable
facility.
results may occur, to the following extent. The
use of the new value may begin between
instructions or during the execution of an instruc- Subspace-Group Dispatchable-Unit
tion, including the instruction that caused the Control Table
change. Moreover, until the ALB is cleared of The dispatchable-unit control table has the fol-
copies of the entry, the ALB may contain both the lowing format:
old and the new values, and it is unpredictable
Hex Dec
whether the old or new value is selected for a par-
ticular ART operation. If the old and new values BASTEO
are used as representations of effective space
designations, failure to recognize that the effective S
space designations are the same may occur, with 4 4 A SSASTEO

the result that operand overlap may not be recog- 8 8
nized. Effective space designations and operand
overlap are discussed in Interlocks within a Single C 12 SSASTESN
Instruction on page 5-80.
1 16 DUALD
When LOAD ACCESS MULTIPLE or LOAD
PSW-Key PSWR
CONTROL changes the parameters associated 14 2 Mask KeyA P
with ART, the values of these parameters at the
start of the operation are in effect for the duration 18 24
of the operation.
1C 28 ///////////////////
All entries are cleared from the ALB by the exe-
cution of PURGE ALB, a COMPARE AND SWAP
AND PURGE instruction that purges the ALB, and In the 24-Bit or 31-Bit
SET PREFIX, and by CPU reset. Addressing Mode

2 32

24 36 B Bits 33-63 of
A Return Address

Chapter 5. Program Execution 5-55


In the 64-Bit Addressing Mode pared to the ASTEO or the entire contents of
bytes 0-3 may be compared to the ASTEO with
2 32 Bits -31 of one leftmost and six rightmost zeros appended.
Return Address
When BRANCH IN SUBSPACE GROUP uses
24 36 Bits 33-63 of ALET 0, bits 1-25 of bytes 0-3, with six zeros
Return Address appended on the right, designate the destination
ASTE.

Subspace-Active Bit (SA): Bit 0 of bytes 4-7


28 4 indicates, when one, that the last BRANCH IN
SUBSPACE GROUP instruction executed for the
2C 44 Trap-Control- dispatchable unit transferred control to a subspace
Block Address E
of the subspace group associated with the
3 48 dispatchable unit. Bit 0 being zero indicates any
/ / one of the following: the last BRANCH IN SUB-
3C 6 SPACE GROUP instruction executed for the
dispatchable unit transferred control to the base
space of the subspace group, BRANCH IN SUB-
The fields in the dispatchable-unit control table SPACE GROUP has not yet been executed for
that are used by the subspace-group facility are the dispatchable unit, or the dispatchable unit is
allocated as follows: not associated with a subspace group. BRANCH
IN SUBSPACE GROUP sets bit 0 of bytes 4-7 to
Base-ASTE Origin (BASTEO): Bits 1-25 of one when it transfers control to a subspace of the
bytes 0-3, with six zeros appended on the right, subspace group associated with the dispatchable
form a 31-bit real address that designates the unit, and it sets bit 0 to zero when it transfers
beginning of the ASN-second-table entry that control to the base space of the subspace group.
specifies the base space of a subspace group
associated with the dispatchable unit. A compar- Subspace-ASTE Origin (SSASTEO): Bits 1-25
ison of bits 1-25 of bytes 0-3 to the primary-ASTE of bytes 4-7, with six zeros appended on the right,
origin (PASTEO) in bit positions 33-57 of control form a 31-bit real address that designates the
register 5 is made by BRANCH IN SUBSPACE beginning of the ASN-second-table entry that
GROUP to determine whether the current primary specifies the subspace last given control by a
address space is in the subspace group for the BRANCH IN SUBSPACE GROUP instruction exe-
current dispatchable unit. For this comparison, cuted for the dispatchable unit. When BRANCH
either bits 1-25 may be compared to the PASTEO IN SUBSPACE GROUP transfers control to a sub-
or the entire contents of bytes 0-3 may be com- space by means of an ALET other than ALET 1, it
pared to the contents of bit positions 33-63 of places the ASTEO for the subspace (the destina-
control register 5. A comparison of bits 1-25 of tion ASTEO) in bit positions 1-25 of bytes 4-7,
bytes 0-3 to the destination-ASTE origin places zeros in bit positions 26-31 of bytes 4-7,
(DASTEO) obtained from an access-list entry by and sets the subspace-active bit, bit 0 of bytes
access-register translation of an ALET other than 4-7, to one. When BRANCH IN SUBSPACE
ALETs 0 and 1 is made by BRANCH IN SUB- GROUP uses ALET 1 to transfer control to a sub-
SPACE GROUP to determine if the destination space, bits 1-25 of bytes 4-7, with six zeros
ASTE is the base-space ASTE. For this compar- appended on the right, designate the destination
ison, either bits 1-25 may be compared to the ASTE, and BRANCH IN SUBSPACE GROUP sets
DASTEO or the entire contents of bytes 0-3 may the subspace-active bit to one and either sets bits
be compared to the DASTEO with one leftmost 26-31 of bytes 4-7 to zeros or leaves those bits
and six rightmost zeros appended. A comparison unchanged. However, if bits 1-25 are all zeros, a
of bits 1-25 of bytes 0-3 to an ASTE origin special-operation exception is recognized. When
(ASTEO) obtained by ASN translation may be BRANCH IN SUBSPACE GROUP transfers
made by PROGRAM CALL, PROGRAM RETURN, control to the base space of the subspace group,
PROGRAM TRANSFER, SET SECONDARY ASN, it sets the subspace-active bit to zero, and bits
and LOAD ADDRESS SPACE PARAMETERS. 1-31 of bytes 4-7 remain unchanged. Bits 1-25 of
For this comparison, either bits 1-25 may be com- bytes 4-7 may be used by PROGRAM CALL,

5-56 z/Architecture Principles of Operation


PROGRAM RETURN, PROGRAM TRANSFER,
SET SECONDARY ASN, and LOAD ADDRESS AX ATL
SPACE PARAMETERS to set bits 0-55 and 57-63
32 48 6 63
of the primary ASCE in control register 1 or the
secondary ASCE in control register 7 from the
same bits of the ASCE in the subspace ASTE. ASCE (RTD, STD, or RSD) Part 1

RTO, STO, or RSTKO
Subspace-ASTE Sequence Number
(SSASTESN): Bytes 12-15 may be used to 64 95
revoke the linkage capability represented by the
SSASTEO, bits 1-25 of bytes 4-7, in the DUCT. RTD or STD Part 2
When BRANCH IN SUBSPACE GROUP transfers
control to a subspace by means of an ALET other RTO/STO (Cont.) GPSXR DTTL R=
than ALET 1, it obtains the ASTESN in the sub-
space ASTE and places it in bytes 12-15. When 96 115 118 122 124 127
BRANCH IN SUBSPACE GROUP uses ALET 1 to
transfer control to a subspace, it compares bytes RSD Part 2
12-15 to the ASTESN in the subspace ASTE, and
RSTKO (Cont.) GPSXR R=1
it recognizes an ASTE-sequence exception if they

are unequal. When the SSASTEO is used by 96 115 118 122 127
PROGRAM CALL, PROGRAM RETURN,
PROGRAM TRANSFER, SET SECONDARY ASN,
ALD
and LOAD ADDRESS SPACE PARAMETERS to
set bits 0-55 and 57-63 of the primary ASCE in ALO ALL
control register 1 or the secondary ASCE in
control register 7 from the same bits of the ASCE 128 153 159
in the subspace ASTE, those instructions first
compare bytes 12-15 to the ASTESN in the sub-
space ASTE, and they recognize an ASTESN
ASTE-sequence exception if the two fields are
16 191
unequal.

Bytes 16-19 are described in Dispatchable-Unit LTD


Control Table and Access-List Designations on
V LTO LTL
page 5-45. Bytes 20-23 are described in

BRANCH AND SET AUTHORITY on page 10-6. 192 217 223
Bytes 32-39 and 44-47 are described in TRAP
on page 10-116. Bytes 24-27, 40-43, and 48-63

are reserved for possible future extensions and /////////////////////////////////
should contain all zeros. Bytes 28-31 are avail-
able for use by programming. 224 255

Subspace-Group ASN-Second-Table For BRANCH IN SUBSPACE GROUP, the fields


Entries in bytes 0-31 of the ASTE are allocated as
The 64-byte ASN-second-table entries have the follows:
following format:
ASX-Invalid Bit (I): Bit 0 controls whether the
address space associated with the ASTE is avail-
I ATO B
able. When bit 0 is zero during access-register
1 3 31 translation of ALET 1 or an ALET other than 0 and
1 for BRANCH IN SUBSPACE GROUP, the trans-
lation proceeds. When the bit is one, an
ASTE-validity exception is recognized. The bit is
ignored during access-register translation of ALET

Chapter 5. Program Execution 5-57


0. When the ASTE is designated by a PROGRAM TRANSFER, SET SECONDARY ASN,
subspace-ASTE origin (SSASTEO) in a and LOAD ADDRESS SPACE PARAMETERS as
dispatchable-unit control table, bit 0 is also used described in ASN-Second-Table Entries on
as described in the definition of bits 160-191 page 3-19.
(ASTESN).
Linkage-Table Designation (LTD): Bits
Authority-Table Origin (ATO): Bits 1-29 are not 192-223 are not used by BRANCH IN SUBSPACE
used by BRANCH IN SUBSPACE GROUP. GROUP.

Base-Space Bit (B): Bit 31 specifies, when one, Access-List Designation (ALD): When this
that the address space associated with the ASTE ASTE is designated by the primary-ASTE origin in
is the base space of a subspace group. When control register 5, bits 128-159 are the primary-
BRANCH IN SUBSPACE GROUP uses an ALET space access-list designation (PSALD). During
other than ALETs 0 and 1 to locate a destination access-register translation when the primary-list
ASTE, it recognizes a special-operation exception bit, bit 7, in the ALET being translated is one, the
if the destination-ASTE origin does not equal the PSALD is the effective access-list designation.
base-ASTE origin in the dispatchable-unit control
table and bit 31 is one in the destination ASTE. ASN-Second-Table-Entry Sequence Number
(ASTESN): Bits 160-191 are used to control
Authorization Index (AX): Bits 32-47 are not revocation of the accessing capability represented
used by BRANCH IN SUBSPACE GROUP. by access-list entries that designate the ASTE.
During access-register translation, bits 160-191
Authority-Table Length (ATL): Bits 48-59 are are compared against the ASTESN in the access-
not used by BRANCH IN SUBSPACE GROUP. list entry, and inequality causes an
ASTE-sequence exception to be recognized.
Address-Space-Control Element (ASCE): Bits
64-127 are an eight-byte address-space-control Bits 224-255 in the ASTE are available for use by
element (ASCE) that may be a segment-table des- programming. When the ASTE is designated by a
ignation (STD), a region-table designation (RTD), subspace-ASTE origin (SSASTEO) in a
or a real-space designation (RSD). (The term dispatchable-unit control table, bits 160-191 are
region-table designation is used to mean a also used to control revocation of the linkage
region-first-table designation, region-second-table capability represented by that SSASTEO. When
designation, or region-third-table designation.) BRANCH IN SUBSPACE GROUP uses ALET 1 to
The ASCE field is obtained as the result of transfer control to the subspace specified by the
access-register translation done for BRANCH IN SSASTEO, or when PROGRAM CALL,
SUBSPACE GROUP. When BRANCH IN SUB- PROGRAM RETURN, PROGRAM TRANSFER,
SPACE GROUP uses an ALET other than ALETs SET SECONDARY ASN, or LOAD ADDRESS
0 and 1 to locate a destination ASTE, it recog- SPACE PARAMETERS uses the SSASTEO to set
nizes a special-operation exception if the bits 0-55 and 57-63 of the primary ASCE in
destination-ASTE origin does not equal the control register 1 or the secondary ASCE in
base-ASTE origin in the dispatchable-unit control control register 7 from the same bits of the ASCE
table and the subspace-group-control bit, bit 118 in the subspace ASTE, those instructions first test
(G), in the destination ASTE is zero. When bit 0 of the subspace ASTE for being zero and
BRANCH IN SUBSPACE GROUP transfers recognize an ASTE-validity exception if it is not,
control to the base space of a subspace group and they then compare bits 160-191 to the
associated with the current dispatchable unit, it subspace-ASTE sequence number (SSASTESN)
places bits 64-127 in control register 1; otherwise, in the dispatchable-unit control table and recog-
when BRANCH IN SUBSPACE GROUP transfers nize an ASTE-sequence exception if there is an
control to a subspace of the subspace group, it inequality. However, when either of the two
places bits 65-119 and 121-127 in bit positions named exception conditions exists for LOAD
0-55 and 57-63, respectively, of control register 1. ADDRESS SPACE PARAMETERS, the instruction
Bits 64-127 are used after ASN translation by sets condition code 1 or 2 instead of recognizing
PROGRAM CALL, PROGRAM RETURN, the exception.

5-58 z/Architecture Principles of Operation


Programming Note: All unused fields in the origin (SSASTEO) in the DUCT, is one. An
ASTE, including the unused fields in bytes 0-31 ASTE-sequence exception is recognized if the
and all of bytes 32-63, should be set to zeros. ASTE-sequence number (ASTESN) in word 5 of
These fields are reserved for future extensions, the subspace ASTE does not equal the subspace
and programs which place nonzero values in ASTESN (SSASTESN) in word 3 of the DUCT.
these fields may not operate compatibly on future However, LOAD ADDRESS SPACE PARAME-
machines. TERS sets a nonzero condition code instead of
recognizing the ASTE-validity or ASTE-sequence
Subspace-Replacement exception. If no exception exists, bits 0-55 and
57-63 of the ASCE for the address space (the
Operations PASCE in control register 1 or SASCE in control
register 7) are replaced by the same bits of the
The subspace-group facility includes subspace-
ASCE in word 2 of the subspace ASTE.
replacement operations of PROGRAM CALL,
PROGRAM TRANSFER, PROGRAM RETURN, If an addressing exception is recognized when
SET SECONDARY ASN, and LOAD ADDRESS attempting to access the DUCT or subspace
SPACE PARAMETERS. The operations apply ASTE, the instruction execution is suppressed. If
when the dispatchable unit for which any of the an ASTE-validity or ASTE-sequence exception is
five named instructions is executed is in a state recognized, the instruction execution is nullified.
called subspace active. A dispatchable unit is Such nullification or suppression causes all control
subspace active if it has used BRANCH IN SUB- register contents to remain unchanged from what
SPACE GROUP to transfer control to a subspace they were at the beginning of the instruction exe-
of its subspace group and has not subsequently cution.
used BRANCH IN SUBSPACE GROUP to return
control to the base space of the group. Key-controlled protection does not apply to any
accesses to the DUCT or subspace ASTE.
The definitions of the subspace-replacement oper-
ations are included in the definitions of the five For comparing the ASTEO obtained by ASN trans-
named instructions in Chapter 10, Control lation to the BASTEO, either the ASTEO may be
Instructions. The operations are described in a compared to the BASTEO or the ASTEO, with one
general way as follows. Whenever an address leftmost and six rightmost zeros appended, may
space is established as the primary or secondary be compared to the entire contents of word 0 of
address space as a result of ASN translation, the DUCT.
then, if that address space is in a subspace group,
as indicated by the subspace-group-control bit, bit When the SSASTEO in the DUCT is used to
54 (G), being one in the address-space-control access the subspace ASTE, no check is made for
element (ASCE) for the address space (the new whether the SSASTEO is all zeros.
PASCE in control register 1 or SASCE in control
register 7), and if the dispatchable unit is The references to the DUCT and subspace ASTE
subspace-active, as indicated by the subspace- are word-concurrent single-access references.
active bit, bit 0 (SA) of word 1, in the The words of the DUCT are accessed in no partic-
dispatchable-unit control table (DUCT) being one, ular order. The words of the subspace ASTE are
the ASN-second-table-entry (ASTE) origin accessed in no particular order except that word 0
(ASTEO) for the address space, which was is accessed first.
obtained by ASN translation, is compared to the
base-ASTE origin (BASTEO), bits 1-25 of word 0, The exceptions that can be recognized during a
in the DUCT. If that ASTEO and the BASTEO are subspace-replacement operation are referred to
equal, the following occurs. An ASTE-validity collectively as the subspace-replacement
exception is recognized if bit 0 in the ASTE for the exceptions and are listed in priority order in
last subspace entered by the dispatchable unit, Subspace-Replacement Exceptions on
which ASTE is designated by the subspace-ASTE page 6-46.

Chapter 5. Program Execution 5-59


tions. With these authorization controls, a nonhi-
Linkage-Stack Introduction erarchical organization of programs may be
Many of the functions related to the linkage stack established, with each program in a sequence of
are described in this section and in Linkage-Stack calling and called programs having a degree of
Operations on page 5-65. Additionally, tracing of authority that is arbitrarily different from those of
the stacking PROGRAM CALL instruction and of programs before or after it in the sequence. The
the PROGRAM RETURN instruction is described range of functions available to each program, and
in Chapter 5, Program Execution; interruptions in the ability to transfer control from one program to
Chapter 6, Interruptions; and the instructions are another, are prescribed in tables that are
described in Chapter 10, Control Instructions. managed by the control program.

The linkage-stack instructions, which are semipriv-


Summary ileged, are described in Chapter 10, Control
Instructions. They are:
These major functions are provided:
BRANCH AND STACK
1. A table-based subroutine-linkage mechanism
EXTRACT STACKED REGISTERS
that provides PSW and control-register status
EXTRACT STACKED STATE
changing and which saves and restores this
MODIFY STACKED STATE
status and the contents of general registers
PROGRAM RETURN
and access registers through the use of an
TEST ACCESS
entry in a linkage stack.
In addition, the PROGRAM CALL instruction
2. A branch-type linkage mechanism that uses
optionally forms an entry in the linkage stack. A
the linkage stack.
PROGRAM CALL instruction that operates on the
3. Instructions for placing an additional two linkage stack is called stacking PROGRAM CALL.
words of status in the current linkage-stack Recognition of PROGRAM CALL as stacking
entry and for retrieving all of the status and PROGRAM CALL is under the control of a bit in
the general-register and access-register con- the entry-table entry.
tents that are in the entry.
4. An instruction for determining whether a Linkage-Stack Functions
program is authorized to use a particular
access-list-entry token. Transferring Program Control
The use of the linkage stack permits programs
5. Aids for program-problem analysis.
operating at arbitrarily different levels of authority
In addition, control and authority mechanisms are to be linked directly without the intervention of the
incorporated to control these functions. control program. The degree of authority of each
program in a sequence of calling and called pro-
It is intended that a separate linkage stack be grams may be arbitrarily different, thus allowing a
associated with and used by each dispatchable nonhierarchical organization of programs to be
unit. The linkage stack for a dispatchable unit established. Modular authorization control can be
resides in the home address space of the obtained principally by associating an extended
dispatchable unit. authorization index with each program module.
This allows program modules with different author-
It is intended that a dispatchable unit's linkage ities to coexist in the same address space. On
stack be protected from the dispatchable unit by the other hand, the extended authorization index
means of key-controlled protection. Key-controlled in effect during the execution of a called program
protection does not apply to the linkage-stack module can be the one that is associated with the
instructions that place information in or retrieve calling program module, thus allowing the called
information from the linkage stack. module to be executed with different authorities on
behalf of different dispatchable units. Options
The linkage-stack functions are for use by pro-
concerning the PSW-key mask and the secondary
grams considered to be semiprivileged, that is,
ASN are other means of associating different
programs which are executed in the problem state
authorities with different programs or with the
but which are authorized to use additional func-

5-60 z/Architecture Principles of Operation


same called program. The authority of each either left unchanged or replaced from the entry-
program is prescribed in tables that are managed table entry. The secondary ASN in control reg-
by the control program. By setting up the tables ister 3 can be set equal to the primary ASN of
so that the same program can be called by means either the calling program or the called program;
of different PC numbers, the program can be thus, the ability of the called program to have
assigned different authorities depending on which access to the primary address space of the calling
PC number is used to call it. The tables also program can be controlled.
allow control over which PC numbers can be used
by a program to call other programs. The stacking PROGRAM CALL operation always
forms an entry, called a state entry, in the linkage
The stacking PROGRAM CALL and PROGRAM stack to save the execution state and the contents
RETURN linkage operations can link programs of general registers 0-15 and access registers
residing in different address spaces and having 0-15. The saved execution state includes the PC
different levels of authority. The execution state number used, a called-space identification, the
and the contents of the general registers and updated PSW before any changes are made due
access registers are saved during the execution of to the entry-table entry, the extended authorization
stacking PROGRAM CALL and are partially index, PSW-key mask, primary ASN, and sec-
restored during the execution of PROGRAM ondary ASN existing before the operation, and the
RETURN. A linkage stack provides an efficient extended-addressing-mode bit existing after the
means of saving and restoring both the execution operation. However, the value of the PER mask
state and the contents of registers during linkage in the saved updated PSW is unpredictable. The
operations. linkage-stack state entry also contains an entry-
type code that identifies the entry as one that was
During the execution of a PROGRAM CALL formed by PROGRAM CALL.
instruction, the PC-number-translation process is
performed to locate a 32-byte entry-table entry. A space-switching operation occurs when the
When the PC-type bit in the entry-table entry is address-space number (ASN) specified in the
one, the stacking PROGRAM CALL operation is entry-table entry is nonzero. When space
specified; otherwise, the basic PROGRAM CALL switching occurs, the operation is called
operation is specified. PROGRAM CALL with space switching (PC-ss).
When no space switching occurs, the operation is
In addition to the information applying to both called PROGRAM CALL to current primary
basic PROGRAM CALL and stacking PROGRAM (PC-cp).
CALL (described in PC-Number Translation on
page 5-29 and consisting of an authorization key PROGRAM CALL with space switching obtains a
mask and specifications of the new ASN, new primary-ASTE origin from the entry-table
addressing mode, instruction address, problem entry and new primary address-space-control
state, PSW-key mask, primary-ASTE address, and element from the new primary ASTE, and it places
entry parameter), the entry-table entry contains them in control registers 5 and 1, respectively. It
information that specifies options concerning the sets the secondary address-space-control element
address-space control and PSW key in the PSW, in control register 7 equal to either the old primary
and the PSW-key mask, extended authorization address-space-control element, or the new one,
index, and secondary ASN in the control registers. depending on whether it set the secondary ASN
equal to the old primary ASN or the new one,
During the stacking PROGRAM CALL operation respectively. PROGRAM CALL to current primary
and by means of the additional information in the sets the secondary ASN equal to the primary ASN
entry-table entry, the address-space control in the and the secondary address-space-control element
PSW can be set to specify either the primary- equal to the primary address-space-control
space mode or the access-register mode. The element.
PSW key can be either left unchanged or replaced
from the entry-table entry. The PSW-key mask in The instruction PROGRAM RETURN restores
control register 3 can be either ORed to or most of the information saved in the linkage stack
replaced from the entry-table entry. The extended by the stacking PROGRAM CALL operation. It
authorization index in control register 8 can be restores the PSW, extended authorization index,

Chapter 5. Program Execution 5-61


PSW-key mask, primary ASN, secondary ASN, Branching Using the Linkage Stack
and the contents of general registers 2-14 and The execution state and the contents of the
access-registers 2-14. However, the PER mask in general registers and access registers can also be
the current PSW remains unchanged. The opera- saved in the linkage stack by means of the
tion of PROGRAM RETURN is referred to by instruction BRANCH AND STACK. BRANCH
saying that PROGRAM RETURN unstacks a state AND STACK uses a branch address as do the
entry. other branching instructions, instead of using a PC
number. BRANCH AND STACK, along with
For PROGRAM RETURN, a space-switching oper- PROGRAM RETURN, can link programs residing
ation occurs when the restored primary ASN is not in the same address space and having the same
equal to the primary ASN existing before the oper- level of authority; that is, BRANCH AND STACK
ation. When space switching occurs, the opera- does not change the execution state except for
tion is called PROGRAM RETURN with space the instruction address.
switching (PR-ss). When no space switching
occurs, the operation is called PROGRAM BRANCH AND STACK forms a linkage-stack state
RETURN to current primary (PR-cp). entry that is almost the same as one formed by
PROGRAM CALL. When it is necessary to distin-
PROGRAM RETURN with space switching per- guish between these two types of state entry, an
forms ASN translation of the restored primary ASN entry formed by PROGRAM CALL is called a
to obtain a new primary-ASTE origin and a new program-call state entry, and one formed by
primary address-space-control element, which it BRANCH AND STACK is called a branch state
places in control registers 5 and 1, respectively. entry. A branch state entry differs from a
For PROGRAM RETURN with space switching or program-call state entry in two ways: (1) it con-
to current primary, (1) if the restored secondary tains a different entry-type code, which identifies it
ASN is the same as the restored primary ASN, the as a branch state entry, and (2) it contains the
secondary address-space-control element in basic-addressing-mode bit and instruction address
control register 7 is set equal to the new primary existing after the operation instead of a PC
address-space-control element in control register number and called-space identification. These
1, or (2) if the restored secondary ASN is not the new values of PSW bits 32 and 64-127 are in
same as the restored primary ASN, ASN trans- addition to the complete PSW that is saved in the
lation and ASN authorization of the restored sec- state entry.
ondary ASN are performed to obtain a new
secondary address-space-control element, which For BRANCH AND STACK, the basic- and
is placed in control register 7. extended addressing mode bits and the instruction
address that are part of the complete PSW saved
The stacking PROGRAM CALL operation and the in the state entry can be the current (at the begin-
PROGRAM RETURN operation each can be per- ning of the operation) addressing-mode bits and
formed successfully only in the primary-space the updated instruction address (the address of
mode or access-register mode. An exception is the next sequential instruction), or they can be
recognized when the CPU is in the real mode, specified in a register. This register can be one
secondary-space mode, or home-space mode. that had link information placed in it by a
BRANCH AND LINK (BALR only), BRANCH AND
A bit, named the unstack-suppression bit, can be SAVE, BRANCH AND SAVE AND SET MODE, or
set to one in a linkage-stack state entry to cause BRANCH AND SET MODE instruction. Thus,
an exception if an attempt is made by PROGRAM BRANCH AND STACK can be used either in a
RETURN to unstack the entry. When the bit is calling program or at (or near) the entry point of a
one, the entry still can be operated on by the called program, and, in either case, a PROGRAM
instructions that add information to or retrieve RETURN instruction located at the end of the
information from the entry. The unstack- called program will return correctly to the calling
suppression bit is intended to allow the control program. The ability to use BRANCH AND
program to gain control when an attempt is made STACK at an entry point allows the linkage stack
to unstack a state entry in which the bit is one. to be used without changing old calling programs.

5-62 z/Architecture Principles of Operation


When the R field of BRANCH AND STACK is doublewords containing a PSW saved in the state
zero, the instruction is executed without causing entry and places them in bit positions 0-63 of a
branching. designated general-register pair. EXTRACT
STACKED STATE sets the condition code to indi-
When PROGRAM RETURN unstacks a branch cate whether the current state entry is a branch
state entry, it ignores the extended authorization state entry or a program-call state entry.
index, PSW-key mask, primary ASN, and sec-
ondary ASN in the entry. The PROGRAM Testing Authorization
RETURN instruction restores the PSW and the The instruction TEST ACCESS has as operands
contents of general registers 2-14 and access reg- an access-list-entry token (ALET) in a designated
isters 2-14 that were saved in the entry. However, access register and an extended authorization
the PER mask in the current PSW remains index (EAX) in a designated general register.
unchanged. TEST ACCESS applies the access-register-
translation process, which uses the specified EAX
BRANCH AND STACK can be executed success- instead of the current EAX in control register 8, to
fully only in the primary-space mode or access- the ALET, and it sets the condition code to indi-
register mode. An exception is recognized when cate the result. The condition code may indicate:
the CPU is in the real mode, secondary-space (1) the ALET is 00000000 hex, (2) the ALET des-
mode, or home-space mode. ignates an entry in the dispatchable-unit access
list and can be translated without exceptions in
The unstack-suppression bit has the same effect access-register translation, (3) the ALET desig-
in a branch state entry as it does in a program-call nates an entry in the primary-space access list
state entry. and can be translated without exceptions in
access-register translation, or (4) the ALET is
Adding and Retrieving Information 00000001 hex or causes exceptions in access-
The instruction MODIFY STACKED STATE can register translation.
be used by a program to place two words of infor-
mation, contained in a designated general-register The principal purpose of TEST ACCESS is to
pair, in an area, called the modifiable area, of the allow a called program to determine whether an
current linkage-stack state entry (a branch state ALET passed to it by the calling program is
entry or a program-call state entry). This is authorized for use by the calling program by
intended to allow a called program to establish a means of the calling program's EAX. This is in
recovery routine that will be given control by the support of a possible programming convention in
control program, if necessary. which a called program will not operate on an
AR-specified address space by means of its own
The instructions EXTRACT STACKED REGIS- EAX unless the calling program is authorized to
TERS and EXTRACT STACKED STATE can be operate on that space by means of the calling pro-
used by a program to obtain any of the informa- gram's EAX. The called program can obtain the
tion saved in the current state entry by BRANCH calling program's EAX, for use by TEST ACCESS,
AND STACK or PROGRAM CALL or placed there from the current linkage-stack state entry by
by MODIFY STACKED STATE. EXTRACT means of the EXTRACT STACKED STATE
STACKED REGISTERS (EREGG) places the con- instruction.
tents of a specified range of general registers and
access registers back in the registers from which Another purpose of TEST ACCESS is to indicate
the contents were saved. EXTRACT STACKED the special cases in which the ALET is 00000000
REGISTERS (EREG) does the same except that it hex, designating the primary address space, or
restores only bits 32-63 of the general registers 00000001 hex, designating the secondary address
and leaves bits 0-31 unchanged. EXTRACT space. Because PROGRAM CALL may change
STACKED STATE obtains pairs of words of the the primary and secondary address spaces,
nonregister information saved or placed in a state ALETs 00000000 hex and 00000001 hex may
entry and places them in bit positions 32-63 of a designate different address spaces when used by
designated general-register pair. Alternatively, the called program than when used by the calling
EXTRACT STACKED STATE obtains two program.

Chapter 5. Program Execution 5-63


Still another purpose of TEST ACCESS is to indi- If Bit 129 is Zero
cate whether the ALET designates an entry in the
primary-space access list since such a designation

after the primary address space was changed by 31
a space-switching program-linkage operation may

be an error.
A Entry Instruction Address P

Program-Problem Analysis 32 63
To aid program-problem analysis, the option is
provided of having a trace entry made implicitly for If Bit 129 is One
three additional linkage operations when the
linkage stack is used. When branch tracing is on, Entry Instruction Address (Part 1)
a trace entry is made each time a BRANCH AND
31
STACK instruction is executed and causes
branching. When ASN tracing is on, a trace entry
is made each time the stacking PROGRAM CALL Entry Instruction Address (Part 2) P

operation is performed and each time PROGRAM 32 63
RETURN unstacks a linkage-stack state entry
formed by PROGRAM CALL. When mode tracing

is on, a trace entry is made each time the stacking Authorization Key Mask ASN
PROGRAM CALL operation or PROGRAM
RETURN operation is performed and changes 64 8 95
PSW bit 31, except that, for PROGRAM RETURN,
a trace entry for mode tracing is not made if one Entry Key Mask
due to ASN tracing is made. A detailed definition
of tracing is contained in Tracing on page 4-10. 96 112 127

As a further analysis aid, BRANCH AND STACK TGKMECS EK Entry Ext. Auth. Index
when it causes branching, stacking PROGRAM
CALL, and PROGRAM RETURN are also recog- 128 131 136 14 144 159
nized as PER successful-branching events. For
PROGRAM RETURN, the unstacked state entry ASTE Address
may have been formed by BRANCH AND STACK
or PROGRAM CALL. 16 186 191

The execution of a space-switching stacking Entry Parameter (Part 1)
PROGRAM CALL or PROGRAM RETURN
192 123
instruction causes a space-switch event if the
primary space-switch-event control is one before
or after the operation or if a PER event is to be Entry Parameter (Part 2)

indicated.
224 155
The fields in bit positions 130-159 are allocated as
Linkage-Stack Entry-Table follows:
Entries PSW-Key Control (K): Bit 131, when one, speci-
All of the fields in the entry-table entry except bits fies that bits 136-139 are to replace the PSW key
130-159 are described in Entry-Table Entries on in the PSW as part of the stacking PROGRAM
page 5-30. This section describes only bits CALL operation. When this bit is zero, the PSW
130-159. key remains unchanged. Bit 131 is ignored during
the basic PROGRAM CALL operation.
The entry-table entry has the following format:

5-64 z/Architecture Principles of Operation


PSW-Key-Mask Control (M): Bit 132, when one, Entry Extended Authorization Index: Bits
specifies that bits 96-111 are to replace the 144-159 replace the current extended authori-
PSW-key mask in control register 3 as part of the zation index, bits 32-47 of control register 8, as
stacking PROGRAM CALL operation. When this part of the stacking PROGRAM CALL operation if
bit is zero, bits 96-111 are ORed into the the extended-authorization-index control, bit 133,
PSW-key mask in control register 3 as part of the is one. Bits 144-159 are ignored, and the current
stacking PROGRAM CALL operation. Bit 132 is extended authorization index remains unchanged,
ignored during the basic PROGRAM CALL opera- if bit 133 is zero. Bits 144-159 are ignored during
tion. the basic PROGRAM CALL operation.

Extended-Authorization-Index Control (E): Bit Bits 130 and 140-143 are reserved for possible
133, when one, specifies that bits 144-159 are to future extensions and should be zeros.
replace the current extended authorization index in
control register 8 as part of the stacking
PROGRAM CALL operation. When this bit is Linkage-Stack Operations
zero, the current extended authorization index
A linkage stack may be formed by the control
remains unchanged. Bit 133 is ignored during the
program for each dispatchable unit. The linkage
basic PROGRAM CALL operation.
stack is used to save the execution state and the
contents of the general registers and access regis-
Address-Space-Control Control (C): Bit 134,
ters during the BRANCH AND STACK and
when one, specifies that bit 17 of the current PSW
stacking PROGRAM CALL operations. The
is to be set to one as part of the stacking
linkage stack is also used to restore a portion of
PROGRAM CALL operation. When this bit is
the execution state and general-register and
zero, bit 17 is set to zero. Because the CPU must
access-register contents during the PROGRAM
be in either the primary-space mode or the
RETURN operation.
access-register mode when a stacking PROGRAM
CALL instruction is issued, the result is that the
A linkage stack resides in virtual storage. The
CPU is placed in the access-register mode if bit
linkage stack for a dispatchable unit is in the
134 is one or the primary-space mode if bit 134 is
home address space for that dispatchable unit.
zero. Bit 134 is ignored during the basic
The home address space is designated by the
PROGRAM CALL operation.
home address-space-control element in control
register 13.
Secondary-ASN Control (S): Bit 135, when one,
specifies that bits 80-95 are to become the new
The linkage stack is intended to be protected from
secondary ASN, and the new SASCE is to be set
problem-state programs so that these programs
equal to the new PASCE, as part of the stacking
cannot examine or modify the information saved in
PROGRAM CALL with-space-switching (PC-ss)
the linkage stack, except by means of the
operation. When this bit is zero, the new SASN
EXTRACT STACKED REGISTERS, EXTRACT
and SASCE are set equal to the PASN and
STACKED STATE, and MODIFY STACKED
PASCE, respectively, of the calling program. Bit
STATE instructions. This protection can be
135 is ignored during the basic PROGRAM CALL
obtained by means of key-controlled protection.
operation and the stacking PROGRAM CALL to-
current-primary (PC-cp) operation. A linkage stack may consist of a number of
linkage-stack sections chained together. A
Entry Key (EK): Bits 136-139 replace the PSW
linkage-stack section is variable in length. The
key in the PSW as part of the stacking
maximum length of each linkage-stack section is
PROGRAM CALL operation if the PSW-key
65,560 bytes.
control, bit 131, is one. Bits 136-139 are ignored,
and the current PSW key remains unchanged, if There are three types of entry in the linkage stack:
bit 131 is zero. Bits 136-139 are ignored during header entry, trailer entry, and state entry. A
the basic PROGRAM CALL operation. header entry and a trailer entry are at the begin-
ning and end, respectively, of a linkage-stack
section, and they are used to chain linkage-stack
sections together. Header entries and trailer

Chapter 5. Program Execution 5-65


entries are formed by the control program. A space in the current section, and if the trailer entry
state entry is used to contain the execution state in the current section indicates that another
and register contents that are saved during the section follows the current section, the new entry
BRANCH AND STACK or stacking PROGRAM is placed immediately after the entry descriptor of
CALL operation, and it is formed during the opera- the header entry of that following section, provided
tion. A state entry is further distinguished as that there is enough remaining free space in that
being a branch state entry if it was formed by section. If the trailer entry indicates that there is
BRANCH AND STACK or as being a program-call not a following section, an exception is recog-
state entry if it was formed by PROGRAM CALL. nized, and a program interruption occurs. It is
then the responsibility of the control program to
The actions of forming a state entry and saving allocate another section, chain it to the current
information in it during the BRANCH AND STACK section, and cause the BRANCH AND STACK or
and stacking PROGRAM CALL operations are stacking PROGRAM CALL instruction to be reexe-
called the stacking process. The actions of cuted. If there is a following section but there is
restoring information from a state entry and log- not enough remaining free space in it, an excep-
ically deleting the entry during the PROGRAM tion is recognized.
RETURN operation are called the unstacking
process. The part of the unstacking process that If the remaining-free-space value that is used to
locates a state entry is also performed during the locate a trailer entry is not a multiple of 8, an
EXTRACT STACKED REGISTERS, EXTRACT exception is recognized. The remaining-free-
STACKED STATE, and MODIFY STACKED space value in the header entry of a linkage-stack
STATE operations. section must be set to a multiple of 8 to ensure
that the remaining-free-space value that may be
Each type of linkage-stack entry has a length that used to locate the trailer entry of the section will
is a multiple of eight bytes. A header entry and be a multiple of 8.
trailer entry each has a length of 16 bytes. A
state entry has a length of 296 bytes. When the stacking process is successful in
forming a new state entry, it updates the linkage-
Each of the header entry, trailer entry, and state stack-entry address in control register 15 so that
entry has a common eight-byte area at its end, the address designates the leftmost byte of the
called the entry descriptor. The linkage-stack- entry descriptor of the new entry, which thus
entry address in control register 15 designates the becomes the new current linkage-stack entry.
leftmost byte of the entry descriptor of the last
linkage-stack entry, other than the trailer entry, in When, during the unstacking process in
a linkage-stack section. This entry is called the PROGRAM RETURN, the current linkage-stack
current linkage-stack entry, and the section is entry is a state entry, the process operates on that
called the current linkage-stack section. entry and then updates the linkage-stack-entry
address so that it designates the entry descriptor
Each entry descriptor in a linkage-stack section, of the preceding entry in the same linkage-stack
except the one in the trailer entry of the section, section. The preceding entry thus becomes the
includes a field that specifies the amount of space current entry. The new current entry may be
existing between the end of the entry descriptor another state entry, or it may be a header entry.
and the beginning of the trailer entry. This field is
named the remaining-free-space field. The The header entry of a linkage-stack section indi-
remaining-free-space field in a trailer entry is cates whether there is a preceding section. If
unused. there is a preceding section, the header entry con-
tains the address of the last linkage-stack entry,
When a new state entry is to be formed in the other than the trailer entry, in the preceding
linkage stack during the stacking process, the new section. That last entry should be a state entry
entry is placed immediately after the entry (not another header entry), unless there is an
descriptor of the current linkage-stack entry, pro- error in the linkage stack.
vided that there is enough remaining free space in
the current linkage-stack section to contain the If the unstacking process is performed when the
new entry. If there is not enough remaining free current linkage-stack entry is a header entry, and

5-66 z/Architecture Principles of Operation


if the header entry indicates that a preceding Linkage-Stack-Entry Address: Bits 0-60 of
linkage-stack section exists, the unstacking control register 15, with three zeros appended on
process proceeds by treating the entry designated the right, form the 64-bit home virtual address of
in the preceding section as if it were the current the entry descriptor of the current linkage-stack
entry, provided that this entry is a state entry. If entry in the current linkage-stack section. Bits
the header entry does not indicate a preceding 0-60 are changed during the stacking process in
section, or if the entry designated in the preceding BRANCH AND STACK and stacking PROGRAM
section is not a state entry, an exception is recog- CALL and during the unstacking process in
nized. PROGRAM RETURN. Bits 61-63 of control reg-
ister 15 are set to zeros when bits 0-60 are
When the unstacking process is performed in changed.
EXTRACT STACKED REGISTERS, EXTRACT
STACKED STATE, or MODIFY STACKED
STATE, the process locates a state entry but does
Linkage Stack
not change the linkage-stack-entry address in
The linkage stack consists of one or more linkage-
control register 15.
stack sections containing linkage-stack entries.
There are three principal types of linkage-stack
Each entry descriptor in a linkage-stack section
entry: header entry, trailer entry, and state entry.
includes a field that specifies the length of the
A state entry is further distinguished as being
next linkage-stack entry, other than the trailer
either a branch state entry or a program-call state
entry, in the section. When a state entry is
entry.
created during the stacking process, zeros are
placed in this field in the created entry, and the
Each type of linkage-stack entry has an entry
length of the state entry is placed in this field in
descriptor at its end. The leftmost byte of the
the preceding entry. When a state entry is log-
entry descriptor of the current linkage-stack entry
ically deleted during the unstacking process in
in the current linkage-stack section is designated
PROGRAM RETURN, zeros are placed in this
by the linkage-stack-entry address in control reg-
field in the preceding entry. This field is named
ister 15.
the next-entry-size field.
The linkage stack resides in the home address
When the stacking or unstacking process operates
space, designated by the home address-space-
on the linkage stack, key-controlled protection
control element in control register 13.
does not apply, but low-address and page pro-
tection do apply.
Entry Descriptors
An entry descriptor is at the end of each linkage-
Linkage-Stack-Operations Control stack entry. The entry descriptor is eight bytes in
length and has the following format:
The use of the linkage stack is controlled by the

home address-space-control element in control UET SI RFS NES
register 13 and the linkage-stack-entry address in
control register 15. The home address-space- 1 8 16 32 48 63
control element is described in Dynamic Address
The fields in the entry descriptor are allocated as
Translation on page 3-26. The linkage-stack-
follows:
entry address is described below.
Unstack-Suppression Bit (U): When bit 0 is one
Control Register 15 in the entry descriptor of a header entry or state
The location of the entry descriptor of the current entry encountered during the unstacking process
linkage-stack entry is specified in control register in PROGRAM RETURN, a stack-operation excep-
15. The register has the following format: tion is recognized. Bit 0 is ignored in a trailer
entry and during the unstacking process in
Linkage-Stack-Entry Address EXTRACT STACKED REGISTERS, EXTRACT
STACKED STATE, and MODIFY STACKED
61 63
STATE. The control program can temporarily set

Chapter 5. Program Execution 5-67


bit 0 to one in the current linkage-stack entry (a Remaining Free Space (RFS): Bits 16-31
header entry or state entry) to prevent PROGRAM specify the number of bytes between the end of
RETURN from being executed successfully while this entry descriptor and the beginning of the
still allowing EXTRACT STACKED REGISTERS, trailer entry in the same linkage-stack section,
EXTRACT STACKED STATE, and MODIFY except that this field in a trailer entry has no
STACKED STATE to be executed successfully. meaning. Thus, in the last state entry in a
Bit 0 is set to zero in the entry descriptor of a section, or in the header entry if there is no state
state entry when the entry is formed during the entry, bits 16-31 specify the number of bytes avail-
stacking process. able in the section for performance of the stacking
process. In the state entry formed by a stacking
Entry Type (ET): Bits 1-7 are a code that speci- process, the process sets bits 16-31 equal to the
fies the type of the linkage-stack entry containing contents of the remaining-free-space field in the
the entry descriptor. The assigned codes are: preceding linkage-stack entry minus the size, in
Code (in bytes, of the new entry. Bits 16-31 must be a
Binary) Entry Type multiple of 8 (bits 29-31 must be zeros) in the
0001001 Header entry entry descriptor of the header entry in a linkage-
0001010 Trailer entry stack section; otherwise, a value that is not a mul-
0001100 Branch state entry tiple of 8 will be propagated to bits 16-31 in the
0001101 Program-call state entry entry descriptor of each state entry in the section,
and a stack-specification exception will be recog-
Codes 0000000-0001000, 0001011, and 0001110 nized if the stacking process attempts to locate
through 0111111 binary are reserved for possible the trailer entry in the section in order to proceed
future assignments. Codes 1000000 through to the next section.
1111111 binary are available for use by program-
ming. Next-Entry Size (NES): Bits 32-47 specify the
size in bytes of the next linkage-stack entry, other
Bits 1-7 are set to 0001100 or 0001101 binary in than a trailer entry, in the same linkage-stack
the entry descriptor of a state entry when the entry section. This field in the current linkage-stack
is formed during the stacking process. entry contains all zeros. This field in a trailer entry
has no meaning. When the stacking process
A stack-type exception is recognized during the forms a state entry, it places zeros in the next-
unstacking process in EXTRACT STACKED REG- entry-size field of the new entry, and it places the
ISTERS, EXTRACT STACKED STATE, MODIFY size of the new entry in the next-entry-size field of
STACKED STATE, or PROGRAM RETURN if bits the preceding entry. When the unstacking
1-7 in the current linkage-stack entry do not indi- process logically deletes a state entry, it places
cate that the entry is a state entry or a header zeros in the next-entry-size field of the preceding
entry; or, when the current entry is a header entry, entry, which entry becomes the current entry.
if bits 1-7 in the entry designated by the backward
stack-entry address in the header entry do not Bits 48-63 are set to zeros in a state entry when
indicate that the designated entry is a state entry. the entry is formed during the stacking process.
However, a stack-specification exception is recog- In a header entry, trailer entry, or state entry, bits
nized, instead of a stack-type exception, if both 48-63 are reserved for possible future extensions
the current entry and the designated entry are and should always be zeros.
header entries.
Programming Note: No entry-type code will be
Section Identification (SI): Bits 8-15 are an assigned in which the leftmost bit of the code is
identification, provided by the control program, of one. The control program can temporarily set the
the linkage-stack section containing the entry leftmost bit to one in the entry-type code of the
descriptor. In the state entry formed by a stacking current linkage-stack entry (a header entry or a
process, the process sets bits 8-15 equal to the state entry) to prevent the successful execution of
contents of the section-identification field in the EXTRACT STACKED REGISTERS, EXTRACT
preceding linkage-stack entry. STACKED STATE, MODIFY STACKED STATE,
or PROGRAM RETURN.

5-68 z/Architecture Principles of Operation


Header Entries Bits 61 and 62 are set to zeros when bits 0-60 are
A header entry is at the beginning of each linkage- set during the stacking process. Bits 61 and 62
stack section. The header entry is 16 bytes in are reserved for possible future extensions.
length and has the following format:
Trailer Entries
A trailer entry is at the end of each linkage-stack
BSEA B section. The trailer entry begins immediately after

61 63 the area specified by the remaining-free-space


field in the entry descriptors of the header entry
and each state entry in the same linkage-stack
Entry Descriptor section. The trailer entry is 16 bytes in length and
has the following format:
64 127

The fields in the first eight bytes of the header FSHA F

entry are allocated as follows: 61 63
Backward Stack-Entry Validity Bit (B): Bit 63,
when one, specifies that the preceding linkage- Entry Descriptor
stack section is available and that the backward
stack-entry address, bits 0-60, is valid. Bit 63 is 64 127
set to one during the stacking process when the
process proceeds to this section from the pre- The fields in the first eight bytes of the trailer entry
ceding one because there is not enough space are allocated as follows:
available in the preceding section to perform the
process. During the unstacking process when this Forward-Section Validity Bit (F): Bit 63, when
header entry is the current linkage-stack entry, a one, specifies that the next linkage-stack section
stack-empty exception is recognized if bit 63 is is available and that the forward-section-header
zero. address, bits 0-60, is valid. During the stacking
process when there is not enough space available
Backward Stack-Entry Address (BSEA): in the current linkage-stack section to perform the
When bit 63 is one, bits 0-60 with three zeros process, a stack-full exception is recognized if bit
appended on the right, form the 64-bit home 63 in the trailer entry of the current section is zero.
virtual address of the entry descriptor of the last
linkage-stack entry, other than the trailer entry, in Forward-Section-Header Address (FSHA):
the preceding linkage-stack section. However, if When bit 63 is one, bits 0-60, with three zeros
the current linkage-stack entry is in the preceding appended on the right, form the 64-bit home
or an earlier linkage-stack section, bits 0-60 may virtual address of the entry descriptor of the
have no meaning because the entry they desig- header entry in the next linkage-stack section.
nate, and earlier entries, may have been logically During the stacking process when there is not
deleted. Bits 0-60 are set during the stacking enough space available in the current section to
process when the process proceeds to this section perform the process and bit 63 is one, the header
from the preceding one because there is not entry designated by bits 0-60 becomes the current
enough space available in the preceding section linkage-stack entry.
to perform the process. During the unstacking
process when this header entry is the current Bits 61 and 62 are reserved for possible future
linkage-stack entry and bit 63 is one, the entry is extensions.
treated as the current entry. 0-60 is treated as the Programming Note: All of the fields in the trailer
current entry. entry are set only by the control program.

Chapter 5. Program Execution 5-69


State Entries cate whether the entry-type code in the entry
Zero, one, or more state entries may follow the descriptor specifies a branch state entry or a
header entry in each linkage-stack section. A program-call state entry.
state entry may be a branch state entry, formed
by a BRANCH AND STACK instruction, or a Bytes 128-223 of the state entry have the fol-
program-call state entry, formed by a stacking lowing detailed format:
PROGRAM CALL instruction. The state entry is
296 bytes in length and has the following format: PKM SASN EAX PASN

Hex Dec 128 13 132 134 135

&
8 8 Contents of PSW Bits -63
/ General Registers / 128 Bytes
7 112 -15 136 143
78 12 6 In a Branch State Entry Made in 24-Bit
or 31-Bit Mode
8 128 &
88 136 Other Status Bits 33-63 of
/ Information / 96 Bytes A Branch Address
D 28
D8 216 6 144 148 151

E 224 & In a Branch State Entry Made in 64-Bit


E8 232 Contents of Mode
/ Access Registers / 64 Bytes
11 272 -15 Bits -62 of Branch Address 1
118 28 6
144 151
12 288 Entry Descriptor 8 Bytes In a Program-Call State Entry Made when
Resulting Mode Is 24-bit or 31-Bit
Bytes 0-127 of the state entry contain the contents
of general registers 0-15 in the ascending order of Called-Space Id. PC Number

the register numbers. Bytes 224-287 contain the 144 148 151
contents of access registers 0-15 in the ascending
In a Program-Call State Entry Made when
order of the register numbers. The contents of
Resulting Mode Is 64-Bit
these fields are moved from the registers to the
state entry during the BRANCH AND STACK and Called-Space Id.1 PC Number
stacking PROGRAM CALL operations. The con-
tents of general registers 2-14 and access regis- 144 148 151
ters 2-14 are restored from the state entry to the
registers during the PROGRAM RETURN opera- Modifiable Area
tion. The contents of a specified range of general
registers and access registers can be restored 152 159
from the state entry to the registers by EXTRACT
STACKED REGISTERS. All Zeros

16 167
Bytes 128-223 of the state entry contain the other
status information that is placed in the entry by
BRANCH AND STACK, stacking PROGRAM PSW Bits 64-127

CALL, and MODIFY STACKED STATE. A portion
168 175
of this status information is restored to the PSW
and control registers by PROGRAM RETURN,

and all of the information can be examined by
/ Unpredictable /
means of EXTRACT STACKED STATE. Bytes
288-295 contain the entry descriptor. EXTRACT
STACKED STATE sets the condition code to indi- 176 223

5-70 z/Architecture Principles of Operation


The fields in bytes 128-175 are allocated as instruction following the BRANCH AND STACK or
follows. In the following, of the calling program stacking PROGRAM CALL instruction that formed
means the value existing at the beginning of the the state entry, or following an EXECUTE instruc-
execution of the BRANCH AND STACK or tion that had the BRANCH AND STACK or
stacking PROGRAM CALL instruction that formed stacking PROGRAM CALL instruction as its target
the state entry. instruction. In a branch state entry formed by a
BRANCH AND STACK instruction in which the R
PSW-Key Mask (PKM): Bytes 128-129 contain field is nonzero, bytes 136-143 and 168-175
the PSW-key mask, bits 32-47 of control register contain the PSW of the calling program, except
3, of the calling program. The PSW-key mask is that the extended-addressing-mode bit in bit posi-
saved in the state entry by BRANCH AND STACK tion 31 of bytes 136-139, the basic-addressing-
or stacking PROGRAM CALL, and it is restored to mode bit in bit position 0 of byte 140, and the
the control register by a PROGRAM RETURN instruction address in bytes 168-175 are as speci-
instruction that unstacks an entry formed by fied by the contents of the general register desig-
stacking PROGRAM CALL. nated by the R field. See the definition of
BRANCH AND STACK in Chapter 10, Control
Secondary ASN (SASN): Bytes 130-131 contain Instructions for how the basic- and extended-
the secondary ASN, bits 48-63 of control register addressing-mode bits and instruction address are
3, of the calling program. The SASN is saved in specified. The value of the PER mask in bytes
the state entry by BRANCH AND STACK or 136-143 is always unpredictable. The PSW is
stacking PROGRAM CALL, and it is restored to saved in the state entry by BRANCH AND STACK
the control register by a PROGRAM RETURN or stacking PROGRAM CALL and is restored as
instruction that unstacks an entry formed by the current PSW by PROGRAM RETURN, except
stacking PROGRAM CALL. that the PER mask is not restored. PROGRAM
RETURN does not change the PER mask in the
Extended Authorization Index (EAX): Bytes current PSW.
132-133 contain the extended authorization index,
bits 32-47 of control register 8, of the calling Basic Addressing Mode (A): In a branch state
program. The EAX is saved in the state entry by entry made in the 24-bit or 31-bit addressing
BRANCH AND STACK or stacking PROGRAM mode, bit position 0 of bytes 148-151 contains the
CALL, and it is restored to the control register by basic-addressing-mode bit, bit 32 of the PSW, at
a PROGRAM RETURN instruction that unstacks the end of the execution of the BRANCH AND
an entry formed by stacking PROGRAM CALL. STACK instruction that formed the state entry.
The basic-addressing-mode bit is saved in bit
Primary ASN (PASN): Bytes 134-135 contain position 0 of bytes 148-151 by BRANCH AND
the primary ASN, bits 48-63 of control register 4, STACK. BRANCH AND STACK does not change
of the calling program. The PASN is saved in the the basic-addressing-mode bit in the PSW.
state entry by BRANCH AND STACK or stacking
PROGRAM CALL, and it is restored to the control Branch Address: In a branch state entry made
register by a PROGRAM RETURN instruction that in the 24-bit or 31-bit addressing mode, bit posi-
unstacks an entry formed by stacking PROGRAM tions 1-31 of bytes 148-151 contain bits 33-63 of
CALL. the instruction address in the PSW at the end of
the execution of the BRANCH AND STACK
Program-Status Word (PSW): In a branch state instruction that formed the state entry, and the
entry formed by a BRANCH AND STACK instruc- contents of bytes 144-147 are unpredictable. In a
tion in which the R field is zero, and in a branch state entry made in the 64-bit addressing
program-call state entry, bytes 136-143 and mode, bytes 144-151 contain bits 0-62 of that
168-175 contain the updated PSW of the calling instruction address with a one appended on the
program. Bytes 136-143 contain bits 0-63 of the right. The instruction address is saved in bytes
PSW, and bytes 168-175 contain bits 64-127 of 148-151 or 144-151 (depending on the addressing
the PSW. Thus, the basic and extended mode) by BRANCH AND STACK. When the R
addressing-mode bits in this PSW specify the field of BRANCH AND STACK is nonzero, the
addressing mode of the calling program, and the instruction causes branching, and the instruction
instruction address designates the next sequential address in bytes 148-151 or 144-151 is the branch

Chapter 5. Program Execution 5-71


address. When the R field of BRANCH AND Stacking Process
STACK is zero, the instruction is executed without
branching, and the instruction address in bytes The stacking process is performed as part of a
148-151 or 144-151 is the address of the next BRANCH AND STACK or stacking PROGRAM
sequential instruction following the BRANCH AND CALL operation. The process locates space for a
STACK instruction, or following an EXECUTE new linkage-stack state entry, forms the entry,
instruction that had the BRANCH AND STACK updates the next-entry-size field in the preceding
instruction as its target instruction. entry, and updates the linkage-stack-entry address
in control register 15 so that the new entry
Called-Space Identification: In a program-call
becomes the current linkage-stack entry.
state entry, bytes 144-147 contain the called-
space identification (CSI). The CSI is saved in the For the stacking process to be performed suc-
state entry by stacking PROGRAM CALL. If the cessfully, DAT must be on and the CPU must be
PROGRAM CALL operation was space switching, in the primary-space mode or access-register
bytes 0 and 1 of the CSI (bytes 144 and 145 of mode; otherwise, a special-operation exception is
the state entry) contain the new primary ASN that recognized, and the operation is suppressed.
was placed in control register 4 by the PROGRAM
CALL instruction, and bytes 2 and 3 of the CSI Except as just mentioned, the stacking process is
(bytes 146 and 147 of the state entry) contain the performed independent of the current addressing
rightmost two bytes of the ASTE sequence mode and translation mode, as specified by bits
number (ASTESN) in the new primary ASTE 31, 32, 16, and 17 of the current PSW. All
whose address was placed in control register 5 by addresses used during the stacking process are
the PROGRAM CALL instruction. If the always 64-bit home virtual addresses.
PROGRAM CALL operation was the to-current-
primary operation, the CSI is all zeros. During the stacking process when any address is
formed through the addition or subtraction of a
PC Number: In a program-call state entry, bit value to or from another address, a carry out of,
positions 12-31 of bytes 148-151 contain the PC or a borrow into, bit position 0 of the address, if
number used by the stacking PROGRAM CALL any, is ignored.
instruction that formed the entry. Stacking
PROGRAM CALL places the PC number in bit When the stacking process fetches or stores by
positions 12-31 of bytes 148-151, it places zeros using an address that designates, after translation,
in bit positions 1-11 of the bytes, and it places a a location that is not available in the configuration,
zero in bit position 0 of the bytes if the resulting an addressing exception is recognized, and the
addressing mode is the 24-bit or 31-bit mode or a operation is suppressed.
one in bit position 0 if the resulting addressing
mode is the 64-bit mode. Key-controlled protection does not apply to the
accesses made during the stacking process, but
Modifiable Area: Bytes 152-159 are the field page protection and low-address protection do
that is set by MODIFY STACKED STATE. apply. A protection exception causes the opera-
BRANCH AND STACK and stacking PROGRAM tion to be suppressed.
CALL place all zeros in bytes 152-159.
Locating Space for a New Entry
All zeros are placed in bytes 160-167 by BRANCH The linkage-stack-entry address in control register
AND STACK and stacking PROGRAM CALL. 15 is used to locate the current linkage-stack
entry. Bits 0-60 of control register 15, with three
The contents of bytes 176-223 are unpredictable.
zeros appended on the right, form the 64-bit home
virtual address of the leftmost byte of the entry
descriptor of the current linkage-stack entry.

The first word of the entry descriptor of the current


linkage-stack entry is fetched by using the 64-bit
home virtual address. This fetch is for the
purpose of obtaining the section-identification and

5-72 z/Architecture Principles of Operation


remaining-free-space fields in the word; the greater than the size of the entry to be formed, the
unstack-suppression bit and entry-type field in the following occurs:
word are not examined.
The linkage-stack-entry address, bits 0-60 of
control register 15, is placed, as the backward
The 16-bit unsigned binary value in the remaining-
stack-entry address, in bit positions 0-60 of
free-space field, bits 16-31 of the entry descriptor,
the header entry in the next linkage-stack
is compared against the size in bytes of the
section, and zeros are placed in bit positions
linkage-stack entry to be formed. The size of a
61 and 62.
state entry is 296 bytes. If the value in the field is
equal to or greater than the size of the entry to be The backward stack-entry validity bit, bit 63, in
formed, processing continues as described in the header entry in the next section is set to
Forming the New Entry; otherwise, processing one.
continues as described below.
Bits 0-60 of the 64-bit home virtual address of
the entry descriptor of the header entry in the
When the remaining-free-space field in the current
next section are placed in bit positions 0-60 of
linkage-stack entry indicates that there is not
control register 15, and zeros are placed in bit
enough space available in the current linkage-
positions 61-63. of control register 15. Thus,
stack section to form the new entry, the first
the header entry in the next section becomes
doubleword of the trailer entry of the current
the current linkage-stack entry, and the next
section is fetched. The address for fetching this
section becomes the current linkage-stack
doubleword is determined as follows: to the
section.
address formed from the contents of control reg-
ister 15, add 8 to address the first byte after the Processing continues as described in
entry descriptor of the current entry, and then add Forming the New Entry.
the contents of the remaining-free-space field of
If the value in the remaining-free-space field of the
the current entry to address the first byte of the
header entry in the next section (before the next
trailer entry. The remaining-free-space value used
section becomes the current section) is less than
in the addition must be a multiple of 8; otherwise,
the size of the linkage-stack entry to be formed, a
a stack-specification exception is recognized, and
stack-specification exception is recognized, and
the operation is nullified.
the operation is nullified.
If the forward-section-validity bit, bit 63, of the
trailer entry is zero, a stack-full exception is recog- Forming the New Entry
nized, and the operation is nullified; otherwise, the When the remaining-free-space field in the current
forward-section-header address in the trailer entry linkage-stack entry indicates that there is enough
is used to locate the header entry in the next space available in the current linkage-stack
linkage-stack section. Bits 0-60, of the trailer section to form the new entry, the new entry is
entry, with three zeros appended on the right, formed beginning immediately after the entry
form the 64-bit home virtual address of the left- descriptor of the current entry.
most byte of the entry descriptor of the header
The new entry is a state entry. The contents of
entry in the next section.
general registers 0-15 are stored in bytes 0-127 of
The first word of the entry descriptor of the header the new entry, in the ascending order of the reg-
entry in the next linkage-stack section is fetched. ister numbers. The contents of access registers
This fetch is for the purpose of obtaining the 0-15 are stored in bytes 224-287 of the new entry,
section-identification and remaining-free-space in the ascending order of the register numbers.
fields in the word; the unstack-suppression bit and The PSW-key mask, bits 32-47 of control register
entry-type field in the word are not examined. 3; secondary ASN, bits 48-63 of control register 3;
extended authorization index, bits 32-47 of control
The value in the remaining-free-space field of the register 8; and primary ASN, bits 48-63 of control
header entry in the next linkage-stack section is register 4, are stored in bytes 128-129, 130-131,
compared against the size in bytes of the entry to 132-133, and 134-135, respectively, of the new
be formed. If the value in the field is equal to or entry. The current PSW, in which the instruction
address has been updated, is stored in bytes

Chapter 5. Program Execution 5-73


136-143 and 168-175 of the new entry. Bytes Zeros are stored in bytes 152-167 of the new
136-143 contain bits 0-63 of the PSW, and bytes entry. The contents of bytes 176-223 are unpre-
168-175 contain bits 64-127 of the PSW. dictable.
However, the value of the PER mask, bit 1 in the
PSW stored, is unpredictable. Also, if the instruc- Bytes 288-295 of the new entry are its entry
tion being executed is a BRANCH AND STACK descriptor. The unstack-suppression bit, bit 0, of
instruction in which the R field is nonzero, the this entry descriptor is set to zero. The code
extended- and basic-addressing-mode bits stored 0001100 binary is stored in the entry-type field,
in bytes 136 and 140, respectively, of the new bits 1-7, of this entry descriptor if the instruction
entry, and the instruction address stored in bytes being executed is BRANCH AND STACK. The
168-175 of the new entry, are as specified by the code 0001101 binary is stored if the instruction is
contents of the general register designated by the PROGRAM CALL. The value in the section-
R field. identification field of the current linkage-stack entry
is stored in the section-identification field, bits
When the instruction is PROGRAM CALL, the 8-15, of this entry descriptor. The value in the
called-space identification is stored in bytes remaining-free-space field of the current entry,
144-147 of the new entry. When the instruction is minus the size in bytes of the new entry, is stored
performing the space-switching PROGRAM CALL in the remaining-free-space field of this entry
operation, the called-space identification is the descriptor. Zeros are stored in the next-entry-size
two-byte ASN, bytes 10 and 11, in the entry-table field, bits 32-47, and in bit positions 48-63 of this
entry used by the instruction, followed by bytes 2 entry descriptor.
and 3 of the ASTE sequence number, bytes 2 and
3 being bits 176-191, in the ASN-second-table The stores into the new entry appear to be word-
entry specified by the ASN. When the instruction concurrent as observed by other CPUs. The
is performing the to-current-primary PROGRAM order in which the stores occur is unpredictable.
CALL operation, the called-space identification is
all zeros. Updating the Current Entry
The size in bytes of the new linkage-stack entry is
When the instruction is BRANCH AND STACK in stored in the next-entry-size field of the current
the 24-bit or 31-bit addressing mode, the basic- entry. The remainder of the current entry remains
addressing-mode bit from the current PSW is unchanged.
stored in bit position 0 of byte 148 in the state
entry, bits 33-63 of the branch address, or of the The order of the stores into the current entry and
updated instruction address if the operation is per- the new entry is unpredictable.
formed without branching, are stored in bit posi-
tions 1-31 of bytes 148-151, and the contents of Updating Control Register 15
bytes 144-147 are unpredictable. In the 64-bit Bits 0-60 of the 64-bit home virtual address of the
addressing mode, bits 0-62 of the branch address entry descriptor of the new linkage-stack entry are
or updated instruction address, with a one placed in bit positions 0-60 of control register 15,
appended on the right, are stored in bytes the linkage-stack-entry address. Zeros are placed
144-151 of the state entry. in bit positions 61-63 of control register 15. Thus,
the new entry becomes the current linkage-stack-
When the instruction is PROGRAM CALL, the entry.
20-bit PC number used is stored in bit positions
12-31 of bytes 148-151. If the resulting Recognition of Exceptions during the
addressing mode after the execution of Stacking Process
PROGRAM CALL is the 24-bit or 31-bit The exceptions which can be encountered during
addressing mode, a zero is stored in bit position 0 the stacking process and their priority are
of byte 148. If the resulting addressing mode is described in the definitions of the BRANCH AND
the 64-bit addressing mode, a one instead of a STACK and PROGRAM CALL instructions.
zero is stored in bit position 0 of byte 148. In any
resulting addressing mode, zeros are stored in bit Programming Note: Any exception recognized
positions 1-11 of bytes 148-151. during the execution of BRANCH AND STACK
and PROGRAM CALL causes either nullification

5-74 z/Architecture Principles of Operation


or suppression. Therefore, if an exception is page protection and low-address protection do
recognized, the stacking process does not store apply. A protection exception causes the opera-
into any linkage-stack entry or change the con- tion to be suppressed.
tents of control register 15.
Locating the Current Entry and
Unstacking Process Processing a Header Entry
The linkage-stack-entry address in control register
The unstacking process is performed as part of 15 is used to locate the current linkage-stack
the PROGRAM RETURN operation. The process entry. Bits 0-60 of control register 15, with three
locates the last state entry in the linkage stack, zeros appended on the right, form the 64-bit home
restores a portion of the information in the entry to virtual address of the leftmost byte of the entry
the CPU registers, updates the next-entry-size descriptor of the current linkage-stack entry.
field in the preceding entry, and updates the
linkage-stack-entry address in control register 15 The first word of the entry descriptor of the current
so that the preceding entry becomes the current linkage-stack entry is fetched by using the 64-bit
linkage-stack entry. The part of the unstacking home virtual address. If the entry-type code in
process that locates the last state entry is also bits 1-7 of the entry descriptor is not 0001001
performed as part of the EXTRACT STACKED binary, indicating that the entry is not a header
REGISTERS, EXTRACT STACKED STATE, and entry, processing continues as described in
MODIFY STACKED STATE operations. Checking for a State Entry on page 5-76; other-
wise, processing continues as described below.
For the unstacking process to be performed suc-
cessfully, DAT must be on and the CPU must be When the entry-type code in the current linkage-
in the primary-space mode or access-register stack entry is 0001001 binary, indicating a header
mode; otherwise, a special-operation exception is entry, the next processing depends on which
recognized, and the operation is suppressed. instruction is being executed. When the
However, when the unstacking process is per- unstacking process is performed as part of the
formed as part of EXTRACT STACKED REGIS- PROGRAM RETURN operation and the unstack-
TERS, EXTRACT STACKED STATE, or MODIFY suppression bit, bit 0, in the entry descriptor of the
STACKED STATE, the CPU may be in the current entry is one, a stack-operation exception is
primary-space, access-register, or home-space recognized, and the operation is nullified. When
mode. the unstacking process is performed as part of
EXTRACT STACKED REGISTERS, EXTRACT
Except as just mentioned, the unstacking process STACKED STATE, or MODIFY STACKED
is performed independent of the current STATE, the unstack-suppression bit is ignored.
addressing mode and translation mode, as speci-
fied by bits 31, 32, 16, and 17 of the current PSW. When there is not an exception due to the
All addresses used during the unstacking process unstack-suppression bit, the first doubleword of
are always 64-bit home virtual addresses. the current linkage-stack entry (a header entry) is
fetched. The address of this doubleword is deter-
During the unstacking process when any address mined by subtracting 8 from the address of the
is formed through the addition or subtraction of a entry descriptor of the current entry.
value to or from another address, a carry out of,
or a borrow into, bit position 0 of the address, if If the backward stack-entry validity bit, bit 63, of
any, is ignored. the current entry is zero, a stack-empty exception
is recognized, and the operation is nullified; other-
When the unstacking process fetches or stores by wise, the backward stack-entry address in the
using an address that designates, after translation, current entry is used to locate a linkage-stack
a location that is not available in the configuration, entry referred to here as the designated entry.
an addressing exception is recognized, and the Bits 0-60 of the current entry, with three zeros
operation is suppressed. appended on the right, form the 64-bit home
virtual address of the leftmost byte of the entry
Key-controlled protection does not apply to the descriptor of the designated entry.
accesses made during the unstacking process, but

Chapter 5. Program Execution 5-75


It is assumed in this definition of the unstacking STACKED STATE, the process is completed; that
process that the designated linkage-stack entry is is, no additional processing occurs as a part of the
the last entry, other than the trailer entry, in the unstacking process.
preceding linkage-stack section. This assumption
does not imply any processing that is not explicitly If the current linkage-stack entry is not a state
described. entry (and necessarily not a header entry either),
a stack-type exception is recognized, and the
The first word of the entry descriptor of the desig- operation is nullified.
nated entry is fetched. If the entry-type code in
this entry descriptor is not 0001001 binary, indi- Restoring Information
cating that the entry is not a header entry, the fol- The remaining parts of the unstacking process
lowing occurs: occur only in the PROGRAM RETURN operation.
When the unstacking process is performed as
The current linkage-stack entry is a state entry. If
part of the PROGRAM RETURN operation,
the unstack-suppression bit in the entry is one, a
bits 0-60 of the 64-bit home virtual address of
stack-operation exception is recognized, and the
the entry descriptor of the designated entry
operation is nullified.
are placed in bit positions 0-60 of control reg-
ister 15, and zeros are placed in bit positions
When there is not an exception due to the
61-63 of control register 15. Thus, the desig-
unstack-suppression bit, a portion of the contents
nated entry becomes the current linkage-stack
of the current linkage-stack entry are restored to
entry, and the preceding section (based on
the CPU registers. The contents of general regis-
the assumption) becomes the current linkage-
ters 2-14 and access registers 2-14 are restored
stack section. When the unstacking process
to those registers from where they were saved in
is performed as part of EXTRACT STACKED
the current entry by the stacking process. When
REGISTERS, EXTRACT STACKED STATE,
the entry-type code in the current entry is 0001101
or MODIFY STACKED STATE, the contents
binary, indicating a program-call state entry, the
of control register 15 remain unchanged, but
PSW-key mask and secondary ASN in control reg-
the designated entry is temporarily, during the
ister 3, extended authorization index in control
remainder of the definition of the instruction,
register 8, and primary ASN in control register 4
referred to as the current linkage-stack entry.
are similarly restored. During this restoration, the
Processing continues as described in authorization index in control register 4 and the
Checking for a State Entry. monitor masks in control register 8 remain
unchanged. (The authorization index may be
If the entry-type code in the designated entry is
changed by the part of the PROGRAM RETURN
0001001 binary, indicating a header entry, a
execution that occurs after the unstacking
stack-specification exception is recognized, and
process.) When the entry-type code is 0001100
the operation is nullified.
binary, indicating a branch state entry, the
PSW-key mask, secondary ASN, extended author-
Checking for a State Entry ization index, and primary ASN in the current entry
When the entry-type code in the current linkage-
are ignored, and all contents of the control regis-
stack entry indicates that the entry is not a header
ters remain unchanged. When the current entry is
entry, the code is checked for being 0001100 or
either a branch state entry or a program-call state
0001101 binary, which are the codes assigned to
entry, bits 0-63 and 64-127 of the current PSW
a state entry.
are restored from bytes 136-143 and bytes
168-175, respectively, of the entry, except that the
If the current linkage-stack entry is a state entry,
PER mask is not restored. The PER mask in the
the next processing depends on which instruction
current PSW remains unchanged. Bytes 144-159
is being executed. When the unstacking process
and bytes 160-167 of the current entry are
is performed as part of the PROGRAM RETURN
ignored.
operation, processing continues as described in
Restoring Information. When the process is per-
The fetches from the current entry appear to be
formed as part of EXTRACT STACKED REGIS-
word-concurrent as observed by other CPUs. The
TERS, EXTRACT STACKED STATE, or MODIFY
order in which the fetches occur is unpredictable.

5-76 z/Architecture Principles of Operation


Updating the Preceding Entry RETURN is space switching, the space-switch
Zeros are stored in the next-entry-size field, bits event can be used as a signal to turn PER on
32-47, of the entry descriptor of the preceding or off, if desired.
linkage-stack entry. The remainder of the pre-
ceding entry remains unchanged. The address of
the entry descriptor of the preceding entry is Sequence of Storage References
determined by subtracting the size in bytes of the The following sections describe the effects which
current entry from the address of the entry can be observed in storage due to overlapped
descriptor of the current entry. operations and piecemeal execution of a CPU
program. Most of the effects described in these
The order of the store into the preceding entry and sections are observable only when two or more
the fetches from the current entry is unpredictable. CPUs or channel programs are in simultaneous
execution and access common storage locations.
Updating Control Register 15 Thus, most of the effects need be taken into
Bits 0-60 of the 64-bit home virtual address of the account by a program only if the program interacts
entry descriptor of the preceding linkage-stack with another CPU or a channel program.
entry are placed in bit positions 0-60 of control
register 15, the linkage-stack-entry address. Some of the effects described in the following
Zeros are placed in bit positions 61-63 of control sections are independent of interaction with
register 15. Thus, the preceding entry becomes another CPU or a channel program. These
the current linkage-stack entry. effects, which are therefore more readily observ-
able, relate to prefetched instructions and overlap-
Recognition of Exceptions during the ping operands of a single instruction. These
Unstacking Process effects are described in Conceptual Sequence
The exceptions which can be encountered during and in Interlocks for Virtual-Storage References
the unstacking process and their priority are on page 5-79.
described in the definition of the PROGRAM
RETURN instruction. The exceptions which apply Conceptual Sequence
to EXTRACT STACKED REGISTERS, EXTRACT In the real mode, primary-space mode, or
STACKED STATE, and MODIFY STACKED secondary-space mode, the CPU conceptually
STATE are described in the definitions of those processes instructions one at a time, with the exe-
instructions. cution of one instruction preceding the execution
of the following instruction. The execution of the
Programming Notes: instruction designated by a successful branch
1. Any exceptions recognized during the exe- follows the execution of the branch. Similarly, an
cution of EXTRACT STACKED REGISTERS, interruption takes place between instructions or,
EXTRACT STACKED STATE, MODIFY for interruptible instructions, between units of oper-
STACKED STATE, or PROGRAM RETURN ation of such instructions.
cause either nullification or suppression.
Therefore, if an exception is recognized, the The sequence of events implied by the processing
unstacking process does not change the con- just described is sometimes called the conceptual
tents of any CPU register (except for updating sequence.
the instruction address in the PSW in the case
Each operation of instruction execution appears to
of suppression) or store into any linkage-stack
the program itself to be performed sequentially,
entry.
with the current instruction being fetched after the
2. The unstacking process in PROGRAM preceding operation is completed and before the
RETURN does not restore the PER mask in execution of the current operation is begun. This
the PSW so that an act of turning PER on or appearance is maintained even though the
off after the execution of the related BRANCH storage-implementation characteristics and overlap
AND STACK or PROGRAM CALL instruction of instruction execution with storage accessing
but before the execution of the PROGRAM may cause actual processing to be different. The
RETURN instruction will not be counteracted. results generated are those that would have been
When PROGRAM CALL or PROGRAM

Chapter 5. Program Execution 5-77


obtained had the operations been performed in and storing results. As a consequence, interme-
the conceptual sequence. Thus, it is possible for diate or partially completed results may be observ-
an instruction to modify the next succeeding able by other CPUs and by channel programs.
instruction in storage.
When a program interacts with the operation on
Operations in the access-register mode or home- another CPU, or with a channel program, the
space mode are the same as in the other trans- program may have to take into consideration that
lation modes, with one exception: an instruction a single operation may consist in a series of
that is a store-type operand of a preceding instruc- storage references, that a storage reference may
tion may appear to be fetched before the store in turn consist in a series of accesses, and that
occurs. Thus, it is not assured that an instruction the conceptual and observed sequences of these
can modify the succeeding instructions. This accesses may differ.
exception applies if either the storing instruction or
the instruction stored is executed in the access- Storage references associated with instruction
register or home-space mode. execution are of the following types: instruction
fetches, ART-table and DAT-table fetches, and
Regardless of the translation mode, another case storage-operand references. For the purpose of
in which the copies of prefetched instructions are describing the sequence of storage references,
not necessarily discarded occurs when the fetch accesses to storage in order to perform ASN
and the store are done by means of different translation, PC-number translation, tracing, and
effective addresses that map to the same real the linkage-stack stacking and unstacking proc-
address. This case is described in more detail in esses are considered to be storage-operand refer-
Interlocks for Virtual-Storage References on ences.
page 5-79.
Programming Note: The sequence of execution
of a CPU may differ from the simple conceptual
Overlapped Operation of Instruction definition in the following ways:
Execution
In simple models in which operations are not over- As observed by the CPU itself, instructions
lapped, the conceptual and actual sequences are may appear to be prefetched in the access-
essentially the same. However, in more complex register or home-space mode regardless of
machines, overlapped operation, buffering of oper- whether the mode exists at the time of the
ands and results, and execution times which are conceptual store or during the execution of the
comparable to the propagation delays between prefetched instruction. They may also appear
units can cause the actual sequence to differ con- to be prefetched when different effective
siderably from the conceptual sequence. In these addresses are used. (See Interlocks for
machines, special circuitry is employed to detect Virtual-Storage References on page 5-79.)
dependencies between operations and ensure that As observed by other CPUs and by channel
the results obtained, as observed by the CPU programs, the execution of an instruction may
which generates them, are those that would have appear to be performed as a sequence of
been obtained if the operations had been per- piecemeal steps. This is described for each
formed in the conceptual sequence. However, type of storage reference in the following
other CPUs and channel programs may, unless sections.
otherwise constrained, observe a sequence that
differs from the conceptual sequence. As observed by other CPUs and by channel
programs, the storage-operand accesses
associated with one instruction are not neces-
Divisible Instruction Execution
sarily performed in the conceptual sequence.
It can normally be assumed that the execution of
(See Relation between Operand Accesses
each instruction occurs as an indivisible event.
on page 5-88.)
However, in actual operation, the execution of an
instruction consists in a series of discrete steps. As observed by channel programs, in certain
Depending on the instruction, operands may be unusual situations, the contents of storage
fetched and stored in a piecemeal fashion, and may appear to change and then be restored
some delay may occur between fetching operands to the original value. (See Storage Change

5-78 z/Architecture Principles of Operation


and Restoration for DAT-Associated Access The interlocks for virtual-storage references are
Exceptions on page 5-22.) considered in two situations: storage references
of one instruction as they affect storage refer-
Interlocks for Virtual-Storage ences of another instruction, and multiple storage
references of a single instruction.
References
As described in the immediately preceding
Interlocks between Instructions
As observed by the CPU itself, the storage
sections, CPU operation appears, with certain
accesses for operands for each instruction appear
exceptions, to be performed sequentially as
to occur in the conceptual sequence independent
observed by the CPU itself; the stores performed
of the effective address used. That is, the
by one instruction generally appear to be com-
operand stores for one instruction appear to be
pleted before the next instruction and its operands
completed before the operand fetches for the next
are fetched. This appearance is maintained in
instruction occur. For instruction fetches, the
overlapped machines by means of interlock circu-
operand stores for one instruction necessarily
itry that detects accesses to a common storage
appear to be completed before the next instruction
location.
is fetched only when the same effective address is
For those instructions which alter the contents of used for the operand store and the instruction
storage and have more than one operand, the fetch, and then only in the real mode, primary-
instruction definition normally describes the results space mode, or secondary-space mode.
that are obtained when the operands overlap in
When an instruction changes the contents of a
storage, this definition being in terms of a
main-storage location in which a conceptually sub-
sequence of stores and fetches. The interlock cir-
sequent instruction is to be executed, either
cuitry is used in determining whether operand
directly or by means of EXECUTE, and when dif-
overlap exists.
ferent effective addresses are used to designate
The purpose of this section is to define those that location for storing the result and fetching the
cases in which the machine must appear to instruction, the instruction may appear to be
operate sequentially, and in which operands of a fetched before the store occurs. When either the
single instruction must or must not be treated as storing instruction or the subsequent instruction is
overlapping. executed in the access-register mode or home-
space mode, changes to the contents of storage
Proper operation is provided in part by comparing are not necessarily recognized even if the effec-
effective addresses. For the purpose of this defi- tive address used to store the value and the effec-
nition, the term effective address means an tive address used to fetch the instruction are the
address before translation, if any, regardless of same. If an intervening operation causes the pre-
whether the address is virtual, real, or absolute. If fetched instructions to be discarded, then the
two effective addresses have the same value, the updated value is recognized. A definition of when
effective addresses are said to be the same even prefetched instructions must be discarded is
though one may be real or in a different address included in Instruction Fetching on page 5-81.
space.
Any change to the storage key appears to be
The values of two virtual effective addresses do completed before the conceptually following refer-
not necessarily indicate whether or not the ence to the associated storage block is made,
addresses designate the same storage location. regardless of whether the reference to the storage
The address-translation tables may be set up so location is made by means of a virtual, real, or
that different effective addresses map to the same absolute address. Analogously, any conceptually
real address, or so that the same effective prior references to the storage block appear to be
address in different address spaces maps to dif- completed when the key for that block is changed
ferent real addresses. or inspected.

Chapter 5. Program Execution 5-79


Interlocks within a Single Instruction recognized when the effective space designations
For those instructions which alter the contents of are different.
storage and have more than one operand, the Programming Note: A single main-storage
instruction definition normally describes the results location can be accessed by means of more than
which are obtained when the operands overlap in one address in several ways:
storage. This result is normally defined in terms
of the sequence of the storage accesses; that is, a 1. The DAT tables may be set up such that mul-
portion of the results of a store-type operand must tiple addresses in a single address space, or
appear to be placed in storage before some addresses in different address spaces,
portion of the other operand is fetched. This defi- including the real address specified by a real-
nition applies provided that the store and fetch space designation, map to a single real
accesses are specified by means of the same address.
effective addresses and the same effective space 2. The translation of logical, instruction, and
designations. virtual addresses may be changed by loading
the DAT parameters in the control registers,
When multiple address spaces are involved in the by changing the address-space-control bits in
access-register mode, the term effective space the PSW, or, for logical and instruction
designation is used to denote the value used by addresses, by turning DAT on or off.
the machine to determine whether two spaces are
the same. In the access-register mode, the 32-bit 3. In the access-register mode, different address
access-list-entry-token (ALET) value associated spaces may be selected by means of each
with each storage-operand address is called the access register. In addition, the primary
effective space designation. When a B field of address space is selected for instruction
zero is specified, a value of all zeros is used for fetching and the target of EXECUTE.
the effective space designation. If the effective 4. STORE USING REAL ADDRESS performs a
space designations are different, the spaces are store by means of a real address.
considered to be different even if both ALETs map
to the same address-space-control-element value. 5. Certain other instructions also use real
addresses (even when a logical address is not
When the store and the fetch accesses are speci- translated by means of a real-space desig-
fied by means of different effective space desig- nation, which is a situation covered in case 1),
nations or by means of different effective and the instructions MOVE TO PRIMARY and
addresses, the operand fetch may appear to MOVE TO SECONDARY access two address
precede the operand store. spaces.
6. Accesses to storage for the purpose of storing
Figure 5-11 on page 5-81 summarizes the cases and fetching information for interruptions is
of overlap and the specified results, including performed by means of real addresses, and,
when MOVE LONG (MVCL) sets condition code 3, for the store-status function, by means of
for each case. absolute addresses, whereas accesses by the
program may be by means of virtual
Effective space designations may be represented addresses.
by ALB entries, and the test for whether two effec-
tive space designations are the same may be per- 7. The real-to-absolute mapping may be
formed by comparing ALB entries. If the program changed by means of the SET PREFIX
changes an attached and valid ART-table entry instruction or a reset.
without subsequently causing the execution of 8. A main-storage location may be accessed by
PURGE ALB or a COMPARE AND SWAP AND channel programs by means of an absolute
PURGE instruction that purges the ALB, two effec- address and by the CPU by means of a real
tive space designations that are the same may or a virtual address.
have different representations in the ALB, and
failure to recognize operand overlap may result. 9. A main-storage location may be accessed by
The use of the ALB never causes overlap to be another CPU by means of one type of
address and by this CPU by means of a dif-
ferent type of address.

5-80 z/Architecture Principles of Operation



Effective Effective Operands Is Overlap Recognized?
Space Addresses Overlap
DesignationsOverlap Destructively MVCL Sets Operand
Equal? Destructively?in Real Storage? CC 3 Results

Yes No No No No
Yes No Yes No Unp.
Yes Yes No \ \
Yes Yes Yes Yes Yes
No No No No No
No No Yes No Unp.
No Yes No No No
No Yes Yes No Unp.

Explanation:

\ This case cannot occur.
Unp. It is unpredictable whether or not the overlap is recognized.

Figure 5-11. Virtual-Storage Interlocks within a Single Instruction

The primary purpose of this section on interlocks Instruction Fetching


is to describe the effects caused in cases 1, 3,
and 4, above. Instruction fetching consists in fetching the one,
For case 2, no effect is observable because pre- two, or three halfwords designated by the instruc-
fetched instructions are discarded when the trans- tion address in the current PSW. The immediate
lation parameters are changed, and the delay of field of an instruction is accessed as part of an
stores by a CPU is not observable by the CPU instruction fetch. If, however, an instruction desig-
itself. nates a storage operand at the location occupied
by the instruction itself, the location is accessed
For case 5, for those instructions which fetch by both as an instruction and as a storage operand.
using real addresses (for example, LOAD REAL The fetch of the target instruction of EXECUTE is
ADDRESS, which fetches a segment-table entry considered to be an instruction fetch.
and a page-table entry, and may fetch a region-
table entry), no effect is observable because only The bytes of an instruction may be fetched piece-
operand accesses between instructions are meal and are not necessarily accessed in a left-to-
involved. All instructions that store by using a real right direction. The instruction may be fetched
address, except STORE USING REAL ADDRESS, multiple times for a single execution; for example,
or that store across address spaces, except in the it may be fetched for testing the addressability of
access-register mode, cause prefetched operands or for inspection of PER events, and it
instructions to be discarded, and no effect is may be refetched for actual execution.
observable.
Instructions are not necessarily fetched in the
Cases 6 and 7 are situations which are defined to sequence in which they are conceptually executed
cause serialization, with the result that prefetched and are not necessarily fetched each time they
instructions are discarded. In these cases, no are executed. In particular, the fetching of an
effect is observable. instruction may precede the storage-operand ref-
erences for an instruction that is conceptually
The handling of cases 8 and 9 involves accesses earlier. The instruction fetch occurs prior to all
as observed by other CPUs and by channel pro- storage-operand references for all instructions that
grams and is covered in the following sections in are conceptually later.
this chapter.
An instruction may be prefetched by using a
virtual address only when the associated DAT
table entries are attached and valid or when

Chapter 5. Program Execution 5-81


entries which qualify for substitution for the table CONTROL FAST instruction can perform the
entries exist in the TLB. An instruction that has same mode changes, but it does not serialize.
been prefetched may be interpreted for execution
only for the same virtual address for which the Programming Notes:
instruction was prefetched. 1. As observed by a CPU itself, its own instruc-
tion prefetching may be apparent when dif-
No limit is established on the number of
ferent effective addresses map to a single real
instructions which may be prefetched, and multiple
address or when the CPU is in the access-
copies of the contents of a single storage location
register or home-space mode. This is
may be fetched. As a result, the instruction exe-
described in Conceptual Sequence on
cuted is not necessarily the most recently fetched
page 5-77 and Interlocks for Virtual-Storage
copy. Storing caused by other CPUs and by
References on page 5-79.
channel programs does not necessarily change
the copy of prefetched instructions. However, if a 2. Any means of changing PSW bits 16 and 17,
store that is conceptually earlier is made by the except the SET ADDRESS SPACE
same CPU using the same effective address as CONTROL FAST instruction, causes serializa-
that by which the instruction is subsequently tion to be performed and prefetched
fetched, and the CPU is in any of the real, instructions to be discarded. Turning DAT on
primary-space, and secondary-space modes when or off causes prefetched instructions to be dis-
the the storing instruction is executed and is in carded. Therefore, any change of the trans-
any of those modes when the subsequent instruc- lation mode, except a change made by SET
tion is executed, the updated information is ADDRESS SPACE CONTROL FAST, always
obtained. If the effective addresses are different causes prefetched instructions to be dis-
or if the CPU is in the access-register mode or carded.
home-space mode during either the storing exe- 3. The following are some effects of instruction
cution or the execution of the instruction that is the prefetching on one CPU as observed by other
destination of the store, the updated information is CPUs and by channel programs.
not necessarily obtained. However, the updated
information is obtained if either execution is in the It is possible for one CPU to prefetch the con-
real mode since prefetched instructions are dis- tents of a storage location, after which another
carded if DAT is turned on or off. CPU or a channel program can change the
contents of that storage location and then set
All copies of prefetched instructions are discarded a flag to indicate that the change has been
when: made. Subsequently, the first CPU can test
and find the flag set, branch to the modified
A serializing function is performed.
location, and execute the original prefetched
The CPU enters the operating state.
contents.
DAT is turned on or off.
A change is made to a translation parameter It is possible, if another CPU or a channel
in control register 1 when in the primary- program concurrently modifies the instruction,
space, secondary-space, or access-register for one CPU to recognize the changes to
mode, or in control register 13 when in the some but not all bit positions of an instruction.
home-space mode. It is possible for one CPU to prefetch an
The SET ADDRESS SPACE CONTROL instruc- instruction and subsequently, before the
tion can change the translation mode between any instruction is executed, for another CPU to
of the primary-space, secondary-space, access- change the storage key. As a result, the first
register, and home-space modes, and it performs CPU may appear to execute instructions from
serialization. The SET ADDRESS SPACE a protected storage location. However, the
copy of the instructions executed is the copy
prefetched before the location was protected.

5-82 z/Architecture Principles of Operation


ART-Table and DAT-Table actual byte access requiring the ART-table or
DAT-table entry.
Fetches
5. An ART-table or DAT-table entry may be
The access-register-translation (ART) table entries fetched for each use of the address, including
are access-list designations, access-list entries, any trial execution, and for each reference to
ASN-second-table entries, and authority-table each byte of each operand.
entries. The dynamic-address-translation (DAT) 6. The DAT page-table-entry fetch precedes the
table entries are region-table entries, segment- reference to the page. When no copy of the
table entries, and page-table entries. The fetching page-table entry is in the TLB, the fetch of the
of these entries may occur as follows: associated segment-table entry precedes the
1. An ART-table entry may be prefetched into fetch of the page-table entry. When no copy
the ART-lookaside buffer (ALB) and used from of the segment-table entry is in the TLB, the
the ALB without refetching from storage, until fetch of the region-third-table entry, if one is
the entry is cleared by a COMPARE AND required, precedes the fetch of the segment-
SWAP AND PURGE, PURGE ALB, or SET table entry. Similarly, the fetch of a required
PREFIX instruction, by CPU reset, or by a set- region-second-table entry precedes the fetch
architecture SIGNAL PROCESSOR order. A of the region-first-table entry, and the fetch of
DAT-table entry may be prefetched into the a required region-first-table entry precedes the
translation-lookaside buffer (TLB) and used fetch of the region-second-table entry.
from the TLB without refetching from storage, 7. When no copy of a region-table entry or
until the entry is cleared by a COMPARE AND segment-table entry designated by means of
SWAP AND PURGE, INVALIDATE PAGE an ART-obtained address-space-control
TABLE ENTRY, PURGE TLB, or SET PREFIX element is in the TLB, the ART fetch of the
instruction, by CPU reset, or by a set- ASN-second-table entry precedes the DAT
architecture SIGNAL PROCESSOR order. region-table-entry or segment-table-entry
ART-table and DAT-table entries are not nec- fetch. When no copy of a required authority-
essarily fetched in the sequence conceptually table entry is in the ALB, the ART fetch of the
called for; they may be fetched at any time associated ASN-second-table entry precedes
they are attached and valid, including during the fetch of the authority-table entry. When
the execution of conceptually previous no copy of a required ASN-second-table entry
instructions. is in the ALB, the fetch of the associated
2. The fetching of access-list designations, access-list entry precedes the fetch of the
access-list entries, ASN-second-table entries, ASN-second-table entry. When no copy of a
and DAT-table entries appears to be word- required access-list entry is in the ALB, the
concurrent as observed by other CPUs. fetch of the associated access-list designation
However, the reference to an entry may precedes the fetch of the access-list entry.
appear to access a single byte at a time as
observed by channel programs. Storage-Key Accesses
3. The order in which the words of an access-list
entry or ASN-second-table entry are fetched is References to the storage key are handled as
unpredictable, except that the leftmost word of follows:
an entry is fetched first. However, the left- 1. Whenever a reference to storage is made and
most word of an ASN-second-table entry is key-controlled protection applies to the refer-
not fetched when access-list-entry token ence, the four access-control bits and the
00000000 hex is translated for BRANCH IN fetch-protection bit associated with the storage
SUBSPACE GROUP. location are inspected concurrently with the
4. An ART-table or DAT-table entry may be reference to the storage location.
fetched even after some operand references 2. When storing is performed, the change bit is
for the instruction have already occurred. The set in the associated storage key concurrently
fetch may occur as late as just prior to the with the store operation.

Chapter 5. Program Execution 5-83


3. The instruction SET STORAGE KEY Storage-operand references are of three types:
EXTENDED causes all seven bits to be set fetches, stores, and updates.
concurrently in the storage key. The access
to the storage key for SET STORAGE KEY Storage-Operand Fetch References
EXTENDED follows the sequence rules for When the bytes of a storage operand participate
storage-operand store references and is a in the instruction execution only as a source, the
single-access reference. operand is called a fetch-type operand, and the
4. The INSERT STORAGE KEY EXTENDED reference to the location is called a storage-
instruction provides a consistent image of bits operand fetch reference. A fetch-type operand is
0-6 of the storage key. Similarly, the identified in individual instruction definitions by
instructions INSERT VIRTUAL STORAGE indicating that the access exception is for fetch.
KEY and TEST PROTECTION provide a con-
All bits within a single byte of a fetch reference
sistent image of bits 0-4 of the storage key.
are accessed concurrently. When an operand
The access to the storage key for all of these
consists of more than one byte, the bytes may be
instructions follows the sequence rules for
fetched from storage piecemeal, one byte at a
storage-operand fetch references and is a
time. Unless otherwise specified, the bytes are
single-access reference.
not necessarily fetched in any particular sequence.
5. The instruction RESET REFERENCE BIT
EXTENDED modifies only the reference bit. The storage-operand fetch references of one
All other bits of the storage key remain instruction occur after those of all preceding
unchanged. The reference bit and change bit instructions and before those of subsequent
are examined concurrently to set the condition instructions, as observed by other CPUs and by
code. The access to the storage key for channel programs. The operands of any one
RESET REFERENCE BIT EXTENDED follows instruction are fetched in the sequence specified
the sequence rules for storage-operand for that instruction. The CPU may fetch the oper-
update references. The reference bit is the ands of instructions before the instructions are
only bit which is updated. executed. There is no defined limit on the length
of time between when an operand is fetched and
The record of references provided by the refer-
when it is used. Still, as observed by the CPU
ence bit is not necessarily accurate, and the han-
itself, its storage-operand references are per-
dling of the reference bit is not subject to the
formed in the conceptual sequence.
concurrency rules. However, in the majority of sit-
uations, reference recording approximately coin-
cides with the storage reference. Storage-Operand Store References
When the bytes of a storage operand participate
The change bit may be set in cases when no in the instruction execution only as a destination,
storing has occurred. See Exceptions to to the extent of being replaced by the result, the
Nullification and Suppression on page 5-22. operand is called a store-type operand, and the
reference to the location is called a storage-
operand store reference. A store-type operand is
Storage-Operand References identified in individual instruction definitions by
indicating that the access exception is for store.
A storage-operand reference is the fetching or
storing of the explicit operand or operands in the All bits within a single byte of a store reference
storage locations designated by the instruction. are accessed concurrently. When an operand
consists of more than one byte, the bytes may be
During the execution of an instruction, all or some
placed in storage piecemeal, one byte at a time.
of the storage operands for that instruction may be
Unless otherwise specified, the bytes are not nec-
fetched, intermediate results may be maintained
essarily stored in any particular sequence.
for subsequent modification, and final results may
be temporarily held prior to placing them in The CPU may delay placing results in storage.
storage. Stores caused by other CPUs and by There is no defined limit on the length of time that
channel programs do not necessarily affect these results may remain pending before they are
intermediate results.

5-84 z/Architecture Principles of Operation


stored. This delay does not affect the sequence immediately after the other, but all store accesses
in which results are placed in storage. and the fetch and store accesses associated with
interlocked-update references by other CPUs are
The results of one instruction are placed in prevented from occurring at the same location
storage after the results of all preceding between the fetch and the store accesses of an
instructions have been placed in storage and interlocked-update reference. Accesses by
before any results of the succeeding instructions channel programs may occur to the location
are stored, as observed by other CPUs and by during the interlock period.
channel programs. The results of any one instruc-
tion are stored in the sequence specified for that The storage-operand update reference for the fol-
instruction. lowing instructions appears to be an interlocked-
update reference as observed by other CPUs.
The CPU does not fetch operands, ART-table The instructions TEST AND SET, COMPARE
entries, or DAT-table entries from a storage AND SWAP, and COMPARE DOUBLE AND
location until all information destined for that SWAP perform an interlocked-update reference.
location by the CPU has been stored. Prefetched On models in which the STORE CHARACTERS
instructions may appear to be updated before the UNDER MASK instruction with a mask of zero
information appears in storage. fetches and stores the byte designated by the
second-operand address, the fetch and store
The stores are necessarily completed only as a accesses are an interlocked-update reference.
result of a serializing operation and before the
CPU enters the stopped state. Within the limitations of the above requirements,
the fetch and store accesses associated with an
Storage-Operand Update References update reference follow the same rules as the
In some instructions, the storage-operand location fetches and stores described in the previous
participates both as a source and as a destination. sections.
In these cases, the reference to the location con-
sists first in a fetch and subsequently in a store. Programming Notes:
The operand is called an update-type operand, 1. When two CPUs attempt to update information
and the combination of the two accesses is at a common main-storage location by means
referred to as an update reference. Instructions of a noninterlocked-update reference, it is pos-
such as MOVE ZONES, TRANSLATE, OR (OC, sible for both CPUs to fetch the information
OI), and ADD DECIMAL cause an update to the and subsequently make the store access.
first-operand location. An update-type operand is The change made by the first CPU to store
identified in the individual instruction definition by the result in such a case is lost. Similarly, if
indicating that the access exception is for both one CPU updates the contents of a field by
fetch and store. means of a noninterlocked-update reference,
but another CPU makes a store access to that
For most instructions which have update-type
field between the fetch and store parts of the
operands, the fetch and store accesses associ-
update reference, the effect of the store is
ated with an update reference do not necessarily
lost. If, instead of a store access, a CPU
occur one immediately after the other, and it is
makes an interlocked-update reference to the
possible for other CPUs and channel programs to
common storage field between the fetch and
make fetch and store accesses to the same
store portions of a noninterlocked-update ref-
location during this time. Such an update refer-
erence due to another CPU, any change in
ence is sometimes called a noninterlocked-update
the contents produced by the interlocked-
storage reference.
update reference is lost.
For certain special instructions, the update refer- 2. The instructions TEST AND SET, COMPARE
ence is interlocked against certain accesses by AND SWAP, and COMPARE DOUBLE AND
other CPUs. Such an update reference is called SWAP facilitate updating of a common
an interlocked-update reference. The fetch and storage field by two or more CPUs. To
store accesses associated with an interlocked- ensure that no changes are lost, all CPUs
update reference do not necessarily occur one must use an instruction providing an

Chapter 5. Program Execution 5-85


interlocked-update reference. In addition, the store access occurs to each byte location within
program must ensure that channel programs the data field. An update reference is said to be
do not store into the same storage location single access if both the fetch and store accesses
since such stores may occur between the are each single access.
fetch and store portions of an interlocked-
update reference. Except for the accesses associated with multiple-
access references and the stores associated with
3. Only those bytes which are included in the
storage change and restoration for
result field of both operations are considered
DAT-associated access exceptions, all storage-
to be part of the common main-storage
operand references are single-access references.
location. However, all bits within a common
byte are considered to be common even if the
bits modified by the two operations do not
Multiple-Access References
In some cases, multiple accesses may be made to
overlap. As an example, if (1) one CPU exe-
all or some of the bytes of a storage operand.
cutes the instruction OR (OC) with a length of
The following cases may involve multiple-access
1 and the value 80 hex in the second-operand
references:
location, (2) the other CPU executes AND
(NC) with a length of 1 and the value FE hex 1. The storage operands of the following
in the second-operand location, and (3) the instructions: CONVERT TO BINARY,
first operand of both instructions is the same CONVERT TO DECIMAL, MOVE INVERSE,
byte, then the result of one of the updates can MOVE WITH OFFSET, PACK, TRANSLATE,
be lost. TRANSLATE EXTENDED, TEST BLOCK,
UNPACK, and UPDATE TREE.
4. When the store access is part of an update
reference by the CPU, the execution of the 2. The stores into that portion of the first operand
storing is not necessarily contingent on of MOVE LONG or MOVE LONG EXTENDED
whether the information to be stored is dif- which is filled with padding bytes.
ferent from the original contents of the
3. The storage operands of the decimal
location. In particular, the contents of all des-
instructions.
ignated byte locations are replaced, and, for
each byte in the field, the entire contents of 4. The stores into a trace entry.
the byte are replaced. 5. The stores associated with the stop-and-store-
Depending on the model, an access to store status and store-status-at-address SIGNAL
information may be performed, for example, in PROCESSOR orders.
the following cases: 6. The storage operands of COMPARE UNTIL
a. Execution of the OR instruction (OI or OC) SUBSTRING EQUAL.
with a second operand of all zeros. 7. The trap control block and trap save area
b. Execution of OR (OC) with the first-and used by TRAP.
second-operand fields coinciding. 8. The main-storage operands of PAGE IN and
c. For those locations of the first operand of PAGE OUT.
TRANSLATE where the argument and When a storage-operand store reference to a
function values are the same. location is not a single-access reference, the value
placed at a byte location is not necessarily the
Storage-Operand Consistency same for each store access; thus, intermediate
results in a single-byte location may be observed
Single-Access References by other CPUs and by channel programs.
A fetch reference is said to be a single-access ref-
erence if the value is fetched in a single access to
each byte of the data field. In the case of overlap-
ping operands, the location may be accessed
once for each operand. A store-type reference is
said to be a single-access reference if a single

5-86 z/Architecture Principles of Operation


Programming Notes: operand references appear to be block-concurrent
as observed by other CPUs. For LOAD PSW
1. When multiple fetch or store accesses are
EXTENDED, the accesses to each of the two
made to a single byte that is being changed
doublewords of the storage operand appear to be
by another CPU or by a channel program, the
block concurrent.
result is not necessarily limited to that which
could be obtained by fetching or storing the
For the instructions COMPARE AND SWAP and
bits individually. For example, the execution
COMPARE DOUBLE AND SWAP, all accesses to
of MULTIPLY DECIMAL may consist in repeti-
the storage operand appear to be block-
tive additions and subtractions, each of which
concurrent as observed by other CPUs.
causes the second operand to be fetched
from storage and the first operand to be For the instruction PERFORM LOCKED OPERA-
updated in storage. TION, the accesses to the even-numbered storage
2. When CPU instructions which make multiple- operands are word concurrent for function codes
access references are used to modify storage that are a multiple of 4 and doubleword concurrent
locations being simultaneously accessed by for function codes that are one, 2, or 3 more than
another CPU or by a channel program, mul- a multiple of 4. The accesses to the doublewords
tiple store accesses to a single byte by the in the parameter list are doubleword concurrent
CPU may result in intermediate values being regardless of the function code.
observed by the other CPU or by the channel
program. To avoid these intermediate values The instructions LOAD MULTIPLE, LOAD MUL-
(for example, when modifying a CCW chain), TIPLE DISJOINT, LOAD MULTIPLE HIGH,
only instructions making single-access refer- STORE MULTIPLE, and STORE MULTIPLE
ences should be used. HIGH, when the operand or operands start on a
word boundary, and the instructions COMPARE
Block-Concurrent References LOGICAL (CLC), COMPARE LOGICAL CHARAC-
For some references, the accesses to all bytes TERS UNDER MASK, INSERT CHARACTERS
within a halfword, word, or doubleword are speci- UNDER MASK, LOAD CONTROL (LCTLG),
fied to appear to be block-concurrent as observed STORE CHARACTERS UNDER MASK, and
by other CPUs. These accesses do not neces- STORE CONTROL (STCTG) access their storage
sarily appear to channel programs to include more operands in a left-to-right direction, and all bytes
than a byte at a time. The halfword, word, or accessed within each doubleword appear to be
doubleword is referred to in this section as a accessed concurrently as observed by other
block. When a fetch-type reference is specified to CPUs.
appear to be concurrent within a block, no store
access to the block by another CPU is permitted The instructions LOAD ACCESS MULTIPLE,
during the time that bytes contained in the block LOAD CONTROL (LCTL), STORE ACCESS MUL-
are being fetched. Accesses to the bytes within TIPLE, and STORE CONTROL (STCTG) access
the block by channel programs may occur the storage operand in a left-to-right direction, and
between the fetches. When a store-type refer- all bytes accessed within each word appear to be
ence is specified to appear to be concurrent within accessed concurrently as observed by other
a block, no access to the block, either fetch or CPUs.
store, is permitted by another CPU during the time
When destructive overlap does not exist, the oper-
that the bytes within the block are being stored.
ands of MOVE (MVC), MOVE WITH KEY, MOVE
Accesses to the bytes in the block by channel pro-
TO PRIMARY, and MOVE TO SECONDARY are
grams may occur between the stores.
accessed as follows:
Consistency Specification 1. The first operand is accessed in a left-to-right
For all instructions in the S, RX, or RXE format, direction, and all bytes accessed within a
with the exception of EXECUTE, CONVERT TO doubleword appear to be accessed concur-
DECIMAL, CONVERT TO BINARY, LOAD PSW rently as observed by other CPUs.
EXTENDED, and the I/O instructions, when the 2. The second operand is accessed left to right,
operand is addressed on a boundary which is inte- and all bytes within a doubleword in the
gral to the size of the operand, the storage-

Chapter 5. Program Execution 5-87


second operand that are moved into a single first and second operands coincide, all bytes
doubleword in the first operand appear to be accessed within a doubleword appear to be
fetched concurrently as observed by other accessed concurrently as observed by other
CPUs. Thus, if the first and second operands CPUs.
begin on the same byte offset within a
Programming Note: In the case of EXCLUSIVE
doubleword, the fetch of the second operand
OR (XC) designating operands which coincide
appears to be doubleword-concurrent as
exactly, the bytes within the field may appear to
observed by other CPUs. If the offsets within
be accessed as many as three times, by two
a doubleword differ by 4, the fetch of the
fetches and one store: once as the fetch portion
second operand appears to be word-
of the first operand update, once as the second-
concurrent as observed by other CPUs.
operand fetch, and then once as the store portion
Destructive overlap is said to exist when the result of the first-operand update. Each of the three
location is used as a source after the result has accesses appears to be doubleword-concurrent as
been stored, assuming processing to be per- observed by other CPUs, but the three accesses
formed one byte at a time. do not necessarily appear to occur one imme-
diately after the other. One or both fetch
The operands of MOVE WITH SOURCE KEY, accesses may be omitted since the instruction can
MOVE WITH DESTINATION KEY, and MOVE be completed without fetching the operands.
STRING are accessed the same as those of
MOVE (MVC), except that destructive overlap is
assumed not to exist.
Relation between Operand
Accesses
The operands for MOVE LONG, MOVE LONG
EXTENDED, and MOVE LONG UNICODE appear As observed by other CPUs and by channel pro-
to be accessed doubleword-concurrent as grams, storage-operand fetches associated with
observed by other CPUs when all of the following one instruction execution appear to precede all
are true: storage-operand references for conceptually sub-
sequent instructions. A storage-operand store
Both operands start on doubleword bounda- specified by one instruction appears to precede all
ries and are an integral number of storage-operand stores specified by conceptually
doublewords in length. subsequent instructions, but it does not neces-
The operands do not overlap. sarily precede storage-operand fetches specified
by conceptually subsequent instructions.
The nonpadding part of the operation is being However, a storage-operand store appears to
executed. precede a conceptually subsequent storage-
The operands for COMPARE LOGICAL LONG, operand fetch from the same main-storage
COMPARE LOGICAL LONG EXTENDED, location.
COMPARE LOGICAL LONG UNICODE, and
COMPARE LOGICAL STRING appear to be When an instruction has two storage operands
accessed doubleword-concurrent as observed by both of which cause fetch references, it is unpre-
other CPUs when both operands start on dictable which operand is fetched first, or how
doubleword boundaries and are an integral much of one operand is fetched before the other
number of doublewords in length. operand is fetched. When the two operands
overlap, the common locations may be fetched
The operands for COMPARE LOGICAL STRING independently for each operand.
appear to be accessed doubleword-concurrent as
observed by other CPUs when both operands When an instruction has two storage operands the
start on doubleword boundaries. The operand for first of which causes a store and the second a
SEARCH STRING appears to be accessed fetch reference, it is unpredictable how much of
doubleword-concurrent as observed by other the second operand is fetched before the results
CPUs when it starts on a doubleword boundary. are stored. In the case of destructively overlap-
ping operands, the portion of the second operand
For EXCLUSIVE OR (XC), the operands are proc- which is common to the first is not necessarily
essed in a left-to-right direction, and, when the fetched from storage.

5-88 z/Architecture Principles of Operation


When an instruction has two storage operands the
first of which causes an update reference and the Serialization
second a fetch reference, it is unpredictable which The sequence of functions performed by a CPU is
operand is fetched first, or how much of one normally independent of the functions performed
operand is fetched before the other operand is by other CPUs and by channel programs. Simi-
fetched. Similarly, it is unpredictable how much of larly, the sequence of functions performed by a
the result is processed before it is returned to channel program is normally independent of the
storage. In the case of destructively overlapping functions performed by other channel programs
operands, the portion of the second operand and by CPUs. However, at certain points in its
which is common to the first is not necessarily execution, serialization of the CPU occurs. Serial-
fetched from storage. ization also occurs at certain points for channel
programs.
The independent fetching of a single location for
each of two operands may affect the program exe-
cution in the following situation. When the same
CPU Serialization
storage location is designated by two operand
All interruptions and the execution of certain
addresses of an instruction, and another CPU or a
instructions cause a serialization of CPU oper-
channel program causes the contents of the
ations. A serialization operation consists in com-
location to change during execution of the instruc-
pleting all conceptually previous storage accesses
tion, the old and new values of the location may
by the CPU, as observed by other CPUs and by
be used simultaneously. For example, compar-
channel programs, before the conceptually subse-
ison of a field to itself may yield a result other than
quent storage accesses occur. Serialization
equal, or EXCLUSIVE-ORing of a field with itself
affects the sequence of all CPU accesses to
may yield a result other than zero.
storage and to the storage keys, except for those
associated with ART-table-entry and
Other Storage References DAT-table-entry fetching.

The restart, program, supervisor-call, external, Serialization is performed by CPU reset, all inter-
input/output, and machine-check PSWs appear to ruptions, and by the execution of the following
be accessed doubleword-concurrent as observed instructions:
by other CPUs. These references appear to occur
The general instructions BRANCH ON CON-
after the conceptually previous unit of operation
DITION (BCR) with the M and R field con-
and before the conceptually subsequent unit of
taining all ones and all zeros, respectively,
operation. The relationship between the
and COMPARE AND SWAP, COMPARE
new-PSW fetch, the old-PSW store, and the
DOUBLE AND SWAP, STORE CLOCK,
interruption-code store is unpredictable.
SUPERVISOR CALL, and TEST AND SET.
Store accesses for interruption codes are not nec- LOAD PSW, LOAD PSW EXTENDED, and
essarily single-access stores. The store accesses SET STORAGE KEY EXTENDED.
for the external and supervisor-call-interruption
All I/O instructions.
codes appear to occur between the conceptually
previous and conceptually subsequent operations. COMPARE AND SWAP AND PURGE,
The store accesses for the program-interruption PURGE ALB, PURGE TLB, and SET PREFIX.
codes may precede the storage-operand refer- COMPARE AND SWAP AND PURGE may
ences associated with the instruction which results also cause the ART-lookaside buffer (ALB)
in the program interruption. and translation-lookaside buffer (TLB) to be
cleared of all entries. PURGE ALB and SET
PREFIX also cause the ALB to be cleared of
all entries. PURGE TLB and SET PREFIX
also cause the TLB to be cleared of all
entries.

Chapter 5. Program Execution 5-89


SIGNAL PROCESSOR. The set-architecture tion. In the case of an interruption, the old
SIGNAL PROCESSOR order causes serializa- PSW, the interruption code, and other infor-
tion on all CPUs in the configuration. mation, if any, are stored, and the new PSW
is fetched, but not necessarily in that
INVALIDATE PAGE TABLE ENTRY.
sequence.
TEST BLOCK.
3. Finally, instruction fetch and operand
MOVE TO PRIMARY, MOVE TO SEC- accesses for conceptually subsequent oper-
ONDARY, PROGRAM CALL, PROGRAM ations may begin.
CALL FAST, PROGRAM TRANSFER, SET
A serializing function affects the sequence of
ADDRESS SPACE CONTROL, and SET
storage accesses that are under the control of the
SECONDARY ASN.
CPU in which the serializing function takes place.
PROGRAM RETURN when the state entry to It does not affect the sequence of storage
be unstacked is a program-call state entry. accesses under the control of other CPUs and of
PERFORM LOCKED OPERATION. Serializa- channel programs.
tion is performed immediately after the lock is
Programming Notes:
obtained and again immediately before it is
released. However, values fetched from the 1. The following are some effects of a serializing
parameter list before the lock is obtained are operation:
not necessarily refetched.
a. When the execution of an instruction
The four trace functionsbranch tracing, ASN changes the contents of a storage location
tracing, mode tracing, and explicit that is used as a source of a following
tracingcause serialization to be performed instruction and when different addresses
before the trace action and after completion of are used to designate the same absolute
the trace action. location for storing the result and fetching
the instruction, a serializing operation fol-
PAGE IN and PAGE OUT.
lowing the change ensures that the modi-
COMPARE AND SWAP AND PURGE, which fied instruction is executed.
can also cause the ALB and the TLB to be
b. When a serializing operation takes place,
cleared of all entries on all CPUs
other CPUs and channel programs
The sequence of events associated with a serial- observe instruction and operand fetching
izing operation is as follows: and result storing to take place in the
1. All conceptually previous storage accesses by sequence established by the serializing
the CPU are completed as observed by other operation.
CPUs and by channel programs. This 2. Storing into a location from which a serializing
includes all conceptually previous stores and instruction is fetched does not necessarily
changes to the storage keys. affect the execution of the serializing instruc-
2. The normal function associated with the serial- tion unless a serializing function has been per-
izing operation is performed. In the case of formed after the storing and before the
instruction execution, operands are fetched, execution of the serializing instruction.
and the storing of results is completed. The 3. Following is an example showing the effects
exceptions are LOAD PSW, LOAD PSW of serialization. Location A initially contains
EXTENDED, and SET PREFIX, in which the X'FF'.
operand may be fetched before previous
stores have been completed, and inter- CPU 1 CPU 2
ruptions, in which the interruption code and
MVI A,X'' G CLI A,X''
associated fields may be stored prior to the BCR 15, BNE G
serialization. The fetching of the serializing
instruction occurs before the execution of the
instruction and may precede the execution of The BCR 15,0 instruction executed by CPU
previous instructions, but may not precede the 1 is a serializing instruction that ensures that
completion of any previous serializing opera- the store by CPU 1 at location A is completed.

5-90 z/Architecture Principles of Operation


However, CPU 2 may loop indefinitely, or until 2. All storage accesses and storage-key
the next I/O or external interruption on CPU 2, accesses by the channel program are com-
because CPU 2 may already have fetched pleted, as observed by CPUs and by other
from location A for every execution of the CLI channel programs, before the subchannel
instruction. A serializing instruction must be in status indicating status-pending with primary
the CPU-2 loop to ensure that CPU 2 will status is made available to any CPU.
again fetch from location A.
3. If a CCW contains a PCI flag or a suspend
flag which is one, all storage accesses and
Channel-Program Serialization storage-key accesses due to CCWs preceding
it in the CCW chain are completed, as
Serialization of a channel program occurs as observed by CPUs and by other channel pro-
follows: grams, before the subchannel status indicating
1. All storage accesses and storage-key status-pending with intermediate status (PCI
accesses by the channel program follow initi- or suspended) is made available to any CPU.
ation of the execution of START SUB- The serialization of a channel program does not
CHANNEL, or, if suspended, RESUME affect the sequence of storage accesses or
SUBCHANNEL, as observed by CPUs and by storage-key accesses caused by other channel
other channel programs. This includes all programs or by another CPU program.
accesses for the CCWs, IDAWs, and data.

Chapter 5. Program Execution 5-91


5-92 z/Architecture Principles of Operation
Chapter 6. Interruptions
Interruption Action . . . . . . . . . . . . . . . . 6-2 Fixed-Point-Divide Exception . . . . . . 6-23
Interruption Code . . . . . . . . . . . . . . . 6-5 Fixed-Point-Overflow Exception . . . . . 6-23
Enabling and Disabling . . . . . . . . . . . 6-6 HFP-Divide Exception . . . . . . . . . . 6-23
Handling of Floating Interruption Conditions 6-7 HFP-Exponent-Overflow Exception . . . 6-23
Instruction-Length Code . . . . . . . . . . . 6-7 HFP-Exponent-Underflow Exception . . 6-23
Zero ILC . . . . . . . . . . . . . . . . . . 6-7 HFP-Significance Exception . . . . . . . 6-24
ILC on Instruction-Fetching Exceptions . 6-8 HFP-Square-Root Exception . . . . . . 6-24
Exceptions Associated with the PSW . . . 6-9 LX-Translation Exception . . . . . . . . 6-24
Early Exception Recognition . . . . . . . 6-9 Monitor Event . . . . . . . . . . . . . . . 6-24
Late Exception Recognition . . . . . . . 6-10 Operand Exception . . . . . . . . . . . . 6-25
External Interruption . . . . . . . . . . . . . . . 6-10 Operation Exception . . . . . . . . . . . 6-25
Clock Comparator . . . . . . . . . . . . . . 6-11 Page-Translation Exception . . . . . . . 6-26
CPU Timer . . . . . . . . . . . . . . . . . . 6-11 PC-Translation-Specification Exception 6-26
Emergency Signal . . . . . . . . . . . . . . 6-11 PER Event . . . . . . . . . . . . . . . . . 6-26
ETR . . . . . . . . . . . . . . . . . . . . . . 6-12 Primary-Authority Exception . . . . . . . 6-26
External Call . . . . . . . . . . . . . . . . . 6-12 Privileged-Operation Exception . . . . . 6-27
Interrupt Key . . . . . . . . . . . . . . . . . 6-12 Protection Exception . . . . . . . . . . . 6-27
Malfunction Alert . . . . . . . . . . . . . . . 6-12 Region-First-Translation Exception . . . 6-28
Service Signal . . . . . . . . . . . . . . . . 6-13 Region-Second-Translation Exception . 6-29
I/O Interruption . . . . . . . . . . . . . . . . . . 6-13 Region-Third-Translation Exception . . 6-29
Machine-Check Interruption . . . . . . . . . . 6-13 Secondary-Authority Exception . . . . . 6-29
Program Interruption . . . . . . . . . . . . . . 6-14 Segment-Translation Exception . . . . . 6-30
Data-Exception Code (DXC) . . . . . . . . 6-14 Space-Switch Event . . . . . . . . . . . 6-30
Priority of Program Interruptions for Special-Operation Exception . . . . . . 6-31
Data Exceptions . . . . . . . . . . . 6-16 Specification Exception . . . . . . . . . . 6-32
Program-Interruption Conditions . . . . . . 6-16 Stack-Empty Exception . . . . . . . . . . 6-33
Addressing Exception . . . . . . . . . . 6-16 Stack-Full Exception . . . . . . . . . . . 6-34
AFX-Translation Exception . . . . . . . . 6-19 Stack-Operation Exception . . . . . . . . 6-34
ALEN-Translation Exception . . . . . . . 6-19 Stack-Specification Exception . . . . . . 6-34
ALE-Sequence Exception . . . . . . . . 6-19 Stack-Type Exception . . . . . . . . . . 6-34
ALET-Specification Exception . . . . . . 6-19 Trace-Table Exception . . . . . . . . . . 6-34
ASCE-Type Exception . . . . . . . . . . 6-19 Translation-Specification Exception . . . 6-35
ASTE-Sequence Exception . . . . . . . 6-20 Collective Program-Interruption Names . . 6-35
ASTE-Validity Exception . . . . . . . . . 6-20 Recognition of Access Exceptions . . . . . 6-35
ASX-Translation Exception . . . . . . . 6-21 Multiple Program-Interruption Conditions . 6-39
Crypto-Operation Exception . . . . . . . 6-21 Access Exceptions . . . . . . . . . . . . 6-42
Data Exception . . . . . . . . . . . . . . 6-21 ASN-Translation Exceptions . . . . . . . 6-45
Decimal-Divide Exception . . . . . . . . 6-22 Subspace-Replacement Exceptions . . 6-46
Decimal-Overflow Exception . . . . . . . 6-22 Trace Exceptions . . . . . . . . . . . . . 6-46
Execute Exception . . . . . . . . . . . . 6-22 Restart Interruption . . . . . . . . . . . . . . . 6-46
EX-Translation Exception . . . . . . . . 6-22 Supervisor-Call Interruption . . . . . . . . . . 6-47
Extended-Authority Exception . . . . . . 6-22 Priority of Interruptions . . . . . . . . . . . . . 6-47

The interruption mechanism permits the CPU to tion of the type of condition, interruption conditions
change its state as a result of conditions external are grouped into six classes: external,
to the configuration, within the configuration, or input/output, machine check, program, restart, and
within the CPU itself. To permit fast response to supervisor call.
conditions of high priority and immediate recogni-

Copyright IBM Corp. 1990, 2000 6-1


executed instruction, thus permitting the program
Interruption Action to respond to the cause of the interruption. In the
An interruption consists in storing the current PSW case of some program conditions for which the
as an old PSW, storing information identifying the normal response is reexecution of the instruction
cause of the interruption, and fetching a new causing the interruption, the instruction address
PSW. Processing resumes as specified by the directly identifies the instruction last executed.
new PSW.
Except for restart, an interruption can occur only
The old PSW stored on an interruption normally when the CPU is in the operating state. The
contains the address of the instruction that would restart interruption can occur with the CPU in
have been executed next had the interruption not either the stopped or operating state.
occurred, thus permitting resumption of the inter-
rupted program. For program and supervisor-call The details of source identification, location deter-
interruptions, the information stored also contains mination, and instruction execution are explained
a code that identifies the length of the last- in later sections and are summarized in
Figure 6-1 on page 6-3.

6-2 z/Architecture Principles of Operation



Mask Bits
in Ctrl Execution of
PSW- Registers Instruction
Source Interruption Mask ILC Identified
Identification Code Bits Reg, Bit Set by Old PSW

MACHINE CHECK Locations 232-239


(old PSW 352,
new PSW 48)

Exigent condition 13 u terminated or
nullified
Repressible cond 13 14, 35-39 u unaffected

SUPERVISOR CALL Locations 138-139


(old PSW 32,
new PSW 448)

Instruction bits ssssssss 1,2 completed

PROGRAM Locations 142-143


(old PSW 336,
new PSW 464) Binary Hex

Operation p1 1 1,2,3suppressed
Privileged oper p1 2 2,3suppressed
Execute p11 3 2 suppressed
Protection p1 4 1,2,3suppressed or
terminated
Addressing p11 5 1,2,3suppressed or
terminated
Specification p11 6 ,1,2,3suppressed or
completed
Data p111 7 1,2,3suppressed,
terminated,
or
completed
Fixed-pt overflow p1 8 2 1,2,3completed
Fixed-point divide p11 9 1,2,3suppressed or
completed
Decimal overflow p11 A 21 2,3completed
Decimal divide p111 B 2,3suppressed
HFP exp. overflow p11 C 1,2,3completed
HFP exp. underflow p111 D 22 1,2,3completed
HFP significance p111 E 23 1,2 completed
HFP divide p1111 F 1,2 suppressed
Segment translation p1 1 1,2,3nullified
Page translation p11 11 1,2,3nullified
Translation spec p11 12 1,2,3suppressed
Special operation p111 13 , 33 1,2,3suppressed
Operand p111 15 2 suppressed
Trace table p111 16 1,2 nullified
Space-switch event p111 1C 1, 57 ,1,2 completed
Square root p1111 1D 2 suppressed
PC-transl spec p11111 1F 2 suppressed

Figure 6-1 (Part 1 of 4). Interruption Action

Chapter 6. Interruptions 6-3



Mask Bits
in Ctrl Execution of
PSW- Registers Instruction
Source Interruption Mask ILC Identified
Identification Code Bits Reg, Bit Set by Old PSW

AFX translation p1 2 1,2 nullified


ASX translation p11 21 1,2 nullified
LX translation p11 22 2 nullified
EX translation p111 23 2 nullified
Primary authority p11 24 2 nullified
Secondary auth p111 25 1,2 nullified
ALET specification p11 28 1,2,3suppressed
ALEN translation p111 29 1,2,3nullified
ALE sequence p111 2A 1,2,3nullified
ASTE validity p1111 2B 1,2,3nullified
ASTE sequence p111 2C 1,2,3nullified
Extended authority p1111 2D 1,2,3nullified
Stack full p11 3 2 nullified
Stack empty p111 31 1,2 nullified
Stack specification p111 32 1,2 nullified
Stack type p1111 33 1,2 nullified
Stack operation p111 34 1,2 nullified
ASCE type p111 38 1,2,3nullified
Region first trans p1111 39 1,2,3nullified
Region second trans p1111 3A 1,2,3nullified
Region third trans p11111 3B 1,2,3nullified
Monitor event p1 4 8, 32-47 2 completed
PER event 1nnnnnnn8 1 9, 32-36,1,2,3completed
Crypto operation 1 p111 119 2 nullified

EXTERNAL Locations 134-135


(old PSW 34,
new PSW 432) Binary Hex

Interrupt key 1 4 7 , 57 u unaffected
Clock comparator 1 1 14 7 , 52 u unaffected
CPU timer 1 11 15 7 , 53 u unaffected
Malfunction alert 11 12 7 , 48 u unaffected
Emergency signal 11 1 121 7 , 49 u unaffected
External call 11 1 122 7 , 5 u unaffected
ETR 11 11 146 7 , 59 u unaffected
Service signal 11 1 241 7 , 54 u unaffected

Figure 6-1 (Part 2 of 4). Interruption Action

6-4 z/Architecture Principles of Operation



Mask Bits
in Ctrl Execution of
PSW- Registers Instruction
Source Interruption Mask ILC Identified
Identification Code Bits Reg, Bit Set by Old PSW

INPUT/OUTPUT Locations 184-191


(old PSW 368,
new PSW 496)

I/O-interruption 6 6, 32-39 u unaffected
subclass

RESTART None
(old PSW 288,
new PSW 416)

Restart key u unaffected

Explanation:

Locations for the old PSWs, new PSWs, and interruption codes are real locations.
A model-independent machine-check interruption code of 64 bits is stored at
real locations 232-239.
The effect of the machine-check condition is indicated by bits in the machine-
check-interruption code. The setting of these bits indicates the extent of
the damage and whether the unit of operation is nullified, terminated, or
unaffected.
The interruption code in the column labeled "Hex" is the hex code for the
basic interruption; this code does not show the effects of concurrent inter-
[BEGIN NO RPQ ONLY]
ruption conditions represented by n or p in the column labeled "Binary."
[END NO RPQ ONLY]
Bits 32-39 of control register 6 provide detailed masking of I/O-interruption
subclasses -7 respectively.
When the interruption code indicates a PER event, an ILC of may be stored
only when bits 8-15 of the interruption code are 111 (PER, specifi-
cation).
The unit of operation is completed, unless a program exception concurrently
indicated causes the unit of operation to be nullified, suppressed, or
terminated.

Figure 6-1 (Part 3 of 4). Interruption Action

Explanation (Continued):

n A possible nonzero code indicating another concurrent program-interruption
condition
p If one, the bit indicates a concurrent PER-event interruption condition.
s Bits of the I field of SUPERVISOR CALL.
u Not stored.

Figure 6-1 (Part 4 of 4). Interruption Action

Interruption Code tion placed in permanently assigned real storage


locations during the interruption. (See also
The six classes of interruptions (external, I/O, Assigned Storage Locations on page 3-51.) For
machine check, program, restart, and supervisor external, program, and supervisor-call inter-
call) are distinguished by the storage locations at ruptions, the interruption code consists of 16 bits.
which the old PSW is stored and from which the
new PSW is fetched. For most classes, the For external interruptions, the interruption code is
causes are further identified by an interruption stored at real locations 134-135. A parameter
code and, for some classes, by additional informa- may be stored at real locations 128-131, or a CPU
address may be stored at real locations 132-133.

Chapter 6. Interruptions 6-5


For I/O interruptions, the I/O-interruption code is HFP-exponent-underflow program-mask bits
stored at real locations 184-191. The affects the manner in which HFP operations are
I/O-interruption code consists of a 32-bit completed when the corresponding condition
subsystem-identification word and a 32-bit inter- occurs. Similarly, the setting of the IEEE mask
ruption parameter. bits in the FPC register affects the manner in
which BFP operations are completed when the
For machine-check interruptions, the interruption corresponding condition occurs.
code consists of 64 bits and is stored at real
locations 232-239. Additional information for iden- Programming Notes:
tifying the cause of the interruption and for recov-
1. Mask bits in the PSW provide a means of dis-
ering the state of the machine may be provided by
allowing most maskable interruptions; thus,
the contents of the machine-check failing-storage
subsequent interruptions can be disallowed by
address and the contents of the fixed-logout and
the new PSW introduced by an interruption.
machine-check-save areas. (See Chapter 11,
Furthermore, the mask bits can be used to
Machine-Check Handling.)
establish a hierarchy of interruption priorities,
where a condition in one class can interrupt
For program interruptions, the interruption code is
the program handling a condition in another
stored at real locations 142-143, and the
class but not vice versa. To prevent an
instruction-length code is stored in bit positions 5
interruption-handling routine from being inter-
and 6 of real location 141. Further information
rupted before the necessary housekeeping
may be provided in the form of the data-exception
steps are performed, the new PSW must
code (DXC), monitor-class number, PER code,
disable the CPU for further interruptions within
addressing-and-translation-mode identification,
the same class or within a class of lower pri-
PER address, exception access identification,
ority.
PER access identification, operand-access identifi-
cation, translation-exception identification, and 2. Because the mask bits in control registers are
monitor code, which are stored at real locations not changed as part of the interruption proce-
144-162 and 168-183. dure, these masks cannot be used to prevent
an interruption immediately after a previous
Enabling and Disabling interruption in the same class. The mask bits
in control registers provide a means for selec-
By means of mask bits in the current PSW, tively enabling the CPU for some sources and
floating-point-control (FPC) register, and control disabling it for others within the same class.
registers, the CPU may be enabled or disabled for 3. Controlling bits exist for several program inter-
all external, I/O, and machine-check interruptions ruptions, but with no mask bit in the PSW.
and for some program interruptions. When a Such bits include the IEEE mask bits in the
mask bit is one, the CPU is enabled for the corre- FPC register, the monitor masks in bit posi-
sponding class of interruptions, and those inter- tions 48-63 of control register 8, and the
ruptions can occur. primary space-switch-event-control bit, bit 57
of control register 1. A bit of this nature is
When a mask bit is zero, the CPU is disabled for somewhat arbitrarily considered to be a
the corresponding interruptions. The conditions mask bit only if the polarity is such that inter-
that cause I/O interruptions remain pending. ruption is enabled when the bit is one. Thus,
External-interruption conditions either remain for example, the SSM-suppression-control bit,
pending or persist until the cause is removed. bit 33 of control register 0, is considered to be
Machine-check-interruption conditions, depending a mask bit, while the AFP-register-control bit,
on the type, are ignored, remain pending, or bit 45 of control register 0, is not. Regardless
cause the CPU to enter the check-stop state. The of the polarity of such control bits, to avoid
disallowed program-interruption conditions are another program interruption, an interruption-
ignored, except that some causes are indicated handling routine must avoid issuing
also by the setting of the condition code, and instructions subject to these bits until they
IEEE exceptions set flags in the FPC register. have been set appropriately.
The setting of the HFP-significance and

6-6 z/Architecture Principles of Operation


Handling of Floating Interruption instruction-length code 2 is set to indicate the
length of EXECUTE and not that of the target
Conditions instruction.
An interruption condition which can be presented The value of a nonzero instruction-length code is
to any CPU in the configuration is called a floating related to the leftmost two bits of the instruction.
interruption condition. The condition is presented The value does not depend on whether the opera-
to the first CPU in the configuration which is tion code is assigned or on whether the instruction
enabled for the corresponding interruption and is installed. The following table summarizes the
which can perform the interruption, and then the meaning of the instruction-length code:
condition is cleared and not presented to any
other CPU in the configuration. A CPU cannot
ILC Instr
perform the interruption when it is in the check- Bits Instruction
stop state, has an invalid prefix, is in a string of DecimalBinary -1 Length
program interruptions due to a specification excep-
tion of the type which is recognized early or is in Not available
the stopped state. However, a CPU with the rate 1 1 One halfword
2 1 1 Two halfwords
control set to instruction step can perform the
2 1 1 Two halfwords
interruption when the start key is activated. 3 11 11 Three halfwords

Service signal, I/O, and certain machine-check
conditions are floating interruption conditions. Zero ILC
Instruction-length code 0, after a program inter-
Instruction-Length Code ruption, indicates that the instruction address
stored in the old PSW does not identify the
The instruction-length code (ILC) occupies two bit instruction causing the interruption.
positions and provides the length of the last
instruction executed. It permits identifying the An ILC of 0 occurs when a specification exception
instruction causing the interruption when the due to a PSW-format error is recognized as part
instruction address in the old PSW designates the of early exception recognition and the PSW has
next sequential instruction. The ILC is provided been introduced by LOAD PSW, LOAD PSW
also by the BRANCH AND LINK instructions in the EXTENDED, PROGRAM RETURN, or an inter-
24-bit addressing mode. ruption. (See Exceptions Associated with the
PSW on page 6-9.) In the case of LOAD PSW,
The ILC for program and supervisor-call inter- LOAD PSW EXTENDED, or PROGRAM
ruptions is stored in bit positions 5 and 6 of the RETURN, the instruction address of the instruction
bytes at real locations 141 and 137, respectively. or of EXECUTE has been replaced by the instruc-
For external, I/O, machine-check, and restart inter- tion address in the new PSW. When the invalid
ruptions, the ILC is not stored since it cannot be PSW is introduced by an interruption, the
related to the length of the last-executed instruc- PSW-format error cannot be attributed to an
tion. instruction.

For supervisor-call and program interruptions, a In the case of LOAD PSW, LOAD PSW
nonzero ILC identifies in halfwords the length of EXTENDED, PROGRAM RETURN, and the
the instruction that was last executed. That supervisor-call interruption, a PER event may be
instruction may be one for which a specification indicated concurrently with a specification excep-
exception was recognized due to an odd instruc- tion having an ILC of 0.
tion address or for which an access exception
(addressing, ASCE-type, page-translation, pro- In the case of a PROGRAM RETURN instruction
tection, region-translation, segment-translation, or that causes both a space-switch event and a
translation-specification) was recognized during PSW-format error, the space-switch event is
the fetching of the instruction. Whenever an recognized, but it is unpredictable whether the ILC
instruction is executed by means of EXECUTE, is 0 or 1, or 0 or 2 if EXECUTE was used.

Chapter 6. Interruptions 6-7


ILC on Instruction-Fetching Exceptions b. An interruption for a PER event occurs
When a program interruption occurs because of before the execution of an interruptible
an exception that prohibits access to the instruc- instruction is completed, and no other
tion, the instruction is considered to have been program-interruption condition is indicated
executed, but the instruction-length code cannot concurrently.
be set on the basis of the first two bits of the c. The interruption is caused by a PER event
instruction. As far as the significance of the ILC or space-switch event due to LOAD PSW,
for this case is concerned, the following two situ- LOAD PSW EXTENDED, or a branch or
ations are distinguished: linkage instruction, including SUPER-
1. When an odd instruction address causes a VISOR CALL (but not including MONITOR
specification exception to be recognized or CALL).
when an addressing, protection, or translation- d. The interruption is caused by an
specification exception is encountered on addressing exception or protection excep-
fetching an instruction, the ILC is set to 1, 2, tion for the storage operand of a LOAD
or 3, indicating the multiple of 2 by which the CONTROL instruction that loads the
instruction address has been incremented. It control register (1 or 13) containing the
is unpredictable whether the instruction address-space-control element that speci-
address is incremented by 2, 4, or 6. By fies the address space from which
reducing the instruction address in the old instructions are fetched.
PSW by the number of halfword locations indi-
cated in the ILC, the instruction address ori- For situations a and b above, the instruction
ginally appearing in the PSW may be address in the PSW is not incremented, and
obtained. the instruction designated by the instruction
address is the same as the last one executed.
2. When an ASCE-type, region-translation, These situations are the only ones in which
segment-translation, or page-translation the instruction address in the old PSW identi-
exception is recognized while fetching an fies the instruction causing the exception. Sit-
instruction, the ILC is arbitrarily set to 1, 2, or uation b can be distinguished from a PER
3. In this case, the operation is nullified, and event indicated after completion of an interrup-
the instruction address is not incremented. tible or noninterruptible instruction in that, for
The ILC is not necessarily related to the first two situation b, the instruction address in the PSW
bits of the instruction when the first halfword of an is the same as the PER address in the
instruction can be fetched but an access exception doubleword at real location 152.
is recognized on fetching the second or third For situation c, the instruction address has
halfword. The ILC may be arbitrarily set to 1, 2, been replaced as part of the operation, and
or 3 in these cases. The instruction address is or the address of the last instruction executed
is not updated, as described in situations 1 and 2 cannot be calculated using the one appearing
above. in the program old PSW.

When any exceptions are encountered on fetching For situation d, the effective address of the
the target instruction of EXECUTE, the ILC is 2. last instruction executed can be calculated,
but, since the address-space-control element
Programming Notes: for the instruction address space is unpredict-
able, the corresponding real address is
1. A nonzero instruction-length code for a
unknown.
program interruption indicates the number of
halfword locations by which the instruction 2. The instruction-length code (ILC) is redundant
address in the program old PSW must be when a PER event is indicated since the PER
reduced to obtain the instruction address of address in the doubleword at real location 152
the last instruction executed, unless one of the identifies the instruction causing the inter-
following situations exists: ruption (or the EXECUTE instruction, as
appropriate). Similarly, the ILC is redundant
a. The interruption is caused by an exception
when the operation is nullified, since in this
resulting in nullification.
case the instruction address in the PSW is not

6-8 z/Architecture Principles of Operation


incremented. If the ILC value is required in Exceptions Associated with the
this case, it can be derived from the operation
code of the instruction identified by the old
PSW
PSW.
Exceptions associated with erroneous information
3. The address of the last instruction executed in the current PSW may be recognized when the
before a program interruption is insufficient to information is introduced into the PSW or may be
locate the program problem if one of the fol- recognized as part of the execution of the next
lowing situations exists: instruction. Errors in the PSW which are
a. The interruption is caused by an access specification-exception conditions are called
exception encountered in fetching an PSW-format errors.
instruction, and the instruction address
was introduced into the PSW by a means Early Exception Recognition
other than sequential operation (by a For the following error conditions, a program inter-
branch or linkage instruction, LOAD PSW, ruption for a specification exception occurs imme-
LOAD PSW EXTENDED, an interruption, diately after the PSW becomes active:
or conclusion of an IPL sequence).
Any of the unassigned bits (0, 2-4, 24-30, or
b. The interruption is caused by a specifica- 33-63) is a one.
tion exception due to an odd instruction
address, which necessarily also results Bit 12 is a one.
from introduction of an instruction address Bits 31 and 32 are zero and one, respectively,
into the PSW. and bits 64-96 are not all zeros.
c. The interruption is caused by an early Bits 31 and 32 are both zero, and bits 64-103
specification exception due to a STORE are not all zeros.
THEN OR SYSTEM MASK or SET
Bits 31 and 32 are one and zero, respectively.
SYSTEM MASK instruction that switches
to or from the real mode while introducing
The interruption occurs regardless of whether the
invalid values in bit positions 0-7 of the
wait state is specified. If the invalid PSW causes
PSW.
the CPU to become enabled for a pending I/O,
For situations a and b, the instruction address external, or machine-check interruption, the
was replaced by the operation preceding the program interruption occurs instead, and the
last instruction execution, and the address of pending interruption is subject to the mask bits of
the program location related to that preceding the new PSW introduced by the program inter-
operation is unavailable. ruption.
For situation c, the address of the last instruc-
When an interruption or the execution of LOAD
tion executed is available, but the corre-
PSW, LOAD PSW EXTENDED, or PROGRAM
sponding real address is unknown.
RETURN introduces a PSW with one of the above
4. The address of the last instruction executed is error conditions, the instruction-length code is set
not available when an interruption is caused to 0, and the newly introduced PSW is stored
by an early specification exception due to a unmodified as the old PSW. When one of the
LOAD PSW, LOAD PSW EXTENDED, or above error conditions is introduced by execution
PROGRAM RETURN instruction or an inter- of SET SYSTEM MASK or STORE THEN OR
ruption. SYSTEM MASK, the instruction-length code is set
to 2, and the instruction address is incremented by
4. The PSW containing the invalid value intro-
duced into the system-mask field is stored as the
old PSW.

Chapter 6. Interruptions 6-9


Late Exception Recognition
For the following conditions, the exception is
External Interruption
recognized as part of the execution of the next The external interruption provides a means by
instruction: which the CPU responds to various signals origi-
nating from either inside or outside the configura-
A specification exception is recognized due to
tion.
an odd instruction address in the PSW (PSW
bit 127 is one). An external interruption causes the old PSW to be
An access exception (addressing, ASCE-type, stored at real locations 304-319 and a new PSW
page-translation, protection, region-translation, to be fetched from real locations 432-447.
segment-translation, or translation-
specification) is associated with the location The source of the interruption is identified in the
designated by the instruction address or with interruption code which is stored at real locations
the location of the second or third halfword of 134-135. The instruction-length code is not
the instruction starting at the designated stored.
instruction address.
Additionally, for the malfunction-alert, emergency-
The instruction-length code and instruction signal, and external-call conditions, a 16-bit CPU
address stored in the program old PSW under address is associated with the source of the inter-
these conditions are discussed in ILC on ruption and is stored at real locations 132-133.
Instruction-Fetching Exceptions on page 6-8. When the CPU address is stored, bit 6 of the
interruption code is set to one. For all other con-
If an I/O, external, or machine-check-interruption ditions, no CPU address is stored, bit 6 of the
condition is pending and the PSW causes the interruption code is set to zero, and zeros are
CPU to be enabled for that condition, the corre- stored at real locations 132-133.
sponding interruption occurs, and the PSW is not
inspected for exceptions which are recognized For the ETR and service-signal interruptions, a
late. Similarly, a PSW specifying the wait state is 32-bit parameter is associated with the interruption
not inspected for exceptions which are recognized and is stored at real locations 128-131. Bit 5 of
late. the external-interruption code indicates that a
parameter has been stored. When bit 5 is zero,
Programming Notes: the contents of real locations 128-131 remain
1. The execution of LOAD ADDRESS SPACE unchanged.
PARAMETERS, LOAD PSW, LOAD PSW
EXTENDED, PROGRAM CALL, PROGRAM External-interruption conditions are of two types:
RETURN, PROGRAM TRANSFER, RESUME those for which an interruption-request condition is
PROGRAM, SET PREFIX, SET SECONDARY held pending, and those for which the condition
ASN, SET SYSTEM MASK, STORE THEN directly requests the interruption. Clock
AND SYSTEM MASK, and STORE THEN OR comparator and CPU timer are conditions which
SYSTEM MASK is suppressed on an directly request external interruptions. If a condi-
addressing or protection exception, and hence tion which directly requests an external inter-
the program old PSW provides information ruption is removed before the request is honored,
concerning the program causing the excep- the request does not remain pending, and no
tion. interruption occurs. Conversely, the request is not
cleared by the interruption, and, if the condition
2. When the first halfword of an instruction can persists, more than one interruption may result
be fetched but an access exception is recog- from a single occurrence of the condition.
nized on fetching the second or third halfword,
the ILC is not necessarily related to the opera- When several interruption requests for a single
tion code. source are generated before the interruption
3. If the new PSW introduced by an interruption occurs, and the interruption condition is of the type
contains a PSW-format error, a string of inter- which is held pending, only one request for that
ruptions may occur. (See Priority of source is preserved and remains pending.
Interruptions on page 6-47.)

6-10 z/Architecture Principles of Operation


An external interruption for a particular source can 2. The TOD clock is in the error or not-
occur only when the CPU is enabled for inter- operational state.
ruption by that source. The external interruption
If the condition responsible for the request is
occurs at the completion of a unit of operation.
removed before the request is honored, the
The external mask, PSW bit 7, and external
request does not remain pending, and no inter-
subclass-mask bits in control register 0 control
ruption occurs. Conversely, the request is not
whether the CPU is enabled for a particular
cleared by the interruption, and, if the condition
source. Each source for an external interruption
persists, more than one interruption may result
has a subclass-mask bit assigned to it, and the
from a single occurrence of the condition.
source can cause an interruption only when the
external-mask bit is one and the corresponding When the TOD clock is set or changes state,
subclass-mask bit is one. interruption conditions, if any, that are due to the
clock comparator may or may not be recognized
When the CPU becomes enabled for a pending
for up to 1.048576 seconds after the change.
external-interruption condition, the interruption
occurs at the completion of the instruction exe- The subclass-mask bit is in bit position 52 of
cution or interruption that causes the enabling. control register 0. This bit is initialized to zero.
More than one source may present a request for The clock-comparator condition is indicated by an
an external interruption at the same time. When external-interruption code of 1004 hex.
the CPU becomes enabled for more than one con-
currently pending request, the interruption occurs
for the pending condition or conditions having the CPU Timer
highest priority.
An interruption request for the CPU timer exists
The priorities for external-interruption requests in whenever the CPU-timer value is negative (bit 0 of
descending order are as follows: the CPU timer is one). If the value is made posi-
tive before the request is honored, the request
Interrupt key does not remain pending, and no interruption
Malfunction alert occurs. Conversely, the request is not cleared by
Emergency signal the interruption, and, if the condition persists,
External call more than one interruption may occur from a
Clock comparator single occurrence of the condition.
CPU timer
ETR When the TOD clock is set or changes state,
Service signal interruption conditions, if any, that are due to the
CPU timer may or may not be recognized for up
All requests are honored one at a time. When to 1.048576 seconds after the change.
more than one emergency-signal request exists at
a time or when more than one malfunction-alert The subclass-mask bit is in bit position 53 of
request exists at a time, the request associated control register 0. This bit is initialized to zero.
with the smallest CPU address is honored first.
The CPU-timer condition is indicated by an
Clock Comparator external-interruption code of 1005 hex.

An interruption request for the clock comparator Emergency Signal


exists whenever either of the following conditions
is met: An interruption request for an emergency signal is
1. The TOD clock is in the set or not-set state, generated when the CPU accepts the emergency-
and the value of the clock comparator is less signal order specified by a SIGNAL PROCESSOR
than the value in the compared portion of the instruction addressing this CPU. The instruction
TOD clock, both compare values being con- may have been executed by this CPU or by
sidered unsigned binary integers. another CPU in the configuration. The request is
preserved and remains pending in the receiving

Chapter 6. Interruptions 6-11


CPU until it is cleared. The pending request is The subclass-mask bit is in bit position 50 of
cleared when it causes an interruption and by control register 0. This bit is initialized to zero.
CPU reset.
The external-call condition is indicated by an
Facilities are provided for holding a separate external-interruption code of 1202 hex. The
emergency-signal request pending in the receiving address of the CPU that executed the SIGNAL
CPU for each CPU in the configuration, including PROCESSOR instruction is stored at real
the receiving CPU itself. locations 132-133.

The subclass-mask bit is in bit position 49 of


control register 0. This bit is initialized to zero.
Interrupt Key
An interruption request for the interrupt key is gen-
The emergency-signal condition is indicated by an
erated when the operator activates that key. The
external-interruption code of 1201 hex. The
request is preserved and remains pending in the
address of the CPU that executed the SIGNAL
CPU until it is cleared. The pending request is
PROCESSOR instruction is stored at real
cleared when it causes an interruption and by
locations 132-133.
CPU reset.

ETR When the interrupt key is activated while the CPU


is in the load state, it depends on the model
An interruption request for the ETR is generated whether an interruption request is generated or
when a port-availability change occurs at any port the condition is lost.
in the current CPC-port group or when an ETR
alert occurs. The terms specific to the ETR are The subclass-mask bit is in bit position 57 of
not defined in this publication. control register 0. This bit is initialized to one.

If the same ETR condition occurs more than once The interrupt-key condition is indicated by an
before the interruption occurs, the request is gen- external-interruption code of 0040 hex.
erated only once. The request is generated for all
CPUs in the configuration. Malfunction Alert
The subclass-mask bit is in bit position 59 of
An interruption request for a malfunction alert is
control register 0. This bit is initialized to zero.
generated when another CPU in the configuration
enters the check-stop state or loses power. The
The ETR condition is indicated by an external-
request is preserved and remains pending in the
interruption code of 1406 hex.
receiving CPU until it is cleared. The pending
request is cleared when it causes an interruption
External Call and by CPU reset.

An interruption request for an external call is gen- Facilities are provided for holding a separate
erated when the CPU accepts the external-call malfunction-alert request pending in the receiving
order specified by a SIGNAL PROCESSOR CPU for each of the other CPUs in the configura-
instruction addressing this CPU. The instruction tion. Removal of a CPU from the configuration
may have been executed by this CPU or by does not generate a malfunction-alert condition.
another CPU in the configuration. The request is
preserved and remains pending in the receiving The subclass-mask bit is in bit position 48 of
CPU until it is cleared. The pending request is control register 0. This bit is initialized to zero.
cleared when it causes an interruption and by
CPU reset. The malfunction-alert condition is indicated by an
external-interruption code of 1200 hex. The
Only one external-call request, along with the address of the CPU that generated the condition
processor address, may be held pending in a CPU is stored at real locations 132-133.
at a time.

6-12 z/Architecture Principles of Operation


Service Signal lished priority for a pending I/O-interruption
condition, the interruption occurs at the completion
An interruption request for a service signal is gen- of the instruction execution or interruption that
erated upon the completion of certain causes the enabling.
configuration-control and maintenance functions,
An I/O interruption causes the old PSW to be
such as those initiated by means of the model-
stored at real locations 368-383 and a new PSW
dependent DIAGNOSE instruction. A 32-bit
to be fetched from real locations 496-511. Addi-
parameter is provided with the interruption to
tional information, in the form of an eight-byte
assist the program in determining the operation for
I/O-interruption code, is stored at real locations
which the interruption is reported.
184-191. The I/O-interruption code consists of a
Service signal is a floating interruption condition 32-bit subsystem-identification word and a 32-bit
and is presented to the first CPU in the configura- interruption parameter.
tion which can perform the interruption. The inter-
An I/O interruption can occur only while a CPU is
ruption condition is cleared when it causes an
enabled for the interruption subclass presenting
interruption in any one of the CPUs and also by
the request. The I/O-mask bit, bit 6 of the PSW,
subsystem reset.
and the I/O-interruption subclass mask in control
The subclass-mask bit is in bit position 54 of register 6 determine whether the CPU is enabled
control register 0. This bit is initialized to zero. for a particular I/O interruption.

The service-signal condition is indicated by an I/O interruptions are grouped into eight
external-interruption code of 2401 hex. A 32-bit I/O-interruption subclasses, numbered from 0-7.
parameter is stored at real locations 128-131. *** Each I/O-interruption subclass has an associated
I/O-interruption subclass-mask bit in bit positions
32-39 of control register 6. Each subchannel has
I/O Interruption an I/O-interruption subclass value associated with
it. The CPU is enabled for I/O interruptions of a
The input/output (I/O) interruption provides a particular I/O-interruption subclass only when
means by which the CPU responds to conditions PSW bit 6 is one and the associated
originating in I/O devices and the channel sub- I/O-interruption subclass-mask bit in control reg-
system. ister 6 is also one. If the corresponding
I/O-interruption subclass-mask bit is zero, then the
A request for an I/O interruption may occur at any CPU is disabled for I/O interruptions with that sub-
time, and more than one request may occur at the class value. I/O interruptions for all subclasses
same time. The requests are preserved and are disallowed when PSW bit 6 is zero.
remain pending until accepted by a CPU, or until
cleared by some other means, such as subsystem
reset. Machine-Check Interruption
The I/O interruption occurs at the completion of a The machine-check interruption is a means for
unit of operation. Priority is established among reporting to the program the occurrence of equip-
requests so that in each CPU only one interruption ment malfunctions. Information is provided to
request is processed at a time. Priority among assist the program in determining the source of
requests for interruptions of differing the fault and extent of the damage.
I/O-interruption subclasses is according to the
numerical value of the I/O-interruption subclass A machine-check interruption causes the old PSW
(with zero having the highest priority), in conjunc- to be stored at real locations 352-367 and a new
tion with the I/O-interruption subclass-mask set- PSW to be fetched from real locations 480-495.
tings in control register 6. For more details, see
Chapter 16, I/O Interruptions. The cause and severity of the malfunction are
identified by a 64-bit machine-check-interruption
When a CPU becomes enabled for I/O inter- code stored at real locations 232-239. Further
ruptions and the channel subsystem has estab- information identifying the cause of the interruption

Chapter 6. Interruptions 6-13


and the location of the fault may be stored at real When there is a corresponding mask bit, a
locations 244-255 and 4608-5119. program interruption can occur only when that
mask bit is one. The program mask in the PSW
The interruption action and the storing of the asso- controls four of the exceptions, the IEEE masks in
ciated information are under the control of PSW the FPC register control the IEEE exceptions, bit
bit 13 and bits in control register 14. See 33 in control register 0 controls whether SET
Chapter 11, Machine-Check Handling for more SYSTEM MASK causes a special-operation
detailed information. exception, bits 48-63 in control register 8 control
interruptions due to monitor events, and a hier-
archy of masks control interruptions due to PER
Program Interruption events. When any controlling mask bit is zero, the
Program interruptions are used to report condition is ignored; the condition does not remain
exceptions and events which occur during exe- pending.
cution of the program.
Programming Notes:
A program interruption causes the old PSW to be 1. When the new PSW for a program interruption
stored at real locations 336-351 and a new PSW has a PSW-format error or causes an excep-
to be fetched from real locations 464-479. tion to be recognized in the process of instruc-
tion fetching, a string of program interruptions
The cause of the interruption is identified by the may occur. See Priority of Interruptions on
interruption code. The interruption code is placed page 6-47 for a description of how such
at real locations 142-143, the instruction-length strings are terminated.
code is placed in bit positions 5 and 6 of the byte
at real location 141 with the rest of the bits set to 2. Some of the conditions indicated as program
zeros, and zeros are stored at real location 140. exceptions may be recognized also by the
For some causes, additional information identifying channel subsystem, in which case the excep-
the reason for the interruption is stored at real tion is indicated in the subchannel-status word
locations 144-183. or extended-status word.

Except for PER events and the crypto-operation Data-Exception Code (DXC)
exception, the condition causing the interruption is
indicated by a coded value placed in the rightmost When a data exception causes a program inter-
seven bit positions of the interruption code. Only ruption, a data-exception code (DXC) is stored at
one condition at a time can be indicated. Bits 0-7 location 147, and zeros are stored at locations
of the interruption code are set to zeros. 144-146. The DXC distinguishes between the
various types of data-exception conditions. When
PER events are indicated by setting bit 8 of the the AFP-register (additional floating-point register)
interruption code to one. When this is the only control bit, bit 45 of control register 0, is one, the
condition, bits 9-15 are set to zeros. When a PER DXC is also placed in the DXC field of the
event is indicated concurrently with another floating-point-control (FPC) register. The DXC
program-interruption condition, bit 8 is one, and field in the FPC register remains unchanged when
the coded value for the other condition is indicated any other program exception is reported. The
in bit positions 9-15. Bits 0-7 of the interruption DXC is an 8-bit code indicating the specific cause
code are always set to zeros. of a data exception. The data exceptions and
data-exception codes are shown in Figure 6-2 on
The crypto-operation exception is indicated by an page 6-15 and Figure 6-3 on page 6-16.
interruption code of 0119 hex, or 0199 hex if a
PER event is also indicated.

6-14 z/Architecture Principles of Operation


DXC DXC
Applicable Effect Placed Placed
Instruction of FPC FPC DXC Interruption in Real in FPC
Exception Types CR0.45 Mask Flag (Binary) Action Loc 147 Byte 2
Decimal operand Decimal 0 none none 0000 Suppress or Yes No
0000 Terminate
1 Yes Yes
AFP register FPS & 0* none none 0000 Suppress Yes No
HFP 0001
BFP instruction BFP 0* none none 0000 Suppress Yes No
0010
IEEE invalid operation BFP 1* 0.0 1.0 1000 Suppress Yes Yes
0000
IEEE division by zero BFP 1* 0.1 1.1 0100 Suppress Yes Yes
0000
IEEE overflow BFP 1* 0.2 1.2 0010 Complete Yes Yes
xy00
IEEE underflow BFP 1* 0.3 1.3 0001 Complete Yes Yes
xy00
IEEE inexact BFP 1* 0.4 1.4 0000 Complete Yes Yes
1y00
Explanation:
Decimal-operand data exception applies to the decimal instructions (Chapter 8) and the general
instruction CONVERT TO BINARY (Chapter 7).
0* This exception is recognized only when CR0.45 is zero.
1* This exception is recognized only when CR0.45 is one.
xy For IEEE overflow and IEEE underflow, bits 4 and 5 of the DXC are set to 00, 10, or 11 binary,
indicating that the result is exact, inexact and truncated, or inexact and incremented, respectively.
y For IEEE inexact, bit 5 of the DXC is set to zero or one, indicating that the result is inexact and
truncated or inexact and incremented, respectively.
BFP Binary-floating-point instructions (Chapter 19).
FPS Floating-point-support instructions (Chapter 9).
HFP Hexadecimal-floating-point instructions (Chapter 18).

Figure 6-2. Data Exceptions

Chapter 6. Interruptions 6-15


The operation is suppressed when the address of
DXC
the instruction is invalid. Similarly, the operation is
(Hex) Data Exception
suppressed when the address of the target
00 Decimal operand instruction of EXECUTE is invalid. Also, the unit
of operation is suppressed when an addressing
01 AFP register
exception is encountered in accessing a table or
02 BFP instruction table entry. The tables and table entries to which
the rule applies are the dispatchable-unit-control
08 IEEE inexact and truncated
table, the primary ASN-second-table entry, and
0C IEEE inexact and incremented entries in the access list, region first table, region
10 IEEE underflow, exact second table, region third table, segment table,
page table, linkage table, entry table, ASN first
18 IEEE underflow, inexact and truncated table, ASN second table, authority table, linkage
1C IEEE underflow, inexact and incremented stack, and trace table. Addressing exceptions
result in suppression when they are encountered
20 IEEE overflow, exact for references to the region first table, region
28 IEEE overflow, inexact and truncated second table, region third table, segment table,
and page table, in both implicit references for
2C IEEE overflow, inexact and incremented dynamic address translation and references asso-
40 IEEE division by zero ciated with the execution of LOAD REAL
ADDRESS, STORE REAL ADDRESS, and TEST
80 IEEE invalid operation
PROTECTION. Similarly, addressing exceptions
for accesses to the dispatchable-unit-control table,
Figure 6-3. Data-exception codes (DXC) primary ASN-second-table entry, access list, ASN
second table, or authority table result in sup-
Priority of Program Interruptions for pression when they are encountered in access-
Data Exceptions register translation done either implicitly or as part
of LOAD REAL ADDRESS, STORE REAL
When more than one data exception applies and ADDRESS, TEST ACCESS, or TEST PRO-
is enabled, the exception with the smallest DXC TECTION. Except for some specific instructions
value is reported. Thus, for example, DXC 2 (BFP whose execution is suppressed, the operation is
instruction) takes precedence over any IEEE terminated for an operand address that can be
exception condition. translated but designates an unavailable location.
See Figure 6-4 on page 6-18.
When both a specification exception and an
AFP-register data exception apply, it is unpredict- For termination, changes may occur only to result
able which one is reported. fields. In this context, the term result field
includes the condition code, registers, and any
Program-Interruption Conditions storage locations that are provided and that are
designated to be changed by the instruction.
The following is a detailed description of each Therefore, if an instruction is due to change only
program-interruption condition. the contents of a field in storage, and every byte
of the field is in a location that is not available in
Addressing Exception the configuration, the operation is suppressed.
An addressing exception is recognized when the When part of an operand location is available in
CPU attempts to reference a main-storage the configuration and part is not, storing may be
location that is not available in the configuration. performed in the part that is available in the con-
A main-storage location is not available in the con- figuration.
figuration when the location is not installed, when
the storage unit is not in the configuration, or When an addressing exception occurs during the
when power is off in the storage unit. An address fetching of an instruction or during the fetching of
designating a storage location that is not available a DAT table entry associated with an instruction
in the configuration is referred to as invalid. fetch, it is unpredictable whether the ILC is 1, 2, or

6-16 z/Architecture Principles of Operation


3. When the exception is associated with fetching indicating the length of the instruction that caused
the target of EXECUTE, the ILC is 2. the reference.

In all cases of addressing exceptions not associ- An addressing exception is indicated by a


ated with instruction fetching, the ILC is 1, 2, or 3, program-interruption code of 0005 hex (or 0085
hex if a concurrent PER event is indicated).

Chapter 6. Interruptions 6-17



Action on

Table- Table- Instruction
Exception Entry FetchEntry Store Fetch Operand Reference

Addressing Suppress Suppress Suppress Suppress for IPTE, LASP,


exception LPSW, LPSWE, MSCH, PLO,
RP, SCKC, SPT, SPX, SSCH,
SSM, STCRW, STNSM, STOSM,
TPI, and TPROT |
Terminate for all others.

Protection -- -- Suppress Suppress for IPTE, LASP,


exception LPSW, LPSWE, MSCH, PLO,
for key- RP, SCKC, SPT, SPX, SSCH,
controlled SSM, STCRW, STNSM, STOSM,
protection and TPI
Terminate for all others.

Protection -- -- -- Suppress
exception
for access-
list-
controlled
protection

Protection -- Suppress -- Suppress


exception
for page
protection

Protection -- Suppress -- Suppress for IPTE, STCRW,


exception STNSM, STOSM, and TPI.
for low-
address
protection Terminate for all others.

Explanation:

-- Not applicable.

Table entries include region table, segment table, page table, linkage
table, entry table, ASN first table, ASN second table, authority table,
dispatchable-unit-control table, primary ASN-second-table entry,
access list, and linkage stack.

Table entries include linkage stack and trace table.

Page protection applies to the linkage stack but not the trace table.

For termination, changes may occur only to result fields. In this
context, "result field" includes condition code, registers, and
storage locations, if any, which are designated to be changed by the
instruction. However, no change is made to a storage location or a
storage key when the reference causes an access exception. Therefore,
if an instruction is due to change only the contents of a field in
main storage, and every byte of that field would cause an access ex-
ception, the result is the same as if the operation had been sup-
pressed. The action may be, for key-controlled protection and low-
address protection, suppression instead of termination; see
"Suppression on Protection" in Chapter 3, "Storage."

When the effective address of TPI is zero, the store access is to
implicit real locations 184-191, and key-controlled protection, page
protection, and low-address protection do not apply.

Suppression occurs only for the compare-and-load and compare-and-
swap operations.

Figure 6-4. Summary of Action for Addressing and Protection Exceptions

6-18 z/Architecture Principles of Operation


AFX-Translation Exception The operation is nullified.
An AFX-translation exception is recognized when,
during ASN translation in the space-switching form The instruction-length code is 1, 2, or 3.
of PROGRAM RETURN, PROGRAM TRANSFER,
or SET SECONDARY ASN, or during ASN trans- The ALE-sequence exception is indicated by a
lation in PROGRAM RETURN when the restored program-interruption code of 002A hex (or 00AA
SASN does not equal the restored PASN, bit 0 of hex if a concurrent PER event is indicated).
the ASN-first-table entry used is not zero.
ALET-Specification Exception
The ASN being translated is stored at real An ALET-specification exception is recognized
locations 174-175, and real locations 172-173 are during access-register translation when bit posi-
set to zeros. tions 0-6 of the access-list-entry token in the
access register used do not contain all zeros.
The operation is nullified. However, when access-register 0 is used, except
in TEST ACCESS, it is treated as containing all
The instruction-length code is 1 or 2. zeros, and this exception is not recognized. TEST
ACCESS uses the actual contents of access reg-
The AFX-translation exception is indicated by a ister 0.
program-interruption code of 0020 hex (or 00A0
hex if a concurrent PER event is indicated). The operation is suppressed.

ALEN-Translation Exception The instruction-length code is 1, 2, or 3.


An ALEN-translation exception is recognized
during access-register translation when either: The ALET-specification exception is indicated by a
program-interruption code of 0028 hex (or 00A8
1. The access register used contains an access- hex if a concurrent PER event is indicated).
list-entry number that designates an access-
list entry which is beyond the end of the ASCE-Type Exception
access list designated by the effective access- An ASCE-type exception is recognized when any
list designation. of the following is true during dynamic address
2. Bit 0 of the access-list entry is not zero. translation:
The number of the access register is stored in bit 1. The address-space-control element being
positions 4-7 at real location 160, and bits 0-3 are used is a region-second-table designation,
set to zeros. and bits 0-10 of the virtual address being
translated are not all zeros.
The operation is nullified.
2. The address-space-control element being
used is a region-third-table designation, and
The instruction-length code is 1, 2, or 3.
bits 0-21 of the virtual address being trans-
The ALEN-translation exception is indicated by a lated are not all zeros.
program-interruption code of 0029 hex (or 00A9 3. The address-space-control element being
hex if a concurrent PER event is indicated). used is a segment-table designation, and bits
0-32 of the virtual address being translated
ALE-Sequence Exception are not all zeros.
An ALE-sequence exception is recognized during
access-register translation when the access reg- The exception is recognized as part of the exe-
ister used contains an access-list-entry sequence cution of the instruction that needs the translation
number (ALESN) which is not equal to the ALESN of an instruction or operand address, except for
in the access-list entry that is designated by the the operand address in LOAD REAL ADDRESS
access register. and TEST PROTECTION, in which case the con-
dition is indicated by the setting of the condition
The number of the access register is stored in bit code.
positions 4-7 at real location 160, and bits 0-3 are
set to zeros.

Chapter 6. Interruptions 6-19


When an interruption occurs, information about the The ASTE-sequence exception is indicated by a
virtual address causing the exception is stored at program-interruption code of 002C hex (or 00AC
real locations 168-175 and conditionally at real hex if a concurrent PER event is indicated).
locations 160 and 162. See Assigned Storage
Programming Note: The storing of zeros at real
Locations on page 3-51 for a detailed description
location 160 in the case of an ASTE-sequence
of this information.
exception recognized during a subspace-
replacement operation is a unique indication since
The unit of operation is nullified.
the use of access register 0 in access-register
The instruction-length code is 1, 2, or 3. translation cannot result in the exception.

The ASCE-type exception is indicated by a ASTE-Validity Exception


program-interruption code of 0038 hex (or 00B8 An ASTE-validity exception is recognized when
hex if a concurrent PER event is indicated). any of the following is true:
1. During access-register translation, except as
ASTE-Sequence Exception in 2, the access-list entry used designates an
An ASTE-sequence exception is recognized when ASN-second-table entry in which bit 0 is not
any of the following is true: zero. The access-list entry is the one desig-
1. During access-register translation, except as nated by the access register used.
in 2, the access-list entry used contains an 2. During access-register translation of ALET 1
ASN-second-table-entry sequence number by BRANCH IN SUBSPACE GROUP, the
(ASTESN) which is not equal to the ASTESN subspace-ASTE origin (SSASTEO) in the
in the ASN-second-table entry that is desig- dispatchable-unit control table designates an
nated by the access-list entry. The access-list ASN-second-table entry in which bit 0 is not
entry is the one designated by the access reg- zero.
ister used.
3. During a subspace-replacement operation, the
2. During access-register translation of ALET 1 subspace-ASTE origin (SSASTEO) in the
by BRANCH IN SUBSPACE GROUP, the dispatchable-unit control table designates an
subspace ASTESN (SSASTESN) in the ASN-second-table entry in which bit 0 is not
dispatchable-unit control table (DUCT) is not zero.
equal to the ASTESN in the subspace ASTE
designated by the subspace-ASTE origin In the first and second cases, the number of the
(SSASTEO) in the DUCT. access register is stored in bit positions 4-7 at real
3. During a subspace-replacement operation, the location 160, and bits 0-3 are set to zeros. In the
subspace ASTESN (SSASTESN) in the third case, all zeros are stored at real location
dispatchable-unit control table (DUCT) is not 160.
equal to the ASTESN in the subspace ASTE
The operation is nullified.
designated by the subspace-ASTE origin
(SSASTEO) in the DUCT.
The instruction-length code is 1, 2, or 3.
In the first and second cases, the number of the
The ASTE-validity exception is indicated by a
access register is stored in bit positions 4-7 at real
program-interruption code of 002B hex (or 00AB
location 160, and bits 0-3 are set to zeros. In the
hex if a concurrent PER event is indicated).
third case, all zeros are stored at real location
160. Programming Note: The storing of zeros at real
location 160 in the case of an ASTE-validity
The operation is nullified. exception recognized during a subspace-
replacement operation is a unique indication since
The instruction-length code is 1, 2, or 3. the use of access register 0 in access-register
translation cannot result in the exception.

6-20 z/Architecture Principles of Operation


ASX-Translation Exception Data Exception
An ASX-translation exception is recognized when, The data-exception conditions are shown in
during execution of the space-switching form of Figure 6-2 on page 6-15. A mask bit may or may
PROGRAM CALL, during ASN translation in the not control whether an interruption occurs, as
space-switching form of PROGRAM RETURN, noted for each condition.
PROGRAM TRANSFER, or SET SECONDARY
ASN, or during ASN translation in PROGRAM When a non-maskable data-exception condition is
RETURN when the restored SASN does not equal recognized, a program interruption for a data
the restored PASN, bit 0 of the ASN-first-table exception always occurs.
entry used is not zero.
Each of the IEEE exception conditions is con-
The ASN being translated is stored at real trolled by a mask bit in the floating-point-control
locations 174-175, and real locations 172-173 are (FPC) register. The handling of these conditions
set to zeros. is described in the section IEEE Exception
Conditions on page 19-10.
The operation is nullified.
A data exception is recognized for the following
The instruction-length code is 1 or 2. cases:
Decimal-operand data exception is recog-
The ASX-translation exception is indicated by a
nized when an instruction which operates on
program-interruption code of 0021 hex (or 00A1
decimal operands encounters invalid decimal
hex if a concurrent PER event is indicated).
digit or sign codes or has its operands speci-
fied improperly. The operation is suppressed,
Crypto-Operation Exception except that, for EDIT and EDIT AND MARK,
A crypto-operation exception is recognized when a
the operation is terminated. See the section
crypto-facility instruction is executed while bit 61 of
Decimal-Operand Data Exception on
control register 0 is zero on a CPU which has the
page 8-4 for details. The decimal-operand
crypto facility installed and available. The crypto-
data exception is reported with DXC 0.
operation exception is also recognized when a
crypto-facility instruction is executed and the AFP-register data exception is recognized
crypto facility is not installed or available on this when bit 45 of control register 0 is zero, and a
CPU, but the facility can be made available to the floating-point-support (FPS) instruction or a
program either on this CPU or another CPU in the hexadecimal-floating-point (HFP) instruction
configuration. specifies a floating-point register other than 0,
2, 4, or 6. The operation is suppressed and is
When a crypto-facility instruction is executed and reported with DXC 1.
the crypto facility is not installed on any CPU
BFP-instruction data exception is recognized
which is or can be placed in the configuration, it
when bit 45 of control register 0 is zero and a
depends on the model whether a crypto-operation
BFP instruction is executed. The operation is
exception or an operation exception is recognized.
suppressed and is reported with DXC 2.
The operation is nullified when the crypto- IEEE-exception-condition data exceptions
operation exception is recognized. are recognized when a BFP instruction
encounters an exceptional condition. The
The instruction-length code is 2. operation is suppressed or completed,
depending on the type of condition. See the
The crypto-operation exception is indicated by a section IEEE Exception Conditions on
program-interruption code of 0119 hex (or 0199 page 19-10 for details.
hex if a concurrent PER event is indicated).
The instruction-length code is 1, 2, or 3.

The data exception is indicated by a program-


interruption code of 0007 hex (or 0087 hex if a
concurrent PER event is indicated).

Chapter 6. Interruptions 6-21


Decimal-Divide Exception EX-Translation Exception
A decimal-divide exception is recognized when in An EX-translation exception is recognized during
decimal division the divisor is zero or the quotient PC-number translation in PROGRAM CALL when
exceeds the specified data-field size. the entry-table entry indicated by the entry-index
part of the PC number is beyond the end of the
The decimal-divide exception is indicated only if entry table as designated by the linkage-table
the sign codes of both the divisor and dividend are entry.
valid and only if the digit or digits used in estab-
lishing the exception are valid. The PC number is stored in bit positions 12-31 of
the word at real location 172, and the leftmost 12
The operation is suppressed. bits of the word are set to zeros.

The instruction-length code is 2 or 3. The operation is nullified.

The decimal-divide exception is indicated by a The instruction-length code is 2.


program-interruption code of 000B hex (or 008B
hex if a concurrent PER event is indicated). The EX-translation exception is indicated by a
program-interruption code of 0023 hex (or 00A3
Decimal-Overflow Exception hex if a concurrent PER event is indicated).
A decimal-overflow exception is recognized when
one or more nonzero digits are lost because the Extended-Authority Exception
destination field in a decimal operation is too short An extended-authority exception is recognized
to contain the result. during access-register translation when all of the
following are true:
The interruption may be disallowed by the
1. The private bit in the access-list entry used is
decimal-overflow mask (PSW bit 21).
one.
The operation is completed. The result is 2. The access-list-entry authorization index
obtained by ignoring the overflow digits, and con- (ALEAX) in the access-list entry is not equal
dition code 3 is set. to the extended authorization index (EAX) in
control register 8.
The instruction-length code is 2 or 3.
3. Either of the following is true:
The decimal-overflow exception is indicated by a a. The authority-table entry designated by
program-interruption code of 000A hex (or 008A the EAX is beyond the length of the
hex if a concurrent PER event is indicated). authority table used. The authority table
is the one designated by the
Execute Exception ASN-second-table entry that is designated
The execute exception is recognized when the by the access-list entry used.
target instruction of EXECUTE is another
b. The secondary-authority bit designated by
EXECUTE.
the EAX is zero.
The operation is suppressed. The access-list entry is the one designated by the
access register used.
The instruction-length code is 2.
The number of the access register is stored in bit
The execute exception is indicated by a program- positions 4-7 at real location 160, and bits 0-3 are
interruption code of 0003 hex (or 0083 hex if a set to zeros.
concurrent PER event is indicated).
The operation is nullified.

The instruction-length code is 1, 2, or 3.

6-22 z/Architecture Principles of Operation


The extended-authority exception is indicated by a The HFP-divide exception is indicated by a
program-interruption code of 002D hex (or 00AD program-interruption code of 000F hex (or 008F
hex if a concurrent PER event is indicated). hex if a concurrent PER event is indicated).

Fixed-Point-Divide Exception HFP-Exponent-Overflow Exception


A fixed-point-divide exception is recognized when An HFP-exponent-overflow exception is recog-
in signed binary division the divisor is zero or nized when the result characteristic of an HFP
when the quotient in signed binary division or the operation exceeds 127 and the result fraction is
result of CONVERT TO BINARY cannot be not zero.
expressed as a 32-bit signed binary integer for a
32-bit result or as a 64-bit signed binary integer The operation is completed. The fraction is nor-
for a 64-bit result. malized, and the sign and fraction of the result
remain correct. The result characteristic is made
In the case of division, the operation is sup- 128 smaller than the correct characteristic.
pressed. The execution of CONVERT TO
BINARY (CVB) is completed by ignoring the left- The instruction-length code is 1, 2, or 3.
most bits that cannot be placed in the register.
The execution of CONVERT TO BINARY (CVBG) The HFP-exponent-overflow exception is indicated
is suppressed. by a program-interruption code of 000C hex (or
008C hex if a concurrent PER event is indicated).
The instruction-length code is 1, 2, or 3.
HFP-Exponent-Underflow Exception
The fixed-point-divide exception is indicated by a An HFP-exponent-underflow exception is recog-
program-interruption code of 0009 hex (or 0089 nized when the result characteristic of an HFP
hex if a concurrent PER event is indicated). operation is less than zero and the result fraction
is not zero. For an extended-format HFP result,
Fixed-Point-Overflow Exception HFP-exponent underflow is indicated only when
A fixed-point-overflow exception is recognized the high-order characteristic underflows.
when an overflow occurs during signed binary
arithmetic or signed left-shift operations. The interruption may be disallowed by the
HFP-exponent-underflow mask (PSW bit 22).
The interruption may be disallowed by the fixed-
point-overflow mask (PSW bit 20). The operation is completed. The
HFP-exponent-underflow mask also affects the
The operation is completed. The result is result of the operation. When the mask bit is
obtained by ignoring the overflow information, and zero, the sign, characteristic, and fraction are set
condition code 3 is set. to zero, making the result a true zero. When the
mask bit is one, the fraction is normalized, the
The instruction-length code is 1, 2, or 3. characteristic is made 128 larger than the correct
characteristic, and the sign and fraction remain
The fixed-point-overflow exception is indicated by correct.
a program-interruption code of 0008 hex (or 0088
hex if a concurrent PER event is indicated). The instruction-length code is 1, 2, or 3.

HFP-Divide Exception The HFP-exponent-underflow exception is indi-


An HFP-divide exception is recognized when in cated by a program-interruption code of 000D hex
HFP division the divisor has a zero fraction. (or 008D hex if a concurrent PER event is indi-
cated).
The operation is suppressed.

The instruction-length code is 1 or 2.

Chapter 6. Interruptions 6-23


HFP-Significance Exception The LX-translation exception is indicated by a
An HFP-significance exception is recognized when program-interruption code of 0022 hex (or 00A2
the result fraction in HFP addition or subtraction is hex if a concurrent PER event is indicated).
zero.
Monitor Event
The interruption may be disallowed by the A monitor event is recognized when MONITOR
HFP-significance mask (PSW bit 23). CALL is executed and the monitor-mask bit in
control register 8 corresponding to the class speci-
The operation is completed. The HFP-significance fied by instruction bits 12-15 is one. The informa-
mask also affects the result of the operation. tion in control register 8 has the following format:
When the mask bit is zero, the operation is com-
pleted by replacing the result with a true zero. Control Register 8
When the mask bit is one, the operation is com-
pleted without further change to the characteristic Monitor Masks

of the result.
48 63
The instruction-length code is 1 or 2.
The monitor-mask bits, bits 48-63 of control reg-
The HFP-significance exception is indicated by a ister 8, correspond to monitor classes 0-15,
program-interruption code of 000E hex (or 008E respectively. Any number of monitor-mask bits
hex if a concurrent PER event is indicated). may be on at a time; together they specify the
classes of monitor events that are monitored at
HFP-Square-Root Exception that time. The mask bits are initialized to zeros.
An HFP-square-root exception is recognized when
the second operand of an HFP SQUARE ROOT When MONITOR CALL is executed and the corre-
instruction is less than zero. sponding monitor-mask bit is one, a program inter-
ruption for monitor event occurs.
The operation is suppressed.
Additional information is stored at real locations
The instruction-length code is 2 or 3. 148-149 and 176-183. The format of the informa-
tion stored at these locations is as follows:
The HFP-square-root exception is indicated by a
program-interruption code of 001D hex (or 009D Real Locations 148-149
hex if a concurrent PER event is indicated).
Monitor
Class No.
LX-Translation Exception
An LX-translation exception is recognized during 8 15
PC-number translation in PROGRAM CALL when
either: Real Locations 176-183
1. The linkage-table entry indicated by the
Monitor Code
linkage-index part of the PC number is beyond

the end of the linkage table as designated by
the linkage-table designation being used.
2. Bit 0 of the linkage-table entry is not zero. The contents of bit positions 8-15 of the
The PC number is stored in bit positions 12-31 of MONITOR CALL instruction are stored at real
the word at real location 172, and the leftmost 12 location 149 and constitute the monitor-class
bits of the word are set to zeros. number. Zeros are stored at real location 148.
The effective address specified by the B and D
The operation is nullified. fields of the instruction forms the monitor code,
which is stored in the doubleword at real location
The instruction-length code is 2. 176. The value of the address is under control of
the addressing mode, bits 31 and 32 of the
current PSW. In the 24-bit addressing mode, bits

6-24 z/Architecture Principles of Operation


0-39 of the address are zeros, while in the 31-bit and bits 40-47 of general register 1 are not all
addressing mode, bits 0-32 are zeros. zeros.
10. Execution of START SUBCHANNEL is
The operation is completed.
attempted, and bits 5, 13, and 25-28 of word 1
The instruction-length code is 2. of the ORB operand are not all zeros.
11. Execution of START SUBCHANNEL is
The monitor event is indicated by a program- attempted, and bit 11 of word 1 of the ORB
interruption code of 0040 hex (or 00C0 hex if a operand is not zero. This exception may or
concurrent PER event is indicated). may not be recognized.

Operand Exception The operation is suppressed.


An operand exception is recognized when any of
the following is true: The instruction-length code is 2.
1. Execution of CLEAR SUBCHANNEL, HALT The operand exception is indicated by a program-
SUBCHANNEL, MODIFY SUBCHANNEL, interruption code of 0015 hex (or 0095 hex if a
RESUME SUBCHANNEL, START SUB- concurrent PER event is indicated).
CHANNEL, STORE SUBCHANNEL, or TEST
SUBCHANNEL is attempted and bit positions
Operation Exception
32-47 of general register 1 do not contain
An operation exception is recognized when the
0001 hex. However, an exception due to
CPU attempts to execute an instruction with an
ones in bit positions 32-39 of the register may
invalid operation code. The operation code may
or may not be recognized.
be unassigned, or the instruction with that opera-
2. Execution of MODIFY SUBCHANNEL is tion code may not be installed on the CPU.
attempted, and bits 1 and 6 of word 1 of the
SCHIB operand are not zeros or bits 9-10 and The operation is suppressed.
25-30 of word 6 of the SCHIB operand are not
all zeros. The instruction-length code is 1, 2, or 3.

3. Execution of MODIFY SUBCHANNEL is The operation exception is indicated by a


attempted, and bits 9 and 10 of word 1 of the program-interruption code of 0001 hex (or 0081
SCHIB operand are both one. hex if a concurrent PER event is indicated).
4. Execution of RESET CHANNEL PATH is
attempted, and bits 40-55 of general register 1 Programming Notes:
are not all zeros. 1. Some models may offer instructions not
5. Execution of SET ADDRESS LIMIT is described in this publication, such as those
attempted, and bits 32 and 48-63 of general provided for assists or as part of special or
register 1 are not all zeros. custom features. Consequently, operation
codes not described in this publication do not
6. Execution of SET CHANNEL MONITOR is necessarily cause an operation exception to
attempted, bit 62 of general register 1 is one, be recognized. Furthermore, these
and bits 59-63 of general register 2 are not all instructions may cause modes of operation to
zeros. be set up or may otherwise alter the machine
7. Execution of SET CHANNEL MONITOR is so as to affect the execution of subsequent
attempted, and the value in bit positions 40-47 instructions. To avoid causing such an opera-
of general register 1 is invalid. tion, an instruction with an operation code not
described in this publication should be exe-
8. Execution of SET CHANNEL MONITOR is cuted only when the specific function associ-
attempted, and bits 36-39 and 48-60 of ated with the operation code is desired.
general register 1 are not all zeros.
2. The operation code 00, with a two-byte
9. Execution of SET CHANNEL MONITOR is instruction format, currently is not assigned. It
attempted, bit 39 of general register 1 is one,

Chapter 6. Interruptions 6-25


is improbable that this operation code will ever 2. The PROGRAM CALL operation is the
be assigned. stacking operation (bit 128 of the ETE is one),
bits 32 and 129 of the ETE are zeros (speci-
Page-Translation Exception fying the 24-bit mode), and bits 33-39 of the
A page-translation exception is recognized when ETE are not all zeros.
the page-invalid bit is one.
The operation is suppressed.
The exception is recognized as part of the exe-
cution of an instruction that needs the page-table The instruction-length code is 2.
entry in the translation of an instruction or operand
address, except for the operand address in LOAD The PC-translation-specification exception is indi-
REAL ADDRESS and TEST PROTECTION, in cated by a program-interruption code of 001F hex
which case the condition is indicated by the (or 009F hex if a concurrent PER event is indi-
setting of the condition code, and except for an cated).
operand address in MOVE PAGE, in which case
the condition is indicated by the setting of the con- PER Event
dition code if the condition-code-option bit, bit 55 A PER event is recognized when the CPU is
of general register 0, is one. enabled for PER and one or more of these events
occur.
When an interruption occurs, information about the
virtual address causing the exception is stored at The PER mask, bit 1 of the PSW, controls
real locations 168-175 and conditionally at real whether the CPU is enabled for PER. When the
locations 160 and 162. See Assigned Storage PER mask is zero, PER events are not recog-
Locations on page 3-51 for a detailed description nized. When the bit is one, PER events are
of this information. recognized, subject to the PER-event-mask bits in
control register 9.
The unit of operation is nullified.
The unit of operation is completed, unless another
When the exception occurs during fetching of an condition has caused the unit of operation to be
instruction, it is unpredictable whether the ILC is 1, inhibited, nullified, suppressed, or terminated.
2, or 3. When the exception occurs during a ref-
erence to the target of EXECUTE, the ILC is 2. Information identifying the event is stored at real
locations 150-159 and conditionally at real location
When the exception occurs during a reference to 161.
an operand location, the instruction-length code
(ILC) is 1, 2, or 3 and indicates the length of the The instruction-length code is 0, 1, 2, or 3. Code
instruction causing the exception. 0 is set only if a specification exception is indi-
cated concurrently.
The page-translation exception is indicated by a
program-interruption code of 0011 hex (or 0091 The PER event is indicated by setting bit 8 of the
hex if a concurrent PER event is indicated). program-interruption code to one.

PC-Translation-Specification Exception See Program-Event Recording on page 4-24 for


A PC-translation-specification exception is recog- a detailed description of the PER event and the
nized during PC-number translation in PROGRAM associated interruption information.
CALL when either of the following is true for the
entry-table entry (ETE) used: Primary-Authority Exception
A primary-authority exception is recognized during
1. The PROGRAM CALL operation is the basic ASN authorization in PROGRAM TRANSFER with
operation (bit 128 of the ETE is zero) in the space switching (PT-ss) when either:
24-bit or 31-bit addressing mode (bit 31 of the
PSW is zero), bit 32 of the ETE is zero (speci- 1. The authority-table entry indicated by the
fying the 24-bit mode), and bits 33-39 of the authorization index in control register 4 is
ETE are not all zeros. beyond the end of the authority table used.

6-26 z/Architecture Principles of Operation


The authority table is the one designated by 7. In the problem state, the result of ANDing the
the ASN-second-table entry for the ASN used. authorization key mask (AKM) with the
PSW-key mask in control register 3 during
2. The primary-authority bit indicated by the
PROGRAM CALL produces a result of zero.
authorization index is zero.
8. In the problem state, bits 20-23 of the second-
The ASN used is stored at real locations 174-175, operand address of the SET ADDRESS
and real locations 172-173 are set to zeros. SPACE CONTROL or SET ADDRESS
SPACE CONTROL FAST instruction have the
The operation is nullified. value 0011 binary.

The instruction-length code is 2. 9. In the problem state, the key value specified
by the rightmost byte of general register 1 for
The primary-authority exception is indicated by a the instruction MOVE WITH SOURCE KEY or
program-interruption code of 0024 hex (or 00A4 MOVE WITH DESTINATION KEY corre-
hex if a concurrent PER event is indicated). sponds to a zero PSW-key-mask bit in control
register 3.
Privileged-Operation Exception 10. In the problem state, the key value specified
A privileged-operation exception is recognized by the rightmost byte of the register desig-
when any of the following is true: nated by the R field for the instruction
1. Execution of a privileged instruction is BRANCH AND SET AUTHORITY corresponds
attempted in the problem state. to a zero PSW-key-mask bit in control register
3.
2. The value of the rightmost bit of the general
register designated by the R field of the 11. In the problem state, bits 16 and 17 of the
PROGRAM TRANSFER instruction is zero PSW field in the second operand of RESUME
and would cause the PSW problem-state bit to PROGRAM have the value 11 binary.
change from the problem state (one) to the The operation is suppressed.
supervisor state (zero).
3. In the problem state, the key value specified The instruction-length code is 2 or 3.
by the second operand of the SET PSW KEY
The privileged-operation exception is indicated by
FROM ADDRESS instruction corresponds to a
a program-interruption code of 0002 hex (or 0082
zero PSW-key-mask bit in control register 3.
hex if a concurrent PER event is indicated).
4. In the problem state, the key value specified
by the rightmost byte of the register desig- Protection Exception
nated by the R field of the MOVE WITH KEY A protection exception is recognized when any of
instruction corresponds to a zero the following is true:
PSW-key-mask bit in control register 3.
1. Key-Controlled Protection: The CPU attempts
5. In the problem state, the key value specified to access a storage location that is protected
by the rightmost byte of the register desig- against the type of reference, and the access
nated by the R field for the instruction MOVE key does not match the storage key.
TO PRIMARY, MOVE TO SECONDARY, or
MOVE WITH KEY corresponds to a zero 2. Access-List-Controlled Protection: The CPU
PSW-key-mask bit in control register 3. attempts to store, in the access-register mode,
by means of an access-list entry which has
6. In the problem state, any of the instructions the fetch-only bit set to one.
EXTRACT PRIMARY ASN 3. Low-Address Protection: The CPU attempts a
EXTRACT SECONDARY ASN store that is subject to low-address protection,
INSERT ADDRESS SPACE CONTROL the effective address is in the range 0-511 or
INSERT PSW KEY 4096-4607, and the low-address protection
INSERT VIRTUAL STORAGE KEY control, bit 35 of control register 0, is one.
is encountered, and the extraction-authority
control, bit 4 of control register 0, is zero.

Chapter 6. Interruptions 6-27


4. Page Protection: The CPU attempts to store, The protection exception is indicated by a
with DAT on, into a page which has the page- program-interruption code of 0004 hex (or 0084
protection bit set to one in either the page- hex if a concurrent PER event is indicated).
table entry or the segment-table entry used in
the translation. Region-First-Translation Exception
A region-first-translation exception is recognized
The operation is suppressed when the location of when a region first table is in the translation path
the instruction is protected against fetching. Simi- for translation of a virtual address and either:
larly, the operation is suppressed when the
location of the target instruction of EXECUTE is 1. The region-first-table entry indicated by the
protected against fetching. region-first-index portion of the virtual address
is outside the region first table.
For access-list-controlled protection and page- 2. The region-invalid bit is one.
protection, the operation is suppressed. For the
other two types of protection, except in the case of The exception is sometimes called simply a
some specific instructions whose execution is sup- region-translation exception, which term applies
pressed, the operation is terminated when a pro- also to a region-second-translation exception and
tection exception is encountered during a a region-third-translation exception.
reference to an operand location. See Figure 6-4
on page 6-18. However, the operation may be The exception is recognized as part of the exe-
suppressed as described in Suppression on cution of an instruction that needs the region-first-
Protection on page 3-12. table entry in the translation of an instruction or
operand address, except for the operand address
For termination, changes may occur only to result in LOAD REAL ADDRESS and TEST PRO-
fields. In this context, the term result field TECTION, in which case the condition is indicated
includes condition code, registers, and storage by the setting of the condition code.
locations, if any, which are due to be changed by
the instruction. However, no change is made to a When an interruption occurs, information about the
storage location when a reference to that location virtual address causing the exception is stored at
causes a protection exception. Therefore, if an real locations 168-175 and conditionally at real
instruction is due to change only the contents of a locations 160 and 162. See Assigned Storage
field in storage, and every byte of that field would Locations on page 3-51 for a detailed description
cause a protection exception, the operation is sup- of this information.
pressed. When termination occurs on fetching,
the protected information is not loaded into an The unit of operation is nullified.
addressable register nor moved to another storage
location. When the exception occurs during fetching of an
instruction, it is unpredictable whether the ILC is 1,
Information about the address causing the excep- 2, or 3. When the exception occurs during the
tion is stored at real locations 168-175 and condi- fetching of the target of EXECUTE, the ILC is 2.
tionally at real location 160. See Suppression on
Protection on page 3-12. When the exception occurs during a reference to
an operand location, the instruction-length code
When the exception occurs during fetching of an (ILC) is 1, 2, or 3 and indicates the length of the
instruction, it is unpredictable whether the ILC is 1, instruction causing the exception.
2, or 3. When the exception occurs during the
fetching of the target of EXECUTE, the ILC is 2. The region-first-translation exception is indicated
by a program-interruption code of 0039 hex (or
For a protected operand location, the instruction- 00B9 hex if a concurrent PER event is indicated).
length code (ILC) is 1, 2, or 3, indicating the
length of the instruction that caused the reference.

6-28 z/Architecture Principles of Operation


Region-Second-Translation Exception Region-Third-Translation Exception
A region-second-translation exception is recog- A region-third-translation exception is recognized
nized when a region second table is in the trans- when a region third table is in the translation path
lation path for translation of a virtual address and for translation of a virtual address and either:
either:
1. The region-third-table entry indicated by the
1. The region-second-table entry indicated by the region-third-index portion of the virtual address
region-second-index portion of the virtual is outside the region third table.
address is outside the region second table.
2. The region-invalid bit is one.
2. The region-invalid bit is one.
The exception is sometimes called simply a
The exception is sometimes called simply a region-translation exception, which term applies
region-translation exception, which term applies also to a region-first-translation exception and a
also to a region-first-translation exception and a region-second-translation exception.
region-third-translation exception.
The exception is recognized as part of the exe-
The exception is recognized as part of the exe- cution of an instruction that needs the region-third-
cution of an instruction that needs the region- table entry in the translation of an instruction or
second-table entry in the translation of an operand address, except for the operand address
instruction or operand address, except for the in LOAD REAL ADDRESS and TEST PRO-
operand address in LOAD REAL ADDRESS and TECTION, in which case the condition is indicated
TEST PROTECTION, in which case the condition by the setting of the condition code.
is indicated by the setting of the condition code.
When an interruption occurs, information about the
When an interruption occurs, information about the virtual address causing the exception is stored at
virtual address causing the exception is stored at real locations 168-175 and conditionally at real
real locations 168-175 and conditionally at real locations 160 and 162. See Assigned Storage
locations 160 and 162. See Assigned Storage Locations on page 3-51 for a detailed description
Locations on page 3-51 for a detailed description of this information.
of this information.
The unit of operation is nullified.
The unit of operation is nullified.
When the exception occurs during fetching of an
When the exception occurs during fetching of an instruction, it is unpredictable whether the ILC is 1,
instruction, it is unpredictable whether the ILC is 1, 2, or 3. When the exception occurs during the
2, or 3. When the exception occurs during the fetching of the target of EXECUTE, the ILC is 2.
fetching of the target of EXECUTE, the ILC is 2.
When the exception occurs during a reference to
When the exception occurs during a reference to an operand location, the instruction-length code
an operand location, the instruction-length code (ILC) is 1, 2, or 3 and indicates the length of the
(ILC) is 1, 2, or 3 and indicates the length of the instruction causing the exception.
instruction causing the exception.
The region-third-translation exception is indicated
The region-second-translation exception is indi- by a program-interruption code of 003B hex (or
cated by a program-interruption code of 003A hex 00BB hex if a concurrent PER event is indicated).
(or 00BA hex if a concurrent PER event is indi-
cated). Secondary-Authority Exception
A secondary-authority exception is recognized
during ASN authorization in SET SECONDARY
ASN with space switching, or during ASN authori-
zation in PROGRAM RETURN when the restored
SASN does not equal the restored PASN, when
either:

Chapter 6. Interruptions 6-29


1. The authority-table entry indicated by the (ILC) is 1, 2, or 3 and indicates the length of the
authorization index in control register 4 is instruction causing the exception.
beyond the end of the authority table used.
The authority table is the one designated by The segment-translation exception is indicated by
the ASN-second-table entry for the ASN used. a program-interruption code of 0010 hex (or 0090
For PROGRAM RETURN, the ASN is the hex if a concurrent PER event is indicated).
SASN being restored from the linkage-stack
state entry used. Space-Switch Event
A space-switch event is recognized at the com-
2. The secondary-authority bit indicated by the
pletion of the operation in each of the following
authorization index is zero.
cases:
The ASN used is stored at real locations 174-175, 1. The space-switching form of PROGRAM
and real locations 172-173 are set to zeros. CALL, PROGRAM RETURN, or PROGRAM
TRANSFER is executed and any of the fol-
The operation is nullified. lowing is true:

The instruction-length code is 1 or 2. a. The primary space-switch-event-control


bit, bit 57 of control register 1, is one
The secondary-authority exception is indicated by before the operation.
a program-interruption code of 0025 hex (or 00A5 b. The primary space-switch-event-control bit
hex if a concurrent PER event is indicated). is one after the operation.

Segment-Translation Exception c. A PER event is indicated.


A segment-translation exception is recognized 2. RESUME PROGRAM, SET ADDRESS
when either: SPACE CONTROL, or SET ADDRESS
1. The segment-table entry indicated by the SPACE CONTROL FAST is executed, the
segment-index portion of a virtual address is CPU is in the home-space mode either before
outside the segment table. or after the operation, but not both before and
after the operation, and any of the following is
2. The segment-invalid bit is one. true:
The exception is recognized as part of the exe- a. The primary space-switch-event-control
cution of an instruction that needs the segment- bit, bit 57 of control register 1, is one.
table entry in the translation of an instruction or
operand address, except for the operand address b. The home space-switch-event-control bit,
in LOAD REAL ADDRESS and TEST PRO- bit 57 of control register 13, is one.
TECTION, in which case the condition is indicated c. A PER event is indicated.
by the setting of the condition code.
For PROGRAM CALL, PROGRAM RETURN, and
When an interruption occurs, information about the PROGRAM TRANSFER, and for a RESUME
virtual address causing the exception is stored at PROGRAM, SET ADDRESS SPACE CONTROL,
real locations 168-175 and conditionally at real or SET ADDRESS SPACE CONTROL FAST
locations 160 and 162. See Assigned Storage instruction that changes the translation mode to
Locations on page 3-51 for a detailed description the home-space mode, the old PASN, which is in
of this information. bit positions 48-63 of control register 4 before the
operation, is stored at real locations 174-175, and
The unit of operation is nullified. the old primary space-switch-event-control bit is
placed in bit position 0 and zeros are placed in bit
When the exception occurs during fetching of an positions 1-15 at real locations 172-173.
instruction, it is unpredictable whether the ILC is 1,
2, or 3. When the exception occurs during the For a RESUME PROGRAM, SET ADDRESS
fetching of the target of EXECUTE, the ILC is 2. SPACE CONTROL, or SET ADDRESS SPACE
CONTROL FAST instruction that changes the
When the exception occurs during a reference to translation mode away from the home-space
an operand location, the instruction-length code

6-30 z/Architecture Principles of Operation


mode, zeros are stored at real locations 174-175, Special-Operation Exception
and the home space-switch-event-control bit is A special-operation exception is recognized when
placed in bit position 0 and zeros are placed in bit any of the following is true:
positions 1-15 at real locations 172-173.
1. Execution of SET SYSTEM MASK is
For a PROGRAM RETURN instruction that intro- attempted in the supervisor state, and the
duces a PSW-format error, it is unpredictable SSM-suppression control, bit 33 of control reg-
whether the instruction-length code is 0 or 1, or 0 ister 0, is one.
or 2 if EXECUTE was used. 2. Execution of any of the following instructions
is attempted with DAT off:
The operation is completed.
EXTRACT PRIMARY ASN
The instruction-length code is 0, 1, or 2. EXTRACT SECONDARY ASN
INSERT ADDRESS SPACE CONTROL
The space-switch event is indicated by a program- INSERT VIRTUAL STORAGE KEY
interruption code of 001C hex (or 009C hex if a SET ADDRESS SPACE CONTROL
concurrent PER event is indicated). SET SECONDARY ASN
3. Execution of MOVE TO PRIMARY or MOVE
Programming Notes:
TO SECONDARY is attempted, and the CPU
1. The space-switch event permits the control is not in the primary-space or secondary-
program to gain control whenever a program space mode.
enters or leaves a particular address space.
4. Execution of basic PROGRAM CALL or
The primary space-switch-event-control bit is
PROGRAM TRANSFER is attempted, and the
loaded into control register 1, along with the
CPU is not in the primary-space mode.
remaining bits of the primary address-space-
control element, whenever control register 1 is 5. Execution of BRANCH AND STACK, stacking
loaded. PROGRAM CALL, PROGRAM RETURN, or
TRAP is attempted, and the CPU is not in the
2. The space-switch event may be useful in
primary-space or access-register mode.
obtaining programmed authorization checking,
in causing additional trace information to be 6. Execution of EXTRACT STACKED REGIS-
recorded, or in enabling or disabling the CPU TERS, EXTRACT STACKED STATE or
for PER or tracing. MODIFY STACKED STATE is attempted, and
the CPU is not in the primary-space, access-
3. Bit 121 of the ASN-second-table entry (ASTE)
register, or home-space mode.
is loaded into bit position 57 of control register
1 as part of the PC-ss, PR-ss, and PT-ss 7. Execution of LOAD ADDRESS SPACE
operations. If bit 121 of the ASTE for a partic- PARAMETERS, PROGRAM CALL with space
ular address space is set to one, then a switching (PC-ss), PROGRAM TRANSFER
space-switch event is recognized when a with space switching (PT-ss), or SET SEC-
program enters or leaves the address space ONDARY ASN (SSAR-cp or SSAR-ss) is
by means of any of PC-ss, PR-ss, or PT-ss. attempted, or execution of a PROGRAM
RETURN instruction requiring PASN or SASN
4. The occurrence of a space-switch event at the
translation is attempted, and the
completion of a PC-ss, PR-ss, or PT-ss opera-
ASN-translation control, bit 34 of control reg-
tion when any PER event is indicated, or at
ister 14, is zero.
the completion of execution of a RESUME
PROGRAM, SET ADDRESS SPACE 8. Execution of PROGRAM CALL or PROGRAM
CONTROL, or SET ADDRESS SPACE TRANSFER is attempted, and the subsystem-
CONTROL FAST instruction that changes to linkage control, bit 192 of the primary
or from the home-space mode when any PER ASN-second-table entry, is zero.
event is indicated, permits the control program 9. Execution of SET ADDRESS SPACE
to determine the address space from which CONTROL, MOVE TO PRIMARY, or MOVE
the instruction causing the PER event was TO SECONDARY is attempted, and the
fetched.

Chapter 6. Interruptions 6-31


secondary-space control, bit 37 of control reg- The operation is suppressed.
ister 0, is zero. The exception may be recog-
nized for this reason when execution of SET The instruction-length code is 1, 2, or 3.
ADDRESS SPACE CONTROL FAST is
attempted. The special-operation exception is indicated by a
program-interruption code of 0013 hex (or 0093
10. Execution of BRANCH IN SUBSPACE hex if a concurrent PER event is indicated).
GROUP is attempted, and any of the following
is true:
Specification Exception
a. The current primary address space is not A specification exception is recognized when any
in a subspace group associated with the of the following is true:
current dispatchable unit, that is, the
1. A one is introduced into an unassigned bit
primary-ASTE origin (PASTEO) in control
position of the PSW (that is, any of bit posi-
register 5 does not equal the base-ASTE
tions 0, 2-4, 24-30, or 33-63). This is handled
origin (BASTEO) in the dispatchable-unit
as an early PSW specification exception.
control table (DUCT).
2. A one is introduced into bit position 12 of the
b. The access-list-entry token (ALET) in
PSW. This is handled as an early PSW spec-
access register R is ALET 1, but a sub-
ification exception.
space has not previously been entered by
the dispatchable unit by means of 3. The PSW is invalid in any of the following
BRANCH IN SUBSPACE GROUP, that is, ways:
the subspace-ASTE origin (SSASTEO) in a. Bit 31 of the PSW is one and bit 32 is
the DUCT is all zeros. zero.
c. The ALET used is other than ALET 0 and b. Bits 31 and 32 of the PSW are zero, indi-
ALET 1, and the destination ASTE cating the 24-bit addressing mode, and
(DASTE) does not specify the base space bits 64-103 of the PSW are not all zeros.
or a subspace of the subspace group, that
is, the DASTE origin (DASTEO) obtained c. Bit 31 of the PSW is zero and bit 32 is
from an access-list entry does not equal one, indicating the 31-bit addressing
the BASTEO in the DUCT, and either the mode, and bits 64-96 of the PSW are not
subspace-group bit (G) in the address- all zeros.
space-control element in the DASTE is This is handled as an early PSW specification
zero or the base-space bit (B) in the exception.
DASTE is one.
4. The PSW contains an odd instruction address.
11. Execution of BRANCH AND SET AUTHORITY
is attempted, and the R field is zero in the 5. An operand address does not designate an
base-authority state or nonzero in the integral boundary in an instruction requiring
reduced-authority state. such integral-boundary designation.

12. Execution of TRAP is attempted, and the 6. An odd-numbered general register is desig-
TRAP-enabled bit, bit 31 in bytes 44-47 of the nated by an R field of an instruction that
dispatchable-unit control table, is zero. requires an even-numbered register desig-
nation.
13. Execution of basic PROGRAM CALL is
attempted, and the extended-addressing-mode 7. A floating-point register other than 0, 1, 4, 5,
bit, bit 31 of the current PSW, does not equal 8, 9, 12, or 13 is designated for an extended
the entry-extended-addressing-mode bit, bit operand.
129, in the entry-table entry. 8. The multiplier or divisor in decimal arithmetic
14. Execution of LOAD REAL ADDRESS (LRA) is exceeds 15 digits and sign.
attempted in the 24-bit or 31-bit addressing 9. The length of the first-operand field is less
mode, and bits 0-32 of the resulting real or than or equal to the length of the second-
absolute address are not all zeros. operand field in decimal multiplication or divi-
sion.

6-32 z/Architecture Principles of Operation


10. Bit positions 8-11 of MONITOR CALL do not 20. Execution of SET ADDRESSING MODE
contain zeros. (SAM24) is attempted, and bits 0-39 of the
unupdated instruction address in the PSW,
11. Bits 52 and 53 of the second-operand address
bits 64-103 of the PSW, are not all zeros.
of SET ADDRESS SPACE CONTROL or SET
ADDRESS SPACE CONTROL FAST are not 21. Execution of SET ADDRESSING MODE
both zeros. (SAM31) is attempted, and bits 0-32 of the
unupdated instruction address in the PSW,
12. When the extended-addressing-mode bit in
bits 64-96 of the PSW, are not all zeros.
the PSW is zero, the basic-addressing-mode
bit, bit 32, in the general register designated The execution of the instruction identified by the
by the R field of PROGRAM TRANSFER is old PSW is suppressed. However, for early PSW
zero, but bits 33-39 of the instruction address specification exceptions (causes 1-3) the operation
in the same register are not all zeros. that introduces the new PSW is completed, but an
interruption occurs immediately thereafter.
13. Execution of COMPARE AND FORM
CODEWORD is attempted, and general regis-
Except as noted below, the instruction-length code
ters 1, 2, and 3 do not initially contain even
(ILC) is 1, 2, or 3, indicating the length of the
values.
instruction causing the exception.
14. Execution of UPDATE TREE is attempted,
and the initial contents of general registers 4 When the instruction address is odd (cause 4 on
and 5 are not a multiple of 8 in the 24-bit or page 6-32), it is unpredictable whether the ILC is
31-bit addressing mode or are not a multiple 1, 2, or 3.
of 16 in the 64-bit addressing mode.
When the exception is recognized because of an
15. Execution of MOVE PAGE is attempted, and early PSW specification exception (causes 1-3)
bit positions 48-51 of general register 0 do not and the exception has been introduced by LOAD
contain zeros or bits 52 and 53 of the register PSW, LOAD PSW EXTENDED, PROGRAM
are both one. RETURN, or an interruption, the ILC is 0. When
16. Execution of COMPARE LOGICAL STRING, the exception is introduced by SET ADDRESSING
MOVE STRING, or SEARCH STRING is MODE (SAM24, SAM31), the ILC is 1. When the
attempted, and bits 32-55 of general register 0 exception is introduced by SET SYSTEM MASK
are not all zeros. or by STORE THEN OR SYSTEM MASK, the ILC
is 2.
17. Execution of EXECUTE is attempted, and the
target address is odd. The specification exception is indicated by a
18. Execution of RESUME PROGRAM is program-interruption code of 0006 hex (or 0086
attempted, and bits 31, 32, and 64-127 of the hex if a concurrent PER event is indicated).
PSW field in the second operand are not valid Programming Note: See Exceptions Associated
for placement in the current PSW. The with the PSW on page 6-9 for a definition of
exception is recognized if any of the following when the exceptions associated with the PSW are
is true: recognized.
Bits 31 and 32 are both zero and bits
64-103 are not all zeros. Stack-Empty Exception
A stack-empty exception is recognized during the
Bits 31 and 32 are zero and one, respec-
unstacking process in EXTRACT STACKED REG-
tively, and bits 64-96 are not all zeros.
ISTERS, EXTRACT STACKED STATE, MODIFY
Bits 31 and 32 are one and zero, respec- STACKED STATE, or PROGRAM RETURN when
tively. the current linkage-stack entry is a header entry
Bit 127 is one. and the backward stack-entry validity bit in the
header entry is zero.
19. Optionally if execution of LOAD PSW is
attempted and bit 12 of the doubleword at the The operation is nullified.
second-operand address is zero.
The instruction-length code is 1 or 2.

Chapter 6. Interruptions 6-33


The stack-empty exception is indicated by a STATE, or PROGRAM RETURN when the
program-interruption code of 0031 hex (or 00B1 current linkage-stack entry is a header entry in
hex if a concurrent PER event is indicated). which the backward stack-entry address des-
ignates another header entry.
Stack-Full Exception The operation is nullified.
A stack-full exception is recognized during the
stacking process in BRANCH AND STACK or The instruction-length code is 1 or 2.
stacking PROGRAM CALL when there is not
enough remaining free space in the current The stack-specification exception is indicated by a
linkage-stack section and the forward-section program-interruption code of 0032 hex (or 00B2
validity bit in the trailer entry of the section is zero. hex if a concurrent PER event is indicated).

The operation is nullified. Stack-Type Exception


A stack-type exception is recognized during the
The instruction-length code is 2.
unstacking process in EXTRACT STACKED REG-
ISTERS, EXTRACT STACKED STATE, MODIFY
The stack-full exception is indicated by a program-
STACKED STATE, or PROGRAM RETURN in
interruption code of 0030 hex (or 00B0 hex if a
each of the following cases:
concurrent PER event is indicated).
1. The current linkage-stack entry is not a
Stack-Operation Exception header entry or a state entry.
A stack-operation exception is recognized during 2. When the current linkage-stack entry is a
the unstacking process in PROGRAM RETURN header entry, the preceding entry, designated
when the unstack-suppression bit is one in any by the backward stack-entry address in the
linkage-stack state entry or header entry encount- header entry, is not a header entry or a state
ered during the process. entry. (A stack-specification exception is
recognized if the preceding entry is a header
The operation is nullified.
entry.)
The instruction-length code is 1 or 2. The operation is nullified.

The stack-operation exception is indicated by a The instruction-length code is 1 or 2.


program-interruption code of 0034 hex (or 00B4
hex if a concurrent PER event is indicated). The stack-type exception is indicated by a
program-interruption code of 0033 hex (or 00B3
Stack-Specification Exception hex if a concurrent PER event is indicated).
A stack-specification exception is recognized in
each of the following cases: Trace-Table Exception
A trace-table exception is recognized when the
1. During the stacking process in BRANCH AND
CPU attempts to store a trace-table entry which
STACK or stacking PROGRAM CALL when
would reach or cross the next 4K-byte block
there is not enough remaining free space in
boundary. For the purpose of recognizing this
the current linkage-stack section and either of
exception in the TRACE instruction, the explicit
the following is true:
trace entry is treated as being 76 bytes long for
a. The remaining-free-space value used to TRACE (TRACE) and as 144 bytes long for
locate the trailer entry of the current TRACE (TRACG). For a PROGRAM CALL
section is not a multiple of 8. instruction that would cause storing of both a
PROGRAM CALL trace entry and a mode-switch
b. There is not enough remaining free space
trace entry, the exception is recognized for the
in the next section.
first entry when either the first or the second entry
2. During the unstacking process in EXTRACT would reach or cross the boundary.
STACKED REGISTERS, EXTRACT
STACKED STATE, MODIFY STACKED The operation is nullified.

6-34 z/Architecture Principles of Operation


The instruction-length code is 1, 2, or 3, indicating When the exception occurs during a reference to
the length of the instruction causing the exception. an operand location, the instruction-length code
(ILC) is 1, 2, or 3 and indicates the length of the
The trace-table exception is indicated by a instruction causing the exception.
program-interruption code of 0016 hex (or 0096
hex if a concurrent PER event is indicated). The translation-specification exception is indicated
by a program-interruption code of 0012 hex (or
Translation-Specification Exception 0092 hex if a concurrent PER event is indicated).
A translation-specification exception is recognized Programming Note: When a translation-
when translation of a virtual address is attempted specification exception is recognized in the
and any of the following is true: process of translating an instruction address, the
1. In the lookup in the table designated by the operation is suppressed. In this case, the
address-space-control element used for the instruction-length code (ILC) is needed to derive
translation, the table-type bits in the selected the address of the instruction, as the instruction
table entry do not equal the designation-type address in the old PSW has been incremented by
bits in the address-space-control element. the amount indicated by the ILC. In the case of
region-first-translation, region-second-translation,
2. In a lookup in a table designated by an entry
region-third-translation, segment-translation, and
in a region first table, region second table, or
page-translation exceptions, the operation is nulli-
region third table, the value of the table-type
fied, the instruction address in the old PSW identi-
bits in the selected table entry is not one less
fies the instruction, and the ILC may be arbitrarily
than the value of the same bits in the desig-
set to 1, 2, or 3.
nating table entry.
3. The private-space control, bit 55 in the Collective Program-Interruption
address-space-control element used for the
translation, is one, the segment-table entry
Names
used for the translation is valid, and the
For the sake of convenience, certain program
common-segment bit, bit 59, in the segment-
exceptions are grouped together under a single
table entry is one.
collective name. These collective names are used
4. The page-table entry used for the translation when it is necessary to refer to the complete set
is valid, and bit positions 52 and 55 in the of exceptions, such as in instruction definitions.
entry do not contain zeros. Four collective names are used:
Any of the above reasons is referred to by saying Access exceptions
that the DAT-table entry has a format error. ASN-translation exceptions
Subspace-replacement exceptions
The exception is recognized only as part of the Trace exceptions
execution of an instruction using address trans-
lation, that is, when DAT is on and a logical The individual exceptions and their priorities are
address, instruction address, or virtual address listed in Multiple Program-Interruption Conditions
must be translated, or when LOAD REAL on page 6-39.
ADDRESS or STORE REAL ADDRESS is exe-
cuted. Recognition of Access
Exceptions
The unit of operation is suppressed.
Figure 6-5 on page 6-36 summarizes the condi-
When the exception occurs during fetching of an tions that can cause access exceptions and the
instruction, it is unpredictable whether the ILC is 1, action taken when they are encountered.
2, or 3. When the exception occurs during the
fetching of the target of EXECUTE, the ILC is 2.

Chapter 6. Interruptions 6-35



Translation for
TAR and TPROT,
Translation for and Access for Translation and
Virtual Address Logical Address Access for Any
of LRA or LRAG of TPROT Other Address

Indi- Indi- Indi-
Condition cation Action cation Action cation Action

Access register
Bits -6 not all zeros cc3 Complete cc3 Complete AS Suppress

Effective access-list designation
Invalid address of designation A Suppress A Suppress A Suppress

Access-list entry
Access-list-length violation cc3 Complete cc3 Complete AT Nullify
Invalid address of entry A Suppress A Suppress A Suppress
I bit on cc3 Complete cc3 Complete AT Nullify
Sequence number in access register cc3 Complete cc3 Complete ALQ Nullify
not equal to sequence number in
entry

ASN-second-table entry
Invalid address of entry A Suppress A Suppress A Suppress
I bit on cc3 Complete cc3 Complete AV Nullify
Sequence number in access-list cc3 Complete cc3 Complete ASQ Nullify
entry not equal to sequence
number in entry

Authority-table entry
Authority-table-length violation cc3 Complete cc3 Complete EA Nullify
Invalid address of entry A Suppress A Suppress A Suppress
Secondary-authority bit not one cc3 Complete cc3 Complete EA Nullify

Address-space-control element
Bits -1, -21, or -32 of cc3 Complete cc3 Complete ATY Nullify
instruction or operand address
not all zeros when address-
space-control element is a
region-second-table designation,
region-third-table designation,
or segment-table designation,
respectively

Region-table-entry designated by
address-space-control element or
region-table-entry
Entry outside of table cc3 Complete cc3 Complete RT Nullify
Invalid address of entry A Suppress A Suppress A Suppress
I bit on cc3 Complete cc3 Complete RT Nullify
TT in entry not equal DT in TS Suppress TS Suppress TS Suppress
address-space-control element or
not one less than TT in next-
higher-level entry

Figure 6-5 (Part 1 of 3). Handling of Access Exceptions

6-36 z/Architecture Principles of Operation



Translation for
TAR and TPROT,
Translation for and Access for Translation and
Virtual Address Logical Address Access for Any
of LRA or LRAG of TPROT Other Address

Indi- Indi- Indi-
Condition cation Action cation Action cation Action

Segment-table entry designated by


address-space-control element or
region-table-entry
Entry outside of table cc3 Complete cc3 Complete ST Nullify
Invalid address of entry A Suppress A Suppress A Suppress
I bit on (except as follows) cc1 Complete cc3 Complete ST Nullify
I bit on (LRA in 24-bit or 31-bit cc3 Complete - - - -
mode when bits -32 of entry
address not all zeros)
One in a bit position which is TS Suppress TS Suppress TS Suppress
checked for zero
TT in entry not equal DT in TS Suppress TS Suppress TS Suppress
address-space-control element or
not one less than TT in next-
higher-level entry (TT not zero)

Page-table entry
Invalid address of entry A Suppress A Suppress A Suppress
I bit on (except as follows) cc2 Complete cc3 Complete PT Nullify
I bit on (LRA in 24-bit or 31-bit cc3 Complete cc3 Complete PT Nullify
mode when bits -32 of entry
address not all zeros)
One in a bit position which is TS Suppress TS Suppress TS Suppress
checked for zero

Access for instruction fetch
Location protected (key-controlled - - - - P Suppress
protection)
Invalid address - - - - A Suppress

Access for operands
Location protected (low-address, - - cc setComplete P Term.\
page, or key-controlled protec-
tion)
Invalid address - - A Suppress A Term.\

Explanation:

- The condition does not apply.
\ Action is to terminate except where otherwise specified in this publication.
For access-list-controlled protection and page protection, the action is
always to suppress.
TAR does not have a logical address. The rows "Address-space-control
element" through "Access for operands" apply only to TPROT, not to TAR.
Protection applies only to accesses for instruction fetch and for operands.
It does not apply to the fetching of the effective access-list
designation or any of the listed entries.
Exceptions related to an access register, effective access-list designa-
tion, access-list entry, ASN-second-table entry, or authority-table entry
are recognized only in the access-register mode except that, for LOAD REAL
ADDRESS and STORE REAL ADDRESS, they are recognized when PSW bits 16 and 17
are 1 binary, and, for TEST ACCESS, they are recognized regardless of the
translation mode.
Authority table is not accessed and secondary-authority bit is not checked
if the private bit in the access-list entry is zero or the access-list-
entry authorization index in the access-list entry is equal to the extended
authorization index in control register 8.
A translation-specification exception for a format error in a table entry
is recognized only when the execution of an instruction requires the entry
for translation of an address.

Figure 6-5 (Part 2 of 3). Handling of Access Exceptions

Chapter 6. Interruptions 6-37



Explanation (Continued):

The condition code is set as follows:
Operand location not protected.
1 Fetches permitted, but stores not permitted.
2 Neither fetches nor stores permitted.
A Addressing exception.
ALQ ALE-sequence exception.
AS ALET-specification exception.
ASQ ASTE-sequence exception.
AT ALEN-translation exception.
ATS ASN-translation-specification exception.
ATY ASCE-type exception.
AV ASTE-validity exception.
cc1 Condition code 1 set.
cc2 Condition code 2 set.
cc3 Condition code 3 set.
EA Extended-authority exception.
P Protection exception.
PT Page-translation exception.
RT Region-first-translation, region-second-translation, or region-third-
translation exception, depending on the level of the table.
ST Segment-translation exception.
TS Translation-specification exception.

Figure 6-5 (Part 3 of 3). Handling of Access Exceptions

Any access exception is recognized as part of the instructions, it is not covered in the individual
execution of the instruction with which the excep- instruction definitions.
tion is associated. An access exception is not
recognized when the CPU attempts to prefetch Except where otherwise indicated in the individual
from an unavailable location or detects some other instruction description, the following rules apply for
access-exception condition, but a branch instruc- exceptions associated with an access to an
tion or an interruption changes the instruction operand location. For a fetch-type operand,
sequence such that the instruction is not exe- access exceptions are necessarily indicated only
cuted. for that portion of the operand which is required
for completing the operation. It is unpredictable
Every instruction can cause an access exception whether access exceptions are indicated for those
to be recognized because of instruction fetch. portions of a fetch-type operand which are not
Additionally, access exceptions associated with required for completing the operation. For a store-
instruction execution may occur because of an type operand, access exceptions are recognized
access to an operand in storage. for the entire operand even if the operation could
be completed without the use of the inaccessible
An access exception due to fetching an instruction part of the operand. In situations where the value
is indicated when the first instruction halfword of a store-type operand is defined to be unpredict-
cannot be fetched without encountering the excep- able, it is unpredictable whether an access excep-
tion. When the first halfword of the instruction has tion is indicated.
no access exceptions, access exceptions may be
indicated for additional halfwords according to the Whenever an access to an operand location can
instruction length specified by the first two bits of cause an access exception to be recognized, the
the instruction; however, when the operation can word access is included in the list of program
be performed without accessing the second or exceptions in the description of the instruction.
third halfwords of the instruction, it is unpredict- This entry also indicates which operand can cause
able whether the access exception is indicated for the exception to be recognized and whether the
the unused part. Since the indication of access exception is recognized on a fetch or store access
exceptions for instruction fetch is common to all to that operand location. Access exceptions are
recognized only for the portion of the operand as
defined for each particular instruction.

6-38 z/Architecture Principles of Operation


Multiple Program-Interruption on page 6-46 and Figure 6-10 on page 6-46,
respectively.
Conditions
For some instructions, the priority is shown in the
Except for PER events, only one program- individual instruction description.
interruption condition is indicated with a program
interruption. The existence of one condition, The relative priorities of any two conditions listed
however, does not preclude the existence of other in the figure can be found by comparing the pri-
conditions. When more than one program- ority numbers, as found in the figure, from left to
interruption condition exists, only the condition right until a mismatch is found. If the first ine-
having the highest priority is identified in the inter- quality is between numeric characters, either the
ruption code. two conditions are mutually exclusive or, if both
can occur, the condition with the smaller number
With two conditions of the same priority, it is is indicated. If the first inequality is between
unpredictable which is indicated. In particular, the alphabetic characters, then the two conditions are
priority of access exceptions associated with the not exclusive, and it is unpredictable which is indi-
two parts of an operand that crosses a page or cated when both occur.
protection boundary is unpredictable and is not
necessarily related to the sequence specified for To understand the use of the table, consider an
the access of bytes within the operand. example involving the instruction ADD DECIMAL,
which is a six-byte instruction. Assume that the
The type of ending which occurs (nullification, sup- first four bytes of the instruction can be accessed
pression, or termination) is that which is defined but that the instruction crosses a boundary so that
for the type of exception that is indicated in the an addressing exception exists for the last two
interruption code. However, if a condition is indi- bytes. Additionally, assume that the first operand
cated which permits termination, and another con- addressed by the instruction contains invalid
dition also exists which would cause either decimal digits and is in a location that can be
nullification or suppression, then the unit of opera- fetched from, but not stored into, because of key-
tion is suppressed. controlled protection. The three exceptions which
could result from attempted execution of the ADD
Figure 6-6 on page 6-40 lists the priorities of all
DECIMAL are:
program-interruption conditions other than PER
events and exceptions associated with some of
the more complex control instructions. All Priority
exceptions associated with references to storage Number Exception
for a particular instruction halfword or a particular
7.B Access exceptions for third instruc-
operand byte are grouped as a single entry called
tion halfword.
access. Figure 6-7 on page 6-43 lists the pri- 8.B Access exceptions (operand 1).
ority of access exceptions for a single access. 8.D Data exception.
Thus, the second figure specifies which of several
exceptions, encountered either in the access of a
particular portion of an instruction or in any partic- Since the first inequality (78) is between numeric
ular access associated with an operand, has characters, the addressing exception would be
highest priority, and the first figure specifies the indicated. If, however, the entire ADD DECIMAL
priority of this condition in relation to other condi- instruction can be fetched, and only the second
tions detected in the operation. Similarly, the pri- two exceptions listed above exist, then the ine-
orities for exceptions occurring as part of ASN quality (BD) is between alphabetic characters,
translation and tracing are covered in Figure 6-8 and it is unpredictable whether the protection
exception or the data exception would be indi-
cated.

Chapter 6. Interruptions 6-39



1. Specification exception due to any PSW error of the type that causes an
immediate interruption.

2. Specification exception due to an odd instruction address in the PSW.

3. Access exceptions for first halfword of EXECUTE.

4. Access exceptions for second halfword of EXECUTE.

5. Specification exception due to target instruction of EXECUTE not being
specified on halfword boundary.

6. Access exceptions for first instruction halfword.

7.A Access exceptions for second instruction halfword.

7.B Access exceptions for third instruction halfword.

7.C.2 Operation exception.

7.C.3 Privileged-operation exception for privileged instructions.

7.C.4 Execute exception.

7.C.5 Special-operation exception.

8.A Specification exception due to conditions other than those included in
1, 2, and 5 above.

8.B Access exceptions for an access to an operand in storage.

8.C Access exceptions for any other access to an operand in storage.

8.D Data exception.

8.E Decimal-divide exception.

8.F Trace exceptions.

9. Events other than PER events, exceptions which result in completion,
and the following exceptions: fixed-point divide, floating-point
divide, operand, square root, and unnormalized operand. Either these
exceptions and events are mutually exclusive or their priority is
specified in the corresponding definitions.

Figure 6-6 (Part 1 of 2). Priority of Program-Interruption Conditions

6-40 z/Architecture Principles of Operation



Explanation:

Numbers indicate priority, with "1" being the highest priority; letters indicate
no priority.

PSW errors which cause an immediate interruption may be introduced by a new
PSW loaded as a result of an interruption or by the instructions LOAD PSW,
PROGRAM RETURN, SET SYSTEM MASK, and STORE THEN OR SYSTEM MASK. The priority
shown in the chart is for a PSW error introduced by an interruption and may
also be considered as the priority for a PSW error introduced by the previous
instruction. The error is introduced only if the instruction encounters no
other exceptions. The resulting interruption has a higher priority than any
interruption caused by the instruction which would have been executed next; it
has lower priority, however, than any interruption caused by the instruction
which introduced the erroneous PSW.

Priorities 3, 4, and 5 are for the EXECUTE instruction, and priorities start-
ing with 6 are for the target instruction. When no EXECUTE is encountered,
priorities 3, 4, and 5 do not apply.

Separate accesses may occur for each halfword of an instruction. The second
instruction halfword is accessed only if bits -1 of the instruction are not
both zeros. The third instruction halfword is accessed only if bits -1 of
of the instruction are both ones. Access exceptions for one of these half-
words are not necessarily recognized if the instruction can be completed
without use of the contents of the halfword or if an exception of lower pri-
ority can be determined without the use of the halfword.

The special-operation exception recognized by LOAD REAL ADDRESS has priority
9.

As in instruction fetching, separate accesses may occur for each portion of
an operand. Each of these accesses, and also accesses for different operands,
are of equal priority, and the two entries 8.B and 8.C are listed to represent
the relative priorities of exceptions associated with any two of these
accesses. Access exceptions for INSERT STORAGE KEY EXTENDED, INSERT VIRTUAL
STORAGE KEY, INVALIDATE PAGE TABLE ENTRY, LOAD REAL ADDRESS, STORE REAL
ADDRESS, RESET REFERENCE BIT EXTENDED, SET STORAGE KEY EXTENDED, and TEST
PROTECTION are also included in 8.B.

For MOVE LONG, MOVE LONG EXTENDED, COMPARE LOGICAL LONG, and COMPARE LOGICAL
LONG EXTENDED, an access exception for a particular operand can be indicated
only if the R field for that operand designates an even-numbered register.

The exception can be indicated only if the sign, digit, or digits responsi-
ble for the exception were fetched without encountering an access exception.

The exception can be indicated only if the digits used in establishing the
exception, and also the signs, were fetched without encountering an access
exception, only if the signs are valid, and only if the digits used in estab-
lishing the exception are valid.

Figure 6-6 (Part 2 of 2). Priority of Program-Interruption Conditions

Chapter 6. Interruptions 6-41


Access Exceptions With DAT on but in other than the access-register
The access exceptions consist of those exceptions mode, exceptions 8-17 in the above list, except for
which can be encountered while using an abso- access-list-controlled protection, can be encount-
lute, instruction, logical, real, or virtual address to ered.
access storage. Thus, in the access-register
mode, the exceptions are: With DAT off, the exceptions are:

1. ALET specification 1. Addressing (the operand or instruction)


2. ALEN translation 2. Protection (key-controlled and low-address)
3. ALE sequence Additionally, even with DAT off, the instruction
4. ASTE validity STORE REAL ADDRESS can encounter
5. ASTE sequence exceptions 1-17, the instruction LOAD REAL
6. Extended authority ADDRESS can encounter exceptions 7, 14, and
7. Addressing (the ART tables) 15, and the instruction INVALIDATE PAGE TABLE
8. ASCE type ENTRY can encounter exception 15.
9. Region first translation
10. Region second translation The access exceptions are listed in more detail in
11. Region third translation Figure 6-7 on page 6-43.
12. Segment translation
Programming Note: The priorities in Figure 6-7
13. Page translation
on page 6-43 could be renumbered, but they are
14. Translation specification
kept as they are to allow easier comparison to the
15. Addressing (the DAT tables)
corresponding ESA/390 priorities. Specifically,
16. Addressing (the operand or instruction)
B.1.A.1-B.1.A.9 could be changed to B.1-B.9, but
17. Protection (key-controlled, access-list-
ESA/390 contains B.1.B Translation-specification
controlled, page, and low-address)
exception due to invalid encoding of bits 8-12 of
control register 0.

6-42 z/Architecture Principles of Operation



A. Protection exception (low-address protection) due to
a store-type operand reference with an effective
address in the range -511 or 496-467. Not
recognized if DAT is on and the address-space-control
element to be used in the translation cannot be
obtained because of another exception.

B.1.A.1 ALET-specification exception due to bits -6 of
access register not being all zeros.

B.1.A.2 Addressing exception for access to effective access-
list designation.

B.1.A.3 ALEN-translation exception due to access-list entry
being outside the list.

B.1.A.4 Addressing exception for access to access-list
entry.

B.1.A.5 ALEN-translation exception due to I bit in access-
list entry having the value one.

B.1.A.6 ALE-sequence exception due to access-list-entry
sequence number (ALESN) in access register not being
equal to ALESN in access-list entry.

B.1.A.7 Addressing exception for access to ASN-second-table
entry.

B.1.A.8 ASTE-validity exception due to I bit in ASN-second-
table entry having the value one.

B.1.A.9 ASTE-sequence exception due to ASN-second-table-
entry sequence number (ASTESN) in access-list entry
not being equal to ASTESN in ASN-second-table entry.

Note: Exceptions B.1.A.1 through B.1.A.12 are
recognized only when the private bit in the access-
list entry is one and the ALEAX in the entry is not
equal to the EAX in control register 8.

B.1.A.1 Extended-authority exception due to authority-table
entry being outside table.

B.1.A.11 Addressing exception for access to authority-table
entry.

B.1.A.12 Extended-authority exception due to (1) private bit
in access-list entry not being zero, (2) access-list-
entry authorization index in access-list entry not
being equal to extended authorization index in con-
trol register 8, and (3) secondary-authority bit
selected by extended authorization index not being
one.

Figure 6-7 (Part 1 of 3). Priority of Access Exceptions .

Chapter 6. Interruptions 6-43



B.2.A Protection exception (access-list-controlled protec-
tion) due to store-type operand reference to a
virtual address which is protected against stores.

B.2.B.1 ASCE-type exception due to bits -1, -21, or -32
of instruction or operand address not being zeros
when address-space-control element is a region-
second-table designation, region-third-table
designation, or segment-table designation,
respectively.

B.2.B.2 Region-first-, region-second-, region-third-, or
segment-translation exception due to required entry
in table designated by address-space-control element
being outside of table.

Note: Exceptions B.2.B.3 through B.2.B.6 are
recognized for a region-first-table, region-second-
table, region-third-table, and segment-table entry in
the order in which the entries are used.

B.2.B.3 Addressing exception for access to table entry.

B.2.B.4 Region-first-, region-second-, region-third-, or
segment-translation exception due to I bit in table
entry having the value one.

B.2.B.5 Translation-specification exception due to (1) TT in
table entry not equal to DT in designating address-
space-control element or not one less than TT in
designating next-higher-level table entry or (2)
invalid one in segment-table entry if this entry is a
segment-table entry (common-segment bit if private-
space bit in address-space-control element is one).

B.2.B.6 Region-second-, region-third-, or segment-translation
exception due to required entry in next-lower-level
table entry, if any, being outside of table.

B.2.B.7 Addressing exception for access to page-table entry.

B.2.B.8 Page-translation exception due to I bit in page-table
entry having the value one.

B.2.B.9 Translation-specification exception due to invalid
ones in page-table entry (bits 52 and 55) in which I
bit is zero.

Note: Exceptions B.3.A, B.3.B, and B.4 are
recognized only when DAT is off or the I bit in the
page-table entry is zero.

Figure 6-7 (Part 2 of 3). Priority of Access Exceptions .

6-44 z/Architecture Principles of Operation



Note: Exceptions B.3.A, B.3.B, and B.4 are
recognized only when DAT is off or the I bit in the
page-table entry is zero.

B.3.A Protection exception (page protection) due to a
store-type operand reference to a virtual address
which is protected against stores.

B.3.B Addressing exception for access to instruction or
operand.

B.4. Protection exception (key-controlled protection) due
to attempt to access a protected instruction or
operand location.

Explanation:

Not applicable when not in the access-register mode; not
applicable for execution of TEST ACCESS and for translation of
operand address of LOAD REAL ADDRESS and TEST PROTECTION.

Not applicable when not in the access-register mode, except
applicable for execution of TEST ACCESS and, when PSW bits 16
and 17 are 1 binary, for translation of operand address of
LOAD REAL ADDRESS and second-operand address of STORE REAL
ADDRESS.

Not applicable when DAT is off except for translation of
second-operand address of STORE REAL ADDRESS; not applicable
to operand addresses of LOAD REAL ADDRESS and TEST PROTECTION.

Not applicable when DAT is off except for translation of
operand address of LOAD REAL ADDRESS and second-operand
address of STORE REAL ADDRESS.

Not applicable when DAT is off, except for execution of
INVALIDATE PAGE TABLE ENTRY and for translation of operand
address of LOAD REAL ADDRESS and second-operand address of
STORE REAL ADDRESS.

Not applicable when DAT is off.

For MOVE PAGE, if the condition is true for both operands, the
exception is recognized for the second operand. Also, if the
condition-code-option bit is one, the exception is not
recognized. Instead, condition code 1 is set if the condition
is true for only the first operand, or condition code 2 is set
if the condition is true for the second operand or both
operands.

Figure 6-7 (Part 3 of 3). Priority of Access Exceptions .

ASN-Translation Exceptions
The ASN-translation exceptions are those
exceptions which are common to the process of
translating an ASN in the instructions PROGRAM
RETURN, PROGRAM TRANSFER, and SET
SECONDARY ASN. The exceptions and the pri-
ority in which they are detected are shown in
Figure 6-8 on page 6-46.

Chapter 6. Interruptions 6-45



1. Addressing exception for access to ASN- A. Protection exception (low-address pro-
first-table entry. tection) due to entry address being in
the range -511 or 496-467.
2. AFX-translation exception due to I bit
(bit ) in ASN-first-table entry being B.1 Trace-table exception due to new entry
one. reaching or crossing next 4K-byte
boundary.
3. Addressing exception for access to ASN-
second-table entry. B.2 Addressing exception for access to
trace-table entry.
4. ASX-translation exception due to I bit
(bit ) in ASN-second-table entry being
one. Figure 6-10. Priority of Trace Exceptions

Figure 6-8. Priority of ASN-Translation Exceptions


Restart Interruption
Subspace-Replacement Exceptions The restart interruption provides a means for the
The subspace-replacement exceptions are those operator or another CPU to invoke the execution
exceptions which can be recognized during a of a specified program. The CPU cannot be disa-
subspace-replacement operation in PROGRAM bled for this interruption.
CALL, PROGRAM RETURN, PROGRAM
TRANSFER, or SET SECONDARY ASN. The A restart interruption causes the old PSW to be
exceptions and their priority are shown in stored at real locations 288-303 and a new PSW,
Figure 6-9. designating the start of the program to be exe-
cuted, to be fetched from real locations 416-431.
The instruction-length code and interruption code
1. Addressing exception for access to are not stored.
dispatchable-unit control table.
If the CPU is in the operating state, the exchange
2. Addressing exception for access to
subspace ASN-second-table entry. of the PSWs occurs at the completion of the
current unit of operation and after all other
3. ASTE-validity exception due to bit pending interruption conditions for which the CPU
being one in subspace ASN-second-table is enabled have been honored. If the CPU is in
entry. the stopped state, the CPU enters the operating

state and exchanges the PSWs without first hon-
4. ASTE-sequence exception due to subspace
ASN-second-table-entry sequence number oring any other pending interruptions.
in dispatchable-unit control table not
being equal to ASN-second-table-entry The restart interruption is initiated by activating the
sequence number in subspace ASN-second- restart key. The operation can also be initiated at
table entry. the addressed CPU by executing a SIGNAL
PROCESSOR instruction which specifies the
Figure 6-9. Priority of Subspace-Replacement restart order.
Exceptions
When the rate control is set to the instruction-step
Trace Exceptions position, it is unpredictable whether restart causes
The trace exceptions are those exceptions which a unit of operation or additional interruptions to be
can be encountered while forming a trace-table performed after the PSWs have been exchanged.
entry. The exceptions and their priority are shown Programming Note: To perform a restart when
in Figure 6-10. the CPU is in the check-stop state, the CPU has
to be reset. Resetting with loss of the least
amount of information can be accomplished by
means of the system-reset-normal key, which
does not clear the contents of program-
addressable registers, including the control regis-
ters, but causes the channel subsystem to be

6-46 z/Architecture Principles of Operation


reset. The CPU-reset SIGNAL PROCESSOR sonable attempt is made to limit the side effects of
order can be used to clear the CPU without an exigent machine-check condition, and requests
affecting the channel subsystem. for external, I/O, and restart interruptions normally
remain unaffected.

Supervisor-Call Interruption In the absence of an exigent machine-check con-


dition, interruption requests existing concurrently
The supervisor-call interruption occurs when the
at the end of a unit of operation are honored, in
instruction SUPERVISOR CALL is executed. The
descending order of priority, as follows:
CPU cannot be disabled for the interruption, and
the interruption occurs immediately upon the exe- Supervisor call
cution of the instruction. Program
Repressible machine check
The supervisor-call interruption causes the old External
PSW to be stored at real locations 320-335 and a Input/output
new PSW to be fetched from real locations Restart
448-463.
The processing of multiple simultaneous inter-
ruption requests consists in storing the old PSW
The contents of bit positions 8-15 of the SUPER-
and fetching the new PSW belonging to the inter-
VISOR CALL instruction are placed in the right-
ruption first honored. This new PSW is subse-
most byte of the interruption code. The leftmost
quently stored without the execution of any
byte of the interruption code is set to zero. The
instructions, and the new PSW associated with the
instruction-length code is 1, unless the instruction
next interruption is fetched. Storing and fetching
was executed by means of EXECUTE, in which
of PSWs continues until no more interruptions are
case the code is 2.
to be serviced. The priority is reevaluated after
The interruption code is placed at real locations each new PSW is loaded. Each evaluation takes
138-139; the instruction-length code is placed in into consideration any additional interruptions
bit positions 5 and 6 of the byte at real location which may have become pending. Additionally,
137, with the other bits set to zeros; and zeros are external and I/O interruptions, as well as machine-
stored at real location 136. check interruptions due to repressible conditions,
occur only if the current PSW at the instant of
evaluation indicates that the CPU is interruptible
Priority of Interruptions for the cause.

During the execution of an instruction, several Instruction execution is resumed using the last-
interruption-causing events may occur simultane- fetched PSW. The order of executing interruption
ously. The instruction may give rise to a program subroutines is, therefore, the reverse of the order
interruption, a request for an external interruption in which the PSWs are fetched.
may be received, equipment malfunctioning may
be detected, an I/O-interruption request may be If the new PSW for a program interruption does
made, and the restart key may be activated. not specify the wait state and has an odd instruc-
Instead of the program interruption, a supervisor- tion address, or causes an access exception to be
call interruption might occur; or both can occur if recognized, another program interruption occurs.
PER is active. Simultaneous interruption requests Since this second interruption introduces the same
are honored in a predetermined order. unacceptable PSW, a string of interruptions is
established. These program exceptions are
An exigent machine-check condition has the recognized as part of the execution of the fol-
highest priority. When it occurs, the current oper- lowing instruction, and the string may be broken
ation is terminated or nullified. Program and by an external, I/O, machine-check, or restart
supervisor-call interruptions that would have interruption or by the stop function.
occurred as a result of the current operation may
be eliminated. Any pending repressible machine- If the new PSW for a program interruption con-
check conditions may be indicated with the tains a one in bit position 12 or in an unassigned
exigent machine-check interruption. Every rea- bit position, if the leftmost 40 bits of the instruction

Chapter 6. Interruptions 6-47


address are not zeros when bit 31 and 32 indicate signed bit position, and the program new PSW is
24-bit addressing, or the leftmost 33 bits are not enabled for external interruptions, then a string of
zeros when bits 31 and 32 indicate 31-bit interruptions occurs, alternating between external
addressing, or if bit 32 is zero when bit 31 is one, and program. Even more complex strings of inter-
another program interruption occurs. This condi- ruptions are possible. As long as more inter-
tion is of higher priority than restart, I/O, external, ruptions must be serviced, the string of
or repressible machine-check conditions, or the interruptions cannot be broken by employing the
stop function, and CPU reset has to be used to stop function; CPU reset is required.
break the string of interruptions.
Similarly, CPU reset has to be invoked to termi-
A string of interruptions for other interruption nate the condition that exists when an interruption
classes can also exist if the new PSW allows the is attempted with a prefix value designating a
interruption which has just occurred. These storage location that is not available to the CPU.
include machine-check interruptions, external
interruptions, and I/O interruptions due to PCI con- Interruptions for all requests for which the CPU is
ditions generated because of CCWs which form a enabled occur before the CPU is placed in the
loop. Furthermore, a string of interruptions stopped state. When the CPU is in the stopped
involving more than one interruption class can state, restart has the highest priority.
exist. For example, assume that the CPU timer is Programming Note: The order in which concur-
negative and the CPU-timer subclass mask is one. rent interruption requests are honored can be
If the external new PSW has a one in an unas- changed to some extent by masking.

6-48 z/Architecture Principles of Operation


Chapter 7. General Instructions
Data Format . . . . . . . . . . . . . . . . . . . 7-2 CONVERT TO DECIMAL . . . . . . . . . . 7-70
Binary-Integer Representation . . . . . . . . . 7-2 CONVERT UNICODE TO UTF-8 . . . . . 7-71
Binary Arithmetic . . . . . . . . . . . . . . . . 7-3 CONVERT UTF-8 TO UNICODE . . . . . 7-74
Signed Binary Arithmetic . . . . . . . . . . 7-4 COPY ACCESS . . . . . . . . . . . . . . . 7-77
Addition and Subtraction . . . . . . . . . 7-4 DIVIDE . . . . . . . . . . . . . . . . . . . . 7-77
Fixed-Point Overflow . . . . . . . . . . . 7-4 DIVIDE LOGICAL . . . . . . . . . . . . . . 7-77
Unsigned Binary Arithmetic . . . . . . . . . 7-4 DIVIDE SINGLE . . . . . . . . . . . . . . . 7-78
Signed and Logical Comparison . . . . . . . . 7-5 EXCLUSIVE OR . . . . . . . . . . . . . . . 7-79
Instructions . . . . . . . . . . . . . . . . . . . . 7-6 EXECUTE . . . . . . . . . . . . . . . . . . . 7-80
ADD . . . . . . . . . . . . . . . . . . . . . . 7-16 EXTRACT ACCESS . . . . . . . . . . . . . 7-81
ADD HALFWORD . . . . . . . . . . . . . . 7-16 EXTRACT PSW . . . . . . . . . . . . . . . 7-81
ADD HALFWORD IMMEDIATE . . . . . . 7-16 INSERT CHARACTER . . . . . . . . . . . 7-81
ADD LOGICAL . . . . . . . . . . . . . . . . 7-17 INSERT CHARACTERS UNDER MASK . 7-81
ADD LOGICAL WITH CARRY . . . . . . . 7-17 INSERT IMMEDIATE . . . . . . . . . . . . 7-82
AND . . . . . . . . . . . . . . . . . . . . . . 7-18 INSERT PROGRAM MASK . . . . . . . . . 7-83
AND IMMEDIATE . . . . . . . . . . . . . . 7-19 LOAD . . . . . . . . . . . . . . . . . . . . . 7-83
BRANCH AND LINK . . . . . . . . . . . . . 7-19 LOAD ACCESS MULTIPLE . . . . . . . . . 7-84
BRANCH AND SAVE . . . . . . . . . . . . 7-20 LOAD ADDRESS . . . . . . . . . . . . . . 7-84
BRANCH AND SAVE AND SET MODE . 7-21 LOAD ADDRESS EXTENDED . . . . . . . 7-84
BRANCH AND SET MODE . . . . . . . . . 7-22 LOAD ADDRESS RELATIVE LONG . . . 7-85
BRANCH ON CONDITION . . . . . . . . . 7-23 LOAD AND TEST . . . . . . . . . . . . . . 7-86
BRANCH ON COUNT . . . . . . . . . . . . 7-24 LOAD COMPLEMENT . . . . . . . . . . . . 7-86
BRANCH ON INDEX HIGH . . . . . . . . . 7-24 LOAD HALFWORD . . . . . . . . . . . . . 7-87
BRANCH ON INDEX LOW OR EQUAL . . 7-25 LOAD HALFWORD IMMEDIATE . . . . . 7-87
BRANCH RELATIVE AND SAVE . . . . . 7-26 LOAD LOGICAL . . . . . . . . . . . . . . . 7-87
BRANCH RELATIVE AND SAVE LONG . 7-26 LOAD LOGICAL CHARACTER . . . . . . 7-87
BRANCH RELATIVE ON CONDITION . . 7-26 LOAD LOGICAL HALFWORD . . . . . . . 7-88
BRANCH RELATIVE ON CONDITION LOAD LOGICAL IMMEDIATE . . . . . . . 7-88
LONG . . . . . . . . . . . . . . . . . . . 7-26 LOAD LOGICAL THIRTY ONE BITS . . . 7-88
BRANCH RELATIVE ON COUNT . . . . . 7-27 LOAD MULTIPLE . . . . . . . . . . . . . . 7-88
BRANCH RELATIVE ON INDEX HIGH . . 7-28 LOAD MULTIPLE DISJOINT . . . . . . . . 7-89
BRANCH RELATIVE ON INDEX LOW LOAD MULTIPLE HIGH . . . . . . . . . . . 7-89
OR EQUAL . . . . . . . . . . . . . . . . 7-28 LOAD NEGATIVE . . . . . . . . . . . . . . 7-90
CHECKSUM . . . . . . . . . . . . . . . . . 7-29 LOAD PAIR FROM QUADWORD . . . . . 7-90
COMPARE . . . . . . . . . . . . . . . . . . 7-32 LOAD POSITIVE . . . . . . . . . . . . . . . 7-90
COMPARE AND FORM CODEWORD . . 7-33 LOAD REVERSED . . . . . . . . . . . . . . 7-91
COMPARE AND SWAP . . . . . . . . . . . 7-40 MONITOR CALL . . . . . . . . . . . . . . . 7-92
COMPARE DOUBLE AND SWAP . . . . . 7-40 MOVE . . . . . . . . . . . . . . . . . . . . . 7-93
COMPARE HALFWORD . . . . . . . . . . 7-42 MOVE INVERSE . . . . . . . . . . . . . . . 7-93
COMPARE HALFWORD IMMEDIATE . . 7-42 MOVE LONG . . . . . . . . . . . . . . . . . 7-94
COMPARE LOGICAL . . . . . . . . . . . . 7-42 MOVE LONG EXTENDED . . . . . . . . . 7-97
COMPARE LOGICAL CHARACTERS MOVE LONG UNICODE . . . . . . . . . 7-101
UNDER MASK . . . . . . . . . . . . . . 7-43 MOVE NUMERICS . . . . . . . . . . . . . 7-104
COMPARE LOGICAL LONG . . . . . . . . 7-44 MOVE STRING . . . . . . . . . . . . . . . 7-104
COMPARE LOGICAL LONG EXTENDED 7-46 MOVE WITH OFFSET . . . . . . . . . . . 7-106
COMPARE LOGICAL LONG UNICODE . 7-50 MOVE ZONES . . . . . . . . . . . . . . . 7-106
COMPARE LOGICAL STRING . . . . . . . 7-53 MULTIPLY . . . . . . . . . . . . . . . . . 7-107
COMPARE UNTIL SUBSTRING EQUAL . 7-54 MULTIPLY HALFWORD . . . . . . . . . 7-107
COMPRESSION CALL . . . . . . . . . . . 7-58 MULTIPLY HALFWORD IMMEDIATE . . 7-108
CONVERT TO BINARY . . . . . . . . . . . 7-69 MULTIPLY LOGICAL . . . . . . . . . . . 7-108

Copyright IBM Corp. 1990, 2000 7-1


MULTIPLY SINGLE . . . . . . . . . . . . 7-109 STORE HALFWORD . . . . . . . . . . . 7-141
OR . . . . . . . . . . . . . . . . . . . . . . 7-110 STORE MULTIPLE . . . . . . . . . . . . 7-141
OR IMMEDIATE . . . . . . . . . . . . . . 7-111 STORE MULTIPLE HIGH . . . . . . . . . 7-142
PACK . . . . . . . . . . . . . . . . . . . . 7-111 STORE PAIR TO QUADWORD . . . . . 7-142
PACK ASCII . . . . . . . . . . . . . . . . 7-112 STORE REVERSED . . . . . . . . . . . . 7-142
PACK UNICODE . . . . . . . . . . . . . . 7-113 SUBTRACT . . . . . . . . . . . . . . . . . 7-143
PERFORM LOCKED OPERATION . . . 7-114 SUBTRACT HALFWORD . . . . . . . . . 7-144
ROTATE LEFT SINGLE LOGICAL . . . 7-129 SUBTRACT LOGICAL . . . . . . . . . . . 7-144
SEARCH STRING . . . . . . . . . . . . . 7-130 SUBTRACT LOGICAL WITH BORROW .7-145
SET ACCESS . . . . . . . . . . . . . . . 7-131 SUPERVISOR CALL . . . . . . . . . . . 7-146
SET ADDRESSING MODE . . . . . . . . 7-131 TEST ADDRESSING MODE . . . . . . . 7-146
SET PROGRAM MASK . . . . . . . . . . 7-132 TEST AND SET . . . . . . . . . . . . . . 7-146
SHIFT LEFT DOUBLE . . . . . . . . . . . 7-132 TEST UNDER MASK (TEST UNDER
SHIFT LEFT DOUBLE LOGICAL . . . . 7-133 MASK HIGH, TEST UNDER MASK
SHIFT LEFT SINGLE . . . . . . . . . . . 7-134 LOW) . . . . . . . . . . . . . . . . . . 7-147
SHIFT LEFT SINGLE LOGICAL . . . . . 7-134 TRANSLATE . . . . . . . . . . . . . . . . 7-148
SHIFT RIGHT DOUBLE . . . . . . . . . . 7-135 TRANSLATE AND TEST . . . . . . . . . 7-149
SHIFT RIGHT DOUBLE LOGICAL . . . 7-135 TRANSLATE EXTENDED . . . . . . . . 7-150
SHIFT RIGHT SINGLE . . . . . . . . . . 7-136 TRANSLATE ONE TO ONE . . . . . . . 7-152
SHIFT RIGHT SINGLE LOGICAL . . . . 7-136 TRANSLATE ONE TO TWO . . . . . . . 7-152
STORE . . . . . . . . . . . . . . . . . . . 7-137 TRANSLATE TWO TO ONE . . . . . . . 7-152
STORE ACCESS MULTIPLE . . . . . . . 7-137 TRANSLATE TWO TO TWO . . . . . . . 7-153
STORE CHARACTER . . . . . . . . . . . 7-137 UNPACK . . . . . . . . . . . . . . . . . . 7-157
STORE CHARACTERS UNDER MASK .7-138 UNPACK ASCII . . . . . . . . . . . . . . 7-158
STORE CLOCK . . . . . . . . . . . . . . 7-138 UNPACK UNICODE . . . . . . . . . . . . 7-159
STORE CLOCK EXTENDED . . . . . . . 7-139 UPDATE TREE . . . . . . . . . . . . . . . 7-160

This chapter includes all the unprivileged unchanged, as in COMPARE or TRANSLATE


instructions described in this publication other than AND TEST, overlapping does not affect the exe-
the decimal and floating-point instructions. cution of the operation. For instructions such as
MOVE and TRANSLATE, one operand is replaced
by new data, and the execution of the operation
Data Format may be affected by the amount of overlap and the
manner in which data is fetched or stored. For
The general instructions treat data as being of four
purposes of evaluating the effect of overlapped
types: signed binary integers, unsigned binary
operands, data is considered to be handled one
integers, unstructured logical data, and decimal
eight-bit byte at a time. Special rules apply to the
data. Data is treated as decimal by the conver-
operands of MOVE LONG and MOVE INVERSE.
sion, packing, and unpacking instructions.
See Interlocks within a Single Instruction on
Decimal data is described in Chapter 8, Decimal
page 5-80 for how overlap is detected in the
Instructions.
access-register mode.
The general instructions manipulate data which
resides in general registers or in storage or is
introduced from the instruction stream. Some Binary-Integer Representation
general instructions operate on data which resides Binary integers are treated as signed or unsigned.
in the PSW or the TOD clock.
In an unsigned binary integer, all bits are used to
In a storage-and-storage operation the operand express the absolute value of the number. When
fields may be defined in such a way that they two unsigned binary integers of different lengths
overlap. The effect of this overlap depends upon are added, the shorter number is considered to be
the operation. When the operands remain extended on the left with zeros.

7-2 z/Architecture Principles of Operation


In some operations, the result is achieved by the The two's complement of the maximum negative
use of the one's complement of the number. The number cannot be represented in the same
one's complement of a number is obtained by number of bits. When an operation, such as
inverting each bit of the number, including the LOAD COMPLEMENT, attempts to produce the
sign. two's complement of the maximum negative
number, the result is the maximum negative
For signed binary integers, the leftmost bit repres- number, and a fixed-point-overflow exception is
ents the sign, which is followed by the numeric recognized. An overflow does not result, however,
field. Positive numbers are represented in true when the maximum negative number is comple-
binary notation with the sign bit set to zero. When mented as an intermediate result but the final
the value is zero, all bits are zeros, including the result is within the representable range. An
sign bit. Negative numbers are represented in example of this case is a subtraction of the
two's-complement binary notation with a one in maximum negative number from -1. The product
the sign-bit position. of two maximum negative numbers of a given
length is representable as a positive number of
Specifically, a negative number is represented by double that length.
the two's complement of the positive number of
the same absolute value. The two's complement In discussions of signed binary integers in this
of a number is obtained by forming the one's com- publication, a signed binary integer includes the
plement of the number, adding a value of one in sign bit. Thus, the expression 32-bit signed
the rightmost bit position, allowing a carry into the binary integer denotes an integer with 31 numeric
sign position, and ignoring any carry out of the bits and a sign bit, and the expression 64-bit
sign position. signed binary integer denotes an integer with 63
numeric bits and a sign bit.
This number representation can be considered the
rightmost portion of an infinitely long represen- In an arithmetic operation, a carry out of the
tation of the number. When the number is posi- numeric field of a signed binary integer is carried
tive, all bits to the left of the most significant bit of into the sign bit. However, in algebraic left-
the number are zeros. When the number is nega- shifting, the sign bit does not change even if sig-
tive, these bits are ones. Therefore, when a nificant numeric bits are shifted out.
signed operand must be extended with bits on the
left, the extension is achieved by setting these bits Programming Notes:
equal to the sign bit of the operand.
1. An alternate way of forming the two's comple-
ment of a signed binary integer is to invert all
The notation for signed binary integers does not
bits to the left of the rightmost one bit, leaving
include a negative zero. It has a number range in
the rightmost one bit and all zero bits to the
which, for a given length, the set of negative
right of it unchanged.
nonzero numbers is one larger than the set of
positive nonzero numbers. The maximum positive 2. The numeric bits of a signed binary integer
number consists of a sign bit of zero followed by may be considered to represent a positive
all ones, whereas the maximum negative number value, with the sign representing a value of
(the negative number with the greatest absolute either zero or the maximum negative number.
value) consists of a sign bit of one followed by all
zeros.
Binary Arithmetic
A signed binary integer of either sign, except for
Many of the instructions that perform a register-
zero and the maximum negative number, can be
and-storage or register-and-register binary-
changed to a number of the same magnitude but
arithmetic operation are provided in sets of three
opposite sign by forming its two's complement.
instructions corresponding to three different combi-
Forming the two's complement of a number is
nations of operand lengths. These three
equivalent to subtracting the number from zero.
instructions have the same name but different
The two's complement of zero is zero.
operation codes and mnemonics. For example,
ADD (A) operates on 32-bit operands and

Chapter 7. General Instructions 7-3


produces a 32-bit result, ADD (AG) operates on Fixed-Point Overflow
64-bit operands and produces a 64-bit result, and A fixed-point-overflow condition exists for signed
ADD (AGF) operates on a 64-bit operand and a binary addition or subtraction when the carry out
32-bit operand and produces a 64-bit result. The of the sign-bit position and the carry out of the left-
letter G alone in the mnemonic indicates a com- most numeric bit position disagree. Detection of
pletely 64-bit operation, and the letters GF indi- an overflow does not affect the result produced by
cate a 32-to-64-bit operation. the addition. In mathematical terms, signed addi-
tion and subtraction produce a fixed-point overflow
In a 32-to-64-bit operation, the intermediate result when the result is outside the range of represen-
is 64 bits. LOAD COMPLEMENT (LCGFR) forms tation for signed binary integers. Specifically, for
the two's complement of the maximum negative ADD (A) and SUBTRACT (S), which operate on
32-bit number without recognizing overflow. 32-bit signed binary integers, there is an overflow
when the proper result would be greater than or
A 32-bit operand in a general register is in bit equal to +2 or less than -2. The actual result
positions 32-63 of the register. In an operation on placed in the general register after an overflow
the operand, such as by ADD (A), bits 0-31 of the differs from the proper result by 2. A fixed-point
register are unused and remain unchanged. A overflow causes a program interruption if allowed
64-bit operand in a general register is in bit posi- by the program mask. Similarly, for ADD (AG)
tions 0-63 of the register, and all of the bits partic- and SUBTRACT (SG), which operate on 64-bit
ipate in an operation on the operand, such as by signed binary integers, there is an overflow when
ADD (AG). However, some instructions, which do the proper result would be greater than or equal to
not have G in their mnemonics, use a 64-bit +2 or less than -2, and the actual result
operand of which the leftmost 32 bits are in bit placed in the general register after an overflow
positions 32-63 of the even register of an differs from the proper result by 2. ADD (AGF)
even-odd general-register pair, and the rightmost and SUBTRACT (SGF) have the same 64-bit
32 bits are in bit positions 32-63 of the odd reg- result and overflow rules as ADD (AG) and SUB-
ister of the pair. TRACT (SG).
The bits of a 32-bit operand in storage are num- The instructions SHIFT LEFT SINGLE and SHIFT
bered 0-31. When the operand is in bit positions LEFT DOUBLE produce an overflow when the
32-63 of a general register, the bits are numbered result is outside the range of representation for
32-63. signed binary integers. The actual result differs
from that for addition and subtraction in that the
Signed Binary Arithmetic sign of the result remains the same as the original
sign.
Addition and Subtraction
Addition of signed binary integers is performed by Unsigned Binary Arithmetic
adding all bits of each operand, including the sign
bits. When one of the operands is shorter, the Addition of unsigned binary integers is performed
shorter operand is considered to be extended on by adding all bits of each operand. Subtraction is
the left to the length of the longer operand by performed by adding the one's complement of the
propagating the sign-bit value. second operand (the subtractor) and a value of
one to the first operand (the subtrahend). In any
For a 32-bit signed binary integer in a general reg- case, when one of the operands is shorter, the
ister, the sign bit is bit 32 of the register. For a shorter operand is considered to be extended on
64-bit signed binary integer in a general register, the left with zeros. During subtraction, this exten-
the sign bit is bit 0 of the register. sion applies before an operand is complemented,
and it applies to the value of one.
Subtraction is performed by adding the one's com-
plement of the second operand and a value of one Unsigned binary arithmetic is used in address
to the first operand. arithmetic for adding the X, B, and D fields. (See
Address Generation on page 5-7.) It is also
used to obtain the addresses of the function bytes

7-4 z/Architecture Principles of Operation


in TRANSLATE and TRANSLATE AND TEST. The condition code then indicates any over-
Furthermore, unsigned binary arithmetic is used flow or the proper sign and magnitude of the
on 32-bit or 64-bit unsigned binary integers by entire result; an overflow is also indicated by a
ADD LOGICAL, ADD LOGICAL WITH CARRY, program interruption for fixed-point overflow if
DIVIDE LOGICAL, MULTIPLY LOGICAL, SUB- allowed by the program mask. When ADD is
TRACT LOGICAL, and SUBTRACT LOGICAL used, a value of one must be added to the
WITH BORROW. sum of the highest-order parts if the condition
code indicated there was a carry from the
Given the same length operands, ADD (A, AG, addition of the next-lower parts.
AGF) and ADD LOGICAL (AL, ALG, ALGF)
2. Another use for ADD LOGICAL is to incre-
produce the same 32-bit or 64-bit result. The
ment values representing binary counters,
instructions differ only in the interpretation of this
which are allowed to wrap around from all
result. ADD interprets the result as a signed
ones to all zeros without indicating overflow.
binary integer and inspects it for sign, magnitude,
and overflow to set the condition code accordingly.
ADD LOGICAL interprets the result as an
unsigned binary integer and sets the condition
Signed and Logical Comparison
code according to whether the result is zero and Comparison operations determine whether two
whether there was a carry out of bit position 32, operands are equal or not and, for most oper-
for a 32-bit integer, or out of bit position 0 for a ations, which of two unequal operands is the
64-bit integer. Such a carry is not considered an greater (high). Signed-binary-comparison oper-
overflow, and no program interruption for overflow ations are provided which treat the operands as
can occur for ADD LOGICAL. signed binary integers, and logical-comparison
operations are provided which treat the operands
SUBTRACT LOGICAL differs from ADD LOGICAL as unsigned binary integers or as unstructured
in that the one's complement of the second data.
operand and a value of one are added to the first
operand. COMPARE (C, CG, CGF) and COMPARE
HALFWORD are signed-binary-comparison oper-
For ADD LOGICAL WITH CARRY, a carry from a ations. These instructions are equivalent to SUB-
previous operation is represented by a one value TRACT (S, SG, SGF) and SUBTRACT
of bit 18 of the current PSW. Bit 18 is the leftmost HALFWORD without replacing either operand, the
bit of the two-bit condition code in the PSW. For resulting difference being used only to set the con-
SUBTRACT LOGICAL WITH BORROW, a borrow dition code. The operations permit comparison of
from a previous operation is represented by a zero numbers of opposite sign which differ by 2 or
value of bit 18. A borrow is equivalent to the more. Thus, unlike SUBTRACT, COMPARE
absence of a carry. cannot cause overflow.

Programming Notes: Logical comparison of two operands is performed


1. Logical addition and subtraction may be used byte by byte, in a left-to-right sequence. The
to perform arithmetic on multiple-precision operands are equal when all their bytes are equal.
binary-integer operands. Thus, for multiple- When the operands are unequal, the comparison
precision addition, ADD LOGICAL can be result is determined by a left-to-right comparison
used to add the lowest-order corresponding of corresponding bit positions in the first unequal
parts of the operands, and ADD LOGICAL pair of bytes: the zero bit in the first unequal pair
WITH CARRY can be used to add the other of bits indicates the low operand, and the one bit
corresponding parts of the operands, moving the high operand. Since the remaining bit and
from right to left in the operands. If the byte positions do not change the comparison, it is
multiple-precision operands are signed, ADD not necessary to continue comparing unequal
should be used on the highest-order parts. operands beyond the first unequal bit pair.

Chapter 7. General Instructions 7-5


Programming Notes:
Instructions
1. Trimodal addressing affects the general
The general instructions and their mnemonics, instructions only in the manner in which logical
formats, and operation codes are listed in storage addresses are handled, except as
Figure 7-1 on page 7-8. The figure also indicates follows.
which instructions are new in z/Architecture as
compared to ESA/390, when the condition code is The instructions BRANCH AND LINK (BAL,
set, the instruction fields that designate access BALR), BRANCH AND SAVE (BAS, BASR),
registers, and the exceptional conditions in BRANCH AND SAVE AND SET MODE,
operand designations, data, or results that cause BRANCH AND SET MODE, BRANCH RELA-
a program interruption. TIVE AND SAVE, and BRANCH RELATIVE
AND SAVE LONG place information in bit
The instructions that are new in z/Architecture are positions 32-39 of general register R as in
indicated in Figure 7-1 by N. A few of the ESA/390 in the 24-bit or 31-bit addressing
instructions that are new in z/Architecture have mode or place address bits in those bit posi-
also been added to ESA/390, and these are indi- tions in the 64-bit addressing mode.
cated by N3. The instructions BRANCH AND SAVE AND
SET MODE and BRANCH AND SET MODE
When the operands of an instruction are 32-bit
place a zero in bit position 63 of general reg-
operands, the mnemonic for the instruction does
ister R in the 24-bit or 31-bit addressing
not include a letter indicating the operand length.
mode or place a one in that bit position in the
If there is an instruction with the same name but
64-bit addressing mode.
with 64-bit operands, its mnemonic includes the
letter G. If there is an instruction with the same The following instructions leave bits 0-31 of a
name but with a 64-bit first operand and a 32-bit general register unchanged in the 24-bit or
second operand, its mnemonic includes the letters 31-bit addressing mode but place or update
GF. In Figure 7-1, when there is an instruction address or length information in them in the
with 32-bit operands and other instructions with 64-bit addressing mode:
the same name but with G or GF added in their BRANCH AND LINK (BAL, BALR)
mnemonics, the first instruction has (32) after its BRANCH AND SAVE (BAS, BASR)
name, and the other instructions have (64) or BRANCH AND SAVE AND SET MODE
(64<32), respectively, after their names. Some BRANCH RELATIVE AND SAVE
32-bit operand-length instructions do not have BRANCH RELATIVE AND SAVE LONG
64-bit operand-length counterparts, and they do CHECKSUM
not have (32) after their names. However, all COMPARE AND FORM CODEWORD
instructions for multiplication or division are COMPARE LOGICAL LONG
marked to show, or approximately show, operand COMPARE LOGICAL LONG EXTENDED
lengths. COMPARE LOGICAL STRING
COMPARE UNTIL SUBSTRING EQUAL
A detailed definition of instruction formats,
COMPRESSION CALL
operand designation and length, and address gen-
CONVERT UNICODE TO UTF-8
eration is contained in Instructions on page 5-2.
CONVERT UTF-8 TO UNICODE
Exceptions to the general rules stated in that
LOAD ADDRESS
section are explicitly identified in the individual
LOAD ADDRESS EXTENDED
instruction descriptions.
LOAD ADDRESS RELATIVE LONG
Note: In the detailed descriptions of the indi- MOVE LONG
vidual instructions, the mnemonic and the sym- MOVE LONG EXTENDED
bolic operand designations for the assembler MOVE STRING
language are shown with each instruction. For SEARCH STRING
LOAD AND TEST with 32-bit operands, for TRANSLATE EXTENDED
example, LTR is the mnemonic and R,R the TRANSLATE AND TEST
operand designation. UPDATE TREE

7-6 z/Architecture Principles of Operation


The instructions in the preceding list are INSERT IMMEDIATE (IIHH, IIHL only)
sometimes called modal instructions. LOAD LOGICAL IMMEDIATE
LOAD MULTIPLE DISJOINT
2. Bits 0-31 of general registers are changed by
LOAD MULTIPLE HIGH
two types of instructions. The first type is a
LOAD PAIR FROM QUADWORD
modal instruction, as listed in the preceding
OR IMMEDIATE (OIHH, OIHL only)
note, when the instruction is executed in the
64-bit addressing mode. The second type is All of the instructions of the second type are
an instruction having, independent of the sometimes referred to as G-type instructions.
addressing mode, either a 64-bit result
If a program is not executed in the 64-bit
operand in a single general register or a
addressing mode and does not contain a
128-bit result operand in an even-odd general-
G-type instruction, it cannot change bits 0-31
register pair.
of any general register.
Most of the instructions of the second type are
3. It is not intended or expected that old pro-
indicated by a G, either alone or in GF, in
grams not containing G-type instructions will
their mnemonics. The other instructions that
be able to be executed successfully in the
change or may change bits 0-31 of a general
64-bit addressing mode. However, this may
register regardless of the current addressing
be possible, particularly if, by programming
mode are:
convention, bits 0-31 of the general registers
AND IMMEDIATE (NIHH, NIHL only) are always all zeros when an old program is
INSERT CHARACTERS UNDER MASK given control.
(ICMH only)

Chapter 7. General Instructions 7-7



Mne- Op
Name monic Characteristics Code

ADD (32) AR RR C IF 1A
ADD (64) AGR RRE C N IF B98
ADD (64<32) AGFR RRE C N IF B918
ADD (32) A RX C A IF B5A
ADD (64) AG RXE C N A IF BE38

ADD (64<32) AGF RXE C N A IF BE318


ADD HALFWORD AH RX C A IF B4A
ADD HALFWORD IMMEDIATE (32) AHI RI C IF A7A
ADD HALFWORD IMMEDIATE (64) AGHI RI C N IF A7B
ADD LOGICAL (32) ALR RR C 1E

ADD LOGICAL (64) ALGR RRE C N B9A


ADD LOGICAL (64<32) ALGFRRRE C N B91A
ADD LOGICAL (32) AL RX C A B5E
ADD LOGICAL (64) ALG RXE C N A BE3A
ADD LOGICAL (64<32) ALGF RXE C N A BE31A

ADD LOGICAL WITH CARRY (32) ALCR RRE C N3 B998


ADD LOGICAL WITH CARRY (64) ALCGRRRE C N B988
ADD LOGICAL WITH CARRY (32) ALC RXE C N3 A BE398
ADD LOGICAL WITH CARRY (64) ALCG RXE C N A BE388
AND (32) NR RR C 14

AND (64) NGR RRE C N B98


AND (32) N RX C A B54
AND (64) NG RXE C N A BE38
AND (character) NC SS C A STB BD4
AND (immediate) NI SI C A STB 94

AND IMMEDIATE (high high) NIHH RI C N A54


AND IMMEDIATE (high low) NIHL RI C N A55
AND IMMEDIATE (low high) NILH RI C N A56
AND IMMEDIATE (low low) NILL RI C N A57
BRANCH AND LINK BALR RR T B 5

BRANCH AND LINK BAL RX B 45


BRANCH AND SAVE BASR RR T B D
BRANCH AND SAVE BAS RX B 4D
BRANCH AND SAVE AND SET MODE BASSMRR T B C
BRANCH AND SET MODE BSM RR T B B

BRANCH ON CONDITION BCR RR B 7


BRANCH ON CONDITION BC RX B 47
BRANCH ON COUNT (32) BCTR RR B 6
BRANCH ON COUNT (64) BCTGRRRE N B B946
BRANCH ON COUNT (32) BCT RX B 46

BRANCH ON COUNT (64) BCTG RXE N B E346


BRANCH ON INDEX HIGH (32) BXH RS B 86
BRANCH ON INDEX HIGH (64) BXHG RSE N B EB44
BRANCH ON INDEX LOW OR EQUAL (32) BXLE RS B 87
BRANCH ON INDEX LOW OR EQUAL (64) BXLEGRSE N B EB45

Figure 7-1 (Part 1 of 8). Summary of General Instructions

7-8 z/Architecture Principles of Operation



Mne- Op
Name monic Characteristics Code

BRANCH RELATIVE AND SAVE BRAS RI B A75


BRANCH RELATIVE AND SAVE LONG BRASLRIL N3 B C5
BRANCH RELATIVE ON CONDITION BRC RI B A74
BRANCH RELATIVE ON CONDITION LONG BRCL RIL N3 B C4
BRANCH RELATIVE ON COUNT (32) BRCT RI B A76

BRANCH RELATIVE ON COUNT (64) BRCTGRI N B A77


BRANCH RELATIVE ON INDEX HIGH (32) BRXH RSI B 84
BRANCH RELATIVE ON INDEX HIGH (64) BRXHGRIE N B EC44
BRANCH RELATIVE ON INDEX L OR E (32)BRXLERSI B 85
BRANCH RELATIVE ON INDEX L OR E (64)BRXLGRIE N B EC45

CHECKSUM CKSM RRE C A SP RB241


COMPARE (32) CR RR C 19
COMPARE (64) CGR RRE C N B92
COMPARE (64<32) CGFR RRE C N B93
COMPARE (32) C RX C A B59

COMPARE (64) CG RXE C N A BE32


COMPARE (64<32) CGF RXE C N A BE33
COMPARE AND FORM CODEWORD CFC S C A SPII GM I1 B21A
COMPARE AND SWAP (32) CS RS C A SP $ ST BBA
COMPARE AND SWAP (64) CSG RSE C N A SP $ ST BEB3

COMPARE DOUBLE AND SWAP (32) CDS RS C A SP $ ST BBB


COMPARE DOUBLE AND SWAP (64) CDSG RSE C N A SP $ ST BEB3E
COMPARE HALFWORD CH RX C A B49
COMPARE HALFWORD IMMEDIATE (32) CHI RI C A7E
COMPARE HALFWORD IMMEDIATE (64) CGHI RI C N A7F

COMPARE LOGICAL (32) CLR RR C 15


COMPARE LOGICAL (64) CLGR RRE C N B921
COMPARE LOGICAL (64<32) CLGFRRRE C N B931
COMPARE LOGICAL (32) CL RX C A B55
COMPARE LOGICAL (64) CLG RXE C N A BE321

COMPARE LOGICAL (64<32) CLGF RXE C N A BE331


COMPARE LOGICAL (character) CLC SS C A B BD5
COMPARE LOGICAL (immediate) CLI SI C A B 95
COMPARE LOGICAL C. UNDER MASK (high)CLMH RSE C N A BEB2
COMPARE LOGICAL C. UNDER MASK (low) CLM RS C A BBD

COMPARE LOGICAL LONG CLCL RR C A SPII R RF


COMPARE LOGICAL LONG EXTENDED CLCLERS C A SP R RA9
COMPARE LOGICAL LONG UNICODE CLCLURSE C E2 A SP R REB8F
COMPARE LOGICAL STRING CLST RRE C A SP G R RB25D
COMPARE UNTIL SUBSTRING EQUAL CUSE RRE C A SPII GM R RB257

Figure 7-1 (Part 2 of 8). Summary of General Instructions

Chapter 7. General Instructions 7-9



Mne- Op
Name monic Characteristics Code

CONVERT TO BINARY (32) CVB RX A Dd IK B4F


COMPRESSION CALL CMPSCRRE C A SPII D GM STR RB263
CONVERT TO BINARY (64) CVBG RXE N A Dd IK BE3E
CONVERT TO DECIMAL (32) CVD RX A ST B4E
CONVERT TO DECIMAL (64) CVDG RXE N A ST BE32E

CONVERT UNICODE TO UTF-8 CUUTFRRE C A SP STR RB2A6


CONVERT UTF-8 TO UNICODE CUTFURRE C A SP STR RB2A7
COPY ACCESS CPYA RRE U UB24D
DIVIDE (32<64) DR RR SP IK 1D
DIVIDE (32<64) D RX A SP IK B5D

DIVIDE LOGICAL (32<64) DLR RRE N3 SP IK B997


DIVIDE LOGICAL (64<128) DLGR RRE N SP IK B987
DIVIDE LOGICAL (32<64) DL RXE N3 A SP IK BE397
DIVIDE LOGICAL (64<128) DLG RXE N A SP IK BE387
DIVIDE SINGLE (64) DSGR RRE N SP IK B9D

DIVIDE SINGLE (64<32) DSGFRRRE N SP IK B91D


DIVIDE SINGLE (64) DSG RXE N A SP IK BE3D
DIVIDE SINGLE (64<32) DSGF RXE N A SP IK BE31D
EXCLUSIVE OR (32) XR RR C 17
EXCLUSIVE OR (64) XGR RRE C N B982

EXCLUSIVE OR (32) X RX C A B57


EXCLUSIVE OR (64) XG RXE C N A BE382
EXCLUSIVE OR (character) XC SS C A STB BD7
EXCLUSIVE OR (immediate) XI SI C A STB 97
EXECUTE EX RX AI SP EX 44

EXTRACT ACCESS EAR RRE UB24F


EXTRACT PSW EPSW RRE N3 B98D
INSERT CHARACTER IC RX A B43
INSERT CHARACTERS UNDER MASK (high) ICMH RSE C N A BEB8
INSERT CHARACTERS UNDER MASK (low) ICM RS C A BBF

INSERT IMMEDIATE (high high) IIHH RI N A5


INSERT IMMEDIATE (high low) IIHL RI N A51
INSERT IMMEDIATE (low high) IILH RI N A52
INSERT IMMEDIATE (low low) IILL RI N A53
INSERT PROGRAM MASK IPM RRE B222

LOAD (32) LR RR 18
LOAD (64) LGR RRE N B94
LOAD (64<32) LGFR RRE N B914
LOAD (32) L RX A B58
LOAD (64) LG RXE N A BE34

LOAD (64<32) LGF RXE N A BE314


LOAD ACCESS MULTIPLE LAM RS A SP UB9A
LOAD ADDRESS LA RX 41
LOAD ADDRESS EXTENDED LAE RX U BP51
LOAD ADDRESS RELATIVE LONG LARL RIL N3 C

Figure 7-1 (Part 3 of 8). Summary of General Instructions

7-10 z/Architecture Principles of Operation



Mne- Op
Name monic Characteristics Code

LOAD AND TEST (32) LTR RR C 12


LOAD AND TEST (64) LTGR RRE C N B92
LOAD AND TEST (64<32) LTGFRRRE C N B912
LOAD COMPLEMENT (32) LCR RR C IF 13
LOAD COMPLEMENT (64) LCGR RRE C N IF B93

LOAD COMPLEMENT (64<32) LCGFRRRE C N IF B913


LOAD HALFWORD (32) LH RX A B48
LOAD HALFWORD (64) LGH RXE N A BE315
LOAD HALFWORD IMMEDIATE (32) LHI RI A78
LOAD HALFWORD IMMEDIATE (64) LGHI RI N A79

LOAD LOGICAL (64<32) LLGFRRRE N B916


LOAD LOGICAL (64<32) LLGF RXE N A BE316
LOAD LOGICAL CHARACTER LLGC RXE N A BE39
LOAD LOGICAL HALFWORD LLGH RXE N A BE391
LOAD LOGICAL IMMEDIATE (high high) LLIHHRI N A5C

LOAD LOGICAL IMMEDIATE (high low) LLIHLRI N A5D


LOAD LOGICAL IMMEDIATE (low high) LLILHRI N A5E
LOAD LOGICAL IMMEDIATE (low low) LLILLRI N A5F
LOAD LOGICAL THIRTY ONE BITS LLGTRRRE N B917
LOAD LOGICAL THIRTY ONE BITS LLGT RXE N A BE317

LOAD MULTIPLE (32) LM RS A B98


LOAD MULTIPLE (64) LMG RSE N A BEB4
LOAD MULTIPLE DISJOINT LMD SS N A B BEF
LOAD MULTIPLE HIGH LMH RSE N A BEB96
LOAD NEGATIVE (32) LNR RR C 11

LOAD NEGATIVE (64) LNGR RRE C N B91


LOAD NEGATIVE (64<32) LNGFRRRE C N B911
LOAD PAIR FROM QUADWORD LPQ RXE N A SP BE38F
LOAD POSITIVE (32) LPR RR C IF 1
LOAD POSITIVE (64) LPGR RRE C N IF B9

LOAD POSITIVE (64<32) LPGFRRRE C N IF B91


LOAD REVERSED (32) LRVR RRE N3 B91F
LOAD REVERSED (64) LRVGRRRE N B9F
LOAD REVERSED (16) LRVH RXE N3 A BE31F
LOAD REVERSED (32) LRV RXE N3 A BE31E

LOAD REVERSED (64) LRVG RXE N A BE3F


MONITOR CALL MC SI SP MO AF
MOVE (character) MVC SS A STB BD2
MOVE (immediate) MVI SI A STB 92
MOVE INVERSE MVCINSS A STB BE8

MOVE LONG MVCL RR C A SPII STR RE


MOVE LONG EXTENDED MVCLERS C A SP STR RA8
MOVE LONG UNICODE MVCLURSE C E2 A SP STR REB8E
MOVE NUMERICS MVN SS A STB BD1
MOVE STRING MVST RRE C A SP G STR RB255

Figure 7-1 (Part 4 of 8). Summary of General Instructions

Chapter 7. General Instructions 7-11



Mne- Op
Name monic Characteristics Code

MOVE WITH OFFSET MVO SS A STB BF1


MOVE ZONES MVZ SS A STB BD3
MULTIPLY (64<32) MR RR SP 1C
MULTIPLY (64<32) M RX A SP B5C
MULTIPLY HALFWORD (32) MH RX A B4C

MULTIPLY HALFWORD IMMEDIATE (32) MHI RI A7C


MULTIPLY HALFWORD IMMEDIATE (64) MGHI RI N A7D
MULTIPLY LOGICAL (64<32) MLR RRE N3 SP B996
MULTIPLY LOGICAL (128<64) MLGR RRE N SP B986
MULTIPLY LOGICAL (64<32) ML RXE N3 A SP BE396

MULTIPLY LOGICAL (128<64) MLG RXE N A SP BE386


MULTIPLY SINGLE (32) MSR RRE B252
MULTIPLY SINGLE (64) MSGR RRE N B9C
MULTIPLY SINGLE (64<32) MSGFRRRE N B91C
MULTIPLY SINGLE (32) MS RX A B71

MULTIPLY SINGLE (64) MSG RXE N A BE3C


MULTIPLY SINGLE (64<32) MSGF RXE N A BE31C
OR (32) OR RR C 16
OR (64) OGR RRE C N B981
OR (32) O RX C A B56

OR (64) OG RXE C N A BE381


OR (character) OC SS C A STB BD6
OR (immediate) OI SI C A STB 96
OR IMMEDIATE (high high) OIHH RI C N A58
OR IMMEDIATE (high low) OIHL RI C N A59

OR IMMEDIATE (low high) OILH RI C N A5A


OR IMMEDIATE (low low) OILL RI C N A5B
PACK PACK SS A STB BF2
PACK ASCII PKA SS E2 A SP STB BE9
PACK UNICODE PKU SS E2 A SP STB BE1

PERFORM LOCKED OPERATION PLO SS C A SP $ GM ST FCEE


ROTATE LEFT SINGLE LOGICAL (32) RLL RSE N3 EB1D
ROTATE LEFT SINGLE LOGICAL (64) RLLG RSE N EB1C
SEARCH STRING SRST RRE C A SP G RB25E
SET ACCESS SAR RRE U B24E

SET ADDRESSING MODE (24) SAM24E N3 SP T 1C


SET ADDRESSING MODE (31) SAM31E N3 SP T 1D
SET ADDRESSING MODE (64) SAM64E N T 1E
SET PROGRAM MASK SPM RR L 4
SHIFT LEFT DOUBLE SLDA RS C SP IF 8F

SHIFT LEFT DOUBLE LOGICAL SLDL RS SP 8D


SHIFT LEFT SINGLE (32) SLA RS C IF 8B
SHIFT LEFT SINGLE (64) SLAG RSE C N IF EBB
SHIFT LEFT SINGLE LOGICAL (32) SLL RS 89
SHIFT LEFT SINGLE LOGICAL (64) SLLG RSE N EBD

Figure 7-1 (Part 5 of 8). Summary of General Instructions

7-12 z/Architecture Principles of Operation



Mne- Op
Name monic Characteristics Code

SHIFT RIGHT DOUBLE SRDA RS C SP 8E


SHIFT RIGHT DOUBLE LOGICAL SRDL RS SP 8C
SHIFT RIGHT SINGLE (32) SRA RS C 8A
SHIFT RIGHT SINGLE (64) SRAG RSE C N EBA
SHIFT RIGHT SINGLE LOGICAL (32) SRL RS 88

SHIFT RIGHT SINGLE LOGICAL (64) SRLG RSE N EBC


STORE (32) ST RX A ST B5
STORE (64) STG RXE N A ST BE324
STORE ACCESS MULTIPLE STAM RS A SP ST UB9B
STORE CHARACTER STC RX A ST B42

STORE CHARACTERS UNDER MASK (high) STCMHRSE N A ST BEB2C


STORE CHARACTERS UNDER MASK (low) STCM RS A ST BBE
STORE CLOCK STCK S C A $ ST BB25
STORE CLOCK EXTENDED STCKES C A $ ST BB278
STORE HALFWORD STH RX A ST B4

STORE MULTIPLE (32) STM RS A ST B9


STORE MULTIPLE (64) STMG RSE N A ST BEB24
STORE MULTIPLE HIGH STMH RSE N A ST BEB26
STORE PAIR TO QUADWORD STPQ RXE N A SP ST BE38E
STORE REVERSED (16) STRVHRXE N3 A ST BE33F

STORE REVERSED (32) STRV RXE N3 A ST BE33E


STORE REVERSED (64) STRVGRXE N A ST BE32F
SUBTRACT (32) SR RR C IF 1B
SUBTRACT (64) SGR RRE C N IF B99
SUBTRACT (64<32) SGFR RRE C N IF B919

SUBTRACT (32) S RX C A IF B5B


SUBTRACT (64) SG RXE C N A IF BE39
SUBTRACT (64<32) SGF RXE C N A IF BE319
SUBTRACT HALFWORD SH RX C A IF B4B
SUBTRACT LOGICAL (32) SLR RR C 1F

SUBTRACT LOGICAL (64) SLGR RRE C N B9B


SUBTRACT LOGICAL (64<32) SLGFRRRE C N B91B
SUBTRACT LOGICAL (32) SL RX C A B5F
SUBTRACT LOGICAL (64) SLG RXE C N A BE3B
SUBTRACT LOGICAL (64<32) SLGF RXE C N A BE31B

SUBTRACT LOGICAL WITH BORROW (32) SLBR RRE C N3 B999


SUBTRACT LOGICAL WITH BORROW (64) SLBGRRRE C N B989
SUBTRACT LOGICAL WITH BORROW (32) SLB RXE C N3 A BE399
SUBTRACT LOGICAL WITH BORROW (64) SLBG RXE C N A BE389
SUPERVISOR CALL SVC RR A

TEST ADDRESSING MODE TAM E C N3 1B


TEST AND SET TS S C A $ ST B93
TEST UNDER MASK TM SI C A B 91
TEST UNDER MASK (high high) TMHH RI C N A72
TEST UNDER MASK (high low) TMHL RI C N A73

Figure 7-1 (Part 6 of 8). Summary of General Instructions

Chapter 7. General Instructions 7-13



Mne- Op
Name monic Characteristics Code

TEST UNDER MASK (low high) TMLH RI C A7


TEST UNDER MASK (low low) TMLL RI C A71
TEST UNDER MASK HIGH TMH RI C A7
TEST UNDER MASK LOW TML RI C A71
TRANSLATE TR SS A STB BDC

TRANSLATE AND TEST TRT SS C A GM B BDD


TRANSLATE EXTENDED TRE RRE C A SP STR RB2A5
TRANSLATE ONE TO ONE TROO RRE C E2 A SP GM STRM RB993
TRANSLATE ONE TO TWO TROT RRE C E2 A SP GM STRM RB992
TRANSLATE TWO TO ONE TRTO RRE C E2 A SP GM STRM RB991

TRANSLATE TWO TO TWO TRTT RRE C E2 A SP GM STRM RB99


UNPACK UNPK SS A STB BF3
UNPACK ASCII UNPKASS C E2 A SP STB BEA
UNPACK UNICODE UNPKUSS C E2 A SP STB BE2
UPDATE TREE UPT E C A SPII GM STI4 12

Explanation:

Causes serialization and checkpoint synchronization.
Causes serialization and checkpoint synchronization when the M and R fields contain all
ones and all zeros, respectively.
$ Causes serialization.
A Access exceptions for logical addresses.
A Access exceptions; not all access exceptions may occur; see instruction description for
details.
AI Access exceptions for instruction address.
B PER branch event.
B B field designates an access register in the access-register mode.
B B field designates an access register in the access-register mode.
BP B field designates an access register when PSW bits 16 and 17 have the value 1 binary.
C Condition code is set.
Dd Decimal-operand data exception.
E E instruction format.
E2 Extended-translation facility 2.
EX Execute exception.
FC Designation of access registers depends on the function code of the instruction.
G Instruction execution includes the implied use of general register .
GM Instruction execution includes the implied use of multiple general registers:
General registers 1, 2, and 3 for COMPARE AND FORM CODEWORD.
General registers and 1 for COMPARE UNTIL SUBSTRING EQUAL and PERFORM LOCKED
OPERATION.
General registers and 1 for COMPRESSION CALL, TRANSLATE ONE TO ONE, TRANSLATE ONE
TO TWO, TRANSLATE TWO TO ONE, and TRANSLATE TWO TO TWO
General registers 1 and 2 for TRANSLATE AND TEST.
General registers -5 for UPDATE TREE.
IF Fixed-point-overflow exception.
II Interruptible instruction.
IK Fixed-point-divide exception.
I1 Access register 1 is implicitly designated in the access-register mode.
I2 Access register 2 is implicitly designated in the access-register mode.
I4 Access register 4 is implicitly designated in the access-register mode.
L New condition code is loaded.

Figure 7-1 (Part 7 of 8). Summary of General Instructions

7-14 z/Architecture Principles of Operation



Explanation (Continued):

MO Monitor event.
N Instruction is new in z/Architecture as compared to ESA/39.
N3 Instruction is new in z/Architecture and has been added to ESA/39.
R R field designates an access register in the access-register mode.
R R field designates an access register in the access-register mode.
R R field designates an access register in the access-register mode.
RI RI instruction format.
RIE RIE instruction format.
RIL RIL instruction format.
RR RR instruction format.
RRE RRE instruction format.
RS RS instruction format.
RSE RSE instruction format.
RSI RSI instruction format.
RX RX instruction format.
RXE RXE instruction format.
S S instruction format.
SI SI instruction format.
SP Specification exception.
SS SS instruction format.
ST PER storage-alteration event.
T Trace exceptions (includes trace table, addressing, and low-address protection).
U R field designates an access register unconditionally.
U R field designates an access register unconditionally.
UB R and R fields designate access registers unconditionally, and B field
designates an access register in the access-register mode.

Figure 7-1 (Part 8 of 8). Summary of General Instructions

Chapter 7. General Instructions 7-15


ADD condition code 3 is set. If the fixed-point-overflow
mask is one, a program interruption for fixed-point
AR R,R [RR] overflow occurs.

Resulting Condition Code:


'1A' R R
0 Result zero; no overflow
8 12 15 1 Result less than zero; no overflow
2 Result greater than zero; no overflow
AGR R,R [RRE] 3 Overflow

Program Exceptions:
'B98' //////// R R
Access (fetch, operand 2 of A, AG, and AGF
16 24 28 31 only)
Fixed-point overflow
AGFR R,R [RRE]
ADD HALFWORD

'B918' //////// R R AH R,D(X,B) [RX]

16 24 28 31
'4A' R X B D
A R,D(X,B) [RX]
8 12 16 2 31

'5A' R X B D
ADD HALFWORD IMMEDIATE
8 12 16 2 31
AHI R,I [RI]
AG R,D(X,B) [RXE]

/ 'A7' R 'A' I
'E3' R X B D //////// '8'
/ 8 12 16 31
8 12 16 2 32 4 47
AGHI R,I [RI]
AGF R,D(X,B) [RXE]

/ 'A7' R 'B' I
'E3' R X B D //////// '18'
/ 8 12 16 31
8 12 16 2 32 4 47
The second operand is added to the first operand,
The second operand is added to the first operand, and the sum is placed at the first-operand
and the sum is placed at the first-operand location. The second operand is two bytes in
location. For ADD (AR, A), the operands and the length and is treated as a 16-bit signed binary
sum are treated as 32-bit signed binary integers. integer. For ADD HALFWORD and ADD
For ADD (AGR, AG), they are treated as 64-bit HALFWORD IMMEDIATE (AHI), the first operand
signed binary integers. For ADD (AGFR, AGF), and the sum are treated as 32-bit signed binary
the second operand is treated as a 32-bit signed integers. For ADD HALFWORD IMMEDIATE
binary integer, and the first operand and the sum (AGHI), they are treated as 64-bit signed binary
are treated as 64-bit signed binary integers. integers.

When there is an overflow, the result is obtained When there is an overflow, the result is obtained
by allowing any carry into the sign-bit position and by allowing any carry into the sign-bit position and
ignoring any carry out of the sign-bit position, and ignoring any carry out of the sign-bit position, and

7-16 z/Architecture Principles of Operation


condition code 3 is set. If the fixed-point-overflow ALGF R,D(X,B) [RXE]
mask is one, a program interruption for fixed-point
overflow occurs. /
'E3' R X B D //////// '1A'
/
Resulting Condition Code: 8 12 16 2 32 4 47
0 Result zero; no overflow
1 Result less than zero; no overflow The second operand is added to the first operand,
2 Result greater than zero; no overflow and the sum is placed at the first-operand
3 Overflow location. For ADD LOGICAL (ALR, AL), the oper-
ands and the sum are treated as 32-bit unsigned
Program Exceptions: binary integers. For ADD LOGICAL (ALGR, ALG),
Access (fetch, operand 2 of AH only) they are treated as 64-bit unsigned binary inte-
Fixed-point overflow gers. For ADD LOGICAL (ALGFR, ALGF) the
second operand is treated as a 32-bit unsigned
Programming Note: An example of the use of binary integer, and the first operand and the sum
the ADD HALFWORD instruction is given in are treated as 64-bit unsigned binary integers.
Appendix A, Number Representation and
Instruction-Use Examples. Resulting Condition Code:
0 Result zero; no carry
ADD LOGICAL 1 Result not zero; no carry
2 Result zero; carry
ALR R,R [RR]
3 Result not zero; carry

'1E' R R Program Exceptions:

8 12 15 Access (fetch, operand 2 of AL, ALG, and


ALGF only)
ALGR R,R [RRE]
ADD LOGICAL WITH CARRY

'B9A' //////// R R ALCR R,R [RRE]

16 24 28 31
'B998' //////// R R

ALGFR R,R [RRE]
16 24 28 31

'B91A' //////// R R ALCGR R,R [RRE]

16 24 28 31
'B988' //////// R R

AL R,D(X,B) [RX]
16 24 28 31

'5E' R X B D ALC R,D(X,B) [RXE]

8 12 16 2 31 /
'E3' R X B D //////// '98'
/
ALG R,D(X,B) [RXE]
8 12 16 2 32 4 47
/
'E3' R X B D //////// 'A'
/
8 12 16 2 32 4 47

Chapter 7. General Instructions 7-17


ALCG R,D(X,B) [RXE] N R,D(X,B) [RX]

/
'E3' R X B D //////// '88' '54' R X B D
/
8 12 16 2 32 4 47 8 12 16 2 31

The second operand and the carry are added to NG R,D(X,B) [RXE]
the first operand, and the sum is placed at the
/
first-operand location. For ADD LOGICAL WITH 'E3' R X B D //////// '8'
CARRY (ALCR, ALC), the operands, the carry, /
and the sum are treated as 32-bit unsigned binary 8 12 16 2 32 4 47
integers. For ADD LOGICAL WITH CARRY
(ALCGR, ALCG), they are treated as 64-bit NI D(B),I [SI]
unsigned binary integers.

Resulting Condition Code: '94' I B D

0 Result zero; no carry 8 16 2 31
1 Result not zero; no carry
2 Result zero; carry NC D(L,B),D(B) [SS]
3 Result not zero; carry
//
Program Exceptions: 'D4' L B D B D
//
Access (fetch, operand 2 of ALC and ALCG 8 16 2 32 36 47
only)

Programming Notes: The AND of the first and second operands is


placed at the first-operand location.
1. A carry is represented by a one value of bit 18
of the current PSW. Bit 18 is the leftmost bit The connective AND is applied to the operands bit
of the two-bit condition code in the PSW. Bit by bit. The contents of a bit position in the result
18 is set to one by an execution of an ADD are set to one if the corresponding bit positions in
LOGICAL or ADD LOGICAL WITH CARRY both operands contain ones; otherwise, the result
instruction that produces a carry out of bit bit is set to zero.
position 0 of the result.
For AND (NC), each operand is processed left to
2. ADD and ADD LOGICAL may provide better
right. When the operands overlap, the result is
performance than ADD LOGICAL WITH
obtained as if the operands were processed one
CARRY, depending on the model.
byte at a time and each result byte were stored
immediately after fetching the necessary operand
AND bytes.
NR R,R [RR] For AND (NI), the first operand is one byte in
length, and only one byte is stored.
'14' R R
For AND (NR, N), the operands are 32 bits, and
8 12 15 for AND (NGR, NG), they are 64 bits.

NGR R,R [RRE] Resulting Condition Code:


0 Result zero

'B98' //////// R R 1 Result not zero


2 --
16 24 28 31 3 --

7-18 z/Architecture Principles of Operation


Program Exceptions: The second operand is ANDed with bits of the first
operand, and the result replaces those bits of the
Access (fetch, operand 2, N, NG, and NC;
first operand. The remainder of the first operand
fetch and store, operand 1, NI and NC)
remains unchanged.
Programming Notes:
For each instruction, the bits of the first operand
1. An example of the use of the AND instruction that are ANDed with the second operand and then
is given in Appendix A, Number Represen- replaced are as follows:
tation and Instruction-Use Examples.
Bits
2. The AND instruction may be used to set a bit
ANDed
to zero.
and
3. Accesses to the first operand of AND (NI) and Instruction Replaced
AND (NC) consist in fetching a first-operand
NIHH 0-15
byte from storage and subsequently storing
the updated value. These fetch and store NIHL 16-31
accesses to a particular byte do not neces-
NILH 32-47
sarily occur one immediately after the other.
Thus, the instruction AND cannot be safely NILL 48-63
used to update a location in storage if the
possibility exists that another CPU or a The connective AND is applied to the operands bit
channel program may also be updating the by bit. The contents of a bit position in the result
location. An example of this effect is shown are set to one if the corresponding bit positions in
for OR (OI) in Multiprogramming and Multi- both operands contain ones; otherwise, the result
processing Examples on page A-43. bit is set to zero.

AND IMMEDIATE Resulting Condition Code:


0 Sixteen-bit result zero
NIHH R,I [RI]
1 Sixteen-bit result not zero
2 --
'A5' R '4' I 3 --

8 12 16 31 Program Exceptions: None.

NIHL R,I [RI] BRANCH AND LINK


BALR R,R [RR]
'A5' R '5' I

8 12 16 31 '5' R R

NILH R,I [RI] 8 12 15

BAL R,D(X,B) [RX]


'A5' R '6' I

8 12 16 31 '45' R X B D

NILL R,I [RI] 8 12 16 2 31

'A5' R '7' I Information from the current PSW, including the


updated instruction address, is saved as link infor-
8 12 16 31 mation at the first-operand location. Subse-

Chapter 7. General Instructions 7-19


quently, the instruction address in the PSW is the link information is loaded without
replaced by the branch address. branching.
3. The BRANCH AND LINK instruction (BAL and
The link information in the 24-bit addressing mode
BALR) is provided for compatibility purposes.
consists of the instruction-length code (ILC), the
It is recommended that, where possible, the
condition code (CC), the program-mask bits, and
BRANCH AND SAVE instruction (BAS and
the rightmost 24 bits of the updated instruction
BASR), BRANCH RELATIVE AND SAVE, or
address, arranged in bit positions 32-63 of the
BRANCH RELATIVE AND SAVE LONG be
first-operand location in the following format:
used and BRANCH AND LINK avoided, since
the latter places nonzero information in bit
IL Prog
positions 32-39 of the link register in the 24-bit
C CCMask Instruction Address
addressing mode, which may lead to prob-
32 34 36 4 63 lems. Additionally, in the 24-bit addressing
mode, BRANCH AND LINK may be slower
The instruction-length code is 1 or 2.
than the other instructions because BRANCH
AND LINK must construct the ILC, condition
The link information in the 31-bit addressing mode
code, and program mask to be placed in bit
consists of bit 32 of the PSW, the basic-
positions 32-39 of the link register.
addressing-mode bit (always a one) and the right-
most 31 bits of the updated instruction address, 4. The condition-code and program-mask infor-
arranged in bit positions 32-63 of the first-operand mation, which is provided in the leftmost byte
location in the following format: of the link information only in the 24-bit
addressing mode, can be obtained in any
1 Instruction Address addressing mode by means of the INSERT
PROGRAM MASK instruction.
32 63

In the 24-bit or 31-bit addressing mode, bits 0-31


BRANCH AND SAVE
of the first-operand location remain unchanged. BASR R,R [RR]
The link information in the 64-bit addressing mode
consists of the updated instruction address, placed 'D' R R
in bit positions 0-63 of the first-operand location.
8 12 15
In the RX format, the second-operand address is
used as the branch address. In the RR format, BAS R,D(X,B) [RX]
the contents of general register R are used to
generate the branch address; however, when the
'4D' R X B D
R field is zero, the operation is performed without
branching. The branch address is computed 8 12 16 2 31
before general register R is changed.

Condition Code: The code remains unchanged. Information from the current PSW, including the
updated instruction address, is saved as link infor-
Program Exceptions: mation at the first-operand location. Subse-
quently, the instruction address in the PSW is
Trace (R field nonzero, BALR only) replaced by the branch address.
Programming Notes: In the 24-bit or 31-bit addressing mode, the link
1. An example of the use of the BRANCH AND information is bits 32 and 97-127 of the PSW,
LINK instruction is given in Appendix A, consisting of the basic-addressing-mode bit and
Number Representation and Instruction-Use the rightmost 31 bits of the updated instruction
Examples. address. The link information is placed in bit posi-
tions 32 and 33-63, respectively, of the first-
2. When the R field in the RR format is zero,

7-20 z/Architecture Principles of Operation


operand location, and bits 0-31 of the location quently, if the R field is nonzero, the
remain unchanged. addressing-mode bits and instruction address in
the PSW are replaced as specified by the second
In the 64-bit addressing mode, the link information operand.
consists of the updated instruction address, placed
in bit positions 0-63 of the first-operand location. In the 24-bit or 31-bit addressing mode, the link
information is bits 32 and 97-127 of the PSW,
In the RX format, the second-operand address is consisting of the basic-addressing-mode bit and
used as the branch address. In the RR format, the rightmost 31 bits of the updated instruction
the contents of general register R are used to address. The link information is placed in bit posi-
generate the branch address; however, when the tions 32 and 33-63, respectively, of the first-
R field is zero, the operation is performed without operand location, and bits 0-31 of the location
branching. The branch address is computed remain unchanged. In the 64-bit addressing
before general register R is changed. mode, the link information is bits 64-126 of the
PSW with a one appended on the right, placed in
Condition Code: The code remains unchanged. bit positions 0-63 of the first-operand location.

Program Exceptions: The contents of general register R specify the


Trace (R field nonzero, BASR only) new addressing mode and designate the branch
address; however, when the R field is zero, the
Programming Notes: operation is performed without branching and
without setting either addressing-mode bit.
1. An example of the use of the BRANCH AND
SAVE instruction is given in Appendix A, When the contents of general register R are used
Number Representation and Instruction-Use and bit 63 of the register is zero, bit 31 of the
Examples. current PSW, the extended-addressing-mode bit,
2. The BRANCH AND SAVE instruction (BAS is set to zero, bit 32 of the register specifies the
and BASR) is intended to be used for linkage new basic addressing mode and replaces bit 32 of
to programs known to be in the same the PSW, and the branch address is generated
addressing mode as the caller. This instruc- from the contents of the register under the control
tion should be used in place of the BRANCH of the new addressing mode. The branch address
AND LINK instruction (BAL and BALR). See replaces the instruction address in the PSW.
the programming notes on pages 5-11 and
5-17 in the section Subroutine Linkage When the contents of general register R are used
without the Linkage Stack for a detailed dis- and bit 63 of the register is one, the following
cussion of this and other linkage instructions. occurs. Bits 31 and 32 of the current PSW are
See also the programming note under set to one, the branch address is generated from
BRANCH AND LINK for a discussion of the the contents of the register, except with bit 63 of
advantages of the BRANCH AND SAVE the register treated as a zero, under the control of
instruction. the new extended addressing mode, and the
branch address replaces the instruction address in
the PSW. Bit 63 of the register remains one.
BRANCH AND SAVE AND SET However, if R is the same as R, the results in
MODE the designated general register are as specified
for the R register.
BASSM R,R [RR]
The new value for the PSW is computed before

'C' R R general register R is changed.

8 12 15 Condition Code: The code remains unchanged.

Program Exceptions:
Information from the current PSW, including the
updated instruction address, is saved as link infor- Trace (R field nonzero)
mation at the first-operand location. Subse-

Chapter 7. General Instructions 7-21


Programming Notes: The action associated with an operand is not per-
formed if the associated R field is zero.
1. An example of the use of the BRANCH AND
SAVE AND SET MODE instruction is given in
The contents of general register R specify the
Appendix A, Number Representation and
new addressing mode and designate the branch
Instruction-Use Examples.
address; however, when the R field is zero, the
2. BRANCH AND SAVE AND SET MODE is operation is performed without branching and
intended to be the principal calling instruction without setting either addressing-mode bit.
to subroutines which may operate in a dif-
ferent addressing mode from that of the caller. When the contents of general register R are used
See the programming notes on pages 5-11 and bit 63 of the register is zero, bit 31 of the
and 5-17 in the section Subroutine Linkage current PSW, the extended-addressing-mode bit,
without the Linkage Stack for a detailed dis- is set to zero, bit 32 of the register specifies the
cussion of this and other linkage instructions. new basic addressing mode and replaces bit 32 of
the PSW, and the branch address is generated
3. An old 24-bit or 31-bit program can use
from the contents of the register under the control
BRANCH AND SAVE AND SET MODE to call
of the new addressing mode. The branch address
a new 64-bit program without any change,
replaces the instruction address in the PSW.
provided that bits 0-31 of general register R
are all zeros. The old program can load into When the contents of general register R are used
bit positions 32-63 of general register R a and bit 63 of the register is one, the following
four-byte address constant, which is provided occurs. Bits 31 and 32 of the current PSW are
from outside the program, in which bit 63 in set to one, the branch address is generated from
the register (bit 31 of the constant in storage) the contents of the register, except with bit 63 of
either is or is not one. If the addressing mode the register treated as a zero, under the control of
is not changed to the 64-bit mode by the exe- the new extended addressing mode, and the
cution of the BRANCH AND SAVE AND SET branch address replaces the instruction address in
MODE instruction, or even if it is, the called the PSW. Bit 63 of the register remains one.
program can set the 64-bit mode by issuing a However, if R is the same as R, the results in
SET ADDRESSING MODE (SAM64) instruc- the designated general register are as specified
tion. for the R register.
4. See the programming notes on page 5-11
(under Simple Branch Instructions). The new value for the PSW is computed before
general register R is changed.
BRANCH AND SET MODE Condition Code: The code remains unchanged.
BSM R,R [RR]
Program Exceptions:
Trace
'B' R R

Programming Notes:
8 12 15
1. An example of the use of the BRANCH AND
In the 24-bit or 31-bit addressing mode, bit 32 of SET MODE instruction is given in
the current PSW, the basic-addressing-mode bit, Appendix A, Number Representation and
is inserted into bit position 32 of the first operand, Instruction-Use Examples.
a zero is inserted into bit position 63 of that 2. BRANCH AND SET MODE with an R field of
operand, and bits 0-31 and 33-62 of the operand zero is intended to be the standard return
remain unchanged. In the 64-bit addressing instruction in a program entered by means of
mode, a one is inserted into bit position 63 of the BRANCH AND SAVE AND SET MODE. It
first operand, and bits 0-62 of the operand remain can also be the return instruction in a program
unchanged. Subsequently, the addressing-mode entered in the 24-bit or 31-bit addressing
bits and instruction address in the PSW are mode by means of BRANCH AND SAVE,
replaced as specified by the second operand. BRANCH RELATIVE AND SAVE, or BRANCH

7-22 z/Architecture Principles of Operation


RELATIVE AND SAVE LONG. BRANCH The current condition code is used to select the
AND SET MODE with a nonzero R field is corresponding mask bit. If the mask bit selected
intended to be used in a glue module to by the condition code is one, the branch is suc-
connect either old 24-bit programs and newer cessful. If the mask bit selected is zero, normal
programs that are executed in the 31-bit instruction sequencing proceeds with the next
addressing mode or old 24-bit or 31-bit pro- sequential instruction.
grams and new programs that are executed in
the 64-bit addressing mode. See the pro- When the M and R fields of BRANCH ON CON-
gramming notes on pages 5-11 and 5-17 in DITION (BCR) are all ones and all zeros, respec-
the section Subroutine Linkage without the tively, a serialization and
Linkage Stack for a detailed discussion of this checkpoint-synchronization function is performed.
and other linkage instructions.
Condition Code: The code remains unchanged.
BRANCH ON CONDITION Program Exceptions: None.
BCR M,R [RR]
Programming Notes:
1. An example of the use of the BRANCH ON
'7' M R CONDITION instruction is given in

8 12 15 Appendix A, Number Representation and


Instruction-Use Examples.
BC M,D(X,B) [RX] 2. When a branch is to depend on more than
one condition, the pertinent condition codes
are specified in the mask as the sum of their
'47' M X B D mask position values. A mask of 12, for

8 12 16 2 31 example, specifies that a branch is to be


made when the condition code is 0 or 1.

The instruction address in the current PSW is 3. When all four mask bits are zeros or when the
replaced by the branch address if the condition R field in the RR format contains zero, the
code has one of the values specified by M; other- branch instruction is equivalent to a no-
wise, normal instruction sequencing proceeds with operation. When all four mask bits are ones,
the updated instruction address. that is, the mask value is 15, the branch is
unconditional unless the R field in the RR
In the RX format, the second-operand address is format is zero.
used as the branch address. In the RR format, 4. Execution of BCR 15,0 (that is, an instruction
the contents of general register R are used to with a value of 07F0 hex) may result in signif-
generate the branch address; however, when the icant performance degradation. To ensure
R field is zero, the operation is performed without optimum performance, the program should
branching. avoid use of BCR 15,0 except in cases when
the serialization or checkpoint-synchronization
The M field is used as a four-bit mask. The four
function is actually required.
condition codes (0, 1, 2, and 3) correspond, left to
right, with the four bits of the mask, as follows: 5. Note that the relation between the RR and RX
formats in branch-address specification is not
Instruction Mask the same as in operand-address specification.
Condition Bit No. of Position For branch instructions in the RX format, the
Code Mask Value branch address is the address specified by
X, B, and D; in the RR format, the branch
8 8 address is contained in the register desig-
1 9 4
2 1 2 nated by R. For operands, the address
3 11 1 specified by X, B, and D is the operand
address, but the register designated by R

Chapter 7. General Instructions 7-23


contains the operand, not the operand is performed without branching. The branch
address. address is generated before general register R is
changed.
BRANCH ON COUNT Condition Code: The code remains unchanged.
BCTR R,R [RR]
Program Exceptions: None.

'6' R R Programming Notes:

8 12 15 1. An example of the use of the BRANCH ON


COUNT instruction is given in Appendix A,
Number Representation and Instruction-Use
BCTGR R,R [RRE]
Examples.
2. The first operand and result can be consid-
'B946' //////// R R
ered as either signed or unsigned binary inte-
16 24 28 31 gers since the result of a binary subtraction is
the same in both cases.
BCT R,D(X,B) [RX] 3. An initial count of one results in zero, and no
branching takes place; an initial count of zero
results in -1 and causes branching to be per-
'46' R X B D
formed; an initial count of -1 results in -2 and
8 12 16 2 31 causes branching to be performed; and so on.
In a loop, branching takes place each time the
BCTG R,D(X,B) [RXE] instruction is executed until the result is again
zero. Note that for BCT or BCTR, because of
/ the number range, an initial count of -2
'E3' R X B D //////// '46' results in a positive value of 2 - 1, or, for
/ BCTG or BCTGR, an initial count of -2
8 12 16 2 32 4 47
results in a positive value of 2 - 1.
4. Counting is performed without branching when
A one is subtracted from the first operand, and the
the R field in the RR or RRE format contains
result is placed at the first-operand location. For
zero.
BRANCH AND COUNT (BCT, BCTR), the first
operand and result are treated as 32-bit binary
integers, with overflow ignored. For BRANCH BRANCH ON INDEX HIGH
AND COUNT (BCTG, BCTGR), the first operand
and result are treated as 64-bit binary integers, BXH R,R,D(B) [RS]
with overflow ignored. When the result is zero,
normal instruction sequencing proceeds with the '86' R R B D
updated instruction address. When the result is
not zero, the instruction address in the current 8 12 16 2 31
PSW is replaced by the branch address.
BXHG R,R,D(B) [RSE]
In the RX or RXE format, the second-operand
address is used as the branch address. In the RR /
or RRE format, the contents of general register R 'EB' R R B D //////// '44'
/
are used to generate the branch address;
8 12 16 2 32 4 47
however, when the R field is zero, the operation

7-24 z/Architecture Principles of Operation


BRANCH ON INDEX LOW OR The original contents of the compare-value reg-
ister are used as the compare value even when
EQUAL that register is also specified to be the first-
BXLE R,R,D(B) [RS] operand location. The branch address is gener-
ated before general register R is changed.

'87' R R B D The sum is placed at the first-operand location,


regardless of whether the branch is taken.
8 12 16 2 31
Condition Code: The code remains unchanged.
BXLEG R,R,D(B) [RSE]
Program Exceptions: None.
/
'EB' R R B D //////// '45' Programming Notes:
/
8 12 16 2 32 4 47 1. Several examples of the use of the BRANCH
ON INDEX HIGH and BRANCH ON INDEX
An increment is added to the first operand, and LOW OR EQUAL instructions are given in
the sum is compared with a compare value. The Appendix A, Number Representation and
result of the comparison determines whether Instruction-Use Examples.
branching occurs. Subsequently, the sum is 2. The word index in the names of these
placed at the first-operand location. The second- instructions indicates that one of the major
operand address is used as a branch address. purposes is the incrementing and testing of an
The R field designates registers containing the index value. The increment, being a signed
increment and the compare value. binary integer, may be used to increase or
decrease the value in general register R by
For BRANCH ON INDEX HIGH, when the sum is an arbitrary amount, subject to the limit of the
high, the instruction address in the current PSW is integer size.
replaced by the branch address. When the sum is
low or equal, normal instruction sequencing pro- 3. Care must be taken in the 31-bit addressing
ceeds with the updated instruction address. mode when a data area in storage is at the
rightmost end of a 31-bit address space and a
For BRANCH ON INDEX LOW OR EQUAL, when BRANCH ON INDEX HIGH (BXH) or
the sum is low or equal, the instruction address in BRANCH ON INDEX LOW OR EQUAL
the current PSW is replaced by the branch (BXLE) instruction is used to step upward
address. When the sum is high, normal instruc- through the data. Since the addition and com-
tion sequencing proceeds with the updated parison operations performed during the exe-
instruction address. cution of these instructions treat the operands
as 32-bit signed binary integers, the value fol-
When the R field is even, it designates a pair of lowing 2 - 1 is not 2, which cannot be
registers; the contents of the even and odd regis- represented in that format, but -2. The
ters of the pair are used as the increment and the instruction does not provide an indication of
compare value, respectively. When the R field is such overflow. Consequently, some common
odd, it designates a single register, the contents of looping techniques based on the use of these
which are used as both the increment and the instructions do not work when a data area
compare value. ends at address 2 - 1. This problem is illus-
trated in a BRANCH ON INDEX LOW OR
For purposes of the addition and comparison, all EQUAL example in Appendix A, Number
operands and results are treated as 32-bit signed Representation and Instruction-Use
binary integers for BXH and BXLE or as 64-bit Examples. A similar caution applies in the
signed binary integers for BXHG and BXLEG. 64-bit addressing mode when data is at the
Overflow caused by the addition is ignored. end of a 64-bit address space and BRANCH
ON INDEX HIGH (BXHG) or BRANCH ON
INDEX LOW OR EQUAL (BXLEG) is used.

Chapter 7. General Instructions 7-25


BRANCH RELATIVE AND SAVE 2. The BRANCH RELATIVE AND SAVE and
BRANCH RELATIVE AND SAVE LONG
BRAS R,I [RI] instructions, like the BRANCH AND SAVE
instruction, are intended to be used for linkage
to programs known to be in the same
'A7' R '5' I addressing mode as the caller. These

8 12 16 31 instructions should be used in place of the


BRANCH AND LINK instruction (BAL and
BALR). See the programming notes on pages
BRANCH RELATIVE AND SAVE 5-11 and 5-17 in the sectionSubroutine
Linkage without the Linkage Stack for a
LONG
detailed discussion of these and other linkage
BRASL R,I [RIL] instructions. See also the programming note
under BRANCH AND LINK for a discussion of
/ the advantages of the BRANCH RELATIVE
'C' R '5' I AND SAVE, BRANCH RELATIVE AND SAVE
/
LONG, and BRANCH AND SAVE instructions.
8 12 16 47
3. When the instruction is the target of
Information from the current PSW, including the EXECUTE, the branch is relative to the target
updated instruction address, is saved as link infor- address; see Branch-Address Generation on
mation at the first-operand location. Subse- page 5-8.
quently, the instruction address in the PSW is
replaced by the branch address. BRANCH RELATIVE ON
CONDITION
In the 24-bit or 31-bit addressing mode, the link
information is bits 32 and 97-127 of the PSW, BRC M,I [RI]
consisting of the basic-addressing-mode bit and
the rightmost 31 bits of the updated instruction
address. The link information is placed in bit posi- 'A7' M '4' I

tions 32 and 33-63, respectively, of the first- 8 12 16 31
operand location, and bits 0-31 of the location
remain unchanged.
BRANCH RELATIVE ON
In the 64-bit addressing mode, the link information
consists of the updated instruction address, placed
CONDITION LONG
in bit positions 0-63 of the first-operand location. BRCL M,I [RIL]

The contents of the I field are a signed binary /


integer specifying the number of halfwords that is 'C' M '4' I
added to the address of the instruction to generate /
the branch address. 8 12 16 47

Condition Code: The code remains unchanged. The instruction address in the current PSW is
replaced by the branch address if the condition
Program Exceptions: None. code has one of the values specified by M; other-
wise, normal instruction sequencing proceeds with
Programming Notes: the updated instruction address.
1. The operation is the same as that of the
BRANCH AND SAVE (BAS) instruction except The contents of the I field are a signed binary
for the means of specifying the branch integer specifying the number of halfwords that is
address. An example of the use of BRANCH added to the address of the instruction to generate
AND SAVE is given in Appendix A. the branch address.

7-26 z/Architecture Principles of Operation


The M field is used as a four-bit mask. The four BRANCH RELATIVE ON COUNT
condition codes (0, 1, 2, and 3) correspond, left to
right, with the four bits of the mask, as follows: BRCT R,I [RI]

Instruction Mask
Condition Bit No. of Position 'A7' R '6' I
Code Mask Value
8 12 16 31
8 8
1 9 4 BRCTG R,I [RI]
2 1 2
3 11 1
'A7' R '7' I
The current condition code is used to select the
8 12 16 31
corresponding mask bit. If the mask bit selected
by the condition code is one, the branch is suc-
cessful. If the mask bit selected is zero, normal A one is subtracted from the first operand, and the
instruction sequencing proceeds with the next result is placed at the first-operand location. For
sequential instruction. BRANCH RELATIVE ON COUNT (BRCT), the first
operand and result are treated as 32-bit binary
Condition Code: The code remains unchanged. integers, with overflow ignored. For BRANCH
RELATIVE ON COUNT (BRCTG), the first
Program Exceptions: None. operand and result are treated as 64-bit binary
integers, with overflow ignored. When the result is
Programming Notes: zero, normal instruction sequencing proceeds with
1. The operation is the same as that of the the updated instruction address. When the result
BRANCH ON CONDITION instruction except is not zero, the instruction address in the current
for the means of specifying the branch PSW is replaced by the branch address.
address. An example of the use of BRANCH
The contents of the I field are a signed binary
ON CONDITION is given in Appendix A.
integer specifying the number of halfwords that is
2. When a branch is to depend on more than added to the address of the instruction to generate
one condition, the pertinent condition codes the branch address.
are specified in the mask as the sum of their
mask position values. A mask of 12, for Condition Code: The code remains unchanged.
example, specifies that a branch is to be
made when the condition code is 0 or 1. Program Exceptions: None.
3. When all four mask bits are zeros, the branch Programming Notes:
instruction is equivalent to a no-operation.
When all four mask bits are ones, that is, the 1. The operation is the same as that of the
mask value is 15, the branch is unconditional. BRANCH ON COUNT instruction except for
the means of specifying the branch address.
4. When the instruction is the target of An example of the use of BRANCH ON
EXECUTE, the branch is relative to the target COUNT is given in Appendix A.
address; see Branch-Address Generation on
page 5-8. 2. The first operand and result can be consid-
ered as either signed or unsigned binary inte-
gers since the result of a binary subtraction is
the same in both cases.
3. An initial count of one results in zero, and no
branching takes place; an initial count of zero
results in -1 and causes branching to be exe-
cuted; an initial count of -1 results in -2 and
causes branching to be executed; and so on.
In a loop, branching takes place each time the

Chapter 7. General Instructions 7-27


instruction is executed until the result is again The contents of the I field are a signed binary
zero. Note that for BRCT, because of the integer specifying the number of halfwords that is
number range, an initial count of -2 results added to the address of the instruction to generate
in a positive value of 2 - 1, or, for BRCTG, the branch address.
an initial count of -2 results in a positive
value of 2 - 1. For BRANCH RELATIVE ON INDEX HIGH, when
the sum is high, the instruction address in the
4. When the instruction is the target of
current PSW is replaced by the branch address.
EXECUTE, the branch is relative to the target
When the sum is low or equal, normal instruction
address; see Branch-Address Generation on
sequencing proceeds with the updated instruction
page 5-8.
address.

BRANCH RELATIVE ON INDEX For BRANCH RELATIVE ON INDEX LOW OR


HIGH EQUAL, when the sum is low or equal, the
instruction address in the current PSW is replaced
BRXH R,R,I [RSI] by the branch address. When the sum is high,
normal instruction sequencing proceeds with the
updated instruction address.
'84' R R I

8 12 16 31 When the R field is even, it designates a pair of


registers; the contents of the even and odd regis-
ters of the pair are used as the increment and the
BRXHG R,R,I [RIE]
compare value, respectively. When the R field is
/ odd, it designates a single register, the contents of
'EC' R R I //////// '44' which are used as both the increment and the
/ compare value.
8 12 16 32 4 47
For purposes of the addition and comparison, all
operands and results are treated as 32-bit signed
BRANCH RELATIVE ON INDEX binary integers for BRXH and BRXLE or as 64-bit
LOW OR EQUAL signed binary integers for BRXHG and BRXLG.
Overflow caused by the addition is ignored.
BRXLE R,R,I [RSI]
The original contents of the compare-value reg-

'85' R R I ister are used as the compare value even when


that register is also specified to be the first-
8 12 16 31 operand location.

BRXLG R,R,I [RIE] The sum is placed at the first-operand location,


regardless of whether the branch is taken.
/
'EC' R R I //////// '45' Condition Code: The code remains unchanged.
/
8 12 16 32 4 47 Program Exceptions: None.

An increment is added to the first operand, and Programming Notes:


the sum is compared with a compare value. The 1. The operations are the same as those of the
result of the comparison determines whether BRANCH ON INDEX HIGH and BRANCH ON
branching occurs. Subsequently, the sum is INDEX LOW OR EQUAL instructions except
placed at the first-operand location. The R field for the means of specifying the branch
designates registers containing the increment and address. Several examples of the use of
the compare value. BRANCH ON INDEX HIGH and BRANCH ON
INDEX LOW OR EQUAL are given in
Appendix A.

7-28 z/Architecture Principles of Operation


2. The word index in the names of these operand. Bits 0-31 of general register R always
instructions indicates that one of the major remain unchanged. If the second operand is not a
purposes is the incrementing and testing of an multiple of four bytes, its last one, two, or three
index value. The increment, being a signed bytes are treated as appended on the right with
binary integer, may be used to increase or the number of all-zeros bytes needed to form a
decrease the value in general register R by four-byte element. The four-byte elements are
an arbitrary amount. added to the first operand until either the entire
second operand or a CPU-determined amount of
3. Care must be taken in the 31-bit addressing
the second operand has been processed. The
mode when a data area in storage is at the
result is indicated in the condition code.
rightmost end of an address space and a
BRANCH RELATIVE ON INDEX HIGH
The R field designates an even-odd pair of
(BRXH) or BRANCH RELATIVE ON INDEX
general registers and must designate an even-
LOW OR EQUAL (BRXLE) instruction is used
numbered register; otherwise, a specification
to step upward through the data. Since the
exception is recognized.
addition and comparison operations performed
during the execution of these instructions treat The location of the leftmost byte of the second
the operands as 32-bit signed binary integers, operand is specified by the contents of the R
the value following 2 - 1 is not 2, which general register. The number of bytes in the
cannot be represented in that format, but -2. second-operand location is specified by the 32-bit
The instruction does not provide an indication or 64-bit unsigned binary integer in the R + 1
of such overflow. Consequently, some general register.
common looping techniques based on the use
of these instructions do not work when a data The handling of the address in general register R
area ends at address 2 - 1. This problem is and the length in general register R + 1 is
illustrated in a BRANCH ON INDEX LOW OR dependent on the addressing mode. In the 24-bit
EQUAL example in Appendix A. A similar addressing mode, the contents of bit positions
caution applies in the 64-bit addressing mode 40-63 of general register R constitute the
when data is at the end of a 64-bit address address, and the contents of bit positions 0-39 are
space and BRANCH RELATIVE ON INDEX ignored. In the 31-bit addressing mode, the con-
HIGH (BRXHG) or BRANCH RELATIVE ON tents of bit positions 33-63 of the register consti-
INDEX LOW OR EQUAL (BRXLG) is used. tute the address, and the contents of bit positions
4. When the instruction is the target of 0-32 are ignored. In the 64-bit addressing mode,
EXECUTE, the branch is relative to the target the contents of bit positions 0-63 of the register
address; see Branch-Address Generation on constitute the address. In the 24-bit or 31-bit
page 5-8. addressing mode, the length is a 32-bit unsigned
binary integer in bit positions 32-63 of general reg-
ister R + 1, and the contents of bit positions
CHECKSUM 0-31 are ignored. In the 64-bit addressing mode,
CKSM R,R [RRE] the length is a 64-bit unsigned binary integer in
the register.

'B241' //////// R R The addition of second-operand four-byte ele-


ments to the first operand proceeds left to right,
16 24 28 31 four-byte element by four-byte element, and ends
as soon as (1) the entire second operand has
Successive four-byte elements of the second been processed or (2) a lesser CPU-determined
operand are added to the first operand in bit posi- amount of the second operand has been proc-
tions 32-63 of general register R to form a 32-bit essed. In either case, the result in bit positions
checksum in those bit positions. The first operand 32-63 of general register R is a 32-bit checksum
and the four-byte elements are treated as 32-bit for the part of the second operand that has been
unsigned binary integers. After each addition of processed. When the second operand is not a
an element, a carry out of bit position 32 of the multiple of four bytes, the final second-operand
first operand is added to bit position 63 of the first bytes in excess of a multiple of four are conceptu-

Chapter 7. General Instructions 7-29


ally appended on the right with an appropriate When the R register is the same register as the
number of all-zeros bytes to form the final four- R or R + 1 register, the results are unpredict-
byte element. able.

If the operation ends because the entire second Access exceptions for the portion of the second
operand has been processed, the condition code operand to the right of the last byte processed
is set to 0. If the operation ends because a lesser may or may not be recognized. For a second
CPU-determined amount of the second operand operand longer than 4K bytes, access exceptions
has been processed, the condition code is set to are not recognized for locations more than 4K
3. When the operation is to end with a setting of bytes beyond the last byte processed.
condition code 3, any carry out of bit position 32
of the first operand is added to bit position 63 of Access exceptions are not recognized if the R
the first operand before the operation ends. field is odd. When the length of the second
operand is zero, no access exceptions are recog-
At the completion of the operation, the 32-bit or nized.
64-bit operand-length field in the R + 1 register
is decremented by the number of actual second- Resulting Condition Code:
operand bytes added to the first operand (not 0 Entire second operand processed
including any conceptually appended all-zeros 1 --
bytes), and the address in the R register is incre- 2 --
mented by the same number. Thus, the the 32-bit 3 CPU-determined amount of second operand
or 64-bit operand-length field contains a zero processed
value if the condition code is set to 0, or it con-
tains a nonzero value if the condition code is set Program Exceptions:
to 3. In the 24-bit or 31-bit addressing mode, bits
0-31 of the R + 1 register always remain Access (fetch, operand 2)
unchanged. Specification

When condition code 3 is set, the general regis- Programming Notes:


ters used by the instruction have been set so that 1. The initial contents of bit positions 32-63 of
the remainder of the second operand can be proc- the R general register contribute to the 32-bit
essed by simply branching back to reexecute the checksum. The program normally should set
instruction. those contents to all zeros before issuing the
CHECKSUM instruction.
The amount of processing that results in the
setting of condition code 3 is determined by the 2. A 16-bit checksum is used in, for example, the
CPU on the basis of improving system perform- TCP/IP application. The following program
ance, and it may be a different amount each time can be executed after the CHECKSUM
the instruction is executed. The minimum amount instruction to produce in bit positions 32-63 of
is four bytes or the number of bytes specified in general register R a 16-bit checksum from
the R + 1 general register, whichever is smaller. the 32-bit checksum in bit positions 32-63 of
general register R. The program is anno-
At the completion of the operation in the 24-bit or tated to show the contents of bit positions
31-bit addressing mode, the leftmost bits which 32-63 of the R and R + 1 registers after the
are not part of the address in bit positions 32-63 execution of each instruction. The contents of
of general register R may be set to zeros or may bit positions 32-63 of the R register are
remain unchanged, even when the initial length in represented as A,B, meaning the value A in
register R + 1 is zero. Bits 0-31 of general reg- bit positions 32-47 and the value B in bit posi-
ister R remain unchanged. tions 48-63. The value C is a carry from
A + B. Note that bit positions 32-63 of reg-
ister R + 1 are known to contain all zeros
when CHECKSUM has set condition code 0.

7-30 z/Architecture Principles of Operation


R2 Bits R2+1 Bits 3. In the access-register mode, access register 0
Program 32-63 32-63 designates the primary address space regard-
less of the contents of access register 0.
LR R2,R1 A,B ,
SRDL R2,16 ,A B, 4. Figure 7-2 on page 7-32 contains a summary
ALR R2,R2+1 B,A B, of the operation.
ALR R2,R1 A+B+C,A+B B,
SRL R2,16 ,A+B+C B,

Chapter 7. General Instructions 7-31



R1 bits 32-63 5 CHECKSUM

Address in R2 5 ADR, length in R2+1 5 LEN


5 Note: All addends are unsigned binary integers
6
No
LEN >= 45LEN 5 INC

Yes INC bytes at ADR followed by
6 4-INC all-zeros bytes 5 ELEMENT

4 5 INC

4 bytes at ADR 5 ELEMENT


%
6

CHECKSUM + ELEMENT 5 CHECKSUM


6
Yes
Carry from addition5CHECKSUM + 1 5 CHECKSUM

No
%
6

ADR + INC 5 ADR, LEN - INC 5 LEN


6

LEN = or CPU-determined
reason to end operation

No Yes

6

CHECKSUM 5 R1 bits 32-63

ADR 5 R2, LEN 5 R2+1


6
No
LEN =

Yes
6 6

Set condition code Set condition code 3


6 6
End operation End operation
Figure 7-2. Execution of CHECKSUM

COMPARE

7-32 z/Architecture Principles of Operation


CR R,R [RR] Program Exceptions:
Access (fetch, operand 2 of C, CG, and CGF
'19' R R only)

8 12 15
COMPARE AND FORM
CGR R,R [RRE] CODEWORD
CFC D(B) [S]
'B92' //////// R R

16 24 28 31 'B21A' B D

16 2 31
CGFR R,R [RRE]

General register 2 contains an index, which is


'B93' //////// R R used along with contents of general registers 1
and 3 to designate the starting addresses of two
16 24 28 31
fields in storage, called the first and third oper-
ands. The first and third operands are logically
C R,D(X,B) [RX] compared, and a codeword is formed for use in
sort/merge algorithms.

'59' R X B D
The second-operand address is not used to
8 12 16 2 31 address data. Bits 49-62 of the second-operand
address, with one rightmost and one leftmost zero
CG R,D(X,B) [RXE] appended, are used as a 16-bit index limit. Bit 63
of the second-operand address is the operand-
/ control bit. When bit 63 is zero, the codeword is
'E3' R X B D //////// '2' formed from the high operand; when bit 63 is one,
/ the codeword is formed from the low operand.
8 12 16 2 32 4 47
The remainder of the second-operand address is
ignored.
CGF R,D(X,B) [RXE]
General registers 1 and 3 contain the base
/
'E3' R X B D //////// '3' addresses of the first and third operands. Bits
/ 48-63 of general register 2 are used as an index
8 12 16 2 32 4 47 for addressing both the first and third operands.
General registers 1, 2, and 3 must all initially
contain even values; otherwise, a specification
The first operand is compared with the second
exception is recognized.
operand, and the result is indicated in the condi-
tion code. For COMPARE (CR, C), the operands
In the access-register mode, access register 1
are treated as 32-bit signed binary integers. For
specifies the address space containing the first
COMPARE (CGR, CG), they are treated as 64-bit
and third operands.
signed binary integers For COMPARE (CGFR,
CGF), the second operand is treated as a 32-bit The size of the units by which the first and third
signed binary integer, and the first operand is operands are compared, the size of the resulting
treated as a 64-bit signed binary integer. codeword, and the participation of bits 0-31 of
general registers 1, 2, and 3 in the operation
Resulting Condition Code:
depend on the addressing mode. In the 24-bit or
0 Operands equal 31-bit addressing mode, the comparison unit is
1 First operand low two bytes, the codeword is four bytes, and bits
2 First operand high 0-31 are ignored and remain unchanged. In the
3 --

Chapter 7. General Instructions 7-33


64-bit addressing mode, the comparison unit is six if operand 1 was lower, bits 32-63 of general reg-
bytes, the codeword is eight bytes, and bits 0-31 isters 1 and 3 are interchanged.
are used in and may be changed by the operation.
For the purpose of recognizing access exceptions,
Operation in the 24-Bit or 31-Bit Addressing operand 1 and operand 3 are both considered to
Mode have a length equal to 2 more than the value of
the index limit minus the index.
The operation consists in comparing the first and
third operands halfword by halfword and incre- Operation in the 64-Bit Addressing Mode
menting the index until an unequal pair of
halfwords is found or the index exceeds the index The operation consists in comparing the first and
limit. This proceeds in units of operation, between third operands in units of six bytes at a time and
which interruptions may occur. incrementing the index until an unequal pair of six-
byte units is found or the index exceeds the index
At the start of a unit of operation, the index, bits limit. This proceeds in units of operation, between
48-63 of general register 2, is logically compared which interruptions may occur.
with the index limit. If the index is larger, the
instruction is completed by placing bits 32-63 of At the start of a unit of operation, the index, bits
general register 3, with bit 32 set to one, in bit 48-63 of general register 2, is logically compared
positions 32-63 of general register 2, and by with the index limit. If the index is larger, the
setting condition code 0. instruction is completed by placing bits 0-63 of
general register 3, with bit 0 set to one, in bit posi-
If the index is less than or equal to the index limit, tions 0-63 of general register 2, and by setting
the index is applied to the first-operand and third- condition code 0.
operand base addresses to locate the current pair
of halfwords to be compared. The index, with 48 If the index is less than or equal to the index limit,
leftmost zeros appended, and bits 32-63 of the index is applied to the first-operand and third-
general register 1, with 32 leftmost zeros operand base addresses to locate the current pair
appended, are added to form a 64-bit intermediate of six-byte units to be compared. The index, with
value. A carry out of bit position 32, if any, is 48 leftmost zeros appended, and bits 0-63 of
ignored. The address of the current first-operand general register 1 are added to form the 64-bit
halfword is generated from the intermediate value address of the current first-operand six-byte unit.
by following the normal rules for operand address A carry out of bit position 0, if any, is ignored.
generation. The address of the current third- The address of the current third-operand six-byte
operand halfword is formed in the same manner unit is formed in the same manner by adding bits
by adding bits 32-63 of general register 3 and the 0-63 of general register 3 and the index.
index.
The current first-operand and third-operand six-
The current first-operand and third-operand byte units are logically compared. If they are
halfwords are logically compared. If they are equal, the contents of general register 2 are incre-
equal, the contents of general register 2 are incre- mented by 6, and a unit of operation ends.
mented by 2, and a unit of operation ends.
If the compare values are unequal, the contents of
If the compare values are unequal, the contents of general register 2 are incremented by 6 and then
general register 2 are incremented by 2 and then shifted left logically by 48 bit positions. If the
shifted left logically by 16 bit positions. The operand-control bit is zero, (1) the one's comple-
shifting occurs only within bit positions 32-63. If ment of the higher six-byte unit is placed in bit
the operand-control bit is zero, (1) the one's com- positions 16-63 of general register 2, and (2) if
plement of the higher halfword is placed in bit operand 1 was higher, bits 0-63 of general regis-
positions 48-63 of general register 2, and (2) if ters 1 and 3 are interchanged. If the operand-
operand 1 was higher, bits 32-63 of general regis- control bit is one, (1) the lower six-byte unit is
ters 1 and 3 are interchanged. If the operand- placed in bit positions 16-63 of general register 2,
control bit is one, (1) the lower halfword is placed and (2) if operand 1 was lower, bits 0-63 of
in bit positions 48-63 of general register 2, and (2) general registers 1 and 3 are interchanged.

7-34 z/Architecture Principles of Operation


For the purpose of recognizing access exceptions, the leftmost 16 bits of the codeword formed in
operand 1 and operand 3 are both considered to general register 2 (bits 32-47 of the register in
have a length equal to 6 more than the value of the 24-bit or 31-bit addressing mode, or bits
the index limit minus the index. 0-15 in the 64-bit addressing mode) by the
execution of COMPARE AND FORM
Specifications Independent of Addressing CODEWORD gives the offset of the first
Mode halfword or six-byte unit not compared. If the
codewords compare equal in an UPDATE
The condition code is unpredictable if the instruc- TREE operation, bit positions 32-47 of general
tion is interrupted. register 2 in the 24-bit or 31-bit addressing
mode, or bit positions 0-15 in the 64-bit
When the index is initially larger than the index addressing mode, will contain the offset at
limit, access exceptions are not recognized for the which another COMPARE AND FORM
storage operands. For operands longer than 4K CODEWORD should resume comparison for
bytes, access exceptions are not recognized more breaking codeword ties. Operand-control-bit
than 4K bytes beyond the byte being processed. values of zero or one are used for sorting
Access exceptions are not recognized when a operands in ascending or descending order,
specification-exception condition exists. respectively. Refer to Sorting Instructions on
page A-51 for a discussion of the use of
If the B field designates general register 2, it is
codewords in sorting.
unpredictable whether or not the index limit is
recomputed; thus, in this case the operand length 3. The condition code indicates the results of
is unpredictable. However, in no case can the comparing operands up to 32,768 bytes long.
operands exceed 2 bytes in length. Equal operands result in a negative codeword
in bit positions 32-63 of general register 2 in
Resulting Condition Code: the 24-bit or 31-bit addressing mode, or in bit
positions 0-63 in the 64-bit addressing mode.
0 Operands equal
A negative codeword also results in the 24-bit
1 Operand-control bit zero and operand 1 low,
or 31-bit mode when the index limit is 32,766
or operand-control bit one and operand 3 low
and the operands that are compared differ in
2 Operand-control bit zero and operand 1 high,
only their last two bytes, or in the 64-bit mode
or operand-control bit one and operand 3 high
when the limit is 32,762 and the operands
3 --
differ in only their last six bytes. If this latter
codeword is used by UPDATE TREE, an
Program Exceptions:
incorrect result may be indicated in general
Access (fetch, operands 1 and 3) registers 0 and 1. Therefore, the index limit
Specification should not exceed 32,764 in the 24-bit or
31-bit mode, or 32,760 in the 64-bit mode,
Programming Notes: when the resulting codeword is to be used by
1. An example of the use of COMPARE AND UPDATE TREE.
FORM CODEWORD is given in Sorting 4. Figure 7-3 on page 7-36 and Figure 7-4 on
Instructions in Appendix A, Number Repre- page 7-37 contain summaries of the opera-
sentation and Instruction-Use Examples. tion in the 24-bit or 31-bit addressing mode,
2. The offset of the halfword or six-byte unit and Figure 7-5 on page 7-38 and Figure 7-6
(depending on the addressing mode) of the on page 7-39 contain summaries of the oper-
first and third operands at which comparison ation in the 64-bit addressing mode.
is to begin should be placed in bit positions 5. Special precautions should be taken if
48-63 of general register 2 before executing COMPARE AND FORM CODEWORD is
COMPARE AND FORM CODEWORD. The made the target of EXECUTE. See the pro-
index limit derived from the second-operand gramming note concerning interruptible
address should be the offset of the last instructions under EXECUTE.
halfword or six-byte unit of the first and third
operands for which comparison can be made. 6. Further programming notes concerning inter-
When the operands do not compare equal, ruptible instructions are included in Interrup-

Chapter 7. General Instructions 7-35


tible Instructions in Chapter 5, Program
Execution.

Operand- ResultingResult inResult inResult in


Control ConditionGR2 (BitsGR1 (Bits|GR3 (Bits
Bit Relation Code 32-63) 32-63) 32-63)

op1 = op3 OGR3b1 - -


op1 < op3 1 X, nop3 - -
op1 > op3 2 X, nop1 OGR3 OGR1
1 op1 = op3 OGR3b1 - -
1 op1 < op3 2 X, top1 OGR3 OGR1
1 op1 > op3 1 X, top3 - -

Explanation:

- The bits remain unchanged.

OGR1 The original value of GR1 bits 32-63.

OGR3 The original value of GR3 bits 32-63.

OGR3b1 The original value of GR3 bits 32-63 with bit 32
set to one.

X Bits 32-47 of GR2 are 2 more than the index of the
first unequal halfword.

nop1 Bits 48-63 of GR2 are the one's complement of the
first unequal halfword in operand 1.

nop3 Bits 48-63 of GR2 are the one's complement of the
first unequal halfword in operand 3.

top1 Bits 48-63 of GR2 are the first unequal halfword
in operand 1.

top3 Bits 48-63 of GR2 are the first unequal halfword
in operand 3.

Figure 7-3. Operation of COMPARE AND FORM CODEWORD in the 24-Bit or 31-bit Addressing Mode

7-36 z/Architecture Principles of Operation



2 x bits 49-62 of 2nd-operand address 5 index limit

Bit 63 of 2nd-operand address 5 operand-control bit


6
No
Bit 63 of GR1, GR2, and GR3 all zeros5 Specification
exception
Yes
5
6
Yes
Bits 48-63 of GR2 > index limit

No
6 6

Unit-of- GR1 + bits 48-63 of GR2 \ GR3 5 GR2 \
operation 5 1st-operand address
boundary 1 5 bit 32 of GR2
GR3 + bits 48-63 of GR2 \
& 5 3rd-operand address 5 Cond code

Fetch halfwords from current
1st- and 3rd-operand locations 6
End operation
GR2 + 2 5 GR2 \


6
Equal 1st op high
Compare halfwords fetched

1st op low
6 6
Zero Zero
Test operand-control bit Test operand-control bit

6 One 6 One
6 6
One's complement One's complement
of 3rd-op HW 1st-op HW of 1st-op HW 3rd-op HW
5 TEMPHW 5 TEMPHW 5 TEMPHW 5 TEMPHW

Exchange Exchange
6 GR1 and GR3 \ GR1 and GR3 \ 6

1 5 Cond code 2 5 Cond code 2 5 Cond code 1 5 Cond code


6 6
5%%

6

Shift GR2 left 16 positions \

TEMPHW 5 bits 48-63 of GR2

\ Only bits 32-63 of a GR partici-
6 pate when no bits are mentioned.
End operation
Figure 7-4. Execution of COMPARE AND FORM CODEWORD in the 24-Bit or 31-bit Addressing Mode

Chapter 7. General Instructions 7-37



Operand- ResultingResult inResult inResult in
Control ConditionGR2 (BitsGR1 (Bits|GR3 (Bits
Bit Relation Code -63) -63) -63)

op1 = op3 OGR3b1 - -


op1 < op3 1 X, nop3 - -
op1 > op3 2 X, nop1 OGR3 OGR1
1 op1 = op3 OGR3b1 - -
1 op1 < op3 2 X, top1 OGR3 OGR1
1 op1 > op3 1 X, top3 - -

Explanation:

- The bits remain unchanged.

OGR1 The original value of GR1 bits -63.

OGR3 The original value of GR3 bits -63.

OGR3b1 The original value of GR3 bits -63 with bit set
to one.

X Bits -15 of GR2 are 6 more than the index of the
first unequal six-byte unit.

nop1 Bits 16-63 of GR2 are the one's complement of the
first unequal six-byte unit in operand 1.

nop3 Bits 16-63 of GR2 are the one's complement of the
first unequal six-byte unit in operand 3.

top1 Bits 16-63 of GR2 are the first unequal six-byte
unit in operand 1.

top3 Bits 16-63 of GR2 are the first unequal six-byte
unit in operand 3.

Figure 7-5. Operation of COMPARE AND FORM CODEWORD in the 64-Bit Addressing Mode

7-38 z/Architecture Principles of Operation



2 x bits 49-62 of 2nd-operand address 5 index limit

Bit 63 of 2nd-operand address 5 operand-control bit


6
No
Bit 63 of GR1, GR2, and GR3 all zeros5 Specification
exception
Yes
5
6
Yes
Bits 48-63 of GR2 > index limit

No
6 6

Unit-of- GR1 + bits 48-63 of GR2 \ GR3 5 GR2 \
operation 5 1st-operand address
boundary 1 5 bit of GR2
GR3 + bits 48-63 of GR2 \
& 5 3rd-operand address 5 Cond code

Fetch six bytes from current
1st- and 3rd-operand locations 6
End operation
GR2 + 6 5 GR2 \


6
Equal 1st op high
Compare six bytes fetched

1st op low
6 6
Zero Zero
Test operand-control bit Test operand-control bit

6 One 6 One
6 6
One's complement One's complement
of 3rd-op six 1st-op six of 1st-op six 3rd-op six
bytes 5 TEMP6 bytes 5 TEMP6 bytes 5 TEMP6 bytes 5 TEMP6

Exchange Exchange
6 GR1 and GR3 \ GR1 and GR3 \ 6

1 5 Cond code 2 5 Cond code 2 5 Cond code 1 5 Cond code


6 6
5%%

6

Shift GR2 left 48 positions \

TEMP6 > bits 16-63 of GR2

\ Bits -63 of a GR participate
6 when no bits are mentioned.
End operation
Figure 7-6. Execution of COMPARE AND FORM CODEWORD in the 64-Bit Addressing Mode

Chapter 7. General Instructions 7-39


COMPARE AND SWAP even-odd pair of general registers, and the second
32 bits occupy bit positions 32-63 of the odd-
CS R,R,D(B) [RS] numbered register of the pair. The second
operand is a doubleword in storage.

'BA' R R B D For COMPARE DOUBLE AND SWAP (CDSG),


the first and third operands are 128 bits in length.
8 12 16 2 31
The first 64 bits of an operand occupy bit positions
0-63 of the even-numbered register of an
CSG R,R,D(B) [RSE] even-odd pair of general registers, and the second
/ 64 bits occupy bit positions 0-63 of the odd-
'EB' R R B D //////// '3' numbered register of the pair. The second
/ operand is a quadword in storage.
8 12 16 2 32 4 47
When an equal comparison occurs, the third
operand is stored at the second-operand location.
COMPARE DOUBLE AND SWAP The fetch of the second operand for purposes of
comparison and the store into the second-operand
CDS R,R,D(B) [RS]
location appear to be a block-concurrent
interlocked-update reference as observed by other
'BB' R R B D CPUs.

8 12 16 2 31 When the result of the comparison is unequal, the


second-operand location remains unchanged.
CDSG R,R,D(B) [RSE] However, on some models, the value may be
fetched and subsequently stored back unchanged
/ at the second-operand location. This update
'EB' R R B D //////// '3E' appears to be a block-concurrent interlocked-
/
8 12 16 2 32 4 47 update reference as observed by other CPUs.

A serialization function is performed before the


The first and second operands are compared. If operand is fetched and again after the operation is
they are equal, the third operand is stored at the completed.
second-operand location. If they are unequal, the
second operand is loaded into the first-operand The second operand of COMPARE AND SWAP
location. The result of the comparison is indicated (CS) must be designated on a word boundary.
in the condition code. The second operand of COMPARE AND SWAP
(CSG) and COMPARE DOUBLE AND SWAP
For COMPARE AND SWAP (CS), the first and (CDS) must be designated on a doubleword
third operands are 32 bits in length, with each boundary. The second operand of COMPARE
operand occupying bit positions 32-63 of a general DOUBLE AND SWAP (CDSG) must be desig-
register. The second operand is a word in nated on a quadword boundary. The R and R
storage. fields for COMPARE DOUBLE AND SWAP must
each designate an even-numbered register. Oth-
For COMPARE AND SWAP (CSG), the first and erwise, a specification exception is recognized.
third operands are 64 bits in length, with each
operand occupying bit positions 0-63 of a general Resulting Condition Code:
register. The second operand is a doubleword in
storage. 0 First and second operands equal, second
operand replaced by third operand
For COMPARE DOUBLE AND SWAP (CDS), the 1 First and second operands unequal, first
first and third operands are 64 bits in length. The operand replaced by second operand
first 32 bits of an operand occupy bit positions 2 --
32-63 of the even-numbered register of an 3 --

7-40 z/Architecture Principles of Operation


Program Exceptions: accomplish this, a word in storage can be
used as a control word, with a zero value
Access (fetch and store, operand 2)
in the word indicating that the common
Specification
area is not in use and that no messages
Programming Notes: exist, a negative value indicating that the
area is in use and that no messages exist,
1. Several examples of the use of the and a nonzero positive value indicating
COMPARE AND SWAP and COMPARE that the common area is in use and that
DOUBLE AND SWAP instructions are given in the value is the address of the most
Appendix A, Number Representation and recent message added to the list. Thus,
Instruction-Use Examples. any number of CPU programs desiring to
2. Some of the following notes are worded, with seize the area can use COMPARE AND
respect to operand size, for CS and CDS. SWAP to update the control word to indi-
Similar notes, worded for a larger operand cate that the area is in use or to add mes-
size, would apply to CSG and CDSG. sages to the list. The single CPU
program which has seized the area can
3. COMPARE AND SWAP can be used by CPU also safely use COMPARE AND SWAP to
programs sharing common storage areas in remove messages from the list.
either a multiprogramming or multiprocessing
environment. Two examples are: 4. COMPARE DOUBLE AND SWAP can be
used in a manner similar to that described for
a. By performing the following procedure, a COMPARE AND SWAP. In addition, it has
CPU program can modify the contents of another use. Consider a chained list, with a
a storage location even though the possi- control word used to address the first
bility exists that the CPU program may be message in the list, as described in program-
interrupted by another CPU program that ming note 2b above. If multiple CPU pro-
will update the location or that another grams are to be permitted to delete messages
CPU program may simultaneously update by using COMPARE AND SWAP (and not just
the location. First, the entire word con- the single CPU program which has seized the
taining the byte or bytes to be updated is common area), there is a possibility the list
loaded into a general register. Next, the will be incorrectly updated. This would occur
updated value is computed and placed in if, for example, after one CPU program has
another general register. Then fetched the address of the most recent
COMPARE AND SWAP is executed with message in order to remove the message,
the R field designating the register that another CPU program removes the first two
contains the original value and the R field messages and then adds the first message
designating the register that contains the back into the chain. The first CPU program,
updated value. If the update has been on continuing, cannot easily detect that the list
successful, condition code 0 is set. If the is changed. By increasing the size of the
storage location no longer contains the control word to a doubleword containing both
original value, the update has not been the first message address and a word with a
successful, the general register desig- change number that is incremented for each
nated by the R field of the COMPARE modification of the list, and by using
AND SWAP instruction contains the new COMPARE DOUBLE AND SWAP to update
current value of the storage location, and both fields together, the possibility of the list
condition code 1 is set. When condition being incorrectly updated is reduced to a neg-
code 1 is set, the CPU program can ligible level. That is, an incorrect update can
repeat the procedure using the new occur only if the first CPU program is delayed
current value. while changes exactly equal in number to a
b. COMPARE AND SWAP can be used for multiple of 2 take place and only if the last
controlled sharing of a common storage change places the original message address
area, including the capability of leaving a in the control word.
message (in a chained list of messages) 5. COMPARE AND SWAP and COMPARE
when the common area is in use. To DOUBLE AND SWAP do not interlock against

Chapter 7. General Instructions 7-41


storage accesses by channel programs. COMPARE HALFWORD
Therefore, the instructions should not be used
to update a location at which a channel
IMMEDIATE
program may store, since the channel- CHI R,I [RI]
program data may be lost.
6. To ensure successful updating of a common
'A7' R 'E' I
storage field by two or more CPUs, all
updates must be done by means of an 8 12 16 31
interlocked-update reference. COMPARE
AND SWAP, COMPARE DOUBLE AND CGHI R,I [RI]
SWAP, and TEST AND SET are the only
instructions that perform an interlocked-update
reference. For example, if one CPU executes 'A7' R 'F' I
OR IMMEDIATE and another CPU executes
8 12 16 31
COMPARE AND SWAP to update the same
byte, the fetch by OR IMMEDIATE may occur
either before the fetch by COMPARE AND The first operand is compared with the second
SWAP or between the fetch and the store by operand, and the result is indicated in the condi-
COMPARE AND SWAP, and then the store tion code. The second operand is two bytes in
by OR IMMEDIATE may occur after the store length and is treated as a 16-bit signed binary
by COMPARE AND SWAP, in which case the integer. For COMPARE HALFWORD and
change made by COMPARE AND SWAP is COMPARE HALFWORD IMMEDIATE (CHI), the
lost. first operand is treated as a 32-bit signed binary
integer. For COMPARE HALFWORD IMME-
7. For the case of a condition-code setting of 1,
DIATE (CGHI), the first operand is treated as a
COMPARE AND SWAP and COMPARE
64-bit signed binary integer.
DOUBLE AND SWAP may or may not,
depending on the model, cause any of the fol- Resulting Condition Code:
lowing to occur for the second-operand
location: a PER storage-alteration event may 0 Operands equal
be recognized; a protection exception for 1 First operand low
storing may be recognized; and, provided no 2 First operand high
access exception exists, the change bit may 3 --
be set to one. Because the contents of
storage remain unchanged, the change bit Program Exceptions:
may or may not be one when a PER storage- Access (fetch, operand 2 of CH only)
alteration event is recognized.
Programming Note: An example of the use of
the COMPARE HALFWORD instruction is given in
COMPARE HALFWORD Appendix A, Number Representation and
Instruction-Use Examples.
CH R,D(X,B) [RX]

COMPARE LOGICAL
'49' R X B D
CLR R,R [RR]
8 12 16 2 31

'15' R R

8 12 15

7-42 z/Architecture Principles of Operation


CLGR R,R [RRE] CLGF), the first operand is treated as 64 bits, and
the second operand is treated as 32 bits with 32
zeros appended on the left.
'B921' //////// R R

16 24 28 31 The comparison proceeds left to right, byte by


byte, and ends as soon as an inequality is found
or the end of the fields is reached. For
CLGFR R,R [RRE]
COMPARE LOGICAL (CL, CLG, CLGF, CLC),
access exceptions may or may not be recognized
'B931' //////// R R for the portion of a storage operand to the right of
the first unequal byte.
16 24 28 31
Resulting Condition Code:
CL R,D(X,B) [RX]
0 Operands equal
1 First operand low
'55' R X B D 2 First operand high
3 --
8 12 16 2 31
Program Exceptions:
CLG R,D(X,B) [RXE]
Access (fetch, operand 2, CL, CLG, CLGF,
/ and CLC; fetch, operand 1, CLI and CLC)
'E3' R X B D //////// '21'
/ Programming Notes:
8 12 16 2 32 4 47
1. Examples of the use of the COMPARE
LOGICAL instruction are given in Appendix A,
CLGF R,D(X,B) [RXE] Number Representation and Instruction-Use
/ Examples.
'E3' R X B D //////// '31' 2. COMPARE LOGICAL treats all bits of each
/
operand alike as part of a field of unstructured
8 12 16 2 32 4 47
logical data. For COMPARE LOGICAL (CLC),
the comparison may extend to field lengths of
CLI D(B),I [SI] 256 bytes.

'95' I B D COMPARE LOGICAL

8 16 2 31 CHARACTERS UNDER MASK


CLM R,M,D(B) [RS]
CLC D(L,B),D(B) [SS]

// 'BD' R M B D
'D5' L B D B D
// 8 12 16 2 31
8 16 2 32 36 47
CLMH R,M,D(B) [RSE]
The first operand is compared with the second
operand, and the result is indicated in the condi- /
tion code. 'EB' R M B D //////// '2'
/
8 12 16 2 32 4 47
For COMPARE LOGICAL (CLR, CL), the oper-
ands are treated as 32 bits. For COMPARE
LOGICAL (CLGR, CLG), the operands are treated The first operand is compared with the second
as 64 bits. For COMPARE LOGICAL (CLGFR, operand under control of a mask, and the result is
indicated in the condition code.

Chapter 7. General Instructions 7-43


The contents of the M field are used as a mask. COMPARE LOGICAL LONG
These four bits, left to right, correspond one for
one with four bytes, left to right, of general register CLCL R,R [RR]
R. For COMPARE LOGICAL CHARACTERS
UNDER MASK (CLM), the four bytes to which the
mask bits correspond are in bit positions 32-63 of 'F' R R

general register R. For COMPARE LOGICAL 8 12 15
CHARACTERS UNDER MASK (CLMH), the four
bytes are in the high-order half, bit positions 0-31,
of the register. The byte positions corresponding The first operand is compared with the second
to ones in the mask are considered as a contig- operand, and the result is indicated in the condi-
uous field and are compared with the second tion code. The shorter operand is considered to
operand. The second operand is a contiguous be extended on the right with padding bytes.
field in storage, starting at the second-operand
address and equal in length to the number of ones The R and R fields each designate an even-odd
in the mask. The bytes in the general register pair of general registers and must designate an
corresponding to zeros in the mask do not partic- even-numbered register; otherwise, a specification
ipate in the operation. exception is recognized.

The comparison proceeds left to right, byte by The location of the leftmost byte of the first
byte, and ends as soon as an inequality is found operand and second operand is designated by the
or the end of the fields is reached. contents of general registers R and R, respec-
tively. The number of bytes in the first-operand
When the mask is not zero, exceptions associated and second-operand locations is specified by
with storage-operand access are recognized for unsigned binary integers in bit positions 40-63 of
no more than the number of bytes specified by the general registers R + 1 and R + 1, respec-
mask. Access exceptions may or may not be tively. Bit positions 32-39 of general register
recognized for the portion of a storage operand to R + 1 contain the padding byte. The contents of
the right of the first unequal byte. When the mask bit positions 0-39 of general register R + 1 and
is zero, access exceptions are recognized for one of bit positions 0-31 of general register R + 1
byte at the second-operand address. are ignored.

Resulting Condition Code: The handling of the addresses in general registers


R and R is dependent on the addressing mode.
0 Operands equal, or mask bits all zeros
1 First operand low In the 24-bit addressing mode, the contents of bit
2 First operand high positions 40-63 of general registers R and R
3 -- constitute the address, and the contents of bit
positions 0-39 are ignored. In the 31-bit
Program Exceptions: addressing mode, the contents of bit positions
Access (fetch, operand 2) 33-63 of the registers constitute the address, and
the contents of bit positions 0-32 are ignored. In
Programming Note: An example of the use of the 64-bit addressing mode, the contents of bit
the COMPARE LOGICAL CHARACTERS UNDER positions 0-63 constitute the address.
MASK instruction is given in Appendix A, Number
Representation and Instruction-Use Examples. The contents of the registers just described are
shown in Figure 7-7 on page 7-45.

7-44 z/Architecture Principles of Operation




24-Bit Addressing Mode 31-Bit Addressing Mode

/ /
R //////////// First-Operand Address //// First-Operand Address
/ /
4 63 33 63

/ /
R + 1 //////////// First-Operand Length //////////// First-Operand Length
/ /
4 63 4 63

/ /
R //////////// Second-Operand Address //// Second-Operand Address
/ /
4 63 33 63

/ /
R + 1 /// Pad Second-Operand Length /// Pad Second-Operand Length
/ /
32 4 63 32 4 63

64-Bit Addressing Mode

/
R First-Operand Address
/
63

/
R + 1 //////////// First-Operand Length
/
4 63

/
R Second-Operand Address
/
63

/
R + 1 /// Pad Second-Operand Length
/
32 4 63

Figure 7-7. Register Contents for COMPARE LOGICAL LONG

The comparison proceeds left to right, byte by The execution of the instruction is interruptible.
byte, and ends as soon as an inequality is found When an interruption occurs, other than one that
or the end of the longer operand is reached. If causes termination, the lengths in general regis-
the operands are not of the same length, the ters R + 1 and R + 1 are decremented by the
shorter operand is considered to be extended on number of bytes compared, and the addresses in
the right with the appropriate number of padding general registers R and R are incremented by
bytes. the same number, so that the instruction, when
reexecuted, resumes at the point of interruption.
If both operands are of zero length, the operands In the 24-bit or 31-bit addressing mode, the left-
are considered to be equal. most bits which are not part of the address in bit
positions 32-63 of general registers R and R are
set to zeros, and the contents of bit positions 0-31

Chapter 7. General Instructions 7-45


remain unchanged. In any addressing mode, the 0 Operands equal, or both zero length
contents of bit positions 0-39 of general registers 1 First operand low
R + 1 and R + 1 remain unchanged, and the 2 First operand high
condition code is unpredictable. If the operation is 3 --
interrupted after the shorter operand has been
exhausted, the length field pertaining to the Program Exceptions:
shorter operand is zero, and its address is Access (fetch, operands 1 and 2)
updated accordingly. Specification
If the operation ends because of an inequality, the Programming Notes:
address fields in general registers R and R at
completion identify the first unequal byte in each 1. An example of the use of the COMPARE
operand. The lengths in bit positions 40-63 of LOGICAL LONG instruction is given in
general registers R + 1 and R + 1 are decre- Appendix A, Number Representation and
mented by the number of bytes that were equal, Instruction-Use Examples.
unless the inequality occurred with the padding 2. When the R and R fields are the same, the
byte, in which case the length field for the shorter operation proceeds in the same way as when
operand is set to zero. The addresses in general two distinct pairs of registers having the same
registers R and R are incremented by the contents are specified, except that the con-
amounts by which the corresponding length fields tents of the designated registers are incre-
were reduced. mented or decremented only by the number of
bytes compared, not by twice the number of
If the two operands, including the padding byte, if bytes compared. In the absence of dynamic
necessary, are equal, both length fields are made modification of the operand area by another
zero at completion, and the addresses are incre- CPU or by a channel program, condition code
mented by the corresponding operand-length 0 is set. However, it is unpredictable whether
values. access exceptions are recognized for the
operand since the operation can be completed
At the completion of the operation, in the 24-bit or
without storage being accessed.
31-bit addressing mode, the leftmost bits which
are not part of the address in bit positions 32-63 3. Special precautions should be taken when
of general registers R and R are set to zeros, COMPARE LOGICAL LONG is made the
even when one or both of the initial length values target of EXECUTE. See the programming
are zero. In any addressing mode, the contents of note concerning interruptible instructions
bit positions 0-39 of general registers R + 1 and under EXECUTE.
R + 1 remain unchanged. 4. Other programming notes concerning interrup-
tible instructions are included in Interruptible
Access exceptions for the portion of a storage
Instructions in Chapter 5, Program
operand to the right of the first unequal byte may
Execution.
or may not be recognized. For operands longer
than 2K bytes, access exceptions are not recog- 5. In the access-register mode, access register 0
nized more than 2K bytes beyond the byte being designates the primary address space regard-
processed. Access exceptions are not indicated less of the contents of access register 0.
for locations more than 2K bytes beyond the first
unequal byte. COMPARE LOGICAL LONG
When the length of an operand is zero, no access
EXTENDED
exceptions are recognized for that operand. CLCLE R,R,D(B) [RS]
Access exceptions are not recognized for an
operand if the R field associated with that operand
is odd. 'A9' R R B D

Resulting Condition Code: 8 12 16 2 31

7-46 z/Architecture Principles of Operation


The first operand is compared with the third specified by the entire contents of general regis-
operand until unequal bytes are compared, the ters R + 1 and R + 1, respectively, and those
end of the longer operand is reached, or a contents are treated as 64-bit unsigned binary
CPU-determined number of bytes have been com- integers.
pared, whichever occurs first. The shorter
operand is considered to be extended on the right The handling of the addresses in general registers
with padding bytes. The result is indicated in the R and R is dependent on the addressing mode.
condition code.
In the 24-bit addressing mode, the contents of bit
The R and R fields each designate an even-odd positions 40-63 of general registers R and R
pair of general registers and must designate an constitute the address, and the contents of bit
even-numbered register; otherwise, a specification positions 0-39 are ignored. In the 31-bit
exception is recognized. addressing mode, the contents of bit positions
33-63 of the registers constitute the address, and
The location of the leftmost byte of the first the contents of bit positions 0-32 are ignored. In
operand and third operand is designated by the the 64-bit addressing mode, the contents of bit
contents of general registers R and R, respec- positions 0-63 constitute the address.
tively. In the 24-bit or 31-bit addressing mode, the
number of bytes in the first-operand and third- The second-operand address is not used to
operand locations is specified by the contents of address data; instead, the rightmost eight bits of
bit positions 32-63 of general registers R + 1 the second-operand address, bits 56-63, are the
and R + 1, respectively, and those contents are padding byte. Bits 0-55 of the second-operand
treated as 32-bit unsigned binary integers. In the address are ignored.
64-bit addressing mode, the number of bytes in
the first-operand and third-operand locations is The contents of the registers and address just
described are shown in Figure 7-8 on page 7-48.

Chapter 7. General Instructions 7-47




24-Bit Addressing Mode 31-Bit Addressing Mode

/ /
R //////////// First-Operand Address //// First-Operand Address
/ /
4 63 33 63

/ /
R + 1 /// First-Operand Length /// First-Operand Length
/ /
32 63 32 63

/ /
R //////////// Third-Operand Address //// Third-Operand Address
/ /
4 63 33 63

/ /
R + 1 /// Third-Operand Length /// Third-Operand Length
/ /
32 63 32 63

/ /
2nd Op. /////////////////////////// Pad /////////////////////////// Pad
Address / /
56 63 56 63

64-Bit Addressing Mode

/
R First-Operand Address
/
63

/
R + 1 First-Operand Length
/
63

/
R Third-Operand Address
/
63

/
R + 1 Third-Operand Length
/
63

/
2nd Op. /////////////////////////// Pad
Address /
56 63

Figure 7-8. Register Contents and Second-Operand Address for COMPARE LOGICAL LONG EXTENDED

The comparison proceeds left to right, byte by CPU-determined number of bytes have been com-
byte, and ends as soon as an inequality is found, pared, whichever occurs first. If the operands are
the end of the longer operand is reached, or a not of the same length, the shorter operand is

7-48 z/Architecture Principles of Operation


considered to be extended on the right with the to change during the execution of the instruction,
appropriate number of padding bytes. the results are unpredictable.

If both operands are of zero length, the operands The amount of processing that results in the
are considered to be equal. setting of condition code 3 is determined by the
CPU on the basis of improving system perform-
If the operation ends because of an inequality, the ance, and it may be a different amount each time
address fields in general registers R and R at the instruction is executed. The maximum amount
completion identify the first unequal byte in each is approximately 4K bytes of either operand.
operand. The lengths in bit positions 32-63, in the
24-bit or 31-bit addressing mode, or in bit posi- At the completion of the operation in the 24-bit or
tions 0-63, in the 64-bit addressing mode, of 31-bit addressing mode, the leftmost bits which
general registers R + 1 and R + 1 are decre- are not part of the address in bit positions 32-63
mented by the number of bytes that were equal, of general registers R and R may be set to
unless the inequality occurred with the padding zeros or may remain unchanged from their original
byte, in which case the length field for the shorter values, even when one or both of the initial length
operand is set to zero. The addresses in general values are zero.
registers R and R are incremented by the
amounts by which the corresponding length fields Access exceptions for the portion of a storage
were decremented. Condition code 1 is set if the operand to the right of the first unequal byte may
first operand is low, or condition code 2 is set if or may not be recognized. For operands longer
the first operand is high. than 4K bytes, access exceptions are not recog-
nized more than 4K bytes beyond the byte being
If the two operands, including the padding byte, if processed. Access exceptions are not indicated
necessary, are equal, both length fields are made for locations more than 4K bytes beyond the first
zero at completion, and the addresses are incre- unequal byte.
mented by the corresponding operand-length
values. Condition code 0 is set. When the length of an operand is zero, no access
exceptions are recognized for that operand.
If the operation is completed because a Access exceptions are not recognized for an
CPU-determined number of bytes have been com- operand if the R field associated with that operand
pared without finding an inequality or reaching the is odd.
end of the longer operand, the lengths in general
registers R + 1 and R + 1 are decremented by Resulting Condition Code:
the number of bytes compared, and the addresses 0 All bytes compared; operands equal, or both
in general registers R and R are incremented by zero length
the same number, so that the instruction, when 1 All bytes compared, first operand low
reexecuted, resumes at the next bytes to be com- 2 All bytes compared, first operand high
pared. If the operation is completed after the 3 CPU-determined number of bytes compared
shorter operand has been exhausted, the length without finding an inequality
field pertaining to the shorter operand is zero, and
the operand address is updated accordingly. Con- Program Exceptions:
dition code 3 is set.
Access (fetch, operands 1 and 3)
In the 24-bit or 31-bit addressing mode, the con- Specification
tents of bit positions 0-31 of general registers R,
R + 1, R, and R + 1, always remain Programming Notes:
unchanged. 1. COMPARE LOGICAL LONG EXTENDED is
intended for use in place of COMPARE
The padding byte may be formed from D(B) LOGICAL LONG when the operand lengths
multiple times during the execution of the instruc- are specified as 32-bit binary integers.
tion, and the registers designated by R and R COMPARE LOGICAL LONG EXTENDED sets
may be updated multiple times. Therefore, if B condition code 3 in cases in which COMPARE
equals R, R + 1, R, or R + 1 and is subject LOGICAL LONG would be interrupted.

Chapter 7. General Instructions 7-49


2. When condition code 3 is set, the program The R and R fields each designate an even-odd
can simply branch back to the instruction to pair of general registers and must designate an
continue the comparison. The program need even-numbered register; otherwise, a specification
not determine the number of bytes that were exception is recognized.
compared.
The location of the leftmost character of the first
3. The function of not processing more than
operand and third operand is designated by the
approximately 4K bytes of either operand is
contents of general registers R and R, respec-
intended to permit software polling of a flag
tively. In the 24-bit or 31-bit addressing mode, the
that may be set by a program on another CPU
number of bytes in the first-operand and third-
during long operations.
operand locations is specified by the contents of
4. When the R and R fields are the same, the bit positions 32-63 of general registers R + 1
operation proceeds in the same way as when and R + 1, respectively, and those contents are
two distinct pairs of registers having the same treated as 32-bit unsigned binary integers. In the
contents are specified, except that the con- 64-bit addressing mode, the number of bytes in
tents of the designated registers are incre- the first-operand and third-operand locations is
mented or decremented only by the number of specified by the contents of bit positions 0-63 of
bytes compared, not by twice the number of general registers R + 1 and R + 1, respec-
bytes compared. In the absence of dynamic tively, and those contents are treated as 64-bit
modification of the operand area by another unsigned binary integers.
CPU or by a channel program, the condition
code is finally set to 0 after possible settings The contents of general registers R + 1 and
to 3. However, it is unpredictable whether R + 1 must specify an even number of bytes;
access exceptions are recognized for the otherwise, a specification exception is recognized.
operand since the operation can be completed
without storage being accessed. If storage is The handling of the addresses in general registers
not accessed, condition code 3 may or may R and R is dependent on the addressing mode.
not be set regardless of the operand length.
In the 24-bit addressing mode, the contents of bit
5. In the access-register mode, access register 0 positions 40-63 of general registers R and R
designates the primary address space regard- constitute the address, and the contents of bit
less of the contents of access register 0. positions 0-39 are ignored. In the 31-bit
addressing mode, the contents of bit positions
COMPARE LOGICAL LONG 33-63 of the registers constitute the address, and
UNICODE the contents of bit positions 0-32 are ignored. In
the 64-bit addressing mode, the contents of bit
CLCLU R,R,D(B) [RSE] positions 0-63 of the registers constitute the
address.
/
'EB' R R B D //////// '8F' The second-operand address is not used to
/ address data; instead, the rightmost 16 bits of the
8 12 16 2 32 4 47
second-operand address, bits 48-63, are the two-
byte padding character. Bits 0-47 of the second-
The first operand is compared with the third operand address are ignored.
operand until unequal two-byte Unicode charac-
ters are compared, the end of the longer operand The contents of the registers and address just
is reached, or a CPU-determined number of char- described are shown in Figure 7-9 on page 7-51.
acters have been compared, whichever occurs
first. The shorter operand is considered to be The comparison proceeds left to right, character
extended on the right with two-byte padding char- by character, and ends as soon as an inequality is
acters. The result is indicated in the condition found, the end of the longer operand is reached,
code. or a CPU-determined number of characters have
been compared, whichever occurs first. If the
operands are not of the same length, the shorter

7-50 z/Architecture Principles of Operation




24-Bit Addressing Mode 31-Bit Addressing Mode

/ /
R //////////// First-Operand Address //// First-Operand Address
/ /
4 63 33 63

/ /
R + 1 /// First-Operand Length /// First-Operand Length
/ /
32 63 32 63

/ /
R //////////// Third-Operand Address //// Third-Operand Address
/ /
4 63 33 63

/ /
R + 1 /// Third-Operand Length /// Third-Operand Length
/ /
32 63 32 63

/ /
2nd Op. /////////////////// Pad /////////////////// Pad
Address / /
48 63 48 63

64-Bit Addressing Mode

/
R First-Operand Address
/
63

/
R + 1 First-Operand Length
/
63

/
R Third-Operand Address
/
63

/
R + 1 Third-Operand Length
/
63

/
2nd Op. /////////////////// Pad
Address /
48 63

Figure 7-9. Register Contents and Second-Operand Address for COMPARE LOGICAL LONG UNICODE

operand is considered to be extended on the right If both operands are of zero length, the operands
with the appropriate number of two-byte padding are considered to be equal.
characters.

Chapter 7. General Instructions 7-51


If the operation ends because of an inequality, the CPU on the basis of improving system perform-
address fields in general registers R and R at ance, and it may be a different amount each time
completion identify the first unequal two-byte char- the instruction is executed.
acter in each operand. The lengths in bit posi-
tions 32-63, in the 24-bit or 31-bit addressing At the completion of the operation in the 24-bit or
mode, or in bit positions 0-63, in the 64-bit 31-bit addressing mode, the leftmost bits which
addressing mode, of general registers R + 1 and are not part of the address in bit positions 32-63
R + 1 are decremented by 2 times the number of general registers R and R may be set to
of characters that were equal, unless the ine- zeros or may remain unchanged from their original
quality occurred with the two-byte padding char- values, including the case when one or both of the
acter, in which case the length field for the shorter initial length values are zero.
operand is set to zero. The addresses in general
registers R and R are incremented by the Access exceptions for the portion of a storage
amounts by which the corresponding length fields operand to the right of the first unequal character
were decremented. Condition code 1 is set if the may or may not be recognized. For operands
first operand is low, or condition code 2 is set if longer than 4K bytes, access exceptions are not
the first operand is high. recognized more than 4K bytes beyond the char-
acter being processed. Access exceptions are not
If the two operands, including the two-byte indicated for locations more than 4K bytes beyond
padding character, if necessary, are equal, both the first unequal character.
length fields are made zero at completion, and the
addresses are incremented by the corresponding When the length of an operand is zero, no access
operand-length values. Condition code 0 is set. exceptions are recognized for that operand.
Access exceptions are not recognized for an
If the operation is completed because a operand if the R field or length associated with
CPU-determined number of characters have been that operand is odd.
compared without finding an inequality or reaching
the end of the longer operand, the lengths in Resulting Condition Code:
general registers R + 1 and R + 1 are decre- 0 All characters compared; operands equal, or
mented by 2 times the number of characters com- both zero length
pared, and the addresses in general registers R 1 First operand low
and R are incremented by the same number, so 2 First operand high
that the instruction, when reexecuted, resumes at 3 CPU-determined number of characters com-
the next characters to be compared. If the opera- pared without finding an inequality
tion is completed after the shorter operand has
been exhausted, the length field pertaining to the Program Exceptions:
shorter operand is zero, and the operand address
Access (fetch, operands 1 and 3)
is updated accordingly. Condition code 3 is set.
Operation (if the extended-translation facility 2
In the 24-bit or 31-bit addressing mode, the con- is not installed)
tents of bit positions 0-31 of general registers R, Specification
R + 1, R, and R + 1, always remain
Programming Notes:
unchanged.
1. COMPARE LOGICAL LONG UNICODE is
The two-byte padding character may be formed intended for use in place of COMPARE
from D(B) multiple times during the execution of LOGICAL LONG or COMPARE LOGICAL
the instruction, and the registers designated by R LONG EXTENDED when two-byte characters
and R may be updated multiple times. There- are to be compared. The characters may be
fore, if B equals R, R + 1, R, or R + 1 and Unicode characters or any other double-byte
is subject to change during the execution of the characters. COMPARE LOGICAL LONG
instruction, the results are unpredictable. UNICODE sets condition code 3 in cases in
which COMPARE LOGICAL LONG would be
The amount of processing that results in the interrupted.
setting of condition code 3 is determined by the

7-52 z/Architecture Principles of Operation


2. When condition code 3 is set, the program contents of general registers R and R, respec-
can simply branch back to the instruction to tively.
continue the comparison. The program need
not determine the number of characters that The handling of the addresses in general registers
were compared. R and R is dependent on the addressing mode.
In the 24-bit addressing mode, the contents of bit
3. When the R and R fields are the same, the
positions 40-63 of general registers R and R
operation proceeds in the same way as when
constitute the address, and the contents of bit
two distinct pairs of registers having the same
positions 0-39 are ignored. In the 31-bit
contents are specified, except that the con-
addressing mode, the contents of bit positions
tents of the designated registers are incre-
33-63 of the registers constitute the address, and
mented or decremented only by 2 times the
the contents of bit positions 0-32 are ignored. In
number of characters compared, not by 4
the 64-bit addressing mode, the contents of bit
times the number of characters compared. In
positions 0-63 constitute the address.
the absence of dynamic modification of the
operand area by another CPU or by a channel The first and second operands may be of the
program, the condition code is finally set to 0 same or different lengths. The end of an operand
after possible settings to 3. However, it is is indicated by an ending character in the last byte
unpredictable whether access exceptions are position of the operand. The ending character to
recognized for the operand since the opera- be used to determine the end of an operand is
tion can be completed without storage being specified in bit positions 56-63 of general register
accessed. If storage is not accessed, condi- 0. Bit positions 32-55 of general register 0 are
tion code 3 may or may not be set regardless reserved for possible future extensions and must
of the operand length. contain all zeros; otherwise, a specification excep-
4. In the access-register mode, access register 0 tion is recognized.
designates the primary address space regard-
less of the contents of access register 0. The operation proceeds left to right, byte by byte,
and ends as soon as the ending character is
5. If padding with a Unicode space character is encountered in either or both operands, unequal
required (or any character whose represen- bytes which do not include an ending character
tation is less than or equal to FFF hex), the are compared, or a CPU-determined number of
character may be represented in the displace- bytes have been compared, whichever occurs
ment field of the instruction, for example: first. The CPU-determined number is at least 256.
CLCLU 6,8,X'2' When the ending character is encountered simul-
taneously in both operands, including when it is in
COMPARE LOGICAL STRING the first byte position of the operands, the oper-
ands are of the same length and are considered
CLST R,R [RRE] to be equal, and condition code 0 is set. When
the ending character is encountered in only one
operand, that operand, which is the shorter
'B25D' //////// R R operand, is considered to be low, and condition

16 24 28 31 code 1 or 2 is set. Condition code 1 is set if the


first operand is low, or condition code 2 is set if
the second operand is low. Similarly, when
The first operand is compared with the second unequal bytes which do not include an ending
operand until unequal bytes are compared, the character are compared, condition code 1 is set if
end of either operand is reached, or a the lower byte is in the first operand, or condition
CPU-determined number of bytes have been com- code 2 is set if the lower byte is in the second
pared, whichever occurs first. The operand. When a CPU-determined number of
CPU-determined number is at least 256. The bytes have been compared, condition code 3 is
result is indicated in the condition code. set.

The location of the leftmost byte of the first When condition code 1 or 2 is set, the address of
operand and second operand is designated by the the last byte processed in the first and second

Chapter 7. General Instructions 7-53


operands is placed in general registers R and Program Exceptions:
R, respectively. That is, when condition code 1
Access (fetch, operands 1 and 2)
is set, the address of the ending character or first
Specification
unequal byte in the first operand, whichever was
encountered, is placed in general register R, and Programming Notes:
the address of the second-operand byte corre-
sponding in position to the first-operand byte is 1. Several examples of the use of the
placed in general register R. When condition COMPARE LOGICAL STRING instruction are
code 2 is set, the address of the ending character given in Appendix A, Number Representation
or first unequal byte in the second operand, and Instruction-Use Examples.
whichever was encountered, is placed in general 2. When condition code 0 is set, no indication is
register R, and the address of the first-operand given of the position of either ending char-
byte corresponding in position to the second- acter.
operand byte is placed in general register R.
When condition code 3 is set, the address of the 3. When condition code 3 is set, the program
next byte to be processed in the first and second can simply branch back to the instruction to
operands is placed in general registers R and continue the comparison. The program need
R, respectively. Whenever an address is placed not determine the number of bytes that were
in a general register, bits 32-39 of the register, in compared.
the 24-bit addressing mode, or bit 32, in the 31-bit 4. R or R may be zero, in which case general
addressing mode, are set to zeros. Bits 0-31 of register 0 is treated as containing an address
the R and R registers always remain unchanged and also the ending character.
in the 24-bit or 31-bit mode.
5. In the access-register mode, access register 0
When condition code 0 is set, the contents of designates the primary address space regard-
general registers R and R remain unchanged. less of the contents of access register 0.

The amount of processing that results in the COMPARE UNTIL SUBSTRING


setting of condition code 3 is determined by the EQUAL
CPU on the basis of improving system perform-
ance, and it may be a different amount each time CUSE R,R [RRE]
the instruction is executed.

Access exceptions for the first and second oper- 'B257' //////// R R
ands are recognized only for that portion of the
16 24 28 31
operand which is necessarily examined in the
operation.
The first operand is compared with the second
Resulting Condition Code: operand until equal substrings (sequences of
bytes) of a specified length are found, the end of
0 Entire operands equal; general registers R
the longer operand is reached, or a
and R unchanged
CPU-determined number of unequal bytes have
1 First operand low; general registers R and
been compared, whichever occurs first. The
R updated with addresses of last bytes proc-
shorter operand is considered to be extended on
essed
the right with padding bytes. The
2 First operand high; general registers R and
CPU-determined number is at least 256. The
R updated with addresses of last bytes proc-
result is indicated in the condition code.
essed
3 CPU-determined number of bytes equal;
The R and R fields each designate an even-odd
general registers R and R updated with
pair of general registers and must designate an
addresses of next bytes
even-numbered register; otherwise, a specification
exception is recognized.

7-54 z/Architecture Principles of Operation


The location of the leftmost byte of the first bytes. Bits 56-63 of general register 1 are the
operand and second operand is specified by the padding byte. Bits 0-55 of general registers 0 and
contents of the R and R general registers, 1 are ignored.
respectively. In the 24-bit or 31-bit addressing
mode, the number of bytes in the first-operand The handling of the addresses in general registers
and second-operand locations is specified by the R and R is dependent on the addressing mode.
32-bit signed binary integer in bit positions 32-63 In the 24-bit addressing mode, the contents of bit
of general registers R + 1 and R + 1, respec- positions 40-63 of general registers R and R
tively. In the 64-bit addressing mode, the number constitute the address, and the contents of bit
of bytes is specified by the 64-bit signed binary positions 0-39 are ignored. In the 31-bit
integer in bit positions 0-63 of those registers. addressing mode, the contents of bit positions
When an operand length is negative, it is treated 33-63 of the registers constitute the address, and
as zero, and it remains unchanged upon com- the contents of bit position 0 are ignored. In the
pletion of the instruction. 64-bit addressing mode, the contents of bit posi-
tions 0-63 constitute the address.
Bits 56-63 of general register 0 specify the
unsigned substring length, a value of 0-255, in The contents of the registers just described are
shown in Figure 7-10 on page 7-56.

Chapter 7. General Instructions 7-55




/ /
GR /////////////////////////// SS Len. GR1 /////////////////////////// Pad
/ /
56 63 56 63


24-Bit Addressing Mode 31-Bit Addressing Mode

/ /
R //////////// First-Operand Address //// First-Operand Address
/ /
4 63 33 63

/ /
R + 1 /// First-Operand Length /// First-Operand Length
/ /
32 63 32 63

/ /
R ////////////Second-Operand Address //// Second-Operand Address
/ /
4 63 33 63

/ /
R + 1 /// Second-Operand Length /// Second-Operand Length
/ /
32 63 32 63

64-Bit Addressing Mode

/
R First-Operand Address
/
63

/
R + 1 First-Operand Length
/
63

/
R Second-Operand Address
/
63

/
R + 1 Second-Operand Length
/
63

Figure 7-10. Register Contents for COMPARE UNTIL SUBSTRING EQUAL

The result is obtained as if the operands were The comparison proceeds left to right, byte by
processed from left to right. However, multiple byte, and ends as soon as (1) equal substrings of
accesses may be made to all or some of the bytes the specified length are found, (2) the end of the
of each operand. longer operand is reached without finding equal
substrings of the specified length, or (3) the last
bytes compared are unequal, and a

7-56 z/Architecture Principles of Operation


CPU-determined number of bytes have been com- designate the first bytes of equal substrings in the
pared. The CPU-determined number is at least two operands, and the lengths in the R + 1 and
256. If the operands are not of the same length, R + 1 registers have been decremented by the
the shorter operand is considered to be extended number of bytes preceding the equal substrings,
on the right with the appropriate number of except when the equal substring in the shorter
padding bytes. operand begins with the padding byte, in which
case the length field for the shorter operand is
If the operation ends because equal substrings of zero, and the corresponding address field has
the specified length were found, the condition been incremented by the operand length. When
code is set to 0. If the operation ends because condition code 2 is set, each address field desig-
the end of the longer operand was reached nates the first byte after the corresponding
without finding equal substrings of the specified operand, and both length fields are zero. When
length, the condition code is set to 1 if equal bytes condition code 3 is set, each address field desig-
were the last bytes compared, or it is set to 2 if nates the first byte after the last compared byte of
unequal bytes were the last bytes compared. If the corresponding operand, and both length fields
the operation ends because unequal bytes were have been decremented by the number of bytes
compared when a CPU-determined number of compared, except that a length field is not decre-
bytes had been compared, the condition code is mented below zero.
set to 3.
When the contents of the R and R fields are the
If the specified substring length is zero, it is con- same, the first and second operands may be com-
sidered that equal substrings of the specified pared, or the condition code may be set to 0 or 1
length were found, and condition code 0 is set. without comparing the operands.

If both operands are of zero length but the speci- In the 24-bit or 31-bit addressing mode, the con-
fied substring length is not zero, it is considered tents of bit positions 0-31 of general registers R,
that the end of the longer operand was reached R + 1, R, and R + 1, always remain
when unequal bytes were the last bytes com- unchanged.
pared, and condition code 2 is set.
The substring length and padding byte may be
If equal bytes have been compared but then fetched from general registers 0 and 1 multiple
unequal bytes are compared, it is considered that times during the execution of the instruction, and
all bytes so far compared are unequal. the registers designated by R and R may be
updated multiple times. Therefore, if R or R is
At the completion of the operation, the operand- zero, the results are unpredictable.
length fields in the R + 1 and R + 1 registers
are decremented by the number of unequal bytes When condition code 3 is set, the general regis-
compared (including equal bytes before unequal ters used by the instruction have been set so that
bytes compared), and the addresses in the R the remainder of the operands can be processed
and R registers are incremented by the same by simply branching back and reexecuting the
number. However, in the case when a byte of the instruction.
longer operand is compared against the padding
byte, the length field for the shorter operand is not The amount of processing that results in the
decremented below zero, and the corresponding setting of condition code 3 is determined by the
address is not incremented above the address of CPU on the basis of improving system perform-
the first byte after the shorter operand. In the ance, and it may be a different amount each time
24-bit or 31-bit addressing mode, the leftmost bits the instruction is executed.
which are not part of the addresses in bit positions
32-63 of registers R and R are set to zeros, The execution of the instruction is interruptible
even if the substring length is zero or both when the last bytes compared are unequal; it is
operand lengths are initially zero. not interruptible when the last bytes compared are
equal. When an interruption occurs, other than
Thus, when condition code 0 or 1 is set, the one that causes termination, the contents of the
resulting addresses in the R and R registers registers designated by the R and R fields are

Chapter 7. General Instructions 7-57


updated the same as upon normal completion of or condition code 1 is set if the operand length
the instruction, so that the instruction, when reexe- is less than the specified substring length.
cuted, resumes at the point of interruption. The Whether or not R equals R, if both operand
condition code is unpredictable. lengths are zero, condition code 0 is set if the
specified substring length is zero, or condition
Access exceptions for the portion of a storage code 2 is set if the specified substring length
operand to the right of the last byte processed is nonzero. In all of these cases, the
may or may not be recognized. For operands addresses in the R and R registers and the
longer than 4K bytes, access exceptions are not lengths in the R + 1 and R + 1 registers
recognized for locations more than 4K bytes remain unchanged.
beyond the last byte processed.
3. Special precautions should be taken when
When the length of an operand is zero, no access COMPARE UNTIL SUBSTRING EQUAL is
exceptions are recognized for that operand. made the target of EXECUTE. See the pro-
Access exceptions are not recognized for an gramming note concerning interruptible
operand if the R field associated with that operand instructions under EXECUTE.
is odd. Although the operand address and length 4. Other programming notes concerning interrup-
fields remain unchanged when a zero substring tible instructions are included in Interruptible
length is specified, the recognition of access Instructions on page 5-20.
exceptions is not necessarily prevented.
5. In the access-register mode, access register 0
Resulting Condition Code: designates the primary address space regard-
less of the contents of access register 0.
0 Equal substrings of specified length found
1 End of longer operand reached when last
bytes compared are equal
COMPRESSION CALL
2 End of longer operand reached when last CMPSC R,R [RRE]
bytes compared are unequal
3 Last bytes compared are unequal, and
CPU-determined number of bytes compared 'B263' //////// R R

Program Exceptions: 16 24 28 31

Access (fetch, operands 1 and 2)


This definition assumes knowledge of the introduc-
Specification
tory information and information about dictionary
Programming Notes: formats in Enterprise Systems Architecture/390
Data Compression, SA22-7208-01.
1. When the R and R fields are the same, the
operation proceeds in the same way as when The second operand is compressed or expanded,
two distinct pairs of registers having the same depending on a specification in general register 0,
contents are specified, and, in the absence of and the results are placed at the first-operand
dynamic modification of the operand area by location. The compressed-data operand normally
another CPU or by a channel program, condi- consists of index symbols corresponding to entries
tion code 0, 1, or 2 is set (as explained in the in a dictionary designated by an address in
next note). However, it is unpredictable general register 1. This dictionary is a com-
whether access exceptions are recognized for pression dictionary during a compression opera-
the operand since the operation can be com- tion or an expansion dictionary during an
pleted without storage being accessed. expansion operation. During compression when
2. If the contents of the R and R fields are the format-1 sibling descriptors are specified in
same and the operand length is nonzero, and general register 0, an expansion dictionary imme-
provided that another CPU or a channel diately follows the compression dictionary. During
program is not changing an operand, condition compression when the symbol-translation option is
code 0 is set if the operand length is equal to specified in general register 0, the index symbols
or greater than the specified substring length, resulting from compression are translated to inter-
change symbols by means of a symbol-translation

7-58 z/Architecture Principles of Operation


table designated by the address and an offset in 0-39 and 52-63 are ignored. In the 31-bit
general register 1, and it is the interchange addressing mode, the contents of bit positions
symbols that are placed at the first-operand 33-51 of register 1, with 12 rightmost zeros
location. The number of bits in a symbol in the appended, constitute the address, and the con-
compressed-data operand is specified in general tents of bit positions 0-32 and 52-63 are ignored.
register 0. The operation proceeds until the end In the 64-bit addressing mode, the contents of bit
of either operand is reached or a CPU-determined positions 0-51 of register 1, with 12 rightmost
amount of data has been processed, whichever zeros appended, constitute the address, and the
occurs first. The results are indicated in the con- contents of bit positions 52-63 are ignored.
dition code.
Although the contents of bit positions 52-63 of
Bits 16-23 of the instruction are ignored. general register 1 are ignored as just described,
those contents are used as follows. The contents
The R and R fields each designate an even-odd of bit positions 61-63 of the register are the
pair of general registers and must designate an compressed-data bit number (CBN). At the begin-
even-numbered register; otherwise, a specification ning of the operation, the CBN designates the left-
exception is recognized. most bit within the leftmost byte of the
compressed-data operand. The compressed-data
The location of the leftmost byte containing any bit operand is the first operand during compression,
of the first operand and second operand is desig- or it is the second operand during expansion.
nated by an address in general registers R and When the symbol-translation option is specified
R, respectively. The number of bytes containing during compression, the contents of bit positions
any bits of the first operand and second operand 52-60 of the register, with seven rightmost zeros
is specified by bits 32-63 of general registers appended, are the byte offset from the beginning
R + 1 and R + 1, respectively, in the 24-bit or of the compression dictionary to the leftmost byte
31-bit addressing mode or by bits 0-63 of the reg- of the symbol-translation table. Symbol translation
isters in the 64-bit addressing mode. The con- cannot be specified during expansion, and the
tents of general registers R + 1 and R + 1 are contents of bit positions 52-60 are ignored during
treated as 32-bit unsigned binary integers in the expansion.
24-bit or 31-bit addressing mode or as 64-bit
unsigned binary integers in the 64-bit addressing The contents of the registers just described and
mode. also of general register 0 are shown in
Figure 7-11 on page 7-60.
The location of the leftmost byte of the com-
pression dictionary during compression, or of the Bit 55 (E) of general register 0 specifies the com-
expansion dictionary during expansion, is desig- pression operation if zero or the expansion opera-
nated on a 4K-byte boundary by an address in tion if one.
general register 1.
Bit 47 (ST) of general register 0 is the symbol-
The handling of the addresses in general registers translation-option bit. During compression when
R, R, and 1 is dependent on the addressing bit 47 is zero, the operation produces indexes,
mode. In the 24-bit addressing mode, the con- called index symbols, to compression-dictionary
tents of bit positions 40-63 of registers R and R entries that represent character strings, and the
constitute the address, and the contents of bit operation then places the index symbols in the
positions 0-39 are ignored. In the 31-bit compressed-data operand. During compression
addressing mode, the contents of bit positions when bit 47 is one, the operation still produces
33-63 of registers R and R constitute the index symbols but then translates the index
address, and the contents of bit positions 0-32 are symbols to other symbols, called interchange
ignored. In the 64-bit addressing mode, the con- symbols, that it then places in the compressed-
tents of bit positions 0-63 of registers R and R data operand. This symbol translation is done by
constitute the address. In the 24-bit addressing using the symbol-translation table specified by the
mode, the contents of bit positions 40-51 of reg- address and offset in general register 1. Bit 47
ister 1, with 12 rightmost zeros appended, consti- and the offset in general register 1 are ignored
tute the address, and the contents of bit positions during expansion. During expansion, the

Chapter 7. General Instructions 7-59



24-Bit Addressing Mode 31-Bit Addressing Mode

/ /
R //////////// First-Operand Address //// First-Operand Address
/ /
4 63 33 63

/ /
R + 1 /// First-Operand Length /// First-Operand Length
/ /
32 63 32 63

/ /
R ////////////Second-Operand Address //// Second-Operand Address
/ /
4 63 33 63

/ /
R + 1 /// Second-Operand Length /// Second-Operand Length
/ /
32 63 32 63

When ST Bit Is Zero during Compression, or during Expansion

/ /
GR1 ////////////Dict. Or.////////CBN ////Dictionary Origin////////CBN
/ /
4 52 61 63 33 52 61 63

When ST Bit Is One during Compression

/ /
GR1 ////////////Dict. Or.STT Off.CBN ////Dictionary OriginSTT Off.CBN
/ /
4 52 61 63 33 52 61 63

64-Bit Addressing Mode



/
R First-Operand Address
/
63

/
R + 1 First-Operand Length
/
63

/
R Second-Operand Address
/
63

/
R + 1 Second-Operand Length
/
63

Figure 7-11 (Part 1 of 2). Register Contents for COMPRESSION CALL

compressed-data operand always contains index as shown in the figure. Bits 48-51 must not have
symbols that designate entries in the expansion any of the values 0000 or 0110-1111 binary; oth-
dictionary. erwise, a specification exception is recognized.
When symbol-translation is not specified, bits
Bits 48-51 (CDSS) of general register 0 specify 48-51 also specify, as shown in the figure, the
the number of bits in the index symbols or inter- number of eight-byte entries in each of the com-
change symbols in the compressed-data operand, pression and expansion dictionaries, and, thus,

7-60 z/Architecture Principles of Operation



64-Bit Addressing Mode (Continued)

When ST Bit Is Zero during Compression,
or during Expansion

/
GR1 Dictionary Origin ////////CBN
/
52 61 63

When ST Bit Is One during Compression

/
GR1 Dictionary Origin STT Off.CBN
/
52 61 63


/
S F
GR /////////////TCDSS//1E////////
/
47 52 54 56 63

Explanation:

Compression dictionary during compression, or expansion dictionary during
expansion
CBN Compressed-data bit number
CDSS Compressed-data symbol size, and dictionary size when symbol
translation not specified
CDSS Symbol Dictionary
(binary) Size Size
Causes a specification exception to be recognized
1 9 bits 512 entries, 4K bytes
1 1 bits 1K entries, 8K bytes
11 11 bits 2K entries, 16K bytes
1 12 bits 4K entries, 32K bytes
11 13 bits 8K entries, 64K bytes
11-1111 Causes a specification exception to be recognized
E Expansion operation
F1 Format-1 sibling descriptors (ignored during expansion)
ST Symbol-translation option (ignored during expansion)
STT Off. Symbol-translation-table offset (ignored during expansion)

Figure 7-11 (Part 2 of 2). Register Contents for COMPRESSION CALL

they specify the size in bytes of each of the dic- are unpredictable. For example, if the CDSS is
tionaries. When symbol translation is specified, 0101, the offset must be at least 32K bytes.
the compression dictionary is considered to extend
to the beginning of the symbol-translation table, Bit 54 (F1) of general register 0 specifies that the
that is, the size in bytes of the compression dic- compression dictionary contains format-0 sibling
tionary is the offset in bit positions 52-60 of descriptors if the bit is zero or format-1 sibling
general register 1, with seven rightmost zeros descriptors if the bit is one. Sibling descriptors
appended. The size in bytes of the symbol- are used during the compression operation. A
translation table is considered to be one fourth format-0 sibling descriptor is eight bytes at an
that of the compression dictionary. However, the index position in the compression dictionary. A
offset in general register 1 must be at least as format-1 sibling descriptor is 16 bytes, with the
large as the size of the compression dictionary first eight bytes at an index position in the com-
would be if symbol translation were not specified pression dictionary and the second eight bytes at
and the CDSS were one less than it actually is, the same index position in the expansion dic-
and, when the CDSS is 0001 binary, the offset tionary. During compression when bit 54 is one,
must be at least 2K bytes; otherwise, the results an expansion dictionary is considered to imme-

Chapter 7. General Instructions 7-61


diately follow the compression dictionary specified If the operation is ended because the end of the
by the address in general register 1. Bit 54 is second operand is reached, condition code 0 is
ignored during expansion. set. If the operation is ended because the end of
the first operand is reached, condition code 1 is
Bits 47 and 54 of general register 0 must not both set, except that condition code 0 is set if the end
be ones; otherwise, the results are unpredictable. of the second operand is also reached. If the
operation is ended because a CPU-determined
The unused bit positions in general register 0 are amount of data has been processed, condition
reserved for possible future extensions and should code 3 is set.
contain zeros; otherwise, the program may not
operate compatibly in the future. At the completion of the operation, the length in
general register R + 1 is decremented by the
In the access-register mode, the contents of number of complete bytes stored at the first-
access register R are used for accessing the first operand location, and the address in general reg-
operand, and the contents of access register R ister R is incremented by the same amount.
are used for accessing the second operand and During compression, a complete byte is consid-
the dictionaries and the symbol-translation table. ered to be stored only if all of its bit positions
contain bits of compressed data. During com-
The operation starts at the left end of both oper- pression when the first bit of compressed data
ands and proceeds to the right. The operation is stored is not in bit position 0 of a byte, the bits in
ended when the end of either operand is reached the byte to the left of the first bit of compressed
or when a CPU-determined amount of data has data remain unchanged. During compression if
been processed, whichever occurs first. the last byte stored does not completely contain
compressed data, the bits in the byte to the right
During a compression operation, the end of the
of the rightmost bit of compressed data in the byte
first operand is considered to be reached when
either are unchanged or are set to zeros.
the number of unused bit positions remaining in
the first-operand location is not sufficient to The length in general register R + 1 is decre-
contain additional compressed data. mented by the number of complete bytes proc-
essed at the second-operand location, and the
During an expansion operation, the end of the
address in general register R is incremented by
first-operand location is considered to be reached
the same amount. During expansion, a complete
when either of the following two conditions is met:
byte is considered to be processed only if all of its
1. The number of unused byte positions bits have been used to produce expanded data.
remaining in the first-operand location is not
sufficient to contain all the characters that The leftmost bits which are not part of the address
would result from expansion of the next index in general registers R and R may be set to
symbol. zeros or may remain unchanged. However, in the
24-bit or 31-bit addressing mode, bits 0-31 of
2. Immediately when the number of unused byte
these registers and also of general registers
positions is zero, that is, immediately when
R + 1 and R + 1 always remain unchanged.
the expansion of an index symbol completely
fills the first-operand location. The bit number of the bit following the last bit of
compressed data processed is placed in bit posi-
During an expansion operation, the end of the
tions 61-63 of general register 1, and bits 52-60 of
second-operand location is considered to be
the register and the leftmost bits which are not
reached when the next index symbol does not
part of the address in the register may be set to
reside entirely within the second-operand location.
zeros or may remain unchanged, except that
The second-operand location ends at the begin-
when one or both of the original length values are
ning of the byte designated by the sum of the
so small that no compressed data can be proc-
address in general register R and the length in
essed, all bits in the register may remain
general register R + 1, regardless of the
unchanged. However, when bit 47 of general reg-
compressed-data bit number in bit positions 61-63
ister 0 is one, bits 52-60 of general register 1
of general register 1.
always remain unchanged. Also, in the 24-bit or

7-62 z/Architecture Principles of Operation


31-bit addressing mode, bits 0-31 of the register be recognized when the instruction is executed
always remain unchanged. again to continue processing the same operands,
assuming that the exception condition still exists.
If the operands overlap one another or the first
operand overlaps the dictionaries or the symbol- During compression, regardless of whether the
translation table in storage in any way, the results exception is recognized or condition code 3 is set,
are unpredictable. a nullifying access-exception condition or a sup-
pressing page-protection exception condition is
When symbol translation is specified, the symbol- handled so that an index symbol is generated only
translation table consists of two-byte entries, and if it is the one that would result if there were no
an entry contains an interchange symbol in the access-exception condition.
rightmost bit positions of the entry. The length of
the interchange symbol is specified by bits 48-51 During compression or expansion, regardless of
of general register 0. The left-hand bits that are whether the exception is recognized or condition
not part of the interchange symbol in a symbol- code 3 is set, a nullifying or suppressing access-
translation-table entry must be zeros; otherwise, exception condition may result in data having
the results are unpredictable. been stored at the first-operand location at or to
the right of the location designated by the final
To translate an index symbol to an interchange address in general register R, which result is not
symbol, the index symbol is multiplied by 2 and true nullification or suppression. The amount of
then added to the address of the beginning of the data stored depends on the reason for the access-
symbol-translation table to locate an entry in the exception condition. If the condition is due to a
table, and then the interchange symbol is obtained reference to a dictionary or the symbol-translation
from the entry. table, up to 4K bytes of data may have been
stored at or to the right of the location designated
The execution of the instruction is interruptible. by the final address. If the condition is due to a
When an interruption occurs, other than one that reference to the first or second operand, part of
causes termination, the contents of the registers one index or interchange symbol, during com-
designated by the R and R fields and of general pression, or part of one character symbol, during
register 1 are updated the same as upon normal expansion, may have been stored at or to the right
completion of the instruction, so that the instruc- of the location designated by the final address. In
tion, when reexecuted, resumes at the point of all cases, the storing will be repeated when the
interruption. The condition code is unpredictable. instruction is executed again to continue proc-
essing the same operands.
For operands longer than 4K bytes, access
exceptions are not recognized for locations more If the end of the first operand is reached and an
than 4K bytes beyond the current location being access exception is due to be recognized for the
processed. Access exceptions may be recognized second operand, it is unpredictable whether condi-
for all locations in the dictionaries and symbol- tion code 1 is set or the access exception is
translation table if those areas are specified to be recognized.
used and even if the locations would not be used
during the operation. Access exceptions are not During expansion when the expansion dictionary
recognized for an operand, the dictionaries, or the is not logically correct, unusual storing may occur
symbol-translation table if the R field associated as described in the section Expansion Process in
with that operand is odd. Also, when the R field Chapter 1. The results of an access exception in
is odd, PER storage-alteration events are not this case may not be true nullification or sup-
recognized, and no change bits are set. pression.

If an access exception is due to be recognized for The references to the operands, dictionaries, and
either of the operands or for a dictionary or the symbol-translation table are multiple-access refer-
symbol-translation table, the result is that either ences.
the exception is recognized or condition code 3 is
set. If condition code 3 is set, the exception will Special Conditions

Chapter 7. General Instructions 7-63


During compression of each character symbol, Programming Notes:
either the characters in the symbol or the dic-
1. When condition code 3 is set, the program
tionary character entries (not sibling descriptors)
can simply branch back to the instruction to
representing characters of the symbol are
continue the operation. The program need
counted, and a data exception is recognized if this
not determine the amount of data processed.
count becomes too large. The count can reach at
least 260 without the exception being recognized. 2. During compression when a nullifying access
exception is due to be recognized, an index
During compression, the number of child charac- symbol is generated only if it is the one that
ters or sibling characters processed during the would result if there were no access-exception
processing of each parent entry are counted, and condition. The result of this is that com-
a data exception is recognized if this count pression of the same expanded data by
becomes too large. The count can reach at least means of one or more executions of the
260 without the exception being recognized. That instruction and by using the same dictionary
is, a parent must not have more than 260 children; always results in the same compressed data.
otherwise, a data exception may be recognized. That is, (1) the best possible matches in the
the dictionary are always found for the charac-
During expansion of each character symbol, either ters in the second operand, or else the exe-
the characters in the symbol or the dictionary cution is ended by either setting CC3 or
entries representing characters of the symbol are recognizing the exception, and (2) the results
counted, and a data exception is recognized if this of compression are repeatable (although pos-
count becomes too large. If the characters in the sibly by means of a different number of exe-
symbol are counted, the count can reach at least cutions of the instruction) and predictable.
260 without the exception being recognized. If the
For example, if the next characters of the
dictionary entries representing characters of the
string being compressed are ABC, and dic-
symbol are counted, the count can reach at least
tionary entry A has a child B, which has a
127 without the exception being recognized.
child C, the normal operation is to compress
Certain error conditions in the dictionaries cause a ABC as a single index symbol, but if the C of
data exception to be recognized and the operation the string is in the first byte of an invalid page
to be terminated. Some of these error conditions (a page-translation exception is due to be
are described in the sections Expansion Process recognized), no index symbol is generated.
and Results of Dictionary Errors in Chapter 1. More specifically, an index symbol corre-
The others are described in Chapter 2. sponding to the character symbol AB is not
generated because this is not the index
Resulting Condition Code: symbol that would be generated if the access-
exception condition did not exist.
0 End of second operand reached
1 End of first operand reached and end of In the above, best possible match refers only
second operand not reached to the characters in the second operand. In
2 -- the example above, if the next two characters
3 CPU-determined amount of data processed of the second operand (the string) are AB,
and these are the last two characters of the
Program Exceptions: second operand, the best possible match is
on AB, even though there could be a match
Access (fetch, operand 2, dictionaries, and
on ABC if the second operand included one
symbol-translation table; store, operand 1)
more byte containing C.
Data
Specification Expansion is normally always repeatable. An
index symbol is always expanded to exactly
the character symbol it represents unless an
exception that causes termination is recog-
nized.
3. During expansion, if at least one unused byte
position remains in the first operand location,

7-64 z/Architecture Principles of Operation


COMPRESSION CALL may completely translation table may result in the storing of
process the next index symbol in the second data at or to the right of the location desig-
operand before it determines that the first- nated by the final address in general register
operand location does not have sufficient R. This storing and the processing needed
unused byte positions to contain the expanded to produce the data stored will be repeated
data that would result from the next index when COMPRESSION CALL is executed
symbol. If that next index symbol causes again to continue processing the same oper-
encountering of bad dictionary entries, the ands. The repeated processing will reduce
result can be either a data exception or condi- the performance of the instruction execution,
tion code 1. and it should be avoided by ensuring that the
environment in which the program is executed
COMPRESSION CALL immediately sets con-
is one in which page-translation-exception
dition code 1 when processing of an index
conditions for the dictionaries and symbol-
symbol exactly fills the first-operand location,
translation table are infrequent.
except that it sets condition code 0 if the end
of the second-operand location also has been 5. Following is an example of how the
reached. Immediately setting condition code 1 compressed-data bit number (CBN) is used
has the advantage that data can be com- and set. In this example:
pressed using one dictionary and then fol-
The operation is an expansion operation.
lowed immediately, possibly on a bit
boundary, by a different type of data com- The CDSS in general register 0 is 0010
pressed using another dictionary. The com- binary. Therefore, there are 1K entries in
pressed data can be successfully expanded if, the expansion dictionary, and the length of
during the expansion of the data compressed an index symbol is 10 bits.
using the first dictionary, the length of the first- The second operand (compressed-data
operand location is specified to be exactly the operand) begins at location 6000 hex and
length of the expanded data that will be has a length of five bytes. The initial CBN
produced. Condition code 1 will then be set is 7. Therefore, there are three index
when the first-operand location is full, at which symbols to be expanded, and the final
time the specification of the dictionary can be CBN will be 5.
changed in order to expand the remainder of
the compressed data using the second dic- The compressed data beginning at
tionary. If the definition allowed condition location 6000 hex is 0081FF9FF8 hex.
code 1 not to be set, it might be attempted to Therefore, the three index symbols are
expand the next index symbol, which resulted 103, 3FC, and 3FF hex.
from use of the second dictionary, by means The first operand (expanded-data
of the first dictionary, and this might cause operand) begins at location 5000 hex and
recognition of a data exception. For example, has a length of 64 bytes. The three index
the next index symbol, which properly desig- symbols are expanded to a total of 14
nates a character entry in the second dic- bytes of expanded data.
tionary, might designate the second half of a
format-1 sibling descriptor in the first dic- The following figure shows the initial and final
tionary, and that second half might begin with contents of general registers R, R + 1, R,
a character, such as 0 (F0 hex), that would and R + 1, the contents of locations
appear to be an invalid partial symbol length 6000-6004 hex in binary, and the way a
in a character entry. cursor corresponding to the CBN is advanced
during the expansion operation.
4. A nullifying access-exception condition due to
a reference to a dictionary or the symbol-

Chapter 7. General Instructions 7-65


Initial Final tionary, which is the largest size VTAM uses.
Contents Contents All of the entries in this dictionary correspond
Register in Hex in Hex to character symbols because there are no
R 5 5E sibling descriptors in the VTAM dictionary.
R+1 4 32 The VTAM dictionary cannot map one-to-one
R 6 64 to a COMPRESSION CALL dictionary
R+1 5 1 because the latter requires that some of the
entries be sibling descriptors. Therefore,
Contents of Locations 6-64 Hex in Binary
VTAM must have an 8K-entry dictionary for
11 11111111 111111 11111 use in the basic compression operation. Only
& & & & the first hundred or so entries in the second
4K of the 8K need to be used, and these
Initial Final entries compensate for (take the place of) the
CBN (7) CBN (5)
entries in the first 4K that must be sibling
descriptors. The STT can and should, to save
6. The reason for allowing a parent to have no space, begin immediately after those hundred
more than 260 children is as follows. The or so entries in the second 4K. In this
parent can contain five identical child charac- example, the index symbols will be 13 bits but
ters. Then, 255 different sibling characters will be transformed to 12-bit interchange
are possible -- all of these must be different symbols.
from the child characters and each other, or
8. A program may place the dictionaries in pages
else they may be wasted (never matched
that are managed by means of chaining fields
against), depending on the implementation.
at their beginnings. In this case, either the
Thus, every possible child is permitted.
parts of a dictionary have to be moved to be
7. Symbol translation is for use by VTAM. compacted into contiguous locations or there
VTAM will begin by doing compression by have to be holes in the dictionaries. The defi-
means of software and an adaptive dictionary. nition of COMPRESSION CALL contains
When the adaptive dictionary has matured nothing explicitly to support holes. However,
such that the degree of compression becomes assuming there is at least one character that
sufficiently good (crosses some threshold), never appears in the expanded data, that
VTAM will freeze (stop adapting) its dic- character can be used as a child character in
tionary, inform the other end of the session to a parent entry or as a sibling character in a
freeze also, transform its adaptive dictionary sibling descriptor to specify a child or children
to the dictionary form used by COM- that will never be referenced, thus creating a
PRESSION CALL, and then use COM- hole.
PRESSION CALL to continue on with the
9. Figure 7-12 on page 7-67 and Figure 7-13 on
compression. The other end of the session
page 7-69 show possible forms (not the only
can continue to use its frozen adaptive dic-
possible forms) of the compression and
tionary.
expansion processes. The figures do not
Following is clarification about the STT offset. show testing for or the results of dictionary
Assume VTAM uses a 4K-entry adaptive dic- errors.

7-66 z/Architecture Principles of Operation


Start Notes: Entry fields are in parent
(1)5 or sibling descriptor.
6 SRC=source, DST=destination.
Another SRC
char exists? No5Set CC and endop.
Yes
(2)5 (8)5Store parent index in DST.
6 Advance 1 index in DST. 5(2)
Another DST index
position exists? No5Set CC1 and endop.
Yes

6
Use next SRC char as
index of alphabet entry.
Call this entry parent.
Advance 1 byte in SRC.
(3)5
6
CCT=? Yes5(9)5Store parent index in DST.
No Advance 1 index in DST. 5(1)
(4)5
6
Set flag=1. Note: Flag is 1 as long as there are equal
comparisons to identical leading CCs.
6
Another SRC
char exists? No5Store parent index in DST.
Yes Advance 1 index in DST.
Set CC and endop.
6
Repeat for each CC. Note: See the definition for how CCT speci-
5(5)5 fies number of CCs and more children.
6
Next SRC char=CC? Yes5Set child index=
No CPTR+CC number
(-origin numbering).
6
Set flag= 6
X=1 for child? No5(See note below.)
6 Yes Store child index in DST.
Another CC? Advance 1 index in DST.
Yes No Advance 1 byte in SRC.

6 6 5(1)
CCT indicates ACT= OR D=
more children? in child? Yes5Call child the parent.
Yes No5(8) No Advance 1 byte in SRC.

6 6 5(3)
(6) Compare SRC chars after
Go to Part 2. next char to AECs in child.

6 Note: The preferred path for X=
(1) is shown, but the other
Go to Part 2. path may be taken.
Figure 7-12 (Part 1 of 2). Compression Process

Chapter 7. General Instructions 7-67


From Part 1. From Part 1.
(6) (1)

6 6
Set sibling Enough SRC chars
descriptor (SD) for comparison? No5Flag=1? No5(8)
index=CPTR+ Yes Yes
number of CCs.
6
Another CC? No5(8)
Yes

(7)5 5(5)
6 6
Repeat for Chars equal? Yes5Call child the parent.
each SC in SD. No Advance in SRC by
1+number of AEC bytes.
Note: See the 6
definition Flag=1? No5(8) 5(3)
for how SCT Yes
specifies
number of 6
SCs and Another CC? No5(8)
more Yes
children. Note: The preferred path for Y=
5 5(5) is shown, but the other
6 path may be taken.
Next SRC char=SC? Yes5Set child index=
No SD index+SC number
(1-origin numbering).
6
Another SC? 6
Yes No Y=1 for child
or no Y? No5(See note above.)
Yes Store child index in DST.
6 Advance 1 index in DST.
SCT indicates Advance 1 byte in SRC.
more children?
Yes No5(8) 6 5(1)
ACT= OR D=
6 in child? Yes5Call child the parent.
Set SD index No Advance 1 byte in SRC.
=current SD
index+number 6 5(3)
of SCs+1 Compare SRC chars after
next char to AECs in child.
5(7)
6
Note: Second half Enough SRC chars
of format-1 for comparison? No5(8)
SD is in Yes
expansion
dictionary. 6
Chars equal? Yes5Call child the parent.
No Advance in SRC by
1+number of AEC bytes.
5(8)
5(3)
Figure 7-12 (Part 2 of 2). Compression Process

7-68 z/Architecture Principles of Operation


Start Notes: Fields are in current entry.
(1)5 SRC=source, DST=destination.
6
Another SRC
index exists? No5Set CC and endop.
Yes

6
> DST byte
positions exist? No5Set CC1 and endop.
Yes

6
Next SRC
index<256? Yes5Another DST byte
No position exists? No5Set CC1 and endop.
Yes
6
Use next SRC index 6
as index of current Store index as char in DST.
entry. Advance 1 index in SRC.
Advance 1 byte in DST. 5(1)
6
PSL=? Yes5CSL DST byte
No positions exist? No5Set CC1 and endop.
Yes
6
Set SYMLEN= 6
PSL+OFST Get CSL ECs from entry
and store in DST.
Advance 1 index in SRC.
6 Advance CSL bytes in DST. 5(1)
SYMLEN DST byte
positions exist? No5Set CC1 and endop.
Yes

6
Get PSL ECs from entry
and store in DST at OFST.
Use PPTR as index of
current entry (see note).
5
6
PSL=? Yes5Get CSL ECs from entry
No and store in DST.
Advance 1 index in SRC.
Advance SYMLEN bytes in DST. 5(1)
6
Get PSL ECs from entry
and store in DST at OFST.
Use PPTR as index of
current entry (see note).

Note: If PPTR<256, the action can be:

Store PPTR as char in DST.


Advance 1 index in SRC.
Advance SYMLEN bytes in DST. 5(1)
Figure 7-13. Expansion Process

CONVERT TO BINARY

Chapter 7. General Instructions 7-69


CVB R,D(X,B) [RX] Condition Code: The code remains unchanged.
Program Exceptions:
'4F' R X B D
Access (fetch, operand 2)
8 12 16 2 31 Data
Fixed-point divide
CVBG R,D(X,B) [RXE]
Programming Notes:
/
'E3' R X B D //////// 'E' 1. An example of the use of the CONVERT TO
/ BINARY instruction is given in Appendix A,
8 12 16 2 32 4 47 Number Representation and Instruction-Use
Examples.
The second operand is changed from decimal to 2. When the second operand is negative, the
binary, and the result is placed at the first-operand result is in two's-complement notation.
location.
3. The storage-operand references for
For CONVERT TO BINARY (CVB), the second CONVERT TO BINARY may be multiple-
operand occupies eight bytes in storage, and, for access references. (See Storage-Operand
CONVERT TO BINARY (CVBG), the second Consistency on page 5-86.)
operand occupies sixteen bytes in storage. The
second operand has the format of packed decimal CONVERT TO DECIMAL
data, as described in Chapter 8, Decimal
Instructions. It is checked for valid sign and digit CVD R,D(X,B) [RX]
codes, and a decimal-operand data exception is
recognized when an invalid code is detected.
'4E' R X B D

For CONVERT TO BINARY (CVB), the result of 8 12 16 2 31
the conversion is a 32-bit signed binary integer,
which is placed in bit positions 32-63 of general
CVDG R,D(X,B) [RXE]
register R. Bits 0-31 of the register remain
unchanged. The maximum positive number that /
can be converted and still be contained in 32 bit 'E3' R X B D //////// '2E'
positions is 2,147,483,647; the maximum negative /
number (the negative number with the greatest 8 12 16 2 32 4 47
absolute value) that can be converted is
-2,147,483,648. For any decimal number outside The first operand is changed from binary to
this range, the operation is completed by placing decimal, and the result is stored at the second-
the 32 rightmost bits of the binary result in the operand location.
register, and a fixed-point-divide exception is
recognized. For CONVERT TO DECIMAL (CVD), the first
operand is treated as a 32-bit signed binary
For CONVERT TO BINARY (CVBG), the result of integer, and the result occupies eight bytes in
the conversion is a 64-bit signed binary integer, storage. For CONVERT TO DECIMAL (CVDG),
which is placed in bit positions 0-63 of general the first operand is treated as a 64-bit signed
register R. The maximum positive number that binary integer, and the result occupies sixteen
can be converted and still be contained in a 64-bit bytes in storage.
register is 9,223,372,036,854,775,807; the
maximum negative number (the negative number The result is in the format for packed decimal
with the greatest absolute value) that can be con- data, as described in Chapter 8, Decimal
verted is -9,223,372,036,854,775,808. For any Instructions. The rightmost four bits of the result
decimal number outside this range, a fixed-point- represent the sign. A positive sign is encoded as
divide exception is recognized, and the operation 1100; a negative sign is encoded as 1101.
is suppressed.

7-70 z/Architecture Principles of Operation


Condition Code: The code remains unchanged. the contents of general registers R and R,
respectively. In the 24-bit or 31-bit addressing
Program Exceptions: mode, the number of bytes in the first-operand
Access (store, operand 2) and second-operand locations is specified by the
contents of bit positions 32-63 of general registers
Programming Notes: R + 1 and R + 1, respectively, and those con-
tents are treated as 32-bit unsigned binary inte-
1. An example of the use of the CONVERT TO gers. In the 64-bit addressing mode, the number
DECIMAL instruction is given in Appendix A, of bytes in the first-operand and second-operand
Number Representation and Instruction-Use locations is specified by the entire contents of
Examples. general registers R + 1 and R + 1, respec-
2. For CVD, the number to be converted is a tively, and those contents are treated as 64-bit
32-bit signed binary integer obtained from a unsigned binary integers.
general register. Since 15 decimal digits are
available for the result, and the decimal equiv- The handling of the addresses in general registers
alent of 31 bits requires at most 10 decimal R and R is dependent on the addressing mode.
digits, an overflow cannot occur. Similarly, for
CVDG, 31 decimal digits are available, the In the 24-bit addressing mode, the contents of bit
decimal equivalent of 63 bits is at most 19 positions 40-63 of general registers R and R
digits, and an overflow cannot occur. constitute the address, and the contents of bit
positions 0-39 are ignored. In the 31-bit
3. The storage-operand references for addressing mode, the contents of bit positions
CONVERT TO DECIMAL may be multiple- 33-63 of the registers constitute the address, and
access references. (See Storage-Operand the contents of bit positions 0-32 are ignored. In
Consistency on page 5-86.) the 64-bit addressing mode, the contents of bit
positions 0-63 constitute the address.
CONVERT UNICODE TO UTF-8
The contents of the registers just described are
CUUTF R,R [RRE] shown in Figure 7-14 on page 7-72.

The characters of the second operand are


'B2A6' //////// R R selected one by one for conversion, proceeding

16 24 28 31 left to right. The bytes resulting from a conversion


are placed at the first-operand location, pro-
ceeding left to right. The operation proceeds until
The two-byte Unicode characters of the second the first-operand or second-operand location is
operand are converted to UTF-8 characters and exhausted or a CPU-determined number of
placed at the first-operand location. The UTF-8 second-operand characters have been converted.
characters are one, two, three, or four bytes,
depending on the Unicode characters that are To show the method of converting a Unicode
converted. The operation proceeds until the end character to a UTF-8 character, the bits of a
of the first or second operand is reached or a Unicode character are identified by letters as
CPU-determined number of characters have been follows:
converted, whichever occurs first. The result is
Unicode Character 111111
indicated in the condition code. Bit Numbers 1234567 8912345
The R and R fields each designate an even-odd Identifying Bit Letters abcdefgh ijklmnop
pair of general registers and must designate an
In the case of a Unicode surrogate pair, which is a
even-numbered register; otherwise, a specification
character pair consisting of a character called a
exception is recognized.
high surrogate followed by a character called a
The location of the leftmost byte of the first low surrogate, the bits are identified by letters as
operand and the second operand is designated by follows:

Chapter 7. General Instructions 7-71




24-Bit Addressing Mode 31-Bit Addressing Mode

/ /
R //////////// First-Operand Address //// First-Operand Address
/ /
4 63 33 63

/ /
R + 1 /// First-Operand Length /// First-Operand Length
/ /
32 63 32 63

/ /
R ////////////Second-Operand Address //// Second-Operand Address
/ /
4 63 33 63

/ /
R + 1 /// Second-Operand Length /// Second-Operand Length
/ /
32 63 32 63

64-Bit Addressing Mode

/
R First-Operand Address
/
63

/
R + 1 First-Operand Length
/
63

/
R Second-Operand Address
/
63

/
R + 1 Second-Operand Length
/
63

Figure 7-14. Register Contents for CONVERT UNICODE TO UTF-8

Unicode High Surrogate 111111 Any Unicode character in the range 0000 to 007F
Bit Numbers 1234567 8912345 hex is converted to a one-byte UTF-8 character as
follows:
Identifying Bit Letters 1111ab cdefghij
Unicode jklmnop
Character
Unicode Low Surrogate 11112222 22222233
Bit Numbers 6789123 4567891 UTF-8 jklmnop
Character
Identifying Bit Letters 11111kl mnopqrst
Any Unicode character in the range 0080 to 07FF
hex is converted to a two-byte UTF-8 character as
follows:

7-72 z/Architecture Principles of Operation


Unicode fgh ijklmnop and R are updated in the 24-bit or 31-bit
Character addressing mode, bits 32-39 of them, in the 24-bit
mode, or bit 32, in the 31-bit mode, may be set to
UTF-8 11fghij 1klmnop
Character zeros or may remain unchanged.

Any Unicode character in the range 0800 to D7FF In the 24-bit or 31-bit addressing mode, the con-
and DC00 to FFFF hex is converted to a three- tents of bit positions 0-31 of general registers R,
byte UTF-8 character as follows: R + 1, R, and R + 1, always remain
Unicode abcdefgh ijklmnop unchanged.
Character
When condition code 3 is set, the registers have
UTF-8 111abcd 1efghij 1klmnop been updated so that the instruction, when reexe-
Character cuted, resumes at the next byte locations to be
Any Unicode surrogate pair starting with a high processed.
surrogate in the range D800 to DBFF hex is con-
verted to a four-byte UTF-8 character as follows: The amount of processing that results in the
setting of condition code 3 is determined by the
Unicode 1111ab cdefghij 11111kl mnopqrst
Characters CPU on the basis of improving system perform-
ance, and it may be a different amount each time
UTF-8 1111uvw 1xyefgh 1ijklmn 1opqrst the instruction is executed.
Character
When the R register is the same register as the
where uvwxy = abcd + 1 R register, the results are unpredictable.
The first six bits of the second Unicode character
are ignored. When the second operand overlaps the first
operand, the results are unpredictable.
The second-operand location is considered
exhausted when it does not contain at least two Access exceptions for the portions of the oper-
remaining bytes or at least four remaining bytes ands to the right of the last byte processed may or
when the first two bytes are a Unicode high surro- may not be recognized. For an operand longer
gate. The first-operand location is considered than 4K bytes, access exceptions are not recog-
exhausted when it does not contain at least the nized for locations more than 4K bytes beyond the
one, two, three, or four remaining bytes required last byte processed.
to contain the UTF-8 character resulting from the
conversion of the next second-operand character When the length of an operand is zero, no access
or surrogate pair. exceptions are recognized for that operand.
Access exceptions are not recognized for an
When the second-operand location is exhausted, operand if the R field associated with that operand
condition code 0 is set. When the first-operand is odd.
location is exhausted, condition code 1 is set,
except that condition code 0 is set if the second- Resulting Condition Code:
operand location also is exhausted. When a 0 Entire second operand processed
CPU-determined number of characters have been 1 End of first operand reached
converted, condition code 3 is set. 2 --
3 CPU-determined number of characters con-
When the operation is completed, the contents of verted
general register R + 1 are decremented by the
number of bytes converted, and the contents of Program Exceptions:
general register R are incremented by the same
number. Also, the contents of general register Access (fetch, operand 2; store, operand 1)
R + 1 are decremented by the number of bytes Specification
placed at the first-operand location, and the con- Programming Note: When condition code 3 is
tents of general register R are incremented by set, the program can simply branch back to the
the same number. When general registers R instruction to continue the conversion. The

Chapter 7. General Instructions 7-73


program need not determine the number of first- the contents of bit positions 0-32 are ignored. In
operand or second-operand bytes that were proc- the 64-bit addressing mode, the contents of bit
essed. positions 0-63 constitute the address.

The contents of the registers just described are


CONVERT UTF-8 TO UNICODE shown in Figure 7-15 on page 7-75.
CUTFU R,R [RRE]
The characters of the second operand are
selected one by one for conversion, proceeding
'B2A7' //////// R R left to right. The bytes resulting from a conversion
are placed at the first-operand location, pro-
16 24 28 31
ceeding left to right. The operation proceeds until
the first-operand or second-operand location is
The one-, two-, three-, or four-byte UTF-8 charac- exhausted, a CPU-determined number of second-
ters of the second operand are converted to two- operand characters have been converted, or an
byte Unicode characters and placed at the invalid UTF-8 character is encountered in the
first-operand location. The operation proceeds second operand.
until the end of the first or second operand is
reached, a CPU-determined number of characters To show the method of converting a UTF-8 char-
have been converted, or an invalid UTF-8 char- acter to a Unicode character, the bits of a Unicode
acter is encountered, whichever occurs first. The character are identified by letters as follows:
result is indicated in the condition code. Unicode Character 111111
Bit Numbers 1234567 8912345
The R and R fields each designate an even-odd
pair of general registers and must designate an Identifying Bit Letters abcdefgh ijklmnop
even-numbered register; otherwise, a specification In the case of a Unicode surrogate pair, which is a
exception is recognized. character pair consisting of a character called a
high surrogate followed by a character called a
The location of the leftmost byte of the first
low surrogate, the bits are identified by letters as
operand and the second operand is designated by
follows:
the contents of general registers R and R,
respectively. In the 24-bit or 31-bit addressing Unicode High Surrogate 111111
Bit Numbers 1234567 8912345
mode, the number of bytes in the first-operand
and second-operand locations is specified by the Identifying Bit Letters 1111ab cdefghij
contents of bit positions 32-63 of general registers
R + 1 and R + 1, respectively, and those con-
tents are treated as 32-bit unsigned binary inte- Unicode Low Surrogate 11112222 22222233
gers. In the 64-bit addressing mode, the number Bit Numbers 6789123 4567891
of bytes in the first-operand and second-operand Identifying Bit Letters 11111kl mnopqrst
locations is specified by the entire contents of
general registers R + 1 and R + 1, respec- When the contents of the first byte of a UTF-8
tively, and those contents are treated as 64-bit character are in the range 00 to 7F hex, the char-
unsigned binary integers. acter is a one-byte character, and it is converted
to a two-byte Unicode character as follows:
The handling of the addresses in general registers UTF-8 jklmnop
R and R is dependent on the addressing mode. Character

In the 24-bit addressing mode, the contents of bit Unicode jklmnop


positions 40-63 of general registers R and R Character
constitute the address, and the contents of bit When the contents of the first byte of a UTF-8
positions 0-39 are ignored. In the 31-bit character are in the range C0 to DF hex, the char-
addressing mode, the contents of bit positions acter is a two-byte character, and it is converted
33-63 of the registers constitute the address, and to a two-byte Unicode character as follows:

7-74 z/Architecture Principles of Operation




24-Bit Addressing Mode 31-Bit Addressing Mode

/ /
R //////////// First-Operand Address //// First-Operand Address
/ /
4 63 33 63

/ /
R + 1 /// First-Operand Length /// First-Operand Length
/ /
32 63 32 63

/ /
R ////////////Second-Operand Address //// Second-Operand Address
/ /
4 63 33 63

/ /
R + 1 /// Second-Operand Length /// Second-Operand Length
/ /
32 63 32 63

64-Bit Addressing Mode

/
R First-Operand Address
/
63

/
R + 1 First-Operand Length
/
63

/
R Second-Operand Address
/
63

/
R + 1 Second-Operand Length
/
63

Figure 7-15. Register Contents for CONVERT UTF-8 TO UNICODE

UTF-8 11fghij 1klmnop UTF-8 111abcd 1efghij 1klmnop


Character Character

Unicode fgh ijklmnop Unicode abcdefgh ijklmnop


Character Character
The first two bits in the second byte of the UTF-8 The first two bits in the second and third bytes of
character are ignored. the UTF-8 character are ignored.

When the contents of the first byte of a UTF-8 When the contents of the first byte of a UTF-8
character are in the range E0 to EF hex, the char- character are in the range F0 to F7 hex, the char-
acter is a three-byte character, and it is converted acter is a four-byte character, and it is converted
to a two-byte Unicode character as follows:

Chapter 7. General Instructions 7-75


to two two-byte Unicode characters (a surrogate mode, or bit 32, in the 31-bit mode, may be set to
pair) as follows: zeros or may remain unchanged.
UTF-8 1111uvw 1xyefgh 1ijklmn 1opqrst
Character In the 24-bit or 31-bit addressing mode, the con-
tents of bit positions 0-31 of general registers R,
Unicode 1111ab cdefghij 11111kl mnopqrst R + 1, R, and R + 1, always remain
Characters unchanged.
where zabcd = uvwxy -1
When condition code 3 is set, the registers have
The first two bits in the second, third, and fourth been updated so that the instruction, when reexe-
bytes of the UTF-8 character are ignored. The cuted, resumes at the next byte locations to be
high order bit (z) produced by the subtract opera- processed.
tion should be zero but is ignored.
When condition code 2 is set, general register R
The second-operand location is considered contains the address of the invalid UTF-8 char-
exhausted when it does not contain at least one acter.
remaining byte or when it does not contain at least
the two, three, or four remaining bytes required to The amount of processing that results in the
contain the two-, three-, or four-byte UTF-8 char- setting of condition code 3 is determined by the
acter indicated by the contents of the first CPU on the basis of improving system perform-
remaining byte. The first-operand location is con- ance, and it may be a different amount each time
sidered exhausted when it does not contain at the instruction is executed.
least two remaining bytes or at least four
remaining bytes in the case when a four byte When the R register is the same register as the
UTF-8 character is to be converted. R register, the results are unpredictable.

When the second-operand location is exhausted, When the second operand overlaps the first
condition code 0 is set. When the first-operand operand, the results are unpredictable.
location is exhausted, condition code 1 is set,
except that condition code 0 is set if the second- Access exceptions for the portions of the oper-
operand location also is exhausted. When a ands to the right of the last byte processed may or
CPU-determined number of characters have been may not be recognized. For an operand longer
processed, condition code 3 is set. than 4K bytes, access exceptions are not recog-
nized for locations more than 4K bytes beyond the
When the contents of the first byte of the next last byte processed.
UTF-8 character are in the range 80 to BF hex or
F8 to FF hex, the character is invalid, and condi- When the length of an operand is zero, no access
tion code 2 is set. exceptions are recognized for that operand.
Access exceptions are not recognized for an
When the conditions for setting condition codes 1 operand if the R field associated with that operand
and 2 are both met, condition code 2 is set. is odd.

When the operation is completed, the contents of Resulting Condition Code:


general register R + 1 are decremented by the 0 Entire second operand processed
number of bytes converted, and the contents of 1 End of first operand reached
general register R are incremented by the same 2 Invalid UTF-8 character
number. Also, the contents of general register 3 CPU-determined number of characters proc-
R + 1 are decremented by the number of bytes essed
placed at the first-operand location, and the con-
tents of general register R are incremented by Program Exceptions:
the same number. When general registers R
Access (fetch, operand 2; store, operand 1)
and R are updated in the 24-bit or 31-bit
Specification
addressing mode, bits 32-39 of them, in the 24-bit

7-76 z/Architecture Principles of Operation


Programming Notes: numbered register; otherwise, a specification
exception is recognized.
1. When condition code 3 is set, the program
can simply branch back to the instruction to
The dividend is treated as a 64-bit signed binary
continue the conversion. The program need
integer. The leftmost 32 bits of the dividend are in
not determine the number of first-operand or
bit positions 32-63 of general register R, and the
second-operand bytes that were processed.
rightmost 32 bits are in bit positions 32-63 of
2. Bits 0 and 1 of the continuation bytes of general register R + 1.
multiple-byte UTF-8 characters are not
checked in order to improve the performance The divisor, remainder, and quotient are treated
of the conversion. Therefore, invalid continua- as 32-bit signed binary integers. For DIVIDE
tion bytes are not detected. (DR), the divisor is in bit positions 32-63 of
general register R. The remainder is placed in
bit positions 32-63 of general register R, and the
COPY ACCESS quotient is placed in bit positions 32-63 of general
CPYA R,R [RRE] register R + 1. Bits 0-31 of the registers remain
unchanged.

'B24D' //////// R R The sign of the quotient is determined by the rules


of algebra, and the remainder has the same sign
16 24 28 31
as the dividend, except that a zero quotient or a
zero remainder is always positive.
The contents of access register R are placed in
access register R. When the divisor is zero, or when the magnitudes
of the dividend and divisor are such that the quo-
Condition Code: The code remains unchanged. tient cannot be expressed by a 32-bit signed
binary integer, a fixed-point-divide exception is
Program Exceptions: None. recognized. This includes the case of division of
zero by zero.
DIVIDE
Condition Code: The code remains unchanged.
DR R,R [RR]
Program Exceptions:

'1D' R R Access (fetch, operand 2 of D only)


Fixed-point divide
8 12 15 Specification

D R,D(X,B) [RX] DIVIDE LOGICAL


DLR R,R [RRE]
'5D' R X B D

8 12 16 2 31 'B997' //////// R R

The 64-bit first operand (the dividend) is divided 16 24 28 31
by the 32-bit second operand (the divisor), and the
32-bit remainder and quotient are placed at the DLGR R,R [RRE]
first-operand location.

'B987' //////// R R
The R field designates an even-odd pair of
general registers and must designate an even- 16 24 28 31

Chapter 7. General Instructions 7-77


DL R,D(X,B) [RXE] LOGICAL (DLGR, DLG), a fixed-point-divide
exception is recognized. This includes the case of
/ division of zero by zero.
'E3' R X B D //////// '97'
/
8 12 16 2 32 4 47 Condition Code: The code remains unchanged.

Program Exceptions:
DLG R,D(X,B) [RXE]
Access (fetch, operand 2 of DL or DLG only)
/ Fixed-point divide
'E3' R X B D //////// '87' Specification
/
8 12 16 2 32 36 4 47
DIVIDE SINGLE
The 64-bit or 128-bit first operand (the dividend) is
DSGR R,R [RRE]
divided by the 32-bit or 64-bit second operand (the
divisor), and the 32-bit or 64-bit remainder and
quotient are placed at the first-operand location. 'B9D' //////// R R

The R field designates an even-odd pair of 16 24 28 31
general registers and must designate an even-
numbered register; otherwise, a specification DSGFR R,R [RRE]
exception is recognized.

For DIVIDE LOGICAL (DLR, DL), the dividend is 'B91D' //////// R R

treated as a 64-bit unsigned binary integer. The 16 24 28 31
leftmost 32 bits of the dividend are in bit positions
32-63 of general register R, and the rightmost 32
DSG R,D(X,B) [RXE]
bits are in bit positions 32-63 of general register
R + 1. /
'E3' R X B D //////// 'D'
The divisor, remainder, and quotient are treated /
as 32-bit unsigned binary integers. For DIVIDE 8 12 16 2 32 4 47
LOGICAL (DLR), the divisor is in bit positions
32-63 of general register R. The remainder is DSGF R,D(X,B) [RXE]
placed in bit positions 32-63 of general register
R, and the quotient is placed in bit positions /
'E3' R X B D //////// '1D'
32-63 of general register R + 1. Bits 0-31 of the
/
registers remain unchanged. 8 12 16 2 32 4 47

For DIVIDE LOGICAL (DLGR, DLG), the dividend


is treated as a 128-bit unsigned binary integer. The 64-bit contents of general register R + 1
The leftmost 64 bits of the dividend are in general (the dividend) are divided by the 64-bit or 32-bit
register R, and the rightmost 64 bits are in second operand (the divisor), the 64-bit remainder
general register R + 1. The divisor, remainder, is placed in general register R, and the 64-bit
and quotient are treated as 64-bit unsigned binary quotient is placed in general register R + 1.
integers. The remainder is placed in general reg-
ister R, and the quotient is placed in general reg- The R field designates an even-odd pair of
ister R + 1. general registers and must designate an even-
numbered register; otherwise, a specification
When the divisor is zero, or when the magnitudes exception is recognized.
of the dividend and divisor are such that the quo-
tient cannot be expressed as a 32-bit unsigned The dividend, quotient, and remainder are treated
binary integer for DIVIDE LOGICAL (DLR, DL), or as 64-bit signed binary integers. For DIVIDE
a 64-bit unsigned binary integer for DIVIDE SINGLE (DSGR, DSG), the divisor is treated as a

7-78 z/Architecture Principles of Operation


64-bit signed binary integer. For DIVIDE SINGLE XI D(B),I [SI]
(DSGFR, DSGF), the divisor is treated as a 32-bit
signed binary integer. For DSGFR, the divisor is
'97' I B D
in bit positions 32-63 of general register R.
8 16 2 31
The sign of the quotient is determined by the rules
of algebra, and the remainder has the same sign
XC D(L,B),D(B) [SS]
as the dividend, except that a zero quotient or a
zero remainder is always positive. //
'D7' L B D B D
When the divisor is zero, or when the magnitudes //
of the dividend and divisor are such that the quo- 8 16 2 32 36 47
tient cannot be expressed by a 64-bit signed
binary integer, a fixed-point-divide exception is The EXCLUSIVE OR of the first and second oper-
recognized. This includes the case of division of ands is placed at the first-operand location.
zero by zero.
The connective EXCLUSIVE OR is applied to the
Condition Code: The code remains unchanged. operands bit by bit. The contents of a bit position
in the result are set to one if the bits in the corre-
Program Exceptions: sponding bit positions in the two operands are
Access (fetch, operand 2 of DSG and DSGF unlike; otherwise, the result bit is set to zero.
only)
Fixed-point divide For EXCLUSIVE OR (XC), each operand is proc-
Specification essed left to right. When the operands overlap,
the result is obtained as if the operands were
processed one byte at a time and each result byte
EXCLUSIVE OR were stored immediately after fetching the neces-
sary operand bytes.
XR R,R [RR]

For EXCLUSIVE OR (XI), the first operand is one


'17' R R byte in length, and only one byte is stored.

8 12 15 For EXCLUSIVE OR (XR, X), the operands are 32


bits, and for EXCLUSIVE OR (XGR, XG), they are
XGR R,R [RRE] 64 bits.

Resulting Condition Code:


'B982' //////// R R
0 Result zero
16 24 28 31 1 Result not zero
2 --
X R,D(X,B) [RX] 3 --

Program Exceptions:
'57' R X B D
Access (fetch, operand 2, X, XG, and XC;
8 12 16 2 31 fetch and store, operand 1, XI and XC)

XG R,D(X,B) [RXE] Programming Notes:


1. An example of the use of the EXCLUSIVE OR
/
instruction is given in Appendix A, Number
'E3' R X B D //////// '82'
/ Representation and Instruction-Use
8 12 16 2 32 4 47 Examples.
2. EXCLUSIVE OR may be used to invert a bit,

Chapter 7. General Instructions 7-79


an operation particularly useful in testing and tial operation, except for the instruction address
setting programmed binary switches. and the instruction-length code.
3. A field EXCLUSIVE-ORed with itself becomes
The instruction address in the current PSW is
all zeros.
increased by the length of EXECUTE. This
4. For EXCLUSIVE OR (XR or XGR), the updated address and the instruction-length code
sequence A EXCLUSIVE-OR B, B of EXECUTE are used, for example, as part of the
EXCLUSIVE-OR A, A EXCLUSIVE-OR B link information when the target instruction is
results in the exchange of the contents of A BRANCH AND LINK. When the target instruction
and B without the use of an additional general is a successful branching instruction, the instruc-
register. tion address in the current PSW is replaced by the
branch address specified by the target instruction.
5. Accesses to the first operand of EXCLUSIVE
OR (XI) and EXCLUSIVE OR (XC) consist in
When the target instruction is in turn EXECUTE,
fetching a first-operand byte from storage and
an execute exception is recognized.
subsequently storing the updated value.
These fetch and store accesses to a particular The effective address of EXECUTE must be even;
byte do not necessarily occur one immediately otherwise, a specification exception is recognized.
after the other. Thus, EXCLUSIVE OR cannot When the target instruction is two or three
be safely used to update a location in storage halfwords in length but can be executed without
if the possibility exists that another CPU or a fetching its second or third halfword, it is unpre-
channel program may also be updating the dictable whether access exceptions are recog-
location. An example of this effect is shown nized for the unused halfwords. Access
for OR (OI) in Multiprogramming and Multi- exceptions are not recognized for the second-
processing Examples in Appendix A, operand address when the address is odd.
Number Representation and Instruction-Use
Examples. The second-operand address of EXECUTE is an
instruction address rather than a logical address;
EXECUTE thus, the target instruction is fetched from the
primary address space when in the primary-space,
EX R,D(X,B) [RX] secondary-space, or access-register mode.
Condition Code: The code may be set by the
'44' R X B D
target instruction.
8 12 16 2 31
Program Exceptions:

The single instruction at the second-operand Access (fetch, target instruction)


address is modified by the contents of general Execute
register R, and the resulting instruction, called Specification
the target instruction, is executed.
Programming Notes:
When the R field is not zero, bits 8-15 of the 1. An example of the use of the EXECUTE
instruction designated by the second-operand instruction is given in Appendix A, Number
address are ORed with bits 56-63 of general reg- Representation and Instruction-Use
ister R. The ORing does not change either the Examples.
contents of general register R or the instruction in
storage, and it is effective only for the interpreta- 2. The ORing of eight bits from the general reg-
tion of the instruction to be executed. When the ister with the designated instruction permits
R field is zero, no ORing takes place. the indirect specification of the length, index,
mask, immediate-data, register, or extended-
The target instruction may be two, four, or six op-code field.
bytes in length. The execution and exception han- 3. The fetching of the target instruction is consid-
dling of the target instruction are exactly as if the ered to be an instruction fetch for purposes of
target instruction were obtained in normal sequen-

7-80 z/Architecture Principles of Operation


program-event recording and for purposes of 0-31 of the operand remain unchanged. The
reporting access exceptions. action associated with the second operand is not
performed if R is zero.
4. An access or specification exception may be
caused by EXECUTE or by the target instruc-
Bits 0-63 of the PSW have the following format:
tion.

5. When an interruptible instruction is made the IE Prog E
RTOX Key MWPA SC C Mask A
target of EXECUTE, the program normally
5 8 12 16 18 2 24 31
should not designate any register updated by
the interruptible instruction as the R, X, or
B
B register for EXECUTE. Otherwise, on A

resumption of execution after an interruption, 32 63
or if the instruction is refetched without an
interruption, the updated values of these regis- Condition Code: The code remains unchanged.
ters will be used in the execution of
EXECUTE. Similarly, the program should Program Exceptions: None.
normally not let the destination field in storage
of an interruptible instruction include the
location of EXECUTE, since the new contents
INSERT CHARACTER
of the location may be interpreted when
IC R,D(X,B) [RX]
resuming execution.

'43' R X B D
EXTRACT ACCESS
8 12 16 2 31
EAR R,R [RRE]

The byte at the second-operand location is


'B24F' //////// R R inserted into bit positions 56-63 of general register

16 24 28 31 R. The remaining bits in the register remain


unchanged.

The contents of access register R are placed in Condition Code: The code remains unchanged.
bit positions 32-63 of general register R. Bits
0-31 of general register R remain unchanged. Program Exceptions:

Condition Code: The code remains unchanged. Access (fetch, operand 2)

Program Exceptions: None. INSERT CHARACTERS UNDER


MASK
EXTRACT PSW
ICM R,M,D(B) [RS]
EPSW R,R [RRE]

'BF' R M B D
'B98D' //////// R R
8 12 16 2 31
16 24 28 31
ICMH R,M,D(B) [RSE]
Bits 0-31 of the current PSW are placed in bit
/
positions 32-63 of the first operand, and bits 0-31 'EB' R M B D //////// '8'
of the operand remain unchanged. Subsequently, /
bits 32-63 of the current PSW are placed in bit 8 12 16 2 32 4 47
positions 32-63 of the second operand, and bits

Chapter 7. General Instructions 7-81


Bytes from contiguous locations beginning at the Programming Notes:
second-operand address are inserted into general
1. Examples of the use of the INSERT CHAR-
register R under control of a mask.
ACTERS UNDER MASK instruction are given
in Appendix A, Number Representation and
The contents of the M field are used as a mask.
Instruction-Use Examples.
These four bits, left to right, correspond one for
one with four bytes, left to right, of general register 2. The condition code for INSERT CHARAC-
R. For INSERT CHARACTERS UNDER MASK TERS UNDER MASK (ICM only) is defined
(ICM), the four bytes to which the mask bits corre- such that, when the mask is 1111, the instruc-
spond are in bit positions 32-63 of general register tion causes the same condition code to be set
R. For INSERT CHARACTERS UNDER MASK as for LOAD AND TEST (LTR only) Thus, the
(ICMH), the four bytes are in the high-order half, instruction may be used as a storage-to-
bit positions 0-31, of the register. The byte posi- register load-and-test operation.
tions corresponding to ones in the mask are filled,
3. INSERT CHARACTERS UNDER MASK (ICM)
left to right, with bytes from successive storage
with a mask of 1111 or 0001 performs a func-
locations beginning at the second-operand
tion similar to that of a LOAD (L) or INSERT
address. When the mask is not zero, the length
CHARACTER (IC) instruction, respectively,
of the second operand is equal to the number of
with the exception of the condition-code
ones in the mask. The bytes in the general reg-
setting. However, the performance of INSERT
ister corresponding to zeros in the mask remain
CHARACTERS UNDER MASK may be
unchanged. For ICM, bits 0-31 of the register
slower.
remain unchanged, and, for ICMH, bits 32-63
remain unchanged.
INSERT IMMEDIATE
The resulting condition code is based on the mask
and on the value of the bits inserted. When the IIHH R,I [RI]
mask is zero or when all inserted bits are zeros,
the condition code is set to 0. When the inserted 'A5' R '' I
bits are not all zeros, the code is set according to
the leftmost bit of the storage operand: if this bit 8 12 16 31
is one, the code is set to 1; if this bit is zero, the
code is set to 2. IIHL R,I [RI]

When the mask is not zero, exceptions associated


with storage-operand access are recognized only 'A5' R '1' I

for the number of bytes specified by the mask.
8 12 16 31
When the mask is zero, access exceptions are
recognized for one byte at the second-operand
address. IILH R,I [RI]


Resulting Condition Code: 'A5' R '2' I
0 All inserted bits zeros, or mask bits all zeros
8 12 16 31
1 Leftmost inserted bit one
2 Leftmost inserted bit zero, and not all inserted
bits zeros IILL R,I [RI]
3 --

'A5' R '3' I
Program Exceptions:
8 12 16 31
Access (fetch, operand 2)

The second operand is placed in bit positions of


the first operand. The remainder of the first
operand remains unchanged.

7-82 z/Architecture Principles of Operation


For each instruction, the bit positions of the first LGFR R,R [RRE]
operand that are loaded with the second operand
are as follows:
'B914' //////// R R

Bit Posi- 16 24 28 31
tions
Instruction Loaded
L R,D(X,B) [RX]
IIHH 0-15

IIHL 16-31 '58' R X B D

IILH 32-47 8 12 16 2 31
IILL 48-63
LG R,D(X,B) [RXE]
Condition Code: The code remains unchanged. /
'E3' R X B D //////// '4'
Program Exceptions: None. /
8 12 16 2 32 4 47
INSERT PROGRAM MASK
LGF R,D(X,B) [RXE]
IPM R [RRE]
/
'E3' R X B D //////// '14'
'B222' //////// R //// /
8 12 16 2 32 4 47
16 24 28 31
The second operand is placed unchanged at the
The condition code and program mask from the first-operand location, except that, for LOAD
current PSW are inserted into bit positions 34 and (LGFR, LGF), it is sign extended.
35 and 36-39, respectively, of general register R.
Bits 32 and 33 of the register are set to zeros; bits For LOAD (LR, L), the operands are 32 bits, and,
0-31 and 40-63 are left unchanged. for LOAD (LGR, LG), the operands are 64 bits.
For LOAD (LGFR, LGF), the second operand is
Condition Code: The code remains unchanged. treated as a 32-bit signed binary integer, and the
first operand is treated as a 64-bit signed binary
Program Exceptions: None. integer.

LOAD Condition Code: The code remains unchanged.

LR R,R [RR] Program Exceptions:


Access (fetch, operand 2 of L, LG, and LGF

'18' R R only)
Programming Note: An example of the use of
8 12 15
the LOAD instruction is given in Appendix A,
Number Representation and Instruction-Use
LGR R,R [RRE] Examples.

'B94' //////// R R

16 24 28 31

Chapter 7. General Instructions 7-83


LOAD ACCESS MULTIPLE bit positions 33-63, bit 32 is set to zero, and bits
0-31 remain unchanged. In the 64-bit addressing
LAM R,R,D(B) [RS] mode, the address is placed in bit positions 0-63.

No storage references for operands take place,


'9A' R R B D and the address is not inspected for access
exceptions.
8 12 16 2 31
Condition Code: The code remains unchanged.
The set of access registers starting with access
register R and ending with access register R is Program Exceptions: None.
loaded from the locations designated by the
second-operand address. Programming Notes:
1. An example of the use of the LOAD
The storage area from which the contents of the
ADDRESS instruction is given in Appendix A,
access registers are obtained starts at the location
Number Representation and Instruction-Use
designated by the second-operand address and
Examples.
continues through as many storage words as the
number of access registers specified. The access 2. LOAD ADDRESS may be used to increment
registers are loaded in ascending order of their the rightmost bits of a general register, other
register numbers, starting with access register R than register 0, by the contents of the D field
and continuing up to and including access register of the instruction. The register to be incre-
R, with access register 0 following access reg- mented should be designated by R and by
ister 15. either X (with B set to zero) or B (with X
set to zero). The instruction updates 24 bits
The second operand must be designated on a in the 24-bit addressing mode, 31 bits in the
word boundary; otherwise, a specification excep- 31-bit addressing mode, and 64 bits in the
tion is recognized. 64-bit addressing mode.

Condition Code: The code remains unchanged.


LOAD ADDRESS EXTENDED
Program Exceptions: LAE R,D(X,B) [RX]
Access (fetch, operand 2)

Specification
'51' R X B D

LOAD ADDRESS 8 12 16 2 31

LA R,D(X,B) [RX] The address specified by the X, B, and D fields


is placed in general register R. Access register
'41' R X B D R is loaded with a value that depends on the
current value of the address-space-control bits,
8 12 16 2 31 bits 16 and 17 of the PSW. If the address-space-
control bits are 01 binary, the value placed in the
The address specified by the X, B, and D fields access register also depends on whether the B
is placed in general register R. The address field is zero or nonzero.
computation follows the rules for address arith-
metic. The address computation follows the rules for
address arithmetic. In the 24-bit addressing
In the 24-bit addressing mode, the address is mode, the address is placed in bit positions 40-63
placed in bit positions 40-63, bits 32-39 are set to of general register R, bits 32-39 are set to zeros,
zeros, and bits 0-31 remain unchanged.. In the and bits 0-31 remain unchanged. In the 31-bit
31-bit addressing mode, the address is placed in addressing mode, the address is placed in bit
positions 33-63, bit 32 is set to zero, and bits 0-31

7-84 z/Architecture Principles of Operation


remain unchanged. In the 64-bit addressing address space. The value 00000002 hex des-
mode, the address is placed in bit positions 0-63. ignates the home address space if the control
program assigns entry 2 of the dispatchable-
The value placed in access register R is as unit access list as designating the home
shown in the following table: address space and places a zero access-list-
entry sequence number (ALESN) in that entry.
PSW
Bits 16
and 17 Value Placed in Access Register R
LOAD ADDRESS RELATIVE
LONG
00 00000000 hex (zeros in bit positions
0-31) LARL R,I [RIL]
10 00000001 hex (zeros in bit positions /
0-30 and one in bit position 31) 'C' R '' I
/
01 If B field is zero: 00000000 hex (zeros
8 12 16 47
in bit positions 0-31)
If B field is nonzero: Contents of The address specified by the I field is placed in
access register B general register R. The address computation
11 00000002 hex (zeros in bit positions follows the rules for the branch address of
0-29 and 31, and one in bit position 30) BRANCH RELATIVE ON CONDITION LONG and
BRANCH RELATIVE AND SAVE LONG.
However, when PSW bits 16 and 17 are 01 binary
In the 24-bit addressing mode, the address is
and the B field is nonzero, bit positions 0-6 of
placed in bit positions 40-63, bits 32-39 are set to
access register B must contain all zeros; other-
zeros, and bits 0-31 remain unchanged. In the
wise, the results in general register R and access
31-bit addressing mode, the address is placed in
register R are unpredictable.
bit positions 33-63, bit 32 is set to zero, and bits
0-31 remain unchanged. In the 64-bit addressing
No storage references for operands take place,
mode, the address is placed in bit positions 0-63.
and the address is not inspected for access
exceptions.
The contents of the I field are a signed binary
integer specifying the number of halfwords that is
Condition Code: The code remains unchanged.
added to the address of the instruction to generate
Program Exceptions: None. the computed address.

Programming Notes: No storage references for operands take place,


and the address is not inspected for access
1. When DAT is on, the different values of the exceptions.
address-space-control bits correspond to
translation modes as follows: Condition Code: The code remains unchanged.

PSW Bits Program Exceptions: None.


16 and
17 Translation Mode Programming Notes:
00 Primary-space mode 1. Only even addresses (halfword addresses)
10 Secondary-space mode can be generated. If an odd address is
01 Access-register mode desired, LOAD ADDRESS can be used to add
11 Home-space mode one to an address formed by LOAD
ADDRESS RELATIVE LONG.
2. In the access-register mode, the value
2. When LOAD ADDRESS RELATIVE LONG is
00000000 hex in an access register desig-
the target of EXECUTE, the address produced
nates the primary address space, and the
is relative to the location of the LOAD
value 00000001 hex designates the secondary

Chapter 7. General Instructions 7-85


ADDRESS RELATIVE LONG instruction, not LOAD COMPLEMENT
of the EXECUTE instruction. This is con-
sistent with the operation of the relative- LCR R,R [RR]
branch instructions.

'13' R R
LOAD AND TEST
8 12 15
LTR R,R [RR]

LCGR R,R [RRE]


'12' R R

8 12 15 'B93' //////// R R

16 24 28 31
LTGR R,R [RRE]

'B92' //////// R R LCGFR R,R [RRE]

16 24 28 31
'B913' //////// R R
LTGFR R,R [RRE]
16 24 28 31

'B912' //////// R R The two's complement of the second operand is

16 24 28 31 placed at the first-operand location. For LOAD


COMPLEMENT (LCR), the second operand and
result are treated as 32-bit signed binary integers.
The second operand is placed unchanged at the For LOAD COMPLEMENT (LCGR), they are
first-operand location, except that, for LOAD AND treated as 64-bit signed binary integers. For
TEST (LTGFR), it is sign extended. The sign and LOAD COMPLEMENT (LCGFR), the second
magnitude of the second operand, treated as a operand is treated as a 32-bit signed binary
signed binary integer, are indicated in the condi- integer, and the result is treated as a 64-bit signed
tion code. binary integer.
For LOAD AND TEST (LTR), the operands are 32 When there is an overflow, the result is obtained
bits, and, for LOAD AND TEST (LTGR), the oper- by allowing any carry into the sign-bit position and
ands are 64 bits. For LOAD AND TEST (LTGFR), ignoring any carry out of the sign-bit position, and
the second operand is 32 bits, and the first condition code 3 is set. If the fixed-point-overflow
operand is treated as a 64-bit signed binary mask is one, a program interruption for fixed-point
integer. overflow occurs.
Resulting Condition Code: Resulting Condition Code:
0 Result zero 0 Result zero; no overflow
1 Result less than zero 1 Result less than zero; no overflow
2 Result greater than zero 2 Result greater than zero; no overflow
3 -- 3 Overflow
Program Exceptions: None. Program Exceptions:
Programming Note: For LOAD AND TEST Fixed-point overflow
(LTR and LTGR) when the R and R fields des-
ignate the same register, the operation is equiv- Programming Note: The operation complements
alent to a test without data movement. all numbers. Zero remains unchanged. For LCR
or LCGR, the maximum negative 32-bit number or
64-bit number, respectively, remains unchanged,

7-86 z/Architecture Principles of Operation


and an overflow condition occurs when the the LOAD HALFWORD instruction is given in
number is complemented. LCGFR complements Appendix A, Number Representation and
the maximum negative 32-bit number without Instruction-Use Examples.
recognizing overflow.
LOAD LOGICAL
LOAD HALFWORD
LLGFR R,R [RRE]
LH R,D(X,B) [RX]

'B916' //////// R R
'48' R X B D
16 24 28 31
8 12 16 2 31
LLGF R,D(X,B) [RXE]
LGH R,D(X,B) [RXE]
/
/ 'E3' R X B D //////// '16'
'E3' R X B D //////// '15' /
/ 8 12 16 2 32 4 47
8 12 16 2 32 4 47
The four-byte second operand is placed in bit
positions 32-63 of general register R, and zeros
LOAD HALFWORD IMMEDIATE are placed in bit positions 0-31 of general register
LHI R,I [RI] R.

For LOAD LOGICAL (LLGFR), the second


'A7' R '8' I operand is in bit positions 32-63 of general reg-
ister R.
8 12 16 31
Condition Code: The code remains unchanged.
LGHI R,I [RI]
Program Exceptions:

'A7' R '9' I Access (fetch, operand 2 of LLGF only)

8 12 16 31
LOAD LOGICAL CHARACTER
The second operand is sign extended and placed LLGC R,D(X,B) [RXE]
at the first-operand location. The second operand
is two bytes in length and is treated as a 16-bit /
'E3' R X B D //////// '9'
signed binary integer. For LOAD HALFWORD
/
(LH) and LOAD HALFWORD IMMEDIATE (LHI), 8 12 16 2 32 4 47
the first operand is treated as a 32-bit signed
binary integer. For LOAD HALFWORD (LGH) and
LOAD HALFWORD IMMEDIATE (LGHI), the first The one-byte second operand is placed in bit
operand is treated as a 64-bit signed binary positions 56-63 of general register R, and zeros
integer. are placed in bit positions 0-55 of general register
R.
Condition Code: The code remains unchanged.
Condition Code: The code remains unchanged.
Program Exceptions:
Program Exceptions:
Access (fetch, operand 2 of LH and LGH)
Access (fetch, operand 2)
Programming Note: An example of the use of

Chapter 7. General Instructions 7-87


LOAD LOGICAL HALFWORD Bit Posi-
tions
LLGH R,D(X,B) [RXE] Instruction Loaded

/ LLIHH 0-15
'E3' R X B D //////// '91' LLIHL 16-31
/
8 12 16 2 32 4 47 LLILH 32-47
LLILL 48-63
The two-byte second operand is placed in bit posi-
tions 48-63 of general register R, and zeros are
Condition Code: The code remains unchanged.
placed in bit positions 0-47 of general register R.
Program Exceptions: None.
Condition Code: The code remains unchanged.

Program Exceptions: LOAD LOGICAL THIRTY ONE


Access (fetch, operand 2) BITS
LLGTR R,R [RRE]
LOAD LOGICAL IMMEDIATE

LLIHH R,I [RI] 'B917' //////// R R

16 24 28 31
'A5' R 'C' I

8 12 16 31 LLGT R,D(X,B) [RXE]

/
LLIHL R,I [RI] 'E3' R X B D //////// '17'
/
8 12 16 2 32 4 47
'A5' R 'D' I

8 12 16 31 For LLGTR, bits 33-63 of general register R, with


33 zeros appended on the left, are placed in
general register R. For LLGT, bits 1-31 of the
LLILH R,I [RI]
four bytes at the second-operand location, with 33
zeros appended on the left, are placed in general
'A5' R 'E' I register R

8 12 16 31 Condition Code: The code remains unchanged.

LLILL R,I [RI] Program Exceptions:

Access (fetch, operand 2 of LLGT only)


'A5' R 'F' I
LOAD MULTIPLE
8 12 16 31
LM R,R,D(B) [RS]
The second operand is placed in bit positions of
the first operand. The remainder of the first
'98' R R B D
operand is set to zeros.
8 12 16 2 31
For each instruction, the bit positions of the first
operand that are loaded with the second operand
are as follows:

7-88 z/Architecture Principles of Operation


LMG R,R,D(B) [RSE] operand address and continuing through as many
locations as needed. Bit positions 32-63 of the
/ same registers are similarly loaded from storage
'EB' R R B D //////// '4'
/ beginning at the location designated by the fourth-
8 12 16 2 32 4 47 operand address.

The general registers are loaded in the ascending


Bit positions of the set of general registers starting
order of their register numbers, starting with
with general register R and ending with general
general register R and continuing up to and
register R are loaded from storage beginning at
including general register R, with general register
the location designated by the second-operand
0 following general register 15.
address and continuing through as many locations
as needed. Condition Code: The code remains unchanged.
For LOAD MULTIPLE (LM), bit positions 32-63 of Program Exceptions:
the general registers are loaded from successive
four-byte fields beginning at the second-operand Access (fetch, operands 2 and 4)
address, and bits 0-31 of the registers remain
unchanged. For LOAD MULTIPLE (LMG), bit Programming Notes:
positions 0-63 of the general registers are loaded 1. All combinations of register numbers specified
from successive eight-byte fields beginning at the by R and R are valid. When the register
second-operand address. numbers are equal, only eight bytes are trans-
mitted. When the number specified by R is
The general registers are loaded in the ascending less than the number specified by R, the reg-
order of their register numbers, starting with ister numbers wrap around from 15 to 0.
general register R and continuing up to and
including general register R, with general register 2. The second-operand and fourth-operand
0 following general register 15. addresses are computed before the contents
of any register are changed.
Condition Code: The code remains unchanged. 3. The combination of a LOAD MULTIPLE
instruction and a LOAD MULTIPLE HIGH
Program Exceptions: instruction provides equal or better perform-
Access (fetch, operand 2) ance than a LOAD MULTIPLE DISJOINT
instruction for the same register range. LOAD
Programming Note: All combinations of register
MULTIPLE DISJOINT is for use when the
numbers specified by R and R are valid. When
second or fourth operand must be addressed
the register numbers are equal, only four bytes,
by means of one of the registers loaded.
for LM, or eight bytes, for LMG, are transmitted.
When the number specified by R is less than the
number specified by R, the register numbers LOAD MULTIPLE HIGH
wrap around from 15 to 0.
LMH R,R,D(B) [RSE]

LOAD MULTIPLE DISJOINT /


'EB' R R B D //////// '96'
LMD R,R,D(B),D(B) [SS] /
8 12 16 2 32 4 47
//
'EF' R R B D B D
The high-order halves, bit positions 0-31, of the
//
8 12 16 2 32 36 47 set of general registers starting with general reg-
ister R and ending with general register R are
loaded from storage beginning at the location des-
Bit positions 0-31 of the set of general registers
ignated by the second-operand address and con-
starting with general register R and ending with
tinuing through as many locations as needed, that
general register R are loaded from storage begin-
is, bit positions 0-31 are loaded from successive
ning at the location designated by the second-

Chapter 7. General Instructions 7-89


four-byte fields beginning at the second-operand Resulting Condition Code:
address. Bits 32-63 of the registers remain
0 Result zero
unchanged.
1 Result less than zero
2 --
The general registers are loaded in the ascending
3 --
order of their register numbers, starting with
general register R and continuing up to and
Program Exceptions: None.
including general register R, with general register
0 following general register 15. Programming Note: The operation complements
positive numbers; negative numbers remain
Condition Code: The code remains unchanged. unchanged. The number zero remains
unchanged.
Program Exceptions:
Access (fetch, operand 2) LOAD PAIR FROM QUADWORD
Programming Note: All combinations of register LPQ R,D(X,B) [RXE]
numbers specified by R and R are valid. When
the register numbers are equal, only four bytes /
are transmitted. When the number specified by 'E3' R X B D //////// '8F'
R is less than the number specified by R, the /
8 12 16 2 32 4 47
register numbers wrap around from 15 to 0.

The quadword second operand is loaded into the


LOAD NEGATIVE
first-operand location with quadword consistency.
LNR R,R [RR] The left doubleword of the quadword is loaded
into general register R, and the right doubleword
is loaded into general register R + 1.
'11' R R
The R field designates an even-odd pair of
8 12 15
general registers and must designate an even-
numbered register. The second operand must be
LNGR R,R [RRE] designated on a quadword boundary. Otherwise,
a specification exception is recognized.

'B91' //////// R R
Condition Code: The code remains unchanged.
16 24 28 31
Program Exceptions:
LNGFR R,R [RRE] Access (fetch, operand 2)
Specification

'B911' //////// R R Programming Note: The LOAD MULTIPLE (LM


or LMG) instruction does not provide quadword
16 24 28 31 consistency.

The two's complement of the absolute value of the LOAD POSITIVE


second operand is placed at the first-operand
location. For LOAD NEGATIVE (LNR), the LPR R,R [RR]
second operand and result are treated as 32-bit
signed binary integers, and, for LOAD NEGATIVE
(LNGR), they are treated as 64-bit signed binary '1' R R

integers. For LOAD NEGATIVE (LNGFR), the 8 12 15
second operand is treated as a 32-bit signed
binary integer, and the result is treated as a 64-bit
signed binary integer.

7-90 z/Architecture Principles of Operation


LPGR R,R [RRE]
LOAD REVERSED

'B9' //////// R R LRVR R,R [RRE]

16 24 28 31
'B91F' //////// R R

LPGFR R,R [RRE] 16 24 28 31

'B91' //////// R R LRVGR R,R [RRE]

16 24 28 31
'B9F' //////// R R

The absolute value of the second operand is 16 24 28 31
placed at the first-operand location. For LOAD
POSITIVE (LPR), the second operand and result LRVH R,D(X,B) [RXE]
are treated as 32-bit signed binary integers, and,
for LOAD POSITIVE (LPGR), they are treated as /
64-bit signed binary integers. For LOAD POSI- 'E3' R X B D //////// '1F'
/
TIVE (LPGFR), the second operand is treated as 8 12 16 2 32 4 47
a 32-bit signed binary integer, and the result is
treated as a 64-bit signed binary integer.
LRV R,D(X,B) [RXE]
When there is an overflow, the result is obtained /
by allowing any carry into the sign-bit position and 'E3' R X B D //////// '1E'
ignoring any carry out of the sign-bit position, and /
condition code 3 is set. If the fixed-point-overflow 8 12 16 2 32 4 47
mask is one, a program interruption for fixed-point
overflow occurs. LRVG R,D(X,B) [RXE]

Resulting Condition Code: /


'E3' R X B D //////// 'F'
0 Result zero; no overflow /
1 -- 8 12 16 2 32 4 47
2 Result greater than zero; no overflow
3 Overflow The second operand is placed at the first-operand
location with the left-to-right sequence of the bytes
Program Exceptions: reversed.
Fixed-point overflow
For LOAD REVERSED (LRVH), the second
Programming Note: The operation complements operand is two bytes, the result is placed in bit
negative numbers; positive numbers and zero positions 48-63 of general register R, and bits
remain unchanged. For LPR or LPGR, an over- 0-47 of the register remain unchanged.
flow condition occurs when the maximum negative
32-bit number or 64-bit number, respectively, is For LOAD REVERSED (LRVR, LRV), the second
complemented; the number remains unchanged. operand is four bytes, the result is placed in bit
LPGFR complements the maximum negative positions 32-63 of general register R, and bits
32-bit number without recognizing overflow. 0-31 of the register remain unchanged. For LOAD
REVERSED (LRVR), the second operand is in bit
positions 32-63 of general register R.

For LOAD REVERSED (LRVGR, LRVG), the


second operand is eight bytes.

Condition Code: The code remains unchanged.

Chapter 7. General Instructions 7-91


Program Exceptions: When the monitor-mask bit corresponding to the
class specified by the I field is one, a monitor-
Access (fetch, operand 2 of LRVH, LRV,
event program interruption occurs. The contents
LRVG only)
of the I field are stored at location 149, with
Programming Notes: zeros stored at location 148. Bit 9 of the program-
interruption code is set to one.
1. The instruction can be used to convert two,
four, or eight bytes from a little-endian format The first-operand address is not used to address
to a big-endian format, or vice versa. In the data; instead, the address specified by the B and
big-endian format, the bytes in a left-to-right D fields forms the monitor code, which is placed
sequence are in the order most significant to in the doubleword at location 176. Address com-
least significant. In the little-endian format, putation follows the rules of address arithmetic; in
the bytes are in the order least significant to the 24-bit addressing mode, bits 0-39 are set to
most significant. For example, the bytes zeros; in the 31-bit addressing mode, bits 0-32 are
ABCD in the big-endian format are DCBA in set to zeros.
the little-endian format.
When the monitor-mask bit corresponding to the
2. LOAD REVERSED (LRVR) can be used with
class specified by bits 12-15 of the instruction is
a two-byte value already in a register as
zero, no interruption occurs, and the instruction is
shown in the following example. In the
executed as a no-operation.
example, the two bytes of interest are in bit
positions 48-63 of the R1 register.
Bit positions 8-11 of the instruction must contain
LRVR R1,R1 zeros; otherwise, a specification exception is
SRA R1,16 recognized.

Condition Code: The code remains unchanged.


The LOAD REVERSED instruction places the
two bytes of interest in bit positions 32-47 of Program Exceptions:
the register, with the order of the bytes
reversed. The SHIFT RIGHT SINGLE (SRA) Monitor event
instruction shifts the two bytes to bit positions Specification
48-63 of the register and extends them on
their left, in bit positions 32-47, with their sign Programming Notes:
bit. The instruction SHIFT RIGHT SINGLE 1. MONITOR CALL provides the capability for
LOGICAL (SRL) should be used, instead, if passing control to a monitoring program when
the two bytes of interest are unsigned. selected points are reached in the monitored
program. This is accomplished by implanting
MONITOR CALL MONITOR CALL instructions at the desired
points in the monitored program. This func-
MC D(B),I [SI] tion may be useful in performing various
measurement functions; specifically, tracing
information can be generated indicating which
'AF' I B D
programs were executed, counting information

8 16 2 31 can be generated indicating how often partic-


ular programs were used, and timing informa-
tion can be generated indicating the amount of
A program interruption is caused if the appropriate time a particular program required for exe-
monitor-mask bit in control register 8 is one. cution.
The monitor-mask bits are in bit positions 48-63 of 2. The monitor masks provide a means of disal-
control register 8, which correspond to monitor lowing all monitor-event program interruptions
classes 0-15, respectively. or allowing monitor-event program inter-
ruptions for all or selected classes.
Bit positions 12-15 in the I field contain a binary
number specifying one of 16 monitoring classes.

7-92 z/Architecture Principles of Operation


3. The monitor code provides a means of associ- MOVE INVERSE
ating descriptive information, in addition to the
class number, with each MONITOR CALL. MVCIN D(L,B),D(B) [SS]
Without the use of a base register, up to
4,096 distinct monitor codes can be associ- //
ated with a monitoring interruption. With the 'E8' L B D B D
//
base register designated by a nonzero value 8 16 2 32 36 47
in the B field, each monitoring interruption
can be identified by a 24-bit, 31-bit, or 64-bit
code, depending on the addressing mode. The second operand is placed at the first-operand
location with the left-to-right sequence of the bytes
inverted.
MOVE
The first-operand address designates the leftmost
MVI D(B),I [SI]
byte of the first operand. The second-operand
address designates the rightmost byte of the
'92' I B D second operand. Both operands have the same
length.
8 16 2 31
The result is obtained as if the second operand
MVC D(L,B),D(B) [SS] were processed from right to left and the first
operand from left to right. The second operand
// may wrap around from location 0 to location
'D2' L B D B D
2 - 1 in the 24-bit addressing mode, to location
//
8 16 2 32 36 47 2 - 1 in the 31-bit addressing mode, or to
location 2 - 1 in the 64-bit addressing mode.
The first operand may wrap around from location
The second operand is placed at the first-operand 2 - 1 to location 0 in the 24-bit addressing
location. mode, from location 2 - 1 to location 0 in the
31-bit addressing mode, or from location 2 - 1
For MOVE (MVC), each operand is processed left
to location 0 in the 64-bit addressing mode.
to right. When the operands overlap, the result is
obtained as if the operands were processed one When the operands overlap by more than one
byte at a time and each result byte were stored byte, the contents of the overlapped portion of the
immediately after fetching the necessary operand result field are unpredictable.
byte.
Condition Code: The code remains unchanged.
For MOVE (MVI), the first operand is one byte in
length, and only one byte is stored. Program Exceptions:
Condition Code: The code remains unchanged. Access (fetch, operand 2; store, operand 1)

Program Exceptions: Programming Notes:

Access (fetch, operand 2 of MVC; store, 1. An example of the use of the MOVE
operand 1, MVI and MVC) INVERSE instruction is given in Appendix A,
Number Representation and Instruction-Use
Programming Notes: Examples.
1. Examples of the use of the MOVE instruction 2. The contents of each byte moved remain
are given in Appendix A, Number Represen- unchanged.
tation and Instruction-Use Examples. 3. MOVE INVERSE is the only SS-format
2. It is possible to propagate one byte through instruction for which the second-operand
an entire field by having the first operand start address designates the rightmost, instead of
one byte to the right of the second operand. the leftmost, byte of the second operand.

Chapter 7. General Instructions 7-93


4. The storage-operand references for MOVE ment starts at the left end of both fields and pro-
INVERSE may be multiple-access references. ceeds to the right. The operation is ended when
(See Storage-Operand Consistency on the number of bytes specified by bits 40-63 of
page 5-86.) general register R + 1 have been moved into the
first-operand location. If the second operand is
MOVE LONG shorter than the first operand, the remaining right-
most bytes of the first-operand location are filled
MVCL R,R [RR] with the padding byte.

As part of the execution of the instruction, the


'E' R R values of the two length fields are compared for
the setting of the condition code, and a check is
8 12 15
made for destructive overlap of the operands.
Operands are said to overlap destructively when
The second operand is placed at the first-operand the first-operand location is used as a source after
location, provided overlapping of operand data has been moved into it, assuming the
locations would not affect the final contents of the inspection for overlap is performed by the use of
first-operand location. The remaining rightmost logical operand addresses. When the operands
byte positions, if any, of the first-operand location overlap destructively, no movement takes place,
are filled with padding bytes. and condition code 3 is set.

The R and R fields each designate an even-odd Operands do not overlap destructively, and move-
pair of general registers and must designate an ment is performed, if the leftmost byte of the first
even-numbered register; otherwise, a specification operand does not coincide with any of the second-
exception is recognized. operand bytes participating in the operation other
than the leftmost byte of the second operand.
The location of the leftmost byte of the first When an operand wraps around from location
operand and second operand is designated by the 2 - 1 (or 2 - 1 or 2 - 1) to location 0,
contents of general registers R and R, respec- operand bytes in locations up to and including
tively. The number of bytes in the first-operand 2 - 1 (or 2 - 1 or 2 - 1) are considered to
and second-operand locations is specified by be to the left of bytes in locations from 0 up.
unsigned binary integers in bit positions 40-63 of
general registers R + 1 and R + 1, respec- In the 24-bit addressing mode, wraparound is from
tively. Bit positions 32-39 of general register location 2 - 1 to location 0; in the 31-bit
R + 1 contain the padding byte. The contents of addressing mode, wraparound is from location
bit positions 0-39 of general register R + 1 and 2 - 1 to location 0; in the 64-bit addressing
of bit positions 0-31 of general register R + 1 mode, wraparound is from location 2 - 1 to
are ignored. location 0.

The handling of the addresses in general registers In the access-register mode, the contents of
R and R is dependent on the addressing mode. access register R and access register R are
compared. If the R or R field is zero, 32 zeros
In the 24-bit addressing mode, the contents of bit are used rather than the contents of access reg-
positions 40-63 of general registers R and R ister 0. If all 32 bits of the compared values are
constitute the address, and the contents of bit equal, then the destructive overlap test is made.
positions 0-39 are ignored. In the 31-bit If all 32 bits of the compared values are not equal,
addressing mode, the contents of bit positions destructive overlap is declared not to exist. If, for
33-63 of the registers constitute the address, and this case, the operands actually overlap in real
the contents of bit positions 0-32 are ignored. In storage, it is unpredictable whether the result
the 64-bit addressing mode, the contents of bit reflects the overlap condition.
positions 0-63 constitute the address.
When the length specified by bits 40-63 of general
The contents of the registers just described are register R + 1 is zero, no movement takes
shown in Figure 7-16 on page 7-95. The move-

7-94 z/Architecture Principles of Operation




24-Bit Addressing Mode 31-Bit Addressing Mode

/ /
R //////////// First-Operand Address //// First-Operand Address
/ /
4 63 33 63

/ /
R + 1 //////////// First-Operand Length //////////// First-Operand Length
/ /
4 63 4 63

/ /
R //////////// Second-Operand Address //// Second-Operand Address
/ /
4 63 33 63

/ /
R + 1 /// Pad Second-Operand Length /// Pad Second-Operand Length
/ /
32 4 63 32 4 63

64-Bit Addressing Mode

/
R First-Operand Address
/
63

/
R + 1 //////////// First-Operand Length
/
4 63

/
R Second-Operand Address
/
63

/
R + 1 /// Pad Second-Operand Length
/
32 4 63

Figure 7-16. Register Contents for MOVE LONG

place, and condition code 0 or 1 is set to indicate most bits which are not part of the address in bit
the relative values of the lengths. positions 32-63 of general registers R and R are
set to zeros, and the contents of bit positions 0-31
The execution of the instruction is interruptible. remain unchanged. In any addressing mode, the
When an interruption occurs, other than one that contents of bit positions 0-39 of general registers
causes termination, the lengths in general regis- R + 1 and R + 1 remain unchanged; and the
ters R + 1 and R + 1 are decremented by the condition code is unpredictable. If the operation is
number of bytes moved, and the addresses in interrupted during padding, the length field in
general registers R and R are incremented by general register R + 1 is 0, the address in
the same number, so that the instruction, when general register R is incremented by the original
reexecuted, resumes at the point of interruption. length in general register R + 1, and general
In the 24-bit or 31-bit addressing mode, the left-

Chapter 7. General Instructions 7-95


registers R and R + 1 reflect the extent of the 0 Operand lengths equal; no destructive overlap
padding operation. 1 First-operand length low; no destructive
overlap
When the first-operand location includes the 2 First-operand length high; no destructive
location of the instruction or of EXECUTE, the overlap
instruction may be refetched from storage and 3 No movement performed because of destruc-
reinterpreted even in the absence of an inter- tive overlap
ruption during execution. The exact point in the
execution at which such a refetch occurs is unpre- Program Exceptions:
dictable.
Access (fetch, operand 2; store, operand 1)
Specification
As observed by other CPUs and by channel pro-
grams, that portion of the first operand which is
Programming Notes:
filled with the padding byte is not necessarily
stored into in a left-to-right direction and may 1. An example of the use of the MOVE LONG
appear to be stored into more than once. instruction is given in Appendix A, Number
Representation and Instruction-Use
At the completion of the operation, the length in Examples.
general register R + 1 is decremented by the
2. MOVE LONG may be used for clearing
number of bytes stored at the first-operand
storage by setting the padding byte to zero
location, and the address in general register R is
and the second-operand length to zero. On
incremented by the same amount. The length in
most models, this is the fastest instruction for
general register R + 1 is decremented by the
clearing storage areas in excess of 256 bytes.
number of bytes moved out of the second-operand
However, the stores associated with this
location, and the address in general register R is
clearing may be multiple-access stores and
incremented by the same amount. In the 24-bit or
should not be used to clear an area if the pos-
31-bit addressing mode, the leftmost bits which
sibility exists that another CPU or a channel
are not part of the address in bit positions 32-63
program will attempt to access and use the
of general registers R and R are set to zeros,
area as soon as it appears to be zero. For
even when one or both of the original length
more details, see Storage-Operand
values are zeros or when condition code 3 is set.
Consistency on page 5-86.
The contents of bit positions 0-31 of the registers
remain unchanged. In any addressing mode, the 3. The program should avoid specification of a
contents of bit positions 0-39 of general registers length for either operand which would result in
R + 1 and R + 1 remain unchanged. an addressing exception. Addressing (and
also protection) exceptions may result in ter-
When condition code 3 is set, no exceptions asso- mination of the entire operation, not just the
ciated with operand access are recognized. When current unit of operation. The termination may
the length of an operand is zero, no access be such that the contents of all result fields
exceptions for that operand are recognized. Simi- are unpredictable; in the case of MOVE
larly, when the second operand is longer than the LONG, this includes the condition code and
first operand, access exceptions are not recog- the two even-odd general-register pairs, as
nized for the part of the second-operand field that well as the first-operand location in main
is in excess of the first-operand field. For oper- storage. The following are situations that
ands longer than 2K bytes, access exceptions are have actually occurred on one or more
not recognized for locations more than 2K bytes models:
beyond the current location being processed.
a. When a protection exception occurs on a
Access exceptions are not recognized for an
4K-byte block of a first operand which is
operand if the R field associated with that operand
several blocks in length, stores to the pro-
is odd. Also, when the R field is odd, PER
tected block are suppressed. However,
storage-alteration events are not recognized, and
the move continues into the subsequent
no change bits are set.
blocks of the first operand, which are not
protected. Similarly, an addressing excep-
Resulting Condition Code:

7-96 z/Architecture Principles of Operation


tion on a block does not necessarily sup- b. When the second operand wraps around,
press processing of subsequent blocks movement is performed if the leftmost
which are available. byte of the first operand coincides with or
is to the left of the leftmost byte of the
b. Some models may update the general
second operand, and if the leftmost byte
registers only when an external, I/O,
of the first operand is to the right of the
repressible machine-check, or restart
rightmost second-operand byte partic-
interruption occurs, or when a program
ipating in the operation.
interruption occurs for which it is required
to nullify or suppress a unit of operation. The rightmost second-operand byte is deter-
Thus, if, after a move into several blocks mined by using the smaller of the first-operand
of the first operand, an addressing or pro- and second-operand lengths.
tection exception occurs, the general reg-
When the second-operand length is one or
isters may remain unchanged.
zero, destructive overlap cannot exist.
4. When the first-operand length is zero, the
7. Special precautions should be taken if MOVE
operation consists in setting the condition
LONG is made the target of EXECUTE. See
code and, in the 24-bit or 31-bit addressing
the programming note concerning interruptible
mode, of setting the leftmost bits in bit posi-
instructions under EXECUTE.
tions 32-63 of general registers R and R to
zero. 8. Since the execution of MOVE LONG is inter-
ruptible, the instruction cannot be used for sit-
5. When the contents of the R and R fields are
uations where the program must rely on
the same, the contents of the designated reg-
uninterrupted execution of the instruction.
isters are incremented or decremented only by
Similarly, the program should normally not let
the number of bytes moved, not by twice the
the first operand of MOVE LONG include the
number of bytes moved. Condition code 0 is
location of the instruction or of EXECUTE
set.
because the new contents of the location may
6. The following is a detailed description of those be interpreted for a resumption after an inter-
cases in which movement takes place, that is, ruption, or the instruction may be refetched
where destructive overlap does not exist. without an interruption.
In the access-register mode, the contents of 9. Further programming notes concerning inter-
the access registers used are called the effec- ruptible instructions are included in Interrup-
tive space designations. When the effective tible Instructions in Chapter 5, Program
space designations are not equal, destructive Execution.
overlap is declared not to exist and movement
10. In the access-register mode, access register 0
occurs. When the effective space desig-
designates the primary address space regard-
nations are the same or when not in the
less of the contents of access register 0.
access-register mode, then the following
cases apply.
MOVE LONG EXTENDED
Depending on whether the second operand
wraps around from location 2 - 1 (or MVCLE R,R,D(B) [RS]
2 - 1 or 2 - 1, depending on the
addressing mode) to location 0, movement
takes place in the following cases: 'A8' R R B D

a. When the second operand does not wrap 8 12 16 2 31
around, movement is performed if the left-
most byte of the first operand coincides All or part of the third operand is placed at the
with or is to the left of the leftmost byte of first-operand location. The remaining rightmost
the second operand, or if the leftmost byte byte positions, if any, of the first-operand location
of the first operand is to the right of the are filled with padding bytes. The operation pro-
rightmost second-operand byte partic- ceeds until the end of the first-operand location is
ipating in the operation. reached or a CPU-determined number of bytes

Chapter 7. General Instructions 7-97


have been placed at the first-operand location, placed, whichever occurs first. If the third operand
whichever occurs first. The result is indicated in is shorter than the first operand, the remaining
the condition code. rightmost bytes of the first-operand location are
filled with the padding byte.
The R and R fields each designate an even-odd
pair of general registers and must designate an When the operation is completed because the end
even-numbered register; otherwise, a specification of the first operand has been reached, the condi-
exception is recognized. tion code is set to 0 if the two operand lengths are
equal, it is set to 1 if the first-operand length is
The location of the leftmost byte of the first less than the third-operand length, or it is set to 2
operand and third operand is designated by the if the first-operand length is greater than the third-
contents of general registers R and R, respec- operand length. When the operation is completed
tively. In the 24-bit or 31-bit addressing mode, the because a CPU-determined number of bytes have
number of bytes in the first-operand and third- been moved without reaching the end of the first
operand locations is specified by the contents of operand, condition code 3 is set.
bit positions 32-63 of general registers R + 1
and R + 1, respectively, and those contents are No test is made for destructive overlap, and the
treated as 32-bit unsigned binary integers. In the results in the first-operand location are unpredict-
64-bit addressing mode, the number of bytes in able when destructive overlap exists. Operands
the first-operand and third-operand locations is are said to overlap destructively when the first-
specified by the entire contents of general regis- operand location is used as a source after data
ters R + 1 and R + 1, respectively, and those has been moved into it.
contents are treated as 64-bit unsigned binary
integers. Operands do not overlap destructively if the left-
most byte of the first operand does not coincide
The handling of the addresses in general registers with any of the third-operand bytes participating in
R and R is dependent on the addressing mode. the operation other than the leftmost byte of the
third operand. When an operand wraps around
In the 24-bit addressing mode, the contents of bit from location 2 - 1 (or 2 - 1 or 2 - 1) to
positions 40-63 of general registers R and R location 0, operand bytes in locations up to and
constitute the address, and the contents of bit including 2 - 1 (or 2 - 1 or 2 - 1) are con-
positions 0-39 are ignored. In the 31-bit sidered to be to the left of bytes in locations from
addressing mode, the contents of bit positions 0 up.
33-63 of the registers constitute the address, and
the contents of bit positions 0-32 are ignored. In In the 24-bit addressing mode, wraparound is from
the 64-bit addressing mode, the contents of bit location 2 - 1 to location 0; in the 31-bit
positions 0-63 constitute the address. addressing mode, wraparound is from location
2 - 1 to location 0; and, in the 64-bit addressing
The second-operand address is not used to mode, wraparound is from location 2 - 1 to
address data; instead, the rightmost eight bits of location 0.
the second-operand address, bits 56-63, are the
padding byte. Bits 0-55 of the second-operand When the length specified in general register
address are ignored. R + 1 is zero, no movement takes place, and
condition code 0 or 1 is set to indicate the relative
The contents of the registers and address just values of the lengths.
described are shown in Figure 7-17 on
page 7-99. As observed by other CPUs and by channel pro-
grams, that portion of the first operand which is
The movement starts at the left end of both fields filled with the padding byte is not necessarily
and proceeds to the right, byte by byte. The oper- stored into in a left-to-right direction and may
ation is ended when the number of bytes specified appear to be stored into more than once.
in general register R + 1 have been placed at
the first-operand location or when a At the completion of the operation, the length in
CPU-determined number of bytes have been general register R + 1 is decremented by the

7-98 z/Architecture Principles of Operation




24-Bit Addressing Mode 31-Bit Addressing Mode

/ /
R //////////// First-Operand Address //// First-Operand Address
/ /
4 63 33 63

/ /
R + 1 /// First-Operand Length /// First-Operand Length
/ /
32 63 32 63

/ /
R //////////// Third-Operand Address //// Third-Operand Address
/ /
4 63 33 63

/ /
R + 1 /// Third-Operand Length /// Third-Operand Length
/ /
32 63 32 63

/ /
2nd Op. /////////////////////////// Pad /////////////////////////// Pad
Address / /
56 63 56 63

64-Bit Addressing Mode

/
R First-Operand Address
/
63

/
R + 1 First-Operand Length
/
63

/
R Third-Operand Address
/
63

/
R + 1 Third-Operand Length
/
63

/
2nd Op. /////////////////////////// Pad
Address /
56 63

Figure 7-17. Register Contents and Second-Operand Address for MOVE LONG EXTENDED

number of bytes stored at the first-operand general register R + 1 is decremented by the


location, and the address in general register R is number of bytes moved out of the third-operand
incremented by the same amount. The length in

Chapter 7. General Instructions 7-99


location, and the address in general register R is recognized for locations more than 4K bytes
incremented by the same amount. beyond the current location being processed.
Access exceptions are not recognized for an
If the operation is completed because a operand if the R field associated with that operand
CPU-determined number of bytes have been is odd. Also, when the R field is odd, PER
moved without reaching the end of the first storage-alteration events are not recognized, and
operand, the lengths in general registers R + 1 no change bits are set.
and R + 1 are decremented by the number of
bytes moved, and the addresses in general regis- Resulting Condition Code:
ters R and R are incremented by the same
0 All bytes moved, operand lengths equal
number, so that the instruction, when reexecuted,
1 All bytes moved, first-operand length low
resumes at the next byte to be moved. If the
2 All bytes moved, first-operand length high
operation is completed during padding, the length
3 CPU-determined number of bytes moved
field in general register R + 1 is zero, the
without reaching end of first operand
address in general register R is incremented by
the original length in general register R + 1, and Program Exceptions:
general registers R and R + 1 reflect the extent
of the padding operation. Access (fetch, operand 3; store, operand 1)
Specification
In the 24-bit or 31-bit addressing mode, the con-
tents of bit positions 0-31 of general registers R, Programming Notes:
R + 1, R, and R + 1, always remain 1. MOVE LONG EXTENDED is intended for use
unchanged. in place of MOVE LONG when the operand
lengths are specified as 32-bit or 64-bit binary
The padding byte may be formed from D(B) integers and a test for destructive overlap is
multiple times during the execution of the instruc- not required. MOVE LONG EXTENDED sets
tion, and the registers designated by R and R condition code 3 in cases in which MOVE
may be updated multiple times. Therefore, if B LONG would be interrupted.
equals R, R + 1, R, or R + 1 and is subject
to change during the execution of the instruction, 2. When condition code 3 is set, the program
the results are unpredictable. can simply branch back to the instruction to
continue the movement. The program need
The amount of processing that results in the not determine the number of bytes that were
setting of condition code 3 is determined by the moved.
CPU on the basis of improving system perform- 3. The function of not processing more than
ance, and it may be a different amount each time approximately 4K bytes of either operand is
the instruction is executed. The maximum amount intended to permit software polling of a flag
is approximately 4K bytes of either operand. that may be set by a program on another CPU
during long operations.
At the completion of the operation in the 24-bit or
31-bit addressing mode, the leftmost bits which 4. MOVE LONG EXTENDED may be used for
are not part of the address in bit positions 32-63 clearing storage by setting the padding byte to
of general registers R and R may be set to zero and the third-operand length to zero.
zeros or may remain unchanged from their original However, the stores associated with this
values, even when one or both of the original clearing may be multiple-access stores and
length values are zeros. should not be used to clear an area if the pos-
sibility exists that another CPU or a channel
When the length of an operand is zero, no access program will attempt to access and use the
exceptions for that operand are recognized. Simi- area as soon as it appears to be zero. For
larly, when the third operand is longer than the more details, see Storage-Operand
first operand, access exceptions are not recog- Consistency on page 5-86.
nized for the part of the third-operand field that is
5. When the contents of the R and R fields are
in excess of the first-operand field. For operands
the same, the contents of the designated reg-
longer than 4K bytes, access exceptions are not
isters are incremented or decremented only by

7-100 z/Architecture Principles of Operation


the number of bytes moved, not by twice the In the 24-bit addressing mode, the contents of bit
number of bytes moved. The condition code positions 40-63 of general registers R and R
is finally set to 0 after possible settings to 3. constitute the address, and the contents of bit
positions 0-39 are ignored. In the 31-bit
6. In the access-register mode, access register 0
addressing mode, the contents of bit positions
designates the primary address space regard-
33-63 of the registers constitute the address, and
less of the contents of access register 0.
the contents of bit positions 0-32 are ignored. In
the 64-bit addressing mode, the contents of bit
MOVE LONG UNICODE positions 0-63 of the registers constitute the
address.
MVCLU R,R,D(B) [RSE]

/ The second-operand address is not used to


'EB' R R B D //////// '8E' address data; instead, the rightmost 16 bits of the
/ second-operand address, bits 48-63, are the two-
8 12 16 2 32 4 47 byte padding character. Bits 0-47 of the second-
operand address are ignored.
All or part of the third operand is placed at the
first-operand location. The remaining rightmost The contents of the registers and address just
two-byte character positions, if any, of the first- described are shown in Figure 7-18 on
operand location are filled with two-byte padding page 7-102.
characters. The operation proceeds until the end
The movement starts at the left end of both fields
of the first-operand location is reached or a
and proceeds to the right, character by character.
CPU-determined number of characters have been
The operation is ended when the number of char-
placed at the first-operand location, whichever
acters specified by the contents of general register
occurs first. The result is indicated in the condi-
R + 1 have been placed at the first-operand
tion code.
location or when a CPU-determined number of
The R and R fields each designate an even-odd characters have been placed, whichever occurs
pair of general registers and must designate an first. If the third operand is shorter than the first
even-numbered register; otherwise, a specification operand, the remaining rightmost character posi-
exception is recognized. tions of the first-operand location are filled with the
two-byte padding character.
The location of the leftmost character of the first
operand and third operand is designated by the When the operation is completed because the end
contents of general registers R and R, respec- of the first operand has been reached, the condi-
tively. In the 24-bit or 31-bit addressing mode, the tion code is set to 0 if the two operand lengths are
number of bytes in the first-operand and third- equal, it is set to 1 if the first-operand length is
operand locations is specified by the contents of less than the third-operand length, or it is set to 2
bit positions 32-63 of general registers R + 1 if the first-operand length is greater than the third-
and R + 1, respectively, and those contents are operand length. When the operation is completed
treated as 32-bit unsigned binary integers. In the because a CPU-determined number of characters
64-bit addressing mode, the number of bytes in have been moved without reaching the end of the
the first-operand and third-operand locations is first operand, condition code 3 is set.
specified by the contents of bit positions 0-63 of
No test is made for destructive overlap, and the
general registers R + 1 and R + 1, respec-
results in the first-operand location are unpredict-
tively, and those contents are treated as 64-bit
able when destructive overlap exists. Operands
unsigned binary integers.
are said to overlap destructively when the first-
The contents of general registers R + 1 and operand location is used as a source after data
R + 1 must specify an even number of bytes; has been moved into it.
otherwise, a specification exception is recognized.
Operands do not overlap destructively if the left-
The handling of the addresses in general registers most character of the first operand does not coin-
R and R is dependent on the addressing mode.

Chapter 7. General Instructions 7-101




24-Bit Addressing Mode 31-Bit Addressing Mode

/ /
R //////////// First-Operand Address //// First-Operand Address
/ /
4 63 33 63

/ /
R + 1 /// First-Operand Length /// First-Operand Length
/ /
32 63 32 63

/ /
R //////////// Third-Operand Address //// Third-Operand Address
/ /
4 63 33 63

/ /
R + 1 /// Third-Operand Length /// Third-Operand Length
/ /
32 63 32 63

/ /
2nd Op. /////////////////// Pad /////////////////// Pad
Address / /
48 63 48 63

64-Bit Addressing Mode

/
R First-Operand Address
/
63

/
R + 1 First-Operand Length
/
63

/
R Third-Operand Address
/
63

/
R + 1 Third-Operand Length
/
63

/
2nd Op. /////////////////// Pad
Address /
48 63

Figure 7-18. Register Contents and Second-Operand Address for MOVE LONG UNICODE

cide with any of the third-operand characters operand wraps around from location 2 - 1 (or
participating in the operation other than the left- 2 - 1 or 2 - 1) to location 0, operand charac-
most character of the third operand. When an ters in locations up to and including 2 - 1 (or

7-102 z/Architecture Principles of Operation


2 - 1 or 2 - 1) are considered to be to the The two-byte padding character may be formed
left of characters in locations from 0 up. from D(B) multiple times during the execution of
the instruction, and the registers designated by R
In the 24-bit addressing mode, wraparound is from and R may be updated multiple times. There-
location 2 - 1 to location 0; in the 31-bit fore, if B equals R, R + 1, R, or R + 1 and
addressing mode, wraparound is from location is subject to change during the execution of the
2 - 1 to location 0; and, in the 64-bit addressing instruction, the results are unpredictable.
mode, wraparound is from location 2 - 1 to
location 0. The amount of processing that results in the
setting of condition code 3 is determined by the
When the length specified in general register CPU on the basis of improving system perform-
R + 1 is zero, no movement takes place, and ance, and it may be a different amount each time
condition code 0 or 1 is set to indicate the relative the instruction is executed.
values of the lengths.
At the completion of the operation in the 24-bit or
As observed by other CPUs and by channel pro- 31-bit addressing mode, the leftmost bits which
grams, that portion of the first operand which is are not part of the address in bit positions 32-63
filled with the two-byte padding character is not of general registers R and R may be set to
necessarily stored into in a left-to-right direction zeros or may remain unchanged from their original
and may appear to be stored into more than once. values, including the case when one or both of the
original length values are zeros.
At the completion of the operation, the length in
general register R + 1 is decremented by 2 When the length of an operand is zero, no access
times the number of characters stored at the first- exceptions for that operand are recognized. Simi-
operand location, and the address in general reg- larly, when the third operand is longer than the
ister R is incremented by the same amount. The first operand, access exceptions are not recog-
length in general register R + 1 is decremented nized for the part of the third-operand field that is
by 2 times the number of characters moved out of in excess of the first-operand field. For operands
the third-operand location, and the address in longer than 4K bytes, access exceptions are not
general register R is incremented by the same recognized for locations more than 4K bytes
amount. beyond the current location being processed.
Access exceptions are not recognized for an
If the operation is completed because a operand if the R field or length associated with
CPU-determined number of characters have been that operand is odd. Also, when the R field or
moved without reaching the end of the first length is odd, PER storage-alteration events are
operand, the lengths in general registers R + 1 not recognized, and no change bits are set.
and R + 1 are decremented by 2 times the
number of characters moved, and the addresses Resulting Condition Code:
in general registers R and R are incremented by
0 All characters moved, operand lengths equal
the same number, so that the instruction, when
1 All characters moved, first-operand length low
reexecuted, resumes at the next character to be
2 All characters moved, first-operand length
moved. If the operation is completed during
high
padding, the length field in general register
3 CPU-determined number of characters moved
R + 1 is zero, the address in general register R
without reaching end of first operand
is incremented by 2 times the number of charac-
ters moved from operand 3, and general registers
Program Exceptions:
R and R + 1 reflect the extent of the padding
operation. Access (fetch, operand 3; store, operand 1)
Operation (if the extended-translation facility 2
In the 24-bit or 31-bit addressing mode, the con- is not installed)
tents of bit positions 0-31 of general registers R, Specification
R + 1, R, and R + 1, always remain
unchanged.

Chapter 7. General Instructions 7-103


Programming Notes: Each operand is processed left to right. When the
operands overlap, the result is obtained as if the
1. MOVE LONG UNICODE is intended for use in
operands were processed one byte at a time and
place of MOVE LONG or MOVE LONG
each result byte were stored immediately after
EXTENDED when the padding character is
fetching the necessary operand bytes.
two bytes. The character may be a Unicode
character or any other double-byte character.
Condition Code: The code remains unchanged.
MOVE LONG UNICODE sets condition code 3
in cases in which MOVE LONG would be Program Exceptions:
interrupted.
Access (fetch, operand 2; fetch and store,
2. When condition code 3 is set, the program operand 1)
can simply branch back to the instruction to
continue the movement. The program need Programming Notes:
not determine the number of characters that
were moved. 1. An example of the use of the MOVE
NUMERICS instruction is given in
3. MOVE LONG UNICODE may be used for Appendix A, Number Representation and
filling storage with padding characters by Instruction-Use Examples.
placing the padding character in the second-
operand address and by setting the third- 2. MOVE NUMERICS moves the numeric portion
operand length to zero. of a decimal-data field that is in the zoned
format. The zoned-decimal format is
4. When the contents of the R and R fields are described in Chapter 8, Decimal
the same, the contents of the designated reg- Instructions. The operands are not checked
isters are incremented or decremented only by for valid sign and digit codes.
2 times the number of characters moved, not
by 4 times the number of characters moved. 3. Accesses to the first operand of MOVE
The condition code is finally set to 0 after pos- NUMERICS consist in fetching the rightmost
sible settings to 3. four bits of each byte in the first operand and
subsequently storing the updated value of the
5. In the access-register mode, access register 0 byte. These fetch and store accesses to a
designates the primary address space regard- particular byte do not necessarily occur one
less of the contents of access register 0. immediately after the other. Thus, this instruc-
6. If padding with a Unicode space character is tion cannot be safely used to update a
required (or any character whose represen- location in storage if the possibility exists that
tation is less than or equal to FFF hex), the another CPU or a channel program may also
character may be represented in the displace- be updating the location. An example of this
ment field of the instruction, for example: effect is shown for OR (OI) in Multiprogram-
ming and Multiprocessing Examples in
MVCLU 6,8,X'2'
Appendix A, Number Representation and
Instruction-Use Examples.
MOVE NUMERICS
MVN D(L,B),D(B) [SS] MOVE STRING
// MVST R,R [RRE]
'D1' L B D B D
//
8 16 2 32 36 47 'B255' //////// R R

16 24 28 31
The rightmost four bits of each byte in the second
operand are placed in the rightmost bit positions
All or part of the second operand is placed in the
of the corresponding bytes in the first operand.
first-operand location. The operation proceeds
The leftmost four bits of each byte in the first
until the end of the second operand is reached or
operand remain unchanged.
a CPU-determined number of bytes have been

7-104 z/Architecture Principles of Operation


moved, whichever occurs first. The processed in the first and second operands is
CPU-determined number is at least one. The placed in general registers R and R, respec-
result is indicated in the condition code. tively. Whenever an address is placed in a
general register, bits 32-39 of the register, in the
The location of the leftmost byte of the first 24-bit addressing mode, or bit 32, in the 31-bit
operand and second operand is designated by the addressing mode, are set to zeros. Bits 0-31 of
contents of general registers R and R, respec- the R and R registers always remain unchanged
tively. in the 24-bit or 31-bit mode.

The handling of the addresses in general registers The amount of processing that results in the
R and R is dependent on the addressing mode. setting of condition code 3 is determined by the
In the 24-bit addressing mode, the contents of bit CPU on the basis of improving system perform-
positions 40-63 of general registers R and R ance, and it may be a different amount each time
constitute the address, and the contents of bit the instruction is executed.
positions 0-39 are ignored. In the 31-bit
addressing mode, the contents of bit positions Access exceptions for the first and second oper-
33-63 of the registers constitute the address, and ands are recognized only for that portion of the
the contents of bit positions 0-32 are ignored. In operand that is necessarily used in the operation.
the 64-bit addressing mode, the contents of bit
positions 0-63 constitute the address. The storage-operand-consistency rules are the
same as for the MOVE (MVC) instruction, except
The end of the second operand is indicated by an that destructive overlap is not recognized.
ending character in the last byte position of the
operand. The ending character to be used to Resulting Condition Code:
determine the end of the second operand is speci- 0 --
fied in bit positions 56-63 of general register 0. Bit 1 Entire second operand moved; general reg-
positions 32-55 of general register 0 are reserved ister R updated with address of ending char-
for possible future extensions and must contain all acter in first operand; general register R
zeros; otherwise, a specification exception is unchanged
recognized. 2 --
3 CPU-determined number of bytes moved;
The operation proceeds left to right and ends as
general registers R and R updated with
soon as the second-operand ending character has
addresses of next bytes
been moved or a CPU-determined number of
second-operand bytes have been moved, which- Program Exceptions:
ever occurs first. The CPU-determined number is
at least one. When the ending character is in the Access (fetch, operand 2; store, operand 1)
first byte position of the second operand, only the Specification
ending character is moved. When the ending
character has been moved, condition code 1 is Programming Notes:
set. When a CPU-determined number of second- 1. An example of the use of the MOVE STRING
operand bytes not including an ending character instruction is given in Appendix A, Number
have been moved, condition code 3 is set. Representation and Instruction-Use
Destructive overlap is not recognized. If the Examples.
second operand is used as a source after it has
2. When condition code 3 is set, the program
been used as a destination, the results are unpre-
can simply branch back to the instruction to
dictable to the extent that an ending character in
continue the data movement. The program
the second operand may not be recognized.
need not determine the number of bytes that
When condition code 1 is set, the address of the were moved.
ending character in the first operand is placed in 3. R or R may be zero, in which case general
general register R, and the contents of general register 0 is treated as containing an address
register R remain unchanged. When condition and also the ending character.
code 3 is set, the address of the next byte to be

Chapter 7. General Instructions 7-105


4. In the access-register mode, access register 0 packed decimal data by an odd number of
designates the primary address space regard- digit positions. The packed-decimal format is
less of the contents of access register 0. described in Chapter 8, Decimal Instructions.
The operands are not checked for valid sign
MOVE WITH OFFSET and digit codes. In many cases, however,
SHIFT AND ROUND DECIMAL may be more
MVO D(L,B),D(L,B) [SS] convenient to use.

// 3. Access to the rightmost byte of the first


'F1' L L B D B D operand of MOVE WITH OFFSET consists in
// fetching the rightmost four bits and subse-
8 12 16 2 32 36 47 quently storing the updated value of this byte.
These fetch and store accesses to the right-
The second operand is placed to the left of and most byte of the first operand do not neces-
adjacent to the rightmost four bits of the first sarily occur one immediately after the other.
operand. Thus, this instruction cannot be safely used to
update a location in storage if the possibility
The rightmost four bits of the first operand are exists that another CPU or a channel program
attached as the rightmost bits to the second may also be updating the location. An
operand, the second-operand bits are offset by example of this effect is shown for OR (OI) in
four bit positions, and the result is placed at the Multiprogramming and Multiprocessing
first-operand location. Examples in Appendix A, Number Repre-
sentation and Instruction-Use Examples.
The result is obtained as if the operands were 4. The storage-operand references for MOVE
processed right to left. When necessary, the WITH OFFSET may be multiple-access refer-
second operand is considered to be extended on ences. (See Storage-Operand Consistency
the left with zeros. If the first operand is too short on page 5-86.)
to contain all of the second operand, the
remaining leftmost portion of the second operand
is ignored. Access exceptions for the unused MOVE ZONES
portion of the second operand may or may not be
MVZ D(L,B),D(B) [SS]
indicated.
//
When the operands overlap, the result is obtained 'D3' L B D B D
as if the operands were processed one byte at a //
time, as if each result byte were stored imme- 8 16 2 32 36 47
diately after fetching the necessary operand bytes,
and as if the left digit of each second-operand The leftmost four bits of each byte in the second
byte were to remain available for the next result operand are placed in the leftmost four bit posi-
byte and need not be refetched. tions of the corresponding bytes in the first
operand. The rightmost four bits of each byte in
Condition Code: The code remains unchanged. the first operand remain unchanged.

Program Exceptions: Each operand is processed left to right. When the


Access (fetch, operand 2; fetch and store, operands overlap, the result is obtained as if the
operand 1) operands were processed one byte at a time and
each result byte were stored immediately after the
Programming Notes: necessary operand byte is fetched.
1. An example of the use of the MOVE WITH
Condition Code: The code remains unchanged.
OFFSET instruction is given in Appendix A,
Number Representation and Instruction-Use Program Exceptions:
Examples.
Access (fetch, operand 2; fetch and store,
2. MOVE WITH OFFSET may be used to shift operand 1)

7-106 z/Architecture Principles of Operation


Programming Notes: numbered register; otherwise, a specification
exception is recognized.
1. An example of the use of the MOVE ZONES
instruction is given in Appendix A, Number
Both the multiplicand and multiplier are treated as
Representation and Instruction-Use
32-bit signed binary integers. The multiplicand is
Examples.
in bit positions 32-63 of general register R + 1.
2. MOVE ZONES moves the zoned portion of a For MULTIPLY (MR), the multiplier is in bit posi-
decimal field in the zoned format. The zoned tions 32-63 of general register R The contents of
format is described in Chapter 8, Decimal general register R and of bit positions 0-31 of
Instructions. The operands are not checked general register R + 1 and, for MR, of general
for valid sign and digit codes. register R are ignored.
3. Accesses to the first operand of MOVE
The product is a 64-bit signed binary integer. Bits
ZONES consist in fetching the leftmost four
0-31 of the product replace bits 32-63 of general
bits of each byte in the first operand and sub-
register R. Bits 32-63 of the product replace bits
sequently storing the updated value of the
32-63 of general register R + 1. Bits 0-31 of
byte. These fetch and store accesses to a
general registers R and R + 1 remain
particular byte do not necessarily occur one
unchanged. An overflow cannot occur.
immediately after the other. Thus, this instruc-
tion cannot be safely used to update a The sign of the product is determined by the rules
location in storage if the possibility exists that of algebra from the multiplier and multiplicand
another CPU or a channel program may also sign, except that a zero result is always positive.
be updating the location. An example of this
effect is shown for the OR (OI) instruction in Condition Code: The code remains unchanged.
Multiprogramming and Multiprocessing
Examples in Appendix A, Number Repre- Program Exceptions:
sentation and Instruction-Use Examples.
Access (fetch, operand 2 of M only)
Specification
MULTIPLY
Programming Notes:
MR R,R [RR]
1. An example of the use of the MULTIPLY
instruction is given in Appendix A, Number
'1C' R R Representation and Instruction-Use

Examples.
8 12 15
2. The significant part of the product usually
M R,D(X,B) [RX] occupies 62 bit positions or fewer. Only when
two maximum 32-bit negative numbers are
multiplied are 63 significant product bits
'5C' R X B D formed.

8 12 16 2 31
MULTIPLY HALFWORD
The 32-bit first operand (the multiplicand) is multi-
MH R,D(X,B) [RX]
plied by the 32-bit second-operand (the multiplier),
and the 64-bit product is placed at the first-
operand location. '4C' R X B D

The R field designates an even-odd pair of 8 12 16 2 31
general registers and must designate an even-

Chapter 7. General Instructions 7-107


MULTIPLY HALFWORD Programming Notes:
IMMEDIATE 1. An example of the use of the MULTIPLY
HALFWORD instruction is given in
MHI R,I [RI] Appendix A, Number Representation and
Instruction-Use Examples.

'A7' R 'C' I 2. For MH and MHI, the significant part of the


product usually occupies 46 bit positions or
8 12 16 31 fewer. Only when two maximum negative
numbers are multiplied are 47 significant
MGHI R,I [RI] product bits formed. Since the rightmost 32
bits of the product are placed unchanged at

the first-operand location, ignoring all bits to


'A7' R 'D' I
the left, the sign bit of the result may differ
8 12 16 31 from the true sign of the product in the case of
overflow. For a negative product, the 32 bits
placed in register R are the rightmost part of
The 32-bit or 64-bit first operand (the multiplicand)
the product in two's-complement notation. For
is multiplied by the 16-bit second operand (the
MGHI, the significant part of the product
multiplier), and the rightmost 32 or 64 bits of the
usually occupies 78 bit positions or fewer.
product are placed at the first-operand location.
The second operand is two bytes in length and is
treated as a 16-bit signed binary integer. MULTIPLY LOGICAL
For MULTIPLY HALFWORD and MULTIPLY MLR R,R [RRE]
HALFWORD IMMEDIATE (MHI), the multiplicand

is treated as a 32-bit signed binary integer in bit 'B996' //////// R R
positions 32-63 of general register R, and it is
replaced by the rightmost 32 bits of the signed- 16 24 28 31
binary-integer product. The bits to the left of the
32 rightmost bits of the product are not tested for MLGR R,R [RRE]
significance; no overflow indication is given. Bits
0-31 of general register R are ignored and
remain unchanged. 'B986' //////// R R

16 24 28 31
For MULTIPLY HALFWORD IMMEDIATE (MGHI),
The multiplicand is treated as a 64-bit signed
binary integer in bit positions 0-63 of general reg- ML R,D(X,B) [RXE]
ister R, and it is replaced by the rightmost 64 bits
/
of the signed-binary-integer product. The bits to 'E3' R X B D //////// '96'
the left of the 64 rightmost bits of the product are /
not tested for significance; no overflow indication 8 12 16 2 32 4 47
is given.
MLG R,D(X,B) [RXE]
The sign of the product is determined by the rules
of algebra from the multiplier and multiplicand /
sign, except that a zero result is always positive. 'E3' R X B D //////// '86'
/
8 12 16 2 32 4 47
Condition Code: The code remains unchanged.

Program Exceptions: The 32-bit or 64-bit first operand (the multiplicand)


is multiplied by the 32-bit or 64-bit second
Access (fetch, operand 2 of MH only)
operand (the multiplier), and the 64-bit or 128-bit
product is placed at the first-operand location.

7-108 z/Architecture Principles of Operation


The R field designates an even-odd pair of MSGFR R,R [RRE]
general registers and must designate an even-
numbered register; otherwise, a specification
'B91C' //////// R R
exception is recognized.
16 24 28 31
For MULTIPLY LOGICAL (MLR, ML), both the
multiplicand and the multiplier are treated as 32-bit
MS R,D(X,B) [RX]
unsigned binary integers. The multiplicand is in
bit positions 32-63 of general register R + 1.
For MULTIPLY LOGICAL (MLR), the multiplier is '71' R X B D
in bit positions 32-63 of general register R. The
contents of general register R and of bit positions 8 12 16 2 31
0-31 of general register R + 1 and, for MLR, of
general register R are ignored. The product is a MSG R,D(X,B) [RXE]
64-bit unsigned binary integer. Bits 0-31 of the
/
product replace bits 32-63 of general register R,
'E3' R X B D //////// 'C'
and bits 32-63 of the product replace bits 32-63 of /
general register R + 1. Bits 0-31 of general reg- 8 12 16 2 32 4 47
isters R and R + 1 remain unchanged. An
overflow cannot occur. MSGF R,D(X,B) [RXE]

For MULTIPLY LOGICAL (MLGR, MLG), the mul- /


tiplicand and the multiplier are treated as 64-bit 'E3' R X B D //////// '1C'
unsigned binary integers. The multiplicand is in /
general register R + 1. The contents of general 8 12 16 2 32 4 47
register R are ignored. The product is a 128-bit
unsigned binary integer. Bits 0-63 of the product The first operand (multiplicand) is multiplied by the
replace the contents of general register R, and second operand (multiplier), and the rightmost 32
bits 64-127 of the product replace the contents of or 64 bits of the product are placed at the first-
general register R + 1. An overflow cannot operand location.
occur.
For MULTIPLY SINGLE (MSR, MS), the multipli-
Condition Code: The code remains unchanged. cand, multiplier, and product are treated as 32-bit
signed binary integers. The multiplicand is taken
Program Exceptions: from bit positions 32-63 of general register R and
Access (fetch, operand 2 of ML and MLG is replaced by the rightmost 32 bits of the signed-
only) binary-integer product. Bits 0-31 of general reg-
Specification ister R remain unchanged. For MSR, the
multiplier is in bit positions 32-63 of general reg-
ister R. The bits to the left of the 32 rightmost
MULTIPLY SINGLE bits of the product are not tested for significance;
no overflow indication is given.
MSR R,R [RRE]

For MULTIPLY SINGLE (MSGR, MSGFR, MSG,


'B252' //////// R R MSGF), the multiplicand, multiplier, and product
are treated as 64-bit signed binary integers,
16 24 28 31 except that, for MSGFR and MSGF, the multiplier
is treated as a 32-bit signed binary integer. The
MSGR R,R [RRE] multiplicand is taken from general register R and
is replaced by the rightmost 64 bits of the signed-
binary-integer product. For MSGFR, the multiplier
'B9C' //////// R R
is in bit positions 32-63 of general register R.

16 24 28 31 The bits to the left of the 64 rightmost bits of the

Chapter 7. General Instructions 7-109


product are not tested for significance; no overflow The OR of the first and second operands is placed
indication is given. at the first-operand location.

The sign of the product is determined by the rules The connective OR is applied to the operands bit
of algebra from the multiplier and multiplicand by bit. The contents of a bit position in the result
sign, except that a zero result is always positive. are set to one if the corresponding bit position in
one or both operands contains a one; otherwise,
Condition Code: The code remains unchanged. the result bit is set to zero.

Program Exceptions: For OR (OC), each operand is processed left to


Access (fetch, operand 2 of MS, MSG, MSGF right. When the operands overlap, the result is
only) obtained as if the operands were processed one
byte at a time and each result byte were stored
immediately after fetching the necessary operand
OR bytes.
OR R,R [RR]
For OR (OI), the first operand is one byte in
length, and only one byte is stored.
'16' R R
For OR (OR, O), the operands are 32 bits, and for
8 12 15 OR (OGR, OG), they are 64 bits.

OGR R,R [RRE] Resulting Condition Code:


0 Result zero

'B981' //////// R R 1 Result not zero


2 --
16 24 28 31 3 --

O R,D(X,B) [RX] Program Exceptions:


Access (fetch, operand 2, O, OG, and OC;

'56' R X B D fetch and store, operand 1, OI and OC)

8 12 16 2 31 Programming Notes:
1. Examples of the use of the OR instruction are
OG R,D(X,B) [RXE] given in Appendix A, Number Representation
and Instruction-Use Examples.
/
'E3' R X B D //////// '81' 2. OR may be used to set a bit to one.
/
8 12 16 2 32 4 47 3. Accesses to the first operand of OR (OI) and
OR (OC) consist in fetching a first-operand
byte from storage and subsequently storing
OI D(B),I [SI]
the updated value. These fetch and store
accesses to a particular byte do not neces-
'96' I B D sarily occur one immediately after the other.
Thus, OR cannot be safely used to update a
8 16 2 31 location in storage if the possibility exists that
another CPU or a channel program may also
OC D(L,B),D(B) [SS] be updating the location. An example of this
effect is shown in Multiprogramming and
//
'D6' L B D B D Multiprocessing Examples in Appendix A,
// Number Representation and Instruction-Use
8 16 2 32 36 47 Examples.

7-110 z/Architecture Principles of Operation


OR IMMEDIATE Resulting Condition Code:
0 Sixteen-bit result zero
OIHH R,I [RI] 1 Sixteen-bit result not zero
2 --
'A5' R '8' I 3 --

8 12 16 31 Program Exceptions: None.

OIHL R,I [RI] PACK


PACK D(L,B),D(L,B) [SS]
'A5' R '9' I
//
8 12 16 31 'F2' L L B D B D
//
OILH R,I [RI] 8 12 16 2 32 36 47

The format of the second operand is changed


'A5' R 'A' I
from zoned to packed, and the result is placed at
8 12 16 31 the first-operand location. The zoned and packed
formats are described in Chapter 8, Decimal
OILL R,I [RI] Instructions.

The second operand is treated as having the


'A5' R 'B' I zoned format. The numeric bits of each byte are
treated as a digit. The zone bits are ignored,
8 12 16 31 except the zone bits in the rightmost byte, which
are treated as a sign.
The second operand is ORed with bits of the first
operand, and the result replaces those bits of the The sign and digits are moved unchanged to the
first operand. The remainder of the first operand first operand and are not checked for valid codes.
remains unchanged. The sign is placed in the rightmost four bit posi-
tions of the rightmost byte of the result field, and
For each instruction, the bits of the first operand the digits are placed adjacent to the sign and to
that are ORed with the second operand and then each other in the remainder of the result field.
replaced are as follows:
The result is obtained as if the operands were
Bits processed right to left. When necessary, the
ORed second operand is considered to be extended on
and the left with zeros. If the first operand is too short
Instruction Replaced to contain all digits of the second operand, the
remaining leftmost portion of the second operand
OIHH 0-15
is ignored. Access exceptions for the unused
OIHL 16-31 portion of the second operand may or may not be
OILH 32-47 indicated.

OILL 48-63 When the operands overlap, the result is obtained


as if each result byte were stored immediately
The connective OR is applied to the operands bit after fetching the necessary operand bytes. Two
by bit. The contents of a bit position in the result second-operand bytes are needed for each result
are set to one if the corresponding bit position in byte, except for the rightmost byte of the result
one or both operands contains a one; otherwise, field, which requires only the rightmost second-
the result bit is set to zero. operand byte.

Chapter 7. General Instructions 7-111


Condition Code: The code remains unchanged. and are not checked for valid codes. The sign is
placed in the rightmost four bit positions of the
Program Exceptions: rightmost byte of the result field, and the digits are
Access (fetch, operand 2; store, operand 1) placed adjacent to the sign and to each other in
the remainder of the result field.
Programming Notes:
The result is obtained as if the operands were
1. An example of the use of the PACK instruc- processed right to left. When necessary, the
tion is given in Appendix A, Number Repre- second operand is considered to be extended on
sentation and Instruction-Use Examples. the left with zeros.
2. PACK may be used to interchange the two
hexadecimal digits in one byte by specifying a The length of the first operand is 16 bytes.
zero in the L and L fields and the same
The length of the second operand is designated
address for both operands.
by the contents of the L field. The second-
3. To remove the zone bits of all bytes of a field, operand length must not exceed 32 bytes (L
including the rightmost byte, both operands must be less than or equal to 31); otherwise, a
should be extended on the right with a dummy specification exception is recognized.
byte, which subsequently should be ignored in
the result field. When the length of the second operand is 32
bytes, the leftmost byte is ignored.
4. The storage-operand references for PACK
may be multiple-access references. (See
No test is made for destructive overlap, and the
Storage-Operand Consistency on
results in the first-operand location are unpredict-
page 5-86.)
able when destructive overlap exists. Operands
are said to overlap destructively when the first-
PACK ASCII operand location is used as a source after packed
data has been placed into it.
PKA D(B),D(L,B) [SS]
As observed by other CPUs and by channel pro-
//
'E9' L B D B D grams, the first-operand location is not necessarily
// stored into in any particular order and may appear
8 16 2 32 36 47 to be stored into more than once.

Condition Code: The code remains unchanged.


The format of the second operand is changed
from ASCII to packed, and the result is placed at
Program Exceptions:
the first-operand location. The packed format is
described in Chapter 8, Decimal Instructions. Access (fetch, operand 2; store, operand 1)
Operation (if the extended-translation facility 2
The second-operand bytes are treated as con- is not installed)
taining decimal digits, having the binary encoding Specification
0000-1001 for 0-9, in their rightmost four bit posi-
tions. The leftmost four bit positions of a byte are Programming Notes:
ignored. The second operand is considered to be 1. Although PACK ASCII is primarily intended to
positive. change the format of ASCII decimal digits, its
use is not restricted to ASCII since the left-
The implied positive sign (1100 binary) and the
most four bits of each byte are ignored.
source digits are placed at the first-operand
location. The source digits are moved unchanged 2. The following example illustrates the use of
the instruction to pack ASCII digits:

7-112 z/Architecture Principles of Operation


ASDIGITS DS CL31 location. The source digits are moved unchanged
DC X'3132333435' and are not checked for valid codes. The sign is
DC X'363738393' placed in the rightmost four bit positions of the
DC X'3132333435' rightmost byte of the result field, and the digits are
DC X'363738393' placed adjacent to the sign and to each other in
DC X'3132333435' the remainder of the result field.
DC X'363738393'
DC X'31' The result is obtained as if the operands were
PKDIGITS DS PL16
processed right to left. When necessary, the
...
PKA PKDIGITS,ASDIGITS(31) second operand is considered to be extended on
the left with zeros.
3. The instruction can also be used to pack
EBCDIC digits, which is especially useful The length of the first operand is 16 bytes.
when the length of the second operand is
greater than the 16-byte second-operand limit The byte length of the second operand is desig-
of PACK. nated by the contents of the L field. The second-
EBDIGITS DS CL31 operand length must not exceed 32 characters or
DC X'F1F2F3F4F5' 64 bytes, and the byte length must be even (L
DC X'F6F7F8F9F' must be less than or equal to 63 and must be
DC X'F1F2F3F4F5' odd); otherwise, a specification exception is recog-
DC X'F6F7F8F9F' nized.
DC X'F1F2F3F4F5'
DC X'F6F7F8F9F' When the length of the second operand is 32
DC X'F1' characters (64 bytes), the leftmost character is
PKDIGITS DS PL16 ignored.
...
PKA PKDIGITS,EBDIGITS(31) No test is made for destructive overlap, and the
results in the first-operand location are unpredict-
PACK UNICODE able when destructive overlap exists. Operands
are said to overlap destructively when the first-
PKU D(B),D(L,B) [SS] operand location is used as a source after packed
data has been placed into it.
//
'E1' L B D B D As observed by other CPUs and by channel pro-
//
8 16 2 32 36 47 grams, the first-operand location is not necessarily
stored into in any particular order and may appear
to be stored into more than once.
The format of the second operand is changed
from Unicode to packed, and the result is placed Condition Code: The code remains unchanged.
at the first-operand location. The packed format is
described in Chapter 8, Decimal Instructions. Program Exceptions:

The two-byte second-operand characters are Access (fetch, operand 2; store, operand 1)
treated as Unicode Basic Latin characters con- Operation (if the extended-translation facility 2
taining decimal digits, having the binary encoding is not installed)
0000-1001 for 0-9, in their rightmost four bit posi- Specification
tions. The leftmost 12 bit positions of a character
Programming Notes:
are ignored. The second operand is considered to
be positive. 1. The following example illustrates the use of
PACK UNICODE to pack European numbers:
The implied positive sign (1100 binary) and the
source digits are placed at the first-operand

Chapter 7. General Instructions 7-113


UNDIGITS DS CL62 and store, compare and swap and double store, or
DC X'3132333435' compare and swap and triple store.
DC X'363738393'
DC X'3132333435' A test bit in general register 0 specifies, when
DC X'363738393' one, that a lock is not to be obtained and none of
DC X'3132333435' the six operations is to be performed but, instead,
DC X'363738393' the validity of the function code is to be tested.
DC X'31' This will be useful if additional function codes for
PKDIGITS DS PL16
additional operations are assigned in the future.
...
PKU PKDIGITS,UNDIGITS(62) This definition is written as if the test bit is zero
except when stated otherwise.
2. Because the leftmost 12 bits of each character
are ignored, those Unicode decimal digits If compare and load is specified, the first-operand
where the digit zero has four rightmost zero comparison value and the second operand are
bits can also be packed by the instruction. compared. If they are equal, the fourth operand is
For example, for Thai digits: placed in the third-operand location. If the com-
UNDIGITS DS CL62 parison indicates inequality, the second operand is
DC X'E51E52E53E54E55' placed in the first-operand-comparison-value
DC X'E56E57E58E59E5' location as a new first-operand comparison value.
DC X'E51E52E53E54E55'
DC X'E56E57E58E59E5' If compare and swap is specified, the first-operand
DC X'E51E52E53E54E55' comparison value and the second operand are
DC X'E56E57E58E59E5' compared. If they are equal, the first-operand
DC X'E51' replacement value is stored at the second-
PKDIGITS DS PL16 operand location. If the comparison indicates ine-
... quality, the second operand is placed in the
PKU PKDIGITS,UNDIGITS(62) first-operand-comparison-value location as a new
first-operand comparison value.
PERFORM LOCKED OPERATION
If double compare and swap is specified, the first-
PLO R,D(B),R,D(B) [SS] operand comparison value and the second
operand are compared. If they are equal, the
// third-operand comparison value and the fourth
'EE' R R B D B D
// operand are compared. If both comparisons indi-
8 12 16 2 32 36 47 cate equality, the first-operand and third-operand
replacement values are stored at the second-
operand location and fourth-operand location,
After the lock specified in general register 1 has
respectively. If the first comparison indicates ine-
been obtained, the operation specified by the
quality, the second operand is placed in the first-
function code in general register 0 is performed,
operand-comparison-value location as a new
and then the lock is released. However, as
first-operand comparison value. If the first com-
observed by other CPUs: (1) storage operands,
parison indicates equality but the second does
including fields in a parameter list that may be
not, the fourth operand is placed in the third-
used, may be fetched, and may be tested for
operand-comparison-value location as a new third-
store-type access exceptions if a store at a tested
operand comparison value.
location is possible, before the lock is obtained,
and (2) operands may be stored in the parameter If compare and swap and store, double store, or
list after the lock has been released. If an triple store is specified, the first-operand compar-
operand not in the parameter list is fetched before ison value and the second operand are compared.
the lock is obtained, it is fetched again after the If they are equal, the first-operand replacement
lock has been obtained. value is stored at the second-operand location,
and the third operand is stored at the fourth-
The function code can specify any of six oper-
operand location. Then, if the operation is the
ations: compare and load, compare and swap,
double-store or triple-store operation, the fifth
double compare and swap, compare and swap

7-114 z/Architecture Principles of Operation


operand is stored at the sixth-operand location,
and, if it is the triple-store operation, the seventh Func- Operand Func-
operand is stored at the eighth-operand location. tion Length tion
If the first-operand comparison indicates ine- Code Operation (Bits) Symbol
quality, the second operand is placed in the first-
0 Compare and load 32 CL
operand-comparison-value location as a new
first-operand comparison value. 1 Same as 0 64 CLG
2 Same as 0 64 CLGR
After any of the six operations, the result of the
comparison or comparisons is indicated in the 3 Same as 0 128 CLX
condition code. 4 Compare and swap 32 CS
The function code (FC) is in bit positions 56-63 of 5 Same as 4 64 CSG
general register 0. The function code specifies 6 Same as 4 64 CSGR
not only the operation to be performed but also
the length of the operands and whether the first- 7 Same as 4 128 CSX
operand comparison and replacement values and 8 Double compare and 32 DCS
the third operand or third-operand comparison and swap
replacement values, which are referred to collec-
tively simply as the first and third operands, are in 9 Same as 8 64 DCSG
general registers or a parameter list. The pattern 10 Same as 8 64 DCSGR
of the function codes is as follows:
11 Same as 8 128 DCSX
A function code that is a multiple of 4
(including 0) specifies a 32-bit length with the 12 Compare and swap and 32 CSST
first and third operands in bit positions 32-63 store
of general registers. 13 Same as 12 64 CSSTG
A function code that is one more than a mul- 14 Same as 12 64 CSSTGR
tiple of 4 specifies a 64-bit length with the first
15 Same as 12 128 CSSTX
and third operands in a parameter list.
16 Compare and swap and 32 CSDST
A function code that is 2 more than a multiple
double store
of 4 specifies a 64-bit length with the first and
third operands in bit positions 0-63 of general 17 Same as 16 64 CSDSTG
registers.
18 Same as 16 64 CSDSTGR
A function code that is 3 more than a multiple
19 Same as 16 128 CSDSTX
of 4 specifies a 128-bit length with the first
and third operands in a parameter list. 20 Compare and swap and 32 CSTST
triple store
Figure 7-19 shows the function codes, operation
names, and operand lengths, and also symbols 21 Same as 20 64 CSTSTG
that may be used to refer to the operations in dis- 22 Same as 20 64 CSTSTGR
cussions. For example, PLO.DCS may be used to
mean PERFORM LOCKED OPERATION with 23 Same as 20 128 CSTSTX
function code 8. In the symbols, the letter G
indicates a 64-bit operand length, the letter R Figure 7-19. PERFORM LOCKED OPERATION Func-
indicates that some or all 64-bit operands are in tion Codes and Operations
general registers, and the letter X indicates a
128-bit operand length. specify operations that the CPU cannot perform
because the operations are not implemented
The CPU can perform all of the operations speci- (installed) are called invalid.
fied by the function codes listed in Figure 7-19.
Function codes specifying operations that the CPU Bit 55 of general register 0 is the test bit (T).
can perform are called valid. Function codes that When bit 55 is zero, the function code in general
have not been assigned to operations or that register 0 must be valid; otherwise, a specification

Chapter 7. General Instructions 7-115


exception is recognized. When bit 55 is one, the register R. For the even-numbered function
condition code is set to 0 if the function code is codes beginning with 4, the first-operand replace-
valid or to 3 if the function code is invalid, and no ment value is in general register R + 1, and R
other operation is performed. designates an even-odd pair of registers and must
designate an even-numbered register; otherwise,
Bits 32-54 of general register 0 must be all zeros; a specification exception is recognized. For func-
otherwise, a specification exception is recognized. tion codes 0 and 2, R can be even or odd.
When bit 55 of the register is one, this is the only
exception that can be recognized. Bits 0-31 of For function codes 0, 2, 12, and 14, the third
general register 0 are ignored. operand is in general register R, and R can be
even or odd.
The lock to be used is represented by a program
lock token (PLT) whose logical address is speci- For function codes 8 and 10, the third-operand
fied in general register 1. In the 24-bit addressing comparison value is in general register R, the
mode, the PLT address is bits 40-63 of general third-operand replacement value is in general reg-
register 1, and bits 0-39 of the register are ister R + 1, and R designates an even-odd pair
ignored. In the 31-bit addressing mode, the PLT of registers and must designate an even-
address is bits 33-63 of the register, and bits 0-32 numbered register; otherwise, a specification
of the register are ignored. In the 64-bit exception is recognized.
addressing mode, the PLT address is bits 0-63 of
the register. For all function codes, the B and D fields of the
instruction specify the second-operand address.
The contents of general registers 0 and 1
described above are as follows: For function codes 0, 2, 8, 10, 12, and 14, the B
and D fields of the instruction specify the fourth-
GR operand address.
/
///T FC For function codes 1, 3, 5, 7, 9, 11, 13, 15, and
/
32 56 63 16-23, the B and D fields of the instruction
specify the address of a parameter list that is used
by the instruction, and this address is not called
GR 1 in 24-Bit Addressing Mode
/ the fourth-operand address. The parameter list
//////////// PLT Address contains odd-numbered operands, including com-
/ parison and replacement values, and addresses of
4 63 even-numbered operands other than the second
operand. In the access-register mode, the param-
GR 1 in 31-Bit Addressing Mode eter list also contains access-list-entry tokens
/ (ALETs) associated with the even-numbered-
//// PLT Address operand addresses.
/
33 63
In the access-register mode, for function codes
that cause use of a parameter list containing an
GR 1 in 64-Bit Addressing Mode ALET, R must not be zero; otherwise, a specifi-
cation exception is recognized.
PLT Address

63 The rules about R and R, and the use of the


address specified by B and D, are summarized
in Figure 7-20 on page 7-117.
For the even-numbered function codes, including
0, the first-operand comparison value is in general

7-116 z/Architecture Principles of Operation


address space containing a fourth operand or a
Function parameter list as shown in Figure 7-21 on
Codes Operation R R D(B) page 7-118. Also, for an operand whose address

and 2 Compare and load EO EO Op4a is in the parameter list, an access-list-entry token
1 and 3 Compare and load - NZ PLa (ALET) is in the list along with the address and is
4 and 6 Compare and swap E - - used in the access-register mode to specify the
5 and 7 Compare and swap - - PLa address space containing the operand.
8 and 1 Double compare E E Op4a
and swap In the access-register mode, if an access excep-
9 and 11 Double compare - NZ PLa
and swap tion or PER storage-alteration event is recognized
12 and 14 Compare and swap E EO Op4a for an operand whose address is in the parameter
and store list, the associated ALET in the parameter list is
13 and 15 Compare and swap - NZ PLa loaded into access register R when the exception
and store or event is recognized. Then, during the resulting
16 and 18 Compare and swap E NZ PLa
and double store program interruption, if a value is due to be stored
17 and 19 Compare and swap - NZ PLa as the exception access identification at real
and double store location 160 or the PER access identification at
2 and 22 Compare and swap E NZ PLa real location 161, R is stored. If the instruction
and triple store execution is completed without the recognition of
21 and 23 Compare and swap - NZ PLa an exception or event, the contents of access reg-
and triple store
ister R are unpredictable. When not in the
Explanation: access-register mode, or when a parameter list
containing an ALET is not used, the contents of
- Ignored. access register R remain unchanged.
E Must be even.
EO Can be even or odd. The even-numbered (2, 4, 6, and 8) storage oper-
NZ Must be nonzero in the access-register
mode. Ignored otherwise. ands must be designated on an integral boundary,
Op4a D(B) is operand-4 address. which is a word boundary for function codes that
PLa D(B) is parameter-list address. are a multiple of 4, a doubleword boundary for
function codes that are one or 2 more than a mul-
Figure 7-20. Register Rules and D(B) Usage for tiple of 4, or a quadword boundary for function
PERFORM LOCKED OPERATION codes that are 3 more than a multiple of 4. A
parameter list, if used, must be designated on a
Figure 7-21 on page 7-118 shows the locations of doubleword boundary. Otherwise, a specification
the operands (including operand comparison and exception is recognized. The program-lock-token
replacement values), operand addresses, and (PLT) address in general register 1 does not have
parameter-list address used by the instruction. a boundary-alignment requirement.

Operand addresses in a parameter list, if used, All unused fields in a parameter list should contain
are in doublewords in the list. In the 24-bit all zeros; otherwise, the program may not operate
addressing mode, an operand address is bits compatibly in the future.
40-63 of a doubleword, and bits 0-39 of the
doubleword are ignored. In the 31-bit addressing A serialization operation is performed immediately
mode, an operand address is bits 33-63 of a after the lock is obtained and again immediately
doubleword, and bits 0-32 of the doubleword are before it is released. However, values fetched
ignored. In the 64-bit addressing mode, an from the parameter list before the lock is obtained
operand address is bits 0-63 of a doubleword. are not necessarily refetched. A serialization
operation is not performed if the test bit, bit 55 of
In the access-register mode, access register 1 general register 0, is one.
specifies the address space containing the
program lock token (PLT), access register B In the following figures showing the parameter lists
specifies the address space containing the second for the different function codes, the offsets shown
operand, and access register B specifies the on the left are byte values.

Chapter 7. General Instructions 7-117



Op3 Op5 Op7
Function or and and
Codes Operation Op1c Op1r Op2a Op3c Op3r Op4a Op6a Op8a PLa

and 2 Compare and load R - D(B) R D(B) - - -



1 and 3 Compare and load PL - D(B) PL PL - - D(B)

4 and 6 Compare and swap R R+1 D(B) - - - - -

5 and 7 Compare and swap PL PL D(B) - - - - D(B)

8 and 1 Double compare R R+1 D(B) R R+1 D(B) - - -
and swap

9 and 11 Double compare PL PL D(B) PL PL PL - - D(B)
and swap

12 and 14 Compare and swap R R+1 D(B) R D(B) - - -
and store

13 and 15 Compare and swap PL PL D(B) PL PL - - D(B)
and store

16 and 18 Compare and swap R R+1 D(B) PL PL PL - D(B)
and double store

17 and 19 Compare and swap PL PL D(B) PL PL PL - D(B)
and double store

2 and 22 Compare and swap R R+1 D(B) PL PL PL PL D(B)
and triple store

21 and 23 Compare and swap PL PL D(B) PL PL PL PL D(B)
and triple store

Explanation:

For function codes that are a multiple of 4 (including ) or one more than a multiple of
4, operands in general registers are in bit positions 32-63 of the registers, and bits
-31 of the registers are ignored and remain unchanged. For function codes that are two
more than a multiple of 4, operands in general registers are in bit positions -63 of the
registers.
- Operand, value, or address is not used in the operation.
OpNc Operand-N comparison value.
OpNr Operand-N replacement value.
OpNa Operand-N address.
PL Operand, value, or address is in the parameter list.
PLa Parameter-list address.

Figure 7-21. Operand and Address Locations for PERFORM LOCKED OPERATION

Function Codes 0-3 (Compare and Load) The locations of the operands and addresses
used by the instruction are as shown in
Figure 7-21.

7-118 z/Architecture Principles of Operation


The parameter list used for function code 1 has the third operand is replaced by the fourth
the following format: operand, and condition code 0 is set.

Parameter List for Function Code 1 When the first-operand comparison value is not
equal to the second operand, the first-operand

comparison value is replaced by the second
8 Operand-1 Comparison Value operand, and condition code 1 is set.

16 Function Codes 4-7 (Compare and Swap)

24 The locations of the operands and addresses
used by the instruction are as shown in
32
Figure 7-21 on page 7-118.
4 Operand 3
The parameter list used for function code 5 has
48 the following format:

56 Parameter List for Function Code 5

64 Operand-4 ALET

72 Operand-4 Address 8 Operand-1 Comparison Value

16

The parameter list used for function code 3 has 24 Operand-1 Replacement Value
the following format:

Parameter List for Function Code 3


The parameter list used for function code 7 has
Operand-1 Comparison Value the following format:

8 Operand-1 Comp. Value (continued) Parameter List for Function Code 7

16 Operand-1 Comparison Value

24 8 Operand-1 Comp. Value (continued)

32 Operand 3 16 Operand-1 Replacement Value

4 Operand 3 (continued) 24 Operand-1 Repl. Value (continued)

48

56 The first-operand comparison value is compared

64 Operand-4 ALET to the second operand. When the first-operand
comparison value is equal to the second operand,
72 Operand-4 Address the first-operand replacement value is stored at
the second-operand location, and condition code 0
is set.

The first-operand comparison value is compared When the first-operand comparison value is not
to the second operand. When the first-operand equal to the second operand, the first-operand
comparison value is equal to the second operand, comparison value is replaced by the second
operand, and condition code 1 is set.

Chapter 7. General Instructions 7-119


Function Codes 8-11 (Double Compare and The first-operand comparison value is compared
Swap) to the second operand. When the first-operand
comparison value is equal to the second operand,
The locations of the operands and addresses the third-operand comparison value is compared
used by the instruction are as shown in to the fourth operand. When the third-operand
Figure 7-21 on page 7-118. comparison value is equal to the fourth operand
(after the first-operand comparison value has been
The parameter list used for function code 9 has found equal to the second operand), the first-
the following format: operand replacement value is stored at the
second-operand location, the third-operand
Parameter List for Function Code 9
replacement value is stored at the fourth-operand
location, and condition code 0 is set.

8 Operand-1 Comparison Value When the first-operand comparison value is not
equal to the second operand, the first-operand
16 comparison value is replaced by the second

operand, and condition code 1 is set.
24 Operand-1 Replacement Value

32 When the third-operand comparison value is not
equal to the fourth operand (after the first-operand
4 Operand-3 Comparison Value comparison value has been found equal to the
second operand), the third-operand comparison
48
value is replaced by the fourth operand, and con-

56 Operand-3 Replacement Value dition code 2 is set.

64 Operand-4 ALET Function Codes 12-15 (Compare and Swap and
Store)
72 Operand-4 Address
The locations of the operands and addresses
used by the instruction are as shown in
Figure 7-21 on page 7-118.
The parameter list used for function code 11 has
the following format:
The parameter list used for function code 13 has
Parameter List for Function Code 11 the following format:

Operand-1 Comparison Value Parameter List for Function Code 13

8 Operand-1 Comp. Value (continued)

16 Operand-1 Replacement Value 8 Operand-1 Comparison Value

24 Operand-1 Repl. Value (continued) 16

32 Operand-3 Comparison Value 24 Operand-1 Replacement Value

4 Operand-3 Comp. Value (continued) 32

48 Operand-3 Replacement Value 4

56 Operand-3 Repl. Value (continued) 48

64 Operand-4 ALET 56 Operand 3

72 Operand-4 Address 64 Operand-4 ALET

72 Operand-4 Address

7-120 z/Architecture Principles of Operation


The parameter list used for function code 15 has Function Codes 16-19 (Compare and Swap and
the following format: Double Store)

Parameter List for Function Code 15 The locations of the operands and addresses
used by the instruction are as shown in
Operand-1 Comparison Value
Figure 7-21 on page 7-118.
8 Operand-1 Comp. Value (continued)
The parameter list used for function code 16 has
16 Operand-1 Replacement Value the following format:

24 Operand-1 Repl. Value (continued) Parameter List for Function Code 16

32

4 8

48 Operand 3 16

56 Operand 3 (continued) 24

64 Operand-4 ALET 32

72 Operand-4 Address 4

48

The first-operand comparison value is compared 56 Operand 3
to the second operand. When the first-operand
comparison value is equal to the second operand, 64 Operand-4 ALET
the first-operand replacement value is stored at
the second-operand location, the third operand is 72 Operand-4 Address

stored at the fourth-operand location, and condi- 8
tion code 0 is set.
88 Operand 5
When the first-operand comparison value is not
equal to the second operand, the first-operand 96 Operand-6 ALET
comparison value is replaced by the second
14 Operand-6 Address
operand, and condition code 1 is set.

Chapter 7. General Instructions 7-121


The parameter list used for function code 17 has The parameter list used for function code 18 has
the following format: the following format:

Parameter List for Function Code 17 Parameter List for Function Code 18



8 Operand-1 Comparison Value 8

16 16

24 Operand-1 Replacement Value 24

32 32

4 4

48 48

56 Operand 3 56 Operand 3

64 Operand-4 ALET 64 Operand-4 ALET

72 Operand-4 Address 72 Operand-4 Address

8 8

88 Operand 5 88 Operand 5

96 Operand-6 ALET 96 Operand-6 ALET

14 Operand-6 Address 14 Operand-6 Address

7-122 z/Architecture Principles of Operation


The parameter list used for function code 19 has Function Codes 20-23 (Compare and Swap and
the following format: Triple Store)

Parameter List for Function Code 19 The locations of the operands and addresses
used by the instruction are as shown in
Operand-1 Comparison Value
Figure 7-21 on page 7-118.
8 Operand-1 Comp. Value (continued)
The parameter list used for function code 20 has
16 Operand-1 Replacement Value the following format:

24 Operand-1 Repl. Value (continued) Parameter List for Function Code 2

32

4 8

48 Operand 3 16

56 Operand 3 (continued) 24

64 Operand-4 ALET 32

72 Operand-4 Address 4

8 Operand 5 48

88 Operand 5 (continued) 56 Operand 3

96 Operand-6 ALET 64 Operand-4 ALET

14 Operand-6 Address 72 Operand-4 Address

8

The first-operand comparison value is compared 88 Operand 5
to the second operand. When the first-operand
96 Operand-6 ALET
comparison value is equal to the second operand,
the first-operand replacement value is stored at 14 Operand-6 Address
the second-operand location, the third operand is
stored at the fourth-operand location, the fifth 112
operand is stored at the sixth-operand location,
12 Operand 7
and condition code 0 is set.
128 Operand-8 ALET
When the first-operand comparison value is not
equal to the second operand, the first-operand 136 Operand-8 Address
comparison value is replaced by the second
operand, and condition code 1 is set.

Chapter 7. General Instructions 7-123


The parameter list used for function code 21 has The parameter list used for function code 22 has
the following format: the following format:

Parameter List for Function Code 21 Parameter List for Function Code 22



8 Operand-1 Comparison Value 8

16 16

24 Operand-1 Replacement Value 24

32 32

4 4

48 48

56 Operand 3 56 Operand 3

64 Operand-4 ALET 64 Operand-4 ALET

72 Operand-4 Address 72 Operand-4 Address

8 8

88 Operand 5 88 Operand 5

96 Operand-6 ALET 96 Operand-6 ALET

14 Operand-6 Address 14 Operand-6 Address

112 112

12 Operand 7 12 Operand 7

128 Operand-8 ALET 128 Operand-8 ALET

136 Operand-8 Address 136 Operand-8 Address

7-124 z/Architecture Principles of Operation


The parameter list used for function code 23 has Locking
the following format:
A lock is obtained at the beginning of the opera-
Parameter List for Function Code 23 tion and released at the end of the operation. The
lock obtained is represented by a program lock
Operand-1 Comparison Value
token (PLT) whose logical address is specified in
8 Operand-1 Comp. Value (continued) general register 1 as already described.

16 Operand-1 Replacement Value A PLT is a value produced by a model-dependent
transformation of the PLT logical address.
24 Operand-1 Repl. Value (continued) Depending on the model, the PLT may be derived

32 directly from the PLT logical address or, when
DAT is on, from the real address that results from
4 transformation of the PLT logical address by DAT.
If DAT is used, access-register translation (ART)
48 Operand 3 precedes DAT in the access-register mode.

56 Operand 3 (continued)
A PLT selects one of a model-dependent number

64 Operand-4 ALET of locks within the configuration. Programs being
executed by different CPUs can be assured of
72 Operand-4 Address specifying the same lock only by specifying PLT
logical addresses that are the same and that can
8 Operand 5 be transformed to the same real address by the

88 Operand 5 (continued) different CPUs.

96 Operand-6 ALET Since a model may or may not use ART and DAT
when forming a PLT, access-exception conditions
14 Operand-6 Address that can be encountered during ART and DAT
may or may not be recognized as exceptions.
112 Operand 7
There is no accessing of a location designated by
12 Operand 7 (continued) a PLT, but an addressing exception may be
recognized for the location. A protection excep-
128 Operand-8 ALET tion is not recognized for any reason during proc-
essing of a PLT logical address.
136 Operand-8 Address

The CPU can hold one lock at a time.

When PERFORM LOCKED OPERATION is exe-


The first-operand comparison value is compared
cuted by this CPU and is to use a lock that is
to the second operand. When the first-operand
already held by another CPU due to the execution
comparison value is equal to the second operand,
of a PERFORM LOCKED OPERATION instruction
the first-operand replacement value is stored at
by the other CPU, the execution by this CPU is
the second-operand location, the third operand is
delayed until the lock is no longer held. An exces-
stored at the fourth-operand location, the fifth
sive delay can be caused only by a machine mal-
operand is stored at the sixth-operand location,
function and is a machine-check condition.
the seventh operand is stored at the eighth-
operand location, and condition code 0 is set.
The order in which multiple requests for the same
lock are satisfied is undefined.
When the first-operand comparison value is not
equal to the second operand, the first-operand
A nonrecoverable failure of a CPU while holding a
comparison value is replaced by the second
lock may result in a machine check, entry into the
operand, and condition code 1 is set.
check-stop state, or system check stop. The
machine check is processing backup if all oper-
ands are undamaged or processing damage if

Chapter 7. General Instructions 7-125


register operands are damaged. If a machine Provided that accessing of an operand is not pro-
check or the check-stop state is the result, either hibited as described in the preceding paragraph,
no storage operands have been changed or else store-type access exceptions may be recognized
all storage operands that were due to be changed for the operand even when a store does not occur
have been correctly changed, and, in either case, because of the results of a comparison. A
the lock has been released. If the storage oper- storage-alteration PER event is recognized, and a
ands are not in either their correct original state or change bit is set, only if a store occurs.
their correct final state, the result is system check
stop. When a comparison is made between an operand
comparison value and an operand before the lock
Storage-Operand References is obtained and indicates inequality, the lock still is
obtained. The condition code is set only as a
The accesses to the even-numbered storage oper- result of a comparison made while the lock is
ands are word concurrent for function codes that held. When condition code 1 or 2 is set, the first-
are a multiple of 4 and doubleword concurrent for operand comparison value or third-operand com-
function codes that are one, 2, or 3 more than a parison value is replaced only by means of a fetch
multiple of 4. The accesses to the doublewords in of the second operand or fourth operand, respec-
the parameter list are doubleword concurrent tively, made while the lock is held, as observed by
regardless of the function code. other CPUs.

As observed by other CPUs, all storage operands In those cases when a store is performed to the
may be tested for access exceptions before a lock second-operand location and one or more of the
is obtained. (A channel program cannot observe fourth-, sixth-, and eighth-operand locations, the
a lock.) store to the second-operand location is always
performed last, as observed by other CPUs and
As observed by other CPUs, in all operations by channel programs.
except the compare-and-swap operation (which
does not have a fourth operand), the fourth Stores into the parameter list may be performed
operand is accessed while the lock is held only if while the lock is held or after it has been released.
a comparison of the first-operand comparison
value to the second operand while the lock is held A serialization operation is performed immediately
has indicated equality. In these operations, the after the lock is obtained and again immediately
fourth operand is accessed before the lock is held before it is released. However, values fetched
only if a comparison of the first-operand compar- from the parameter list before the lock is obtained
ison value to the second operand has indicated are not necessarily refetched. A serialization
equality and only if, when DAT is on, an INVALI- operation is not performed if the test bit, bit 55 of
DATE PAGE TABLE ENTRY instruction executed general register 0, is one.
by another CPU after the fetch of the second
operand will not be the cause of a page- Access exceptions may be recognized for
translation exception recognized for the fourth parameter-list locations even when the locations
operand, which it will if it sets to one the page- are not required in the operation. The locations
invalid bit in the page-table entry for the fourth are those beginning at offset 0 and extending up
operand when this CPU does not have a TLB through the last location defined for the function
entry corresponding to that page-table entry. In code used.
the compare-and-swap-and-double-store and
compare-and-swap-and-triple-store operations, the For the compare-and-load and compare-and-swap
sixth operand, and also the eighth operand in the operations, the operation is suppressed on all
triple-store operation, are treated the same as the addressing and protection exceptions.
fourth operand described above. The reason for
this specification about INVALIDATE PAGE When a nonrecoverable failure of a CPU while
TABLE ENTRY is given in programming note 6 on holding a lock results in a machine check or entry
page 7-127. into the check-stop state, either no storage oper-
ands have been changed or else all storage oper-
ands that were due to be changed have been

7-126 z/Architecture Principles of Operation


correctly changed. The latter may be accom- TION instructions that are executed concur-
plished by repeating stores that were performed rently by different CPUs and that use the
successfully before the failure. Therefore, there same lock, the changes to operands not in the
may be two single-access store references (pos- parameter list will be completed by one of the
sibly the store part of an update reference and CPUs before they are begun by the other
then a store reference) to the store-type operands, CPU, depending on which CPU first obtains
with the first value stored equal to the second the lock.
value stored.
3. The compare-and-swap functions of
PERFORM LOCKED OPERATION are not
Resulting Condition Code:
performed by means of interlocked-update ref-
When test bit is zero: erences. Concurrent store references by
another CPU to the storage operands, even if
0 All comparisons equal; replacement value or they are interlocked-update references, will
values stored or loaded interfere unpredictably, in terms of the
1 First-operand comparison not equal; first- resulting register and storage contents, with
operand comparison value replaced the intended operation of PERFORM
2 -- (all operations except double compare and LOCKED OPERATION. All changes to the
swap) contents of the storage locations must be
2 First-operand comparison equal but third- made by PERFORM LOCKED OPERATION
operand comparison not equal; third-operand instructions that use the same lock, if predict-
comparison value replaced (double compare able storage results are to be obtained.
and swap)
3 -- 4. Because a nonrecoverable failure of a CPU
while executing PERFORM LOCKED OPERA-
When test bit is one: TION may cause two stores of the same value
to a store-type operand, a concurrent store
0 Function code valid made by another CPU to the same operand
1 -- but not by executing PERFORM LOCKED
2 -- OPERATION may be lost.
3 Function code invalid
5. When programs in different address spaces
Program Exceptions: are using the same lock when DAT is on, the
programs must ensure that they are using
Access (for all function codes, fetch, except
PLT logical addresses that are the same and
addressing and protection for PLT location,
that will be translated to the same real
program lock token, model dependent; for all
address regardless of the address space in
function codes, fetch and store, operand 2; for
which a translation occurs. Otherwise, the
odd-numbered function codes, fetch and store,
programs may in fact use different locks.
parameter list; for function codes 16, 18, 20,
and 22, fetch, parameter list; for function 6. The section Storage-Operand References on
codes 0-3, fetch, operand 4; for function page 7-126 contains a specification con-
codes 8-11, fetch and store, operand 4; for cerning the INVALIDATE PAGE TABLE
function codes 12-23, store, operand 4; for ENTRY (IPTE) instruction. The need for the
function codes 16-23, store, operand 6; for specification is shown by the following
function codes 20-23, store, operand 8) example that is possible without the specifica-
Specification tion.
a. CPU 1 begins to execute a PERFORM
Programming Notes:
LOCKED OPERATION instruction with
1. An example of the use of the PERFORM function code 8, which is referred to as
LOCKED OPERATION instruction is given in PLO.DCS. Operand 2 is a location, Qtail,
Appendix A, Number Representation and containing the address (the first-operand
Instruction-Use Examples. comparison value) of the last element,
element X, on a queue, and operand 4 is
2. When the contents of storage locations are
a location in that element containing the
changed by PERFORM LOCKED OPERA-

Chapter 7. General Instructions 7-127


address (0, the third-operand comparison d. CPU 2 completes its IPTE instruction.
value) of the next (nonexisting) element The program on CPU 2 sets a software bit
on the queue. The purpose of the PLO in the page-table entry to one to indicate
instruction is to enqueue an element by that the page has been freemained and
placing the address of the element (the that, therefore, a reference to the page
first-operand and third-operand replace- should result in presentation by the control
ment values) in both operand 2 and program of an addressing exception to the
operand 4. With the lock not held, the program making the reference.
PLO instruction fetches operand 2 and
e. CPU 1 attempts to do DAT for operand 4
compares it, with an equal result, to the
and sees that the page-invalid bit is one.
first-operand comparison value.
CPU 1 performs a program interruption
b. CPU 2 completely executes a PLO.DCS indicating a page-translation exception.
instruction to dequeue element X, which is The exception handler sees that the soft-
the only element on the queue, from the ware bit indicating freemained is one, and
queue. The PLO instruction stores 0 in it presents an addressing exception to the
Qtail and also in Qhead, which is a CPU 1 program, which causes an abend
location containing the address of the first of the program.
element on the queue. The program on
If CPU 1 had had a TLB entry for the page, its
CPU 2 processes the dequeued element
PLO instruction would not have been inter-
and then invokes the freemain service of
rupted, and the comparison of the first-
the control program to deallocate the
operand comparison value to the second
storage containing the element. The
operand while the lock was held would indi-
freemain service uses IPTE to set the
cate that CPU 2 had changed the second
page-invalid bit to one in the page-table
operand. The PLO instruction would set con-
entry for the page containing element X.
dition code 1. If CPU 1 did not have a TLB
The IPTE instruction immediately sets the
entry but IPTE could not set the page-invalid
page-invalid bit to one, and then it waits
bit to one while CPU 1 was executing an
for the signal that all other CPUs have
instruction, CPU 1 could successfully translate
cleared their TLBs of entries corre-
the operand-4 address and, again, discover
sponding to the page.
while the lock was held that operand 2 had
c. CPU 1 attempts to fetch operand 4. CPU changed. The case when operand 2 points to
1 does not have a TLB entry for the element X but the freemained bit for the
operand-4 page. CPU 1 signals CPU 2 element-X page is one is a programming
that the CPU 2 IPTE instruction may error.
proceed.
7. Figure 7-22 on page 7-129 summarizes the
results of the operation.

7-128 z/Architecture Principles of Operation



Cond
Op1c=Op2Op3c=Op4Code Action

Function Codes -3 (Compare and Load)



No - 1 Op2 5 Op1c
Yes - Op4 5 Op3

Function Codes 4-7 (Compare and Swap)



No - 1 Op2 5 Op1c
Yes - Op1r 5 Op2

Function Codes 8-11 (Double Compare and Swap)



No - 1 Op2 5 Op1c
Yes No 2 Op4 5 Op3c
Yes Yes Op1r 5 Op2 Op3r 5 Op4

Function Codes 12-15 (Compare and Swap and Store)



No - 1 Op2 5 Op1c
Yes - Op1r 5 Op2 Op3 5 Op4

Function Codes 16-19 (Compare and Swap and Double Store)



No - 1 Op2 5 Op1c
Yes - Op1r 5 Op2 Op3 5 Op4
Op5 5 Op6

Function Codes 2-23 (Compare and Swap and Triple Store)



No - 1 Op2 5 Op1c
Yes - Op1r 5 Op2 Op3 5 Op4
Op5 5 Op6
Op7 5 Op8

Explanation:

- Not applicable.
OpNc Operand-N comparison value.
OpNr Operand-N replacement value.

Figure 7-22. Summary of PERFORM LOCKED OPERATION Results

ROTATE LEFT SINGLE LOGICAL The 32-bit or 64-bit third operand is rotated left the
number of bits specified by the second-operand
RLL R,R,D(B) [RSE] address, and the result is placed at the first-
operand location. The third operand remains
/ unchanged in general register R. For ROTATE
'EB' R R B D //////// '1D'
LEFT SINGLE LOGICAL (RLL), bits 0-31 of
/
8 12 16 2 32 4 47 general registers R and R remain unchanged.

The second-operand address is not used to


RLLG R,R,D(B) [RSE]
address data; its rightmost six bits indicate the
/ number of bit positions to be rotated. The
'EB' R R B D //////// '1C' remainder of the address is ignored.
/
8 12 16 2 32 4 47

Chapter 7. General Instructions 7-129


For RLL, the first and third operands are in bit The character for which the search occurs is spec-
positions 32-63 of general registers R and R, ified in bit positions 56-63 of general register 0.
respectively. For RLLG, the operands are in bit Bit positions 32-55 of general register 0 are
positions 0-63 of the registers. reserved for possible future extensions and must
contain all zeros; otherwise, a specification excep-
All 32 or 64 bits of the third operand participate in tion is recognized.
a left shift. Each bit shifted out of the leftmost bit
position of the operand reenters in the rightmost The operation proceeds left to right and ends as
bit position of the operand. soon as the specified character has been found in
the second operand, the address of the next
Condition Code: The code remains unchanged. second-operand byte to be examined equals the
address in general register R, or a
Program Exceptions: None. CPU-determined number of second-operand bytes
have been examined, whichever occurs first. The
SEARCH STRING CPU-determined number is at least 256. When
the specified character is found, condition code 1
SRST R,R [RRE] is set. When the address of the next second-
operand byte to be examined equals the address
in general register R, condition code 2 is set.
'B25E' //////// R R
When a CPU-determined number of second-
16 24 28 31 operand bytes have been examined, condition
code 3 is set. When the CPU-determined number
of second-operand bytes have been examined
The second operand is searched until a specified
and the address of the next second-operand byte
character is found, the end of the second operand
is in general register R, it is unpredictable
is reached, or a CPU-determined number of bytes
whether condition code 2 or 3 is set.
have been searched, whichever occurs first. The
CPU-determined number is at least 256. The When condition code 1 is set, the address of the
result is indicated in the condition code. specified character found in the second operand is
placed in general register R, and the contents of
The location of the leftmost byte of the second
general register R remain unchanged. When
operand is designated by the contents of general
condition code 3 is set, the address of the next
register R. The location of the first byte after the
byte to be processed in the second operand is
second operand is designated by the contents of
placed in general register R, and the contents of
general register R.
general register R remain unchanged. When
condition code 2 is set, the contents of general
The handling of the addresses in general registers
registers R and R remain unchanged. When-
R and R is dependent on the addressing mode.
ever an address is placed in a general register,
In the 24-bit addressing mode, the contents of bit
bits 32-39 of the register, in the 24-bit addressing
positions 40-63 of general registers R and R
mode, or bit 32, in the 31-bit addressing mode,
constitute the address, and the contents of bit
are set to zeros. Bits 0-31 of the R and R reg-
positions 0-39 are ignored. In the 31-bit
isters always remain unchanged in the 24-bit or
addressing mode, the contents of bit positions
31-bit mode.
33-63 of the registers constitute the address, and
the contents of bit positions 0-32 are ignored. In
The amount of processing that results in the
the 64-bit addressing mode, the contents of bit
setting of condition code 3 is determined by the
positions 0-63 constitute the address.
CPU on the basis of improving system perform-
ance, and it may be a different amount each time
In the access-register mode, the address space
the instruction is executed.
containing the second operand is specified only by
means of access register R. The contents of
Access exceptions for the second operand are
access register R are ignored.
recognized only for that portion of the operand
that is necessarily examined.

7-130 z/Architecture Principles of Operation


The storage-operand-consistency rules are the SET ACCESS
same as for the COMPARE LOGICAL LONG
instruction. SAR R,R [RRE]

Resulting Condition Code:


'B24E' //////// R R
0 --
1 Specified character found; general register R 16 24 28 31
updated with address of character; general
register R unchanged The contents of bit positions 32-63 of general reg-
2 Specified character not found in entire second ister R are placed in access register R.
operand; general registers R and R
unchanged Condition Code: The code remains unchanged.
3 CPU-determined number of bytes searched;
general register R unchanged; general reg- Program Exceptions: None.
ister R updated with address of next byte

Program Exceptions:
SET ADDRESSING MODE
Access (fetch, operand 2) SAM24 [E]
Specification

'1C'
Programming Notes:
1. Examples of the use of the SEARCH STRING 15
instruction are given in Appendix A, Number SAM31 [E]
Representation and Instruction-Use Examples

'1D'
2. When condition code 3 is set, the program
can simply branch back to the instruction to 15
continue the search. The program need not SAM64 [E]
determine the number of bytes that were
searched.
'1E'
3. When the address in general register R
equals the address in general register R, 15
condition code 2 is set immediately, and
access exceptions are not recognized. When The addressing mode is set by setting the
the address in general register R is less than extended-addressing-mode bit, bit 31 of the
the address in general register R, condition current PSW, and the basic-addressing-mode bit,
code 2 can be set only if the operand wraps bit 32 of the current PSW, as follows:
around from the top of storage to location 0.
Instruc- PSW Bit PSW Bit Resulting
4. R or R may be zero, in which case general tion 31 32 Addressing Mode
register 0 is treated as containing an address
and also the specified character. SAM24 0 0 24-bit

5. When it is desired to search a string of SAM31 0 1 31-bit


unknown length for its ending character, and SAM64 1 1 64-bit
assuming that (1) the string does not start
below location 256 (or below location 1 if the
The instruction address in the PSW is updated
ending character is 00 hex), (2) the string
under the control of the new addressing mode, as
does not wrap around to location 0, and (3)
follows. The value 2 (the instruction length) is
the specified character in general register 0
added to the contents of bit positions 64-127 of
need not be preserved, then R can be zero
the PSW, or the value 4 is added if the instruction
in order to have SEARCH STRING use only
two general registers instead of three.

Chapter 7. General Instructions 7-131


is the target of EXECUTE. In either case, a carry Bits 34 and 35 of general register R replace the
out of bit position 0 is ignored. Then bits 64-103 condition code, and bits 36-39 replace the
of the PSW are set to zeros if the new addressing program mask. Bits 0-33 and 40-63 of general
mode is the 24-bit mode, or bits 64-96 are set to register R are ignored.
zeros if the new addressing mode is the 31-bit
mode. Condition Code: The code is set as specified by
bits 34 and 35 of general register R.
The instruction is completed only if the new
addressing mode and the unupdated instruction Program Exceptions: None.
address in the PSW are a valid combination.
When the new addressing mode is to be the 24-bit Programming Notes:
mode, bits 64-103 of the unupdated PSW must be 1. Bits 34-39 of the general register may have
all zeros, or, when the new addressing mode is to been loaded from the PSW by execution of
be the 31-bit mode, bits 64-96 of the unupdated BRANCH AND LINK in the 24-bit addressing
PSW must be all zeros; otherwise, a specification mode or by execution of INSERT PROGRAM
exception is recognized. MASK in either the 24-bit or 31-bit addressing
mode.
Condition Code: The code remains unchanged.
2. SET PROGRAM MASK permits setting of the
Program Exceptions: condition code and the mask bits in either the
problem state or the supervisor state.
Specification (SAM24 and SAM31 only)
Trace 3. The program should take into consideration
that the setting of the program mask can have
Programming Note: Checking the unupdated
a significant effect on subsequent execution of
instruction address prevents completion in two
the program. Not only do the four mask bits
major cases: the instruction is located at address
control whether the corresponding inter-
2 or above and the new addressing mode is to
ruptions occur, but the exponent-underflow
be the 24-bit mode, or the instruction is located at
and significance masks also determine the
address 2 or above and the new addressing
result which is obtained.
mode is to be the 24-bit or 31-bit mode. In these
cases, if the instruction were completed, the
updating of the instruction address under the SHIFT LEFT DOUBLE
control of the new addressing mode would cause
SLDA R,D(B) [RS]
one or more leftmost bits of the address to be set
to zeros, which would cause the next instruction to
be fetched from other than the next sequential '8F' R //// B D
location. This action is sometimes called a wild
branch. A wild branch still can occur if the instruc- 8 12 16 2 31
tion is located at 2 - 2 or 2 - 2, or at 2 - 4
or 2 - 4 if EXECUTE is used. The 63-bit numeric part of the signed first operand
is shifted left the number of bits specified by the
SET PROGRAM MASK second-operand address, and the result is placed
at the first-operand location. The first operand
SPM R [RR] consists of bits 32-63 of general register R fol-
lowed on the right by bits 32-63 of general register
R + 1.
'4' R ////

8 12 15 The R field designates an even-odd pair of


general registers and must designate an even-
numbered register; otherwise, a specification
The first operand is used to set the condition code exception is recognized.
and the program mask of the current PSW.
The second-operand address is not used to
address data; its rightmost six bits indicate the

7-132 z/Architecture Principles of Operation


number of bit positions to be shifted. The 3. A zero shift amount in the two signed double-
remainder of the address is ignored. shift operations provides a double-length sign
and magnitude test.
The first operand is treated as a 64-bit signed
4. The base register participating in the gener-
binary integer. The sign bit of the first operand,
ation of the second-operand address permits
bit 32 of the even-numbered register, remains
indirect specification of the shift amount by
unchanged. Bit position 32 of the odd-numbered
means of placement of the shift amount in the
register contains a numeric bit, which participates
base register. A zero in the B field indicates
in the shift in the same manner as the other
the absence of indirect shift specification.
numeric bits. Zeros are supplied to the vacated
bit positions on the right. Bits 0-31 of general reg-
isters R and R + 1 remain unchanged. SHIFT LEFT DOUBLE LOGICAL
If one or more bits unlike the sign bit are shifted SLDL R,D(B) [RS]
out of bit position 33 of the even-numbered reg-

ister, an overflow occurs, and condition code 3 is '8D' R //// B D
set. If the fixed-point-overflow mask bit is one, a
program interruption for fixed-point overflow 8 12 16 2 31
occurs.
The 64-bit first operand is shifted left the number
Resulting Condition Code:
of bits specified by the second-operand address,
0 Result zero; no overflow and the result is placed at the first-operand
1 Result less than zero; no overflow location. The first operand consists of bits 32-63
2 Result greater than zero; no overflow of general register R followed on the right by bits
3 Overflow 32-63 of general register R + 1.

Program Exceptions: The R field designates an even-odd pair of


general registers and must designate an even-
Fixed-point overflow
numbered register; otherwise, a specification
Specification
exception is recognized.
Programming Notes:
The second-operand address is not used to
1. An example of the use of the SHIFT LEFT address data; its rightmost six bits indicate the
DOUBLE instruction is given in Appendix A, number of bit positions to be shifted. The
Number Representation and Instruction-Use remainder of the address is ignored.
Examples.
All 64 bits of the first operand participate in the
2. The eight shift instructions that are in both
shift. Bits shifted out of bit position 32 of the
ESA/390 and z/Architecture provide the fol-
even-numbered register are not inspected and are
lowing three pairs of alternatives for 32 bits in
lost. Zeros are supplied to the vacated bit posi-
one general register or, for double, in each of
tions on the right. Bits 0-31 of general registers
two general registers: left or right, single or
R and R + 1 remain unchanged.
double, and signed or logical. The four addi-
tional shift instructions in z/Architecture
Condition Code: The code remains unchanged.
provide left or right, signed or logical shifts of
64 bits in one general register. The signed Program Exceptions:
shifts differ from the logical shifts in that, in
the signed shifts, overflow is recognized, the Specification
condition code is set, and the leftmost bit par-
ticipates as a sign.

Chapter 7. General Instructions 7-133


SHIFT LEFT SINGLE the fixed-point-overflow mask bit is one, a program
interruption for fixed-point overflow occurs.
SLA R,D(B) [RS]
Resulting Condition Code:

'8B' R //// B D 0 Result zero; no overflow


1 Result less than zero; no overflow
8 12 16 2 31 2 Result greater than zero; no overflow
3 Overflow
SLAG R,R,D(B) [RSE]
Program Exceptions:
/
Fixed-point overflow
'EB' R R B D //////// 'B'
/
8 12 16 2 32 4 47 Programming Notes:
1. An example of the use of the SHIFT LEFT
For SHIFT LEFT SINGLE (SLA), the 31-bit SINGLE instruction is given in Appendix A,
numeric part of the signed first operand is shifted Number Representation and Instruction-Use
left the number of bits specified by the second- Examples.
operand address, and the result is placed at the 2. For SHIFT LEFT SINGLE (SLA), for numbers
first-operand location. Bits 0-31 of general reg- with a value greater than or equal to -2 and
ister R remain unchanged. less than 2, a left shift of one bit position is
equivalent to multiplying the number by 2. For
For SHIFT LEFT SINGLE (SLAG), the 63-bit
SHIFT LEFT SINGLE (SLAG), the comparable
numeric part of the signed third operand is shifted
values are -2 and 2.
left the number of bits specified by the second-
operand address, and the result, with the sign bit 3. For SHIFT LEFT SINGLE (SLA), shift
of the third operand appended on its left, is placed amounts from 31 to 63 cause the entire
at the first-operand location. The third operand numeric part to be shifted out of the register,
remains unchanged in general register R. leaving a result of the maximum negative
number or zero, depending on whether or not
The second-operand address is not used to the initial contents were negative. For SHIFT
address data; its rightmost six bits indicate the LEFT SINGLE (SLAG), a shift amount of 63
number of bit positions to be shifted. The causes the same effect.
remainder of the address is ignored.

For SLA, the first operand is treated as a 32-bit


SHIFT LEFT SINGLE LOGICAL
signed binary integer in bit positions 32-63 of SLL R,D(B) [RS]
general register R. The sign of the first operand
remains unchanged. All 31 numeric bits of the
operand participate in the left shift. '89' R //// B D

8 12 16 2 31
For SLAG, the first and third operands are treated
as 64-bit signed binary integers in bit positions
0-63 of general registers R and R, respectively. SLLG R,R,D(B) [RSE]
The sign of the first operand is set equal to the
/
sign of the third operand. All 63 numeric bits of 'EB' R R B D //////// 'D'
the third operand participate in the left shift. /
8 12 16 2 32 4 47
For SLA or SLAG, zeros are supplied to the
vacated bit positions on the right.
For SHIFT LEFT SINGLE LOGICAL (SLL), the
32-bit first operand is shifted left the number of
If one or more bits unlike the sign bit are shifted
bits specified by the second-operand address, and
out of bit position 33, for SLA, or 1, for SLAG, an
the result is placed at the first-operand location.
overflow occurs, and condition code 3 is set. If

7-134 z/Architecture Principles of Operation


Bits 0-31 of general register R remain number of bit positions to be shifted. The
unchanged. remainder of the address is ignored.

For SHIFT LEFT SINGLE LOGICAL (SLLG), the The first operand is treated as a 64-bit signed
64-bit third operand is shifted left the number of binary integer. The sign bit of the first operand,
bits specified by the second-operand address, and bit 32 of the even-numbered register, remains
the result is placed at the first-operand location. unchanged. Bit position 32 of the odd-numbered
The third operand remains unchanged in general register contains a numeric bit, which participates
register R. in the shift in the same manner as the other
numeric bits. Bits shifted out of bit position 63 of
The second-operand address is not used to the odd-numbered register are not inspected and
address data; its rightmost six bits indicate the are lost. Bits equal to the sign are supplied to the
number of bit positions to be shifted. The vacated bit positions on the left. Bits 0-31 of
remainder of the address is ignored. general registers R and R + 1 remain
unchanged.
For SLL, the first operand is in bit positions 32-63
of general register R. All 32 bits of the operand Resulting Condition Code:
participate in the left shift.
0 Result zero
For SLLG, the first and third operands are in bit 1 Result less than zero
positions 0-63 of general registers R and R, 2 Result greater than zero
respectively. All 64 bits of the third operand par- 3 --
ticipate in the left shift.
Program Exceptions:
For SLL or SLLG, zeros are supplied to the Specification
vacated bit positions on the right.

Condition Code: The code remains unchanged.


SHIFT RIGHT DOUBLE LOGICAL
SRDL R,D(B) [RS]
Program Exceptions: None.

SHIFT RIGHT DOUBLE '8C' R //// B D

8 12 16 2 31
SRDA R,D(B) [RS]

The 64-bit first operand is shifted right the number


'8E' R //// B D of bits specified by the second-operand address,

8 12 16 2 31 and the result is placed at the first-operand


location. The first operand consists of bits 32-63
of general register R followed on the right by bits
The 63-bit numeric part of the signed first operand 32-63 of general register R + 1.
is shifted right the number of bits specified by the
second-operand address, and the result is placed The R field designates an even-odd pair of
at the first-operand location. The first operand general registers and must designate an even-
consists of bits 32-63 of general register R fol- numbered register; otherwise, a specification
lowed on the right by bits 32-63 of general register exception is recognized.
R + 1.
The second-operand address is not used to
The R field designates an even-odd pair of address data; its rightmost six bits indicate the
general registers and must designate an even- number of bit positions to be shifted. The
numbered register; otherwise, a specification remainder of the address is ignored.
exception is recognized.
All 64 bits of the first operand participate in the
The second-operand address is not used to shift. Bits shifted out of bit position 63 of the odd-
address data; its rightmost six bits indicate the

Chapter 7. General Instructions 7-135


numbered register are not inspected and are lost. The sign of the first operand is set equal to the
Zeros are supplied to the vacated bit positions on sign of the third operand. All 63 numeric bits of
the left. Bits 0-31 of general registers R and the third operand participate in the right shift.
R + 1 remain unchanged.
For SRA or SRAG, bits shifted out of bit position
Condition Code: The code remains unchanged. 63 are not inspected and are lost. Bits equal to
the sign are supplied to the vacated bit positions
Program Exceptions: on the left.
Specification
Resulting Condition Code:

SHIFT RIGHT SINGLE 0 Result zero


1 Result less than zero
SRA R,D(B) [RS] 2 Result greater than zero
3 --

'8A' R //// B D Program Exceptions: None.

8 12 16 2 31
Programming Notes:

SRAG R,R,D(B) [RSE] 1. A right shift of one bit position is equivalent to


division by 2 with rounding downward. When
/ an even number is shifted right one position,
'EB' R R B D //////// 'A' the result is equivalent to dividing the number
/ by 2. When an odd number is shifted right
8 12 16 2 32 4 47
one position, the result is equivalent to
dividing the next lower number by 2. For
For SHIFT RIGHT SINGLE (SRA), The 31-bit example, +5 shifted right by one bit position
numeric part of the signed first operand is shifted yields +2, whereas -5 yields -3.
right the number of bits specified by the second-
2. For SHIFT RIGHT SINGLE (SRA), shift
operand address, and the result is placed at the
amounts from 31 to 63 cause the entire
first-operand location. Bits 0-32 of general reg-
numeric part to be shifted out of the register,
ister R remain unchanged.
leaving a result of -1 or zero, depending on
For SHIFT RIGHT SINGLE (SRAG), the 63-bit whether or not the initial contents were nega-
numeric part of the signed third operand is shifted tive. For SHIFT RIGHT SINGLE (SRAG), a
right the number of bits specified by the second- shift amount of 63 causes the same effect.
operand address, and the result, with the sign bit
of the third operand appended on its left, is placed SHIFT RIGHT SINGLE LOGICAL
at the first-operand location. The third operand
remains unchanged in general register R. SRL R,D(B) [RS]


The second-operand address is not used to
'88' R //// B D
address data; its rightmost six bits indicate the
number of bit positions to be shifted. The 8 12 16 2 31
remainder of the address is ignored.
SRLG R,R,D(B) [RSE]
For SRA, The first operand is treated as a 32-bit
signed binary integer in bit positions 32-63 of /
general register R. The sign of the first operand 'EB' R R B D //////// 'C'
remains unchanged. All 31 numeric bits of the /
operand participate in the right shift. 8 12 16 2 32 4 47

For SRAG, the first and third operands are treated For SHIFT RIGHT SINGLE LOGICAL (SRL), the
as 64-bit signed binary integers in bit positions 32-bit first operand is shifted right the number of
0-63 of general registers R and R, respectively.

7-136 z/Architecture Principles of Operation


bits specified by the second-operand address, and Condition Code: The code remains unchanged.
the result is placed at the first-operand location.
Bits 0-31 of general register R remain Program Exceptions:
unchanged. Access (store, operand 2)
For SHIFT RIGHT SINGLE LOGICAL (SRLG), the
64-bit third operand is shifted right the number of STORE ACCESS MULTIPLE
bits specified by the second-operand address, and
STAM R,R,D(B) [RS]
the result is placed at the first-operand location.
The third operand remains unchanged in general
register R. '9B' R R B D

The second-operand address is not used to 8 12 16 2 31
address data; its rightmost six bits indicate the
number of bit positions to be shifted. The The contents of the set of access registers starting
remainder of the address is ignored. with access register R and ending with access
register R are stored at the locations designated
For SRL, the first operand is in bit positions 32-63 by the second-operand address.
of general register R. All 32 bits of the operand
participate in the right shift. The storage area where the contents of the
access registers are placed starts at the location
For SRLG, the first and third operands are in bit designated by the second-operand address and
positions 0-63 of general registers R and R, continues through as many storage words as the
respectively. All 64 bits of the third operand par- number of access registers specified. The con-
ticipate in the right shift. tents of the access registers are stored in
ascending order of their register numbers, starting
For SRL or SRLG, bits shifted out of bit position
with access register R and continuing up to and
63 are not inspected and are lost. Zeros are sup-
including access register R, with access register
plied to the vacated bit positions on the left.
0 following access register 15. The contents of
the access registers remain unchanged.
Condition Code: The code remains unchanged.
The second operand must be designated on a
Program Exceptions: None.
word boundary; otherwise, a specification excep-
tion is recognized.
STORE
Condition Code: The code remains unchanged.
ST R,D(X,B) [RX]
Program Exceptions:

'5' R X B D Access (store, operand 2)


Specification
8 12 16 2 31

STG R,D(X,B) [RXE]


STORE CHARACTER
/ STC R,D(X,B) [RX]
'E3' R X B D //////// '24'
/
8 12 16 2 32 4 47 '42' R X B D

8 12 16 2 31
The first operand is placed unchanged at the
second-operand location.
Bits 56-63 of general register R are placed
unchanged at the second-operand location. The
For STORE (ST), the operands are 32 bits, and,
second operand is one byte in length.
for STORE (STG), the operands are 64 bits.

Chapter 7. General Instructions 7-137


Condition Code: The code remains unchanged. unchanged at the same storage location. This
update appears to be an interlocked-update refer-
Program Exceptions: ence as observed by other CPUs.
Access (store, operand 2)
Condition Code: The code remains unchanged.

STORE CHARACTERS UNDER Program Exceptions:


MASK Access (store, operand 2)
STCM R,M,D(B) [RS]
Programming Notes:
1. An example of the use of the STORE CHAR-
'BE' R M B D ACTERS UNDER MASK instruction is given in

8 12 16 2 31 Appendix A, Number Representation and


Instruction-Use Examples.
STCMH R,M,D(B) [RSE] 2. STORE CHARACTERS UNDER MASK with a
mask of 0111 may be used to store a three-
/ byte address, for example, in modifying the
'EB' R M B D //////// '2C' address in a CCW.
/
8 12 16 2 32 4 47 3. STORE CHARACTERS UNDER MASK
(STCM) with a mask of 1111, 0011, or 0001
Bytes selected from general register R under performs the same function as STORE (ST),
control of a mask are placed at contiguous byte STORE HALFWORD, or STORE CHAR-
locations beginning at the second-operand ACTER, respectively. However, on most
address. models, the performance of STORE CHAR-
ACTERS UNDER MASK is slower.
The contents of the M field are used as a mask. 4. Using STORE CHARACTERS UNDER MASK
These four bits, left to right, correspond one for with a zero mask should be avoided since this
one with four bytes, left to right, of general register instruction, depending on the model, may
R. For STORE CHARACTERS UNDER MASK perform a fetch and store of the single byte
(STCM), the four bytes to which the mask bits cor- designated by the second-operand address.
respond are in bit positions 32-63 of general reg- This reference is not interlocked against
ister R. For STORE CHARACTERS UNDER accesses by channel programs. In addition, it
MASK (STCMH), the four bytes are in the high- may cause any of the following to occur for
order half, bit positions 0-31, of the register. The the byte designated by the second-operand
bytes corresponding to ones in the mask are address: a PER storage-alteration event may
placed in the same order at successive and con- be recognized; access exceptions may be
tiguous storage locations beginning at the second- recognized; and, provided no access
operand address. When the mask is not zero, the exceptions exist, the change bit may be set to
length of the second operand is equal to the one. Because the contents of storage remain
number of ones in the mask. The contents of the unchanged, the change bit may or may not be
general register remain unchanged. one when a PER storage-alteration event is
recognized.
When the mask is not zero, exceptions associated
with storage-operand accesses are recognized
only for the number of bytes specified by the STORE CLOCK
mask.
STCK D(B) [S]
When the mask is zero, the single byte designated
by the second-operand address remains 'B25' B D
unchanged; however, on some models, the value
may be fetched and subsequently stored back 16 2 31

7-138 z/Architecture Principles of Operation


The current value of bits 0-63 of the TOD clock is codes 2 and 3 mean that the value provided
stored in the eight-byte field designated by the by STORE CLOCK cannot be used for time
second-operand address, provided the clock is in measurement or indication.
the set, stopped, or not-set state.
3. Condition code 3 indicates that the clock is in
either the stopped state or the not-operational
When the clock is stopped, zeros are stored in
state. These two states can normally be dis-
positions to the right of the rightmost bit position
tinguished because an all-zero value is stored
that is incremented when the clock is running.
when the clock is in the not-operational state.
When the value of a running clock is stored,
nonzero values may be stored in positions to the 4. If a problem program written for z/Architecture
right of the rightmost incremented bit; this is to is to be executed also on a system in the
ensure that a unique value is stored. System/370 mode, then the program should
take into account that, in the System/370
Zeros are stored for the rightmost bit positions that mode, the value stored when the condition
are not provided by the clock. code is 2 is not necessarily zero.

Zeros are stored at the operand location when the


clock is in the error state or the not-operational
STORE CLOCK EXTENDED
state. STCKE D(B) [S]
The quality of the clock value stored by the
instruction is indicated by the resultant condition- 'B278' B D
code setting.
16 2 31
A serialization function is performed before the
value of the clock is fetched and again after the The current value of bits 0-103 of the TOD clock
value is placed in storage. is stored in byte positions 1-13 of the sixteen-byte
field designated by the second-operand address,
Resulting Condition Code: provided the clock is in the set, stopped, or not-set
0 Clock in set state state. Zeros are stored in byte position 0. The
1 Clock in not-set state TOD programmable field, bits 16-31 of the TOD
2 Clock in error state programmable register, is stored in byte positions
3 Clock in stopped state or not-operational state 14 and 15.

Program Exceptions: The operand just described has the following


format:
Access (store, operand 2)

Programm-
Programming Notes:
Zeros TOD Clock able Field
1. Bit position 31 of the clock is incremented
every 1.048576 seconds; hence, for timing 8 112 127
applications involving human responses, the
When the clock is stopped, zeros are stored in the
leftmost clock word may provide sufficient
clock value in positions to the right of the right-
resolution.
most bit position that is incremented when the
2. Condition code 0 normally indicates that the clock is running. The programmable field still is
clock has been set by the control program. stored.
Accordingly, the value may be used in
elapsed-time measurements and as a valid When the value of a running clock is stored, the
time-of-day and calendar indication. Condition value in bit positions 64-103 of the clock (bit posi-
code 1 indicates that the clock value is the tions 72-111 of the storage operand) is always
elapsed time since the power for the clock nonzero; this ensures that values stored by
was turned on. In this case, the value may be STORE CLOCK EXTENDED are unique when
used in elapsed-time measurements but is not compared with values stored by STORE CLOCK
a valid time-of-day indication. Condition and extended with zeros.

Chapter 7. General Instructions 7-139


Zeros are stored at the operand location when the and hex values adjusted so they apply to bits
clock is in the error state or the not-operational 0-71 of the value stored by STORE CLOCK
state. EXTENDED.
3. The following chart shows the time interval
The quality of the clock value stored by the
between instants at which various bits of the
instruction is indicated by the resultant condition-
TOD-clock value stored by STORE CLOCK
code setting.
EXTENDED are stepped. This time value
A serialization function is performed before the may also be considered as the weighted time
value of the clock is fetched and again after the value that the bit, when one, represents. The
value is placed in storage. bit numbers are those of the STORE CLOCK
EXTENDED operand.
Resulting Condition Code:
Stepping Interval
0 Clock in set state STCKE
1 Clock in not-set state Bit DaysHoursMin. Seconds
2 Clock in error state
3 Clock in stopped state or not-operational state 59 . 1
55 . 16
Program Exceptions: 51 . 256

Access (store, operand 2) 47 .4 96
43 .65 536
Programming Notes: 39 1.48 576

1. Condition code 0 normally indicates that the 35 16.777 216
clock has been set by the control program. 31 4 28.435 456
27 1 11 34.967 296
Accordingly, the value may be used in

elapsed-time measurements and as a valid 23 19 5 19.476 736
time-of-day and calendar indication. Condition 19 12 17 25 11.627 776
code 1 indicates that the clock value is the 15 23 14 43 6.44 416
elapsed time since the power for the clock 11 3257 19 29 36.71 656
was turned on. In this case, the value may be
used in elapsed-time measurements but is not 4. The following chart shows the setting of bits
a valid time-of-day indication. Condition 0-63 of the STORE CLOCK EXTENDED
codes 2 and 3 mean that the value provided operand for 00:00:00 (0 am), UTC time, for
by STORE CLOCK EXTENDED cannot be several dates: January 1, 1900, January 1,
used for time measurement or indication. 1972, and for that instant in time just after
2. Programming notes beginning on page 4-38 each of the 22 leap seconds that have
show hex values related to the value of the occurred through January, 1999. Each of
TOD clock as it is stored by the STORE these leap seconds was inserted in the UTC
CLOCK instruction. Notes 3-5, below, are time scale beginning at 23:59:60 UTC of the
repetitions of those notes except with the text day previous to the one listed and ending at
00:00:00 UTC of the day listed.

7-140 z/Architecture Principles of Operation



Leap STCKE Value (Hex)
STORE HALFWORD
Year MthDaySec. Bits -63
STH R,D(X,B) [RX]
19 1 1
1972 1 1 81 26D6 E46
1972 7 1 1 82 BA9 811E 24 '4' R X B D
1973 1 1 2 82 F3 AEE2 48
1974 1 1 3 84 BDE9 7114 6C 8 12 16 2 31
1975 1 1 4 86 88D2 3346 9
1976 1 1 5 88 53BA F578 B4 Bits 48-63 of general register R are placed
1977 1 1 6 8A 1FE5 952 D8
1978 1 1 7 8B EACE 5752 FC unchanged at the second-operand location. The
1979 1 1 8 8D B5B7 1985 2 second operand is two bytes in length.
198 1 1 9 8F 89F DBB7 44
1981 7 1 1 92 35C FCD 68 Condition Code: The code remains unchanged.
1982 7 1 11 93 FB44 D1FF 8C
1983 7 1 12 95 C62D 9431 B Program Exceptions:
1985 7 1 13 99 5D4 F517 D4
1988 1 1 14 9D DA69 A557 F8 Access (store, operand 2)
199 1 1 15 A1 717D 63E 1C
1991 1 1 16 A3 3C65 C87 4
1992 7 1 17 A5 EC21 FC86 64 STORE MULTIPLE
1993 7 1 18 A7 B7A BEB8 88
1994 7 1 19 A9 81F3 8EA AC STM R,R,D(B) [RS]
1996 1 1 2 AC 3433 6FEC D
1997 7 1 21 AE E3EF A42 F4
1999 1 1 22 B1 962F 935 18 '9' R R B D

8 12 16 2 31
5. The stepping value of TOD-clock bit position
63, if implemented, is 2- microseconds, or
STMG R,R,D(B) [RSE]
approximately 244 picoseconds. This value is
called a clock unit. /
'EB' R R B D //////// '24'
The following chart shows various time inter-
/
vals in clock units expressed in hexadecimal 8 12 16 2 32 4 47
notation. The chart shows the values stored
in bit positions 0-71 of the STORE CLOCK
EXTENDED operand. Bit 71 of the operand The contents of bit positions of the set of general
represents a clock unit. registers starting with general register R and
ending with general register R are placed in the
storage area beginning at the location designated
Clock Units (Hex)
Interval Bits -71 by the second-operand address and continuing
through as many locations as needed.
1 microsecond 1
1 millisecond 3E8 For STORE MULTIPLE (STM), the contents of bit
1 second F4 24 positions 32-63 of the general registers are stored
1 minute 3938 7 in successive four-byte fields beginning at the
1 hour D 693A 4
1 day 141 DD76 second-operand address. For STORE MULTIPLE
365 days 1 CAE8 C13E (STMG), the contents of bit positions 0-63 of the
366 days 1 CC2A 9EB4 general registers are stored in successive eight-
1,461 days\ 7 2CE4 E26E byte fields beginning at the second-operand
address.
\ Number of days in four years,
including a leap year. Note that
the year 19 was not a leap year. The general registers are stored in the ascending
Thus, the four-year span starting order of their register numbers, starting with
in 19 has only 1,46 days. general register R and continuing up to and
including general register R, with general register
0 following general register 15.

Chapter 7. General Instructions 7-141


Condition Code: The code remains unchanged. STORE PAIR TO QUADWORD
Program Exceptions: STPQ R,D(X,B) [RXE]
Access (store, operand 2)
/
Programming Note: An example of the use of 'E3' R X B D //////// '8E'
the STORE MULTIPLE instruction is given in /
8 12 16 2 32 4 47
Appendix A, Number Representation and
Instruction-Use Examples.
The quadword first operand is stored at the
second-operand location with quadword consist-
STORE MULTIPLE HIGH
ency. The left doubleword of the first operand is
STMH R,R,D(B) [RSE] in general register R, and the right doubleword is
in general register R + 1.
/
'EB' R R B D //////// '26' The R field designates an even-odd pair of
/ general registers and must designate an even-
8 12 16 2 32 4 47
numbered register. The second operand must be
designated on a quadword boundary. Otherwise,
The contents of the high-order halves, bit positions a specification exception is recognized.
0-31, of the set of general registers starting with
general register R and ending with general reg- Condition Code: The code remains unchanged.
ister R are placed in the storage area beginning
at the location designated by the second-operand Program Exceptions:
address and continuing through as many locations Access (store, operand 2)
as needed, that is, the contents of bit positions Specification
0-31 are stored in successive four-byte fields
beginning at the second-operand address. Bits Programming Note: The STORE MULTIPLE
32-63 of the registers are ignored. (STM or STMG) instruction does not provide
quadword consistency.
The general registers are stored in the ascending
order of their register numbers, starting with STORE REVERSED
general register R and continuing up to and
including general register R, with general register STRVH R,D(X,B) [RXE]
0 following general register 15.
/
Condition Code: The code remains unchanged. 'E3' R X B D //////// '3F'
/
8 12 16 2 32 4 47
Program Exceptions:
Access (store, operand 2) STRV R,D(X,B) [RXE]
Programming Note: All combinations of register
/
numbers specified by R and R are valid. When 'E3' R X B D //////// '3E'
the register numbers are equal, only four bytes /
are transmitted. When the number specified by 8 12 16 2 32 4 47
R is less than the number specified by R, the
register numbers wrap around from 15 to 0. STRVG R,D(X,B) [RXE]

/
'E3' R X B D //////// '2F'
/
8 12 16 2 32 4 47

7-142 z/Architecture Principles of Operation


The first operand is placed at the second-operand S R,D(X,B) [RX]
location with the left-to-right sequence of the bytes
reversed.
'5B' R X B D

For STORE REVERSED (STRVH), the first 8 12 16 2 31
operand is two bytes in bit positions 48-63 of
general register R. For STORE REVERSED
SG R,D(X,B) [RXE]
(STRV), the first operand is four bytes in bit posi-
tions 32-63 of general register R. For STORE /
REVERSED (STRVG), the first operand is eight 'E3' R X B D //////// '9'
bytes in bit positions 0-63 of general register R. /
8 12 16 2 32 4 47
Condition Code: The code remains unchanged.
SGF R,D(X,B) [RXE]
Program Exceptions:
/
Access (store, operand 2) 'E3' R X B D //////// '19'
/
Programming Note: The instruction can be used 8 12 16 2 32 4 47
to convert two, four, or eight bytes from a little-
endian format to a big-endian format, or vice
versa. In the big-endian format, the bytes in a The second operand is subtracted from the first
left-to-right sequence are in the order most signif- operand, and the difference is placed at the first-
icant to least significant. In the little-endian operand location. For SUBTRACT (SR, S), the
format, the bytes are in the order least significant operands and the difference are treated as 32-bit
to most significant. For example, the bytes ABCD signed binary integers. For SUBTRACT (SGR,
in the big-endian format are DCBA in the little- SG), they are treated as 64-bit signed binary inte-
endian format. gers. For SUBTRACT (SGFR, SGF), the second
operand is treated as a 32-bit signed binary
integer, and the first operand and the difference
SUBTRACT are treated as 64-bit signed binary integers.
SR R,R [RR]
When there is an overflow, the result is obtained
by allowing any carry into the sign-bit position and
'1B' R R ignoring any carry out of the sign-bit position, and
condition code 3 is set. If the fixed-point-overflow
8 12 15 mask is one, a program interruption for fixed-point
overflow occurs.
SGR R,R [RRE]
Resulting Condition Code:

'B99' //////// R R 0 Result zero; no overflow


1 Result less than zero; no overflow
16 24 28 31 2 Result greater than zero; no overflow
3 Overflow
SGFR R,R [RRE]
Program Exceptions:

'B919' //////// R R Access (fetch, operand 2 of S, SG, and SGF


only)
16 24 28 31 Fixed-point overflow

Chapter 7. General Instructions 7-143


Programming Notes: SUBTRACT LOGICAL
1. For SR and SGR, when R and R designate
the same register, subtracting is equivalent to SLR R,R [RR]
clearing the register.
2. Subtracting a maximum negative number from '1F' R R
itself gives a zero result and no overflow.
8 12 15

SUBTRACT HALFWORD SLGR R,R [RRE]


SH R,D(X,B) [RX]
'B9B' //////// R R

'4B' R X B D 16 24 28 31

8 12 16 2 31
SLGFR R,R [RRE]

The second operand is subtracted from the first


operand, and the difference is placed at the first- 'B91B' //////// R R
operand location. The second operand is two
16 24 28 31
bytes in length and is treated as a 16-bit signed
binary integer. The first operand and the differ-
ence are treated as 32-bit signed binary integers. SL R,D(X,B) [RX]


When there is an overflow, the result is obtained
'5F' R X B D
by allowing any carry into the sign-bit position and
ignoring any carry out of the sign-bit position, and 8 12 16 2 31
condition code 3 is set. If the fixed-point-overflow
mask is one, a program interruption for fixed-point SLG R,D(X,B) [RXE]
overflow occurs.
/
Resulting Condition Code: 'E3' R X B D //////// 'B'
/
0 Result zero; no overflow 8 12 16 2 32 4 47
1 Result less than zero; no overflow
2 Result greater than zero; no overflow SLGF R,D(X,B) [RXE]
3 Overflow
/
Program Exceptions: 'E3' R X B D //////// '1B'
/
Access (fetch, operand 2) 8 12 16 2 32 4 47
Fixed-point overflow
Programming Note: The function of a SUB- The second operand is subtracted from the first
TRACT HALFWORD IMMEDIATE instruction, operand, and the difference is placed at the first-
which is an instruction not provided, can be operand location. For SUBTRACT LOGICAL
obtained by using an ADD HALFWORD IMME- (SLR, SL), the operands and the difference are
DIATE instruction with a negative I field. treated as 32-bit unsigned binary integers. For
SUBTRACT LOGICAL (SLGR, SLG), they are
treated as 64-bit unsigned binary integers. For
SUBTRACT LOGICAL (SLGFR, SLGF) the
second operand is treated as a 32-bit unsigned
binary integer, and the first operand and the differ-
ence are treated as 64-bit unsigned binary inte-
gers.

7-144 z/Architecture Principles of Operation


Resulting Condition Code: SLB R,D(X,B) [RXE]
0 -- /
1 Result not zero; borrow 'E3' R X B D //////// '99'
2 Result zero; no borrow /
3 Result not zero; no borrow 8 12 16 2 32 4 47

Program Exceptions: SLBG R,D(X,B) [RXE]


Access (fetch, operand 2 of SL, SLG, and /
SLGF only) 'E3' R X B D //////// '89'
/
Programming Notes: 8 12 16 2 32 4 47
1. Logical subtraction is performed by adding the
one's complement of the second operand and The second operand and the borrow are sub-
a value of one to the first operand. The use tracted from the first operand, and the difference
of the one's complement and the value of one is placed at the first-operand location. For SUB-
instead of the two's complement of the second TRACT LOGICAL WITH BORROW (SLBR, SLB),
operand results in a carry when the second the operands, the borrow, and the difference are
operand is zero. treated as 32-bit unsigned binary integers. For
SUBTRACT LOGICAL WITH BORROW (SLBGR,
2. SUBTRACT LOGICAL differs from SUB- SLBG), they are treated as 64-bit unsigned binary
TRACT only in the meaning of the condition integers.
code and in the absence of the interruption for
overflow. Resulting Condition Code:
3. A zero difference is always accompanied by a 0 Result zero; borrow
carry out of bit position 0 for SLGR, SLGFR, 1 Result not zero; borrow
SLG, and SLGF or bit position 32 for SLR and 2 Result zero; no borrow
SL and, therefore, no borrow. 3 Result not zero; no borrow
4. The condition-code setting for SUBTRACT
LOGICAL can also be interpreted as indicating Program Exceptions:
the presence or absence of a carry, as Access (fetch, operand 2 of SLB and SLBG
follows: only)
1 Result not zero; no carry
Programming Notes:
2 Result zero; carry
3 Result not zero; carry 1. A borrow is represented by a zero value of bit
18 of the current PSW. Bit 18 is the leftmost
SUBTRACT LOGICAL WITH bit of the two-bit condition code in the PSW.
Bit 18 is set to zero by an execution of a
BORROW SUBTRACT LOGICAL or SUBTRACT
SLBR R,R [RRE] LOGICAL WITH BORROW instruction that
produces a borrow into the leftmost bit posi-
tion of the 32-bit or 64-bit result.
'B999' //////// R R
2. Logical subtraction with borrow is performed
16 24 28 31 by adding the one's complement of the
second operand and bit 18 of the current
SLBGR R,R [RRE] PSW to the first operand. Therefore, when bit
18 is one, indicating no borrow, the addition is
the same as for SUBTRACT LOGICAL.
'B989' //////// R R
3. Condition code zero is set for SUBTRACT
16 24 28 31 LOGICAL WITH BORROW (SLBR, SLB),
when the maximum 32-bit unsigned binary
integer, 2-1, is subtracted from zero when

Chapter 7. General Instructions 7-145


PSW bit 18 indicates a borrow. For SUB- PSW, respectively, are tested, and the result is
TRACT LOGICAL WITH BORROW (SLBGR, indicated in the condition code.
SLBG) condition code zero is set when the
maximum 64-bit unsigned binary integer, Resulting Condition Code:
2-1, is subtracted from zero when PSW bit 0 PSW bits 31 and 32 zeros (indicating 24-bit
18 indicates a borrow. addressing mode)
4. SUBTRACT and SUBTRACT LOGICAL may 1 PSW bit 31 zero and bit 32 one (indicating
provide better performance than SUBTRACT 31-bit addressing mode)
LOGICAL WITH BORROW, depending on the 2 --
model. 3 PSW bits 31 and 32 ones (indicating 64-bit
addressing mode)
SUPERVISOR CALL Program Exceptions: None.
SVC I [RR] Programming Note: The case when PSW bit 31
is one and bit 32 is zero causes an early PSW

specification exception to be recognized.


'A' I

8 15 TEST AND SET


The instruction causes a supervisor-call inter- TS D(B) [S]
ruption, with the I field of the instruction providing
the rightmost byte of the interruption code. '93' //////// B D

Bits 8-15 of the instruction, with eight zeros 8 16 2 31
appended on the left, are placed in the supervisor-
call interruption code that is stored in the course The leftmost bit (bit position 0) of the byte located
of the interruption. See Supervisor-Call at the second-operand address is used to set the
Interruption on page 6-47. condition code, and then the byte is set to all
ones.
A serialization and checkpoint-synchronization
function is performed. Bits 8-15 of the instruction are ignored.
Condition Code: The code remains unchanged The byte in storage is set to all ones as it is
and is saved as part of the old PSW. A new con- fetched for the testing of bit 0. This update
dition code is loaded as part of the supervisor-call appears to be an interlocked-update reference as
interruption. observed by other CPUs.
Program Exceptions: None. A serialization function is performed before the
byte is fetched and again after the storing of all
TEST ADDRESSING MODE ones.

TAM [E] Resulting Condition Code:


0 Leftmost bit zero
'1B' 1 Leftmost bit one
2 --
15 3 --
The extended-addressing-mode bit and basic- Program Exceptions:
addressing-mode bit, bits 31 and 32 of the current
Access (fetch and store, operand 2)

7-146 z/Architecture Principles of Operation


Programming Notes: TMLL or TML R,I [RI]
1. TEST AND SET may be used for controlled
sharing of a common storage area by pro- 'A7' R '1' I
grams operating on different CPUs. This
instruction is provided primarily for compat- 8 12 16 31
ibility with programs written for System/360.
The instructions COMPARE AND SWAP and A mask is used to select bits of the first operand,
COMPARE DOUBLE AND SWAP provide and the result is indicated in the condition code.
functions which are more suitable for sharing
among programs on a single CPU or for pro- TEST UNDER MASK is a new name of, and
grams that may be interrupted. See the TMLH and TMLL are new mnemonics for, the
description of these instructions and the asso- ESA/390 instructions TEST UNDER MASK HIGH
ciated programming notes for details. (TMH) and TEST UNDER MASK LOW (TML),
respectively.
2. TEST AND SET does not interlock against
storage accesses by channel programs. In TEST UNDER MASK (TM), the byte of imme-
Therefore, the instruction should not be used diate data, I, is used as an eight-bit mask. The
to update a location into which a channel bits of the mask are made to correspond one for
program may store, since the channel- one with the bits of the byte in storage designated
program data may be lost. by the first-operand address.

TEST UNDER MASK (TEST A mask bit of one indicates that the storage bit is
UNDER MASK HIGH, TEST to be tested. When the mask bit is zero, the
storage bit is ignored. When all storage bits thus
UNDER MASK LOW) selected are zero, condition code 0 is set. Condi-
TM D(B),I [SI] tion code 0 is also set when the mask is all zeros.
When the selected bits are all ones, condition
code 3 is set; otherwise, condition code 1 is set.
'91' I B D
Access exceptions associated with the storage
8 16 2 31 operand are recognized for one byte even when
the mask is all zeros.
TMHH R,I [RI]
In TEST UNDER MASK (TMHH, TMHL, TMLH,
TMLL), The contents of the I field are used as a
'A7' R '2' I
16-bit mask. For each instruction, the bits of the
8 12 16 31 mask are made to correspond one for one with 16
bits of the first operand as follows:
TMHL R,I [RI]
Bits
Instruction Tested
'A7' R '3' I
TMHH 0-15
8 12 16 31 TMHL 16-31
TMLH (or TMH) 32-47
TMLH or TMH R,I [RI]
TMLL (or TML) 48-63

'A7' R '' I
A mask bit of one indicates that the first-operand
8 12 16 31 bit is to be tested. When the mask bit is zero, the
first-operand bit is ignored. When all first-operand
bits thus selected are zero, condition code 0 is
set. Condition code 0 is also set when the mask
is all zeros. When the selected bits are mixed

Chapter 7. General Instructions 7-147


zeros and ones, condition code 1 is set if the left- The sum is used as the address of the function
most selected bit is zero, or condition code 2 is byte, which then replaces the original argument
set if the leftmost selected bit is one. When the byte.
selected bits are all ones, condition code 3 is set.
The operation proceeds until the first-operand field
Resulting Condition Code: is exhausted. The list is not altered unless an
overlap occurs.
0 Selected bits all zeros; or mask bits all zeros
1 Selected bits mixed zeros and ones (TM only)
When the operands overlap, the result is obtained
1 Selected bits mixed zeros and ones, and left-
as if each result byte were stored immediately
most is zero (TMHH, TMHL, TMLH, TMLL)
after fetching the corresponding function byte.
2 -- (TM only)
2 Selected bits mixed zeros and ones, and left- Access exceptions are recognized only for those
most is one (TMHH, TMHL, TMLH, TMLL) bytes in the second operand which are actually
3 Selected bits all ones required.
Program Exceptions: Condition Code: The code remains unchanged.
Access (fetch, operand 1, TM only)
Program Exceptions:
Programming Notes: Access (fetch, operand 2; fetch and store,
1. An example of the use of the TEST UNDER operand 1)
MASK (TM) instruction is given in
Appendix A, Number Representation and Programming Notes:
Instruction-Use Examples. 1. An example of the use of the TRANSLATE
2. When the mask for TMHH, TMHL, TMLH, or instruction is given in Appendix A, Number
TMLL selects exactly two bits, the two Representation and Instruction-Use
selected bits effectively are loaded into the Examples.
condition code. 2. TRANSLATE may be used to convert data
from one code to another code.
TRANSLATE 3. The instruction may also be used to rearrange
data. This may be accomplished by placing a
TR D(L,B),D(B) [SS]
pattern in the destination area, by designating
// the pattern as the first operand of TRANS-
'DC' L B D B D LATE, and by designating the data that is to
// be rearranged as the second operand. Each
8 16 2 32 36 47 byte of the pattern contains an eight-bit
number specifying the byte destined for this
The bytes of the first operand are used as position. Thus, when the instruction is exe-
eight-bit arguments to reference a list designated cuted, the pattern selects the bytes of the
by the second-operand address. Each function second operand in the desired order.
byte selected from the list replaces the corre-
4. Because each eight-bit argument byte is
sponding argument in the first operand.
added to the initial second-operand address to
obtain the address of a function byte, the list
The L field specifies the length of only the first
may contain 256 bytes. In cases where it is
operand.
known that not all eight-bit argument values
The bytes of the first operand are selected one by will occur, it is possible to reduce the size of
one for translation, proceeding left to right. Each the list.
argument byte is added to the initial second- 5. Significant performance degradation is pos-
operand address. The addition is performed fol- sible when, with DAT on, the second-operand
lowing the rules for address arithmetic, with the address of TRANSLATE designates a location
argument byte treated as an eight-bit unsigned that is less than 256 bytes to the left of a
binary integer and extended with zeros on the left.

7-148 z/Architecture Principles of Operation


4K-byte boundary. This is because the When the first-operand field is exhausted before a
machine may perform a trial execution of the nonzero function byte is encountered, the opera-
instruction to determine if the second operand tion is completed by setting condition code 0. The
actually crosses the boundary. contents of general registers 1 and 2 remain
unchanged.
6. The fetch and subsequent store accesses to a
particular byte in the first-operand field do not
When the function byte is nonzero, the operation
necessarily occur one immediately after the
is completed by inserting the function byte in
other. Thus, this instruction cannot be safely
general register 2 and the related argument
used to update a location in storage if the
address in general register 1. This address points
possibility exists that another CPU or a
to the argument byte last translated. The function
channel program may also be updating the
byte replaces bits 56-63 of general register 2, and
location. An example of this effect is shown
bits 0-55 of this register remain unchanged. In the
for OR (OI) in Multiprogramming and Multi-
24-bit addressing mode, the address replaces bits
processing Examples in Appendix A,
40-63 of general register 1, and bits 0-39 of this
Number Representation and Instruction-Use
register remain unchanged. In the 31-bit
Examples on page A-1.
addressing mode, the address replaces bits 33-63
7. The storage-operand references of TRANS- of general register 1, bit 32 of this register is set to
LATE may be multiple-access references. zero, and bits 0-31 of the register remain
(See Storage-Operand Consistency on unchanged. In the 64-bit addressing mode, the
page 5-86.) address replaces bits 0-63 of general register 1.

When the function byte is nonzero, either condi-


TRANSLATE AND TEST tion code 1 or 2 is set, depending on whether the
TRT D(L,B),D(B) [SS] argument byte is the rightmost byte of the first
operand. Condition code 1 is set if one or more
// argument bytes remain to be translated. Condi-
'DD' L B D B D tion code 2 is set if no more argument bytes
// remain.
8 16 2 32 36 47
The contents of access register 1 always remain
The bytes of the first operand are used as unchanged.
eight-bit arguments to select function bytes from a
list designated by the second-operand address. Access exceptions are recognized only for those
The first nonzero function byte is inserted in bytes in the second operand which are actually
general register 2, and the related argument required. Access exceptions are not recognized
address in general register 1. for those bytes in the first operand which are to
the right of the first byte for which a nonzero func-
The L field specifies the length of only the first tion byte is obtained.
operand.
Resulting Condition Code:
The bytes of the first operand are selected one by
0 All function bytes zero
one for translation, proceeding left to right. The
1 Nonzero function byte; first-operand field not
first operand remains unchanged in storage. Cal-
exhausted
culation of the address of the function byte is per-
2 Nonzero function byte; first-operand field
formed as in the TRANSLATE instruction. The
exhausted
function byte retrieved from the list is inspected for
3 --
a value of zero.
Program Exceptions:
When the function byte is zero, the operation pro-
ceeds with the next byte of the first operand. Access (fetch, operands 1 and 2)

Chapter 7. General Instructions 7-149


Programming Notes: the first-operand location is specified by the entire
contents of general register R + 1, and those
1. An example of the use of the TRANSLATE
contents are treated as a 64-bit unsigned binary
AND TEST instruction is given in Appendix A,
integer.
Number Representation and Instruction-Use
Examples.
The handling of the addresses in general registers
2. TRANSLATE AND TEST may be used to R and R is dependent on the addressing mode.
scan the first operand for characters with
special meaning. The second operand, or list, In the 24-bit addressing mode, the contents of bit
is set up with all-zero function bytes for those positions 40-63 of general registers R and R
characters to be skipped over and with constitute the address, and the contents of bit
nonzero function bytes for the characters to positions 0-39 are ignored. In the 31-bit
be detected. addressing mode, the contents of bit positions
33-63 of the registers constitute the address, and
the contents of bit positions 0-32 are ignored. In
TRANSLATE EXTENDED the 64-bit addressing mode, the contents of bit
TRE R,R [RRE] positions 0-63 constitute the address.

The test byte is in bit positions 56-63 of general


'B2A5' //////// R R register 0, and the contents of bit positions 0-55 of
this register are ignored.
16 24 28 31
The contents of the registers just described are
shown in Figure 7-23 on page 7-151.
The bytes of the first operand are compared to a
test byte in general register 0 and, unless an The bytes of the first operand are selected one by
equal comparison occurs, are used as eight-bit one for translation, proceeding left to right. Each
arguments to reference a 256-byte translation argument byte is first compared to the test byte in
table designated by the second-operand address. general register 0. If the result is an equal com-
Each function byte selected from the second parison, the operation is completed. If the argu-
operand replaces the corresponding argument in ment byte is not equal to the test byte, the
the first operand. The operation proceeds until a argument byte is added to the initial second-
first-operand byte equal to the test byte is operand address. The addition is performed fol-
encountered, the end of the first operand is lowing the rules for address arithmetic, with the
reached, or a CPU-determined number of bytes argument byte treated as an eight-bit unsigned
have been processed, whichever occurs first. The binary integer and extended with zeros on the left.
result is indicated in the condition code. The sum is used as the address of the function
byte, which then replaces the original argument
Bits 16-23 of the instruction are ignored. byte. The second operand is not altered unless
an overlap occurs.
The R field designates an even-odd pair of
general registers and must designate an even- The operation proceeds until a first-operand byte
numbered register; otherwise, a specification equal to the test byte is encountered, the first-
exception is recognized. operand location is exhausted, or a
CPU-determined number of first-operand bytes
The location of the leftmost byte of the first have been processed.
operand and second operand is designated by the
contents of general registers R and R, respec- When the first-operand location is exhausted
tively. In the 24-bit or 31-bit addressing mode, the without finding a byte equal to the test byte, condi-
number of bytes in the first-operand location is tion code 0 is set. When a first-operand byte
specified by the contents of bit positions 32-63 of equal to the test byte is encountered, condition
general register R + 1, and those contents are code 1 is set. When a CPU-determined number
treated as a 32-bit unsigned binary integer. In the of bytes have been processed, condition code 3 is
64-bit addressing mode, the number of bytes in set. Condition code 3 may be set even when the

7-150 z/Architecture Principles of Operation


first-operand location is exhausted or when the operand byte equal to the test byte was encount-
next byte to be processed is equal to the test ered, and the contents of general register R are
byte. In these cases, condition code 0 or 1, incremented by the same number, so that general
respectively, will be set when the instruction is register R contains the address of the equal byte.
executed again. If the operation is completed with condition code
3, the contents of general register R + 1 are
If the operation is completed with condition code decremented by the number of bytes processed,
0, the contents of general register R are incre- and the contents of general register R are incre-
mented by the contents of general register mented by the same number, so that the instruc-
R + 1, and then the contents of general register tion, when reexecuted, resumes at the next byte
R + 1 are set to zero. If the operation is com- to be processed. When general register R is
pleted with condition code 1, the contents of updated in the 24-bit or 31-bit addressing mode,
general register R + 1 are decremented by the bits 32-39 of it, in the 24-bit mode, or bit 32, in the
number of bytes processed before the first-


/
GR /////////////////////////// Test
/
56 63


24-Bit Addressing Mode 31-Bit Addressing Mode

/ /
R //////////// First-Operand Address //// First-Operand Address
/ /
4 63 33 63

/ /
R + 1 /// First-Operand Length /// First-Operand Length
/ /
32 63 32 63

/ /
R //////////// Second-Operand Address //// Second-Operand Address
/ /
4 63 33 63

64-Bit Addressing Mode

/
R First-Operand Address
/
63

/
R + 1 First-Operand Length
/
63

/
R Second-Operand Address
/
63

Figure 7-23. Register Contents for TRANSLATE EXTENDED

Chapter 7. General Instructions 7-151


31-bit mode, may be set to zeros or may remain Program Exceptions:
unchanged from their original values.
Access (fetch, operand 2; store, operand 1)
Specification
In the 24-bit or 31-bit addressing mode, the con-
tents of bit positions 0-31 of general registers R
Programming Notes:
and R + 1 always remain unchanged.
1. When condition code 3 is set, the program
The amount of processing that results in the can simply branch back to the instruction to
setting of condition code 3 is determined by the continue the translation. The program need
CPU on the basis of improving system perform- not determine the number of bytes that were
ance, and it may be a different amount each time translated.
the instruction is executed.
2. The instruction can improve performance by
being used in place of a TRANSLATE AND
When the R register is the same register as the
TEST instruction that locates an escape char-
R or R + 1 register, the results are unpredict-
acter, followed by a TRANSLATE instruction
able.
that translates the bytes preceding the escape
When R or R is zero, the results are unpredict- character.
able. 3. The storage operand references of TRANS-
LATE EXTENDED may be multiple-access
When the second operand overlaps the first references. (See Storage-Operand
operand, the results are unpredictable. Consistency on page 5-86.)

Access exceptions for the portion of the first


operand to the right of the last byte processed TRANSLATE ONE TO ONE
may or may not be recognized. For an operand
TROO R,R [RRE]
longer than 4K bytes, access exceptions are not
recognized for locations more than 4K bytes
beyond the last byte processed. 'B993' //////// R R

Access exceptions for all 256 bytes of the second 16 24 28 31
operand may be recognized, even if not all bytes
are used.
TRANSLATE ONE TO TWO
Access exceptions are not recognized if the R
TROT R,R [RRE]
field is odd. When the length of the first operand
is zero, no access exceptions for the first operand
are recognized. 'B992' //////// R R

Resulting Condition Code: 16 24 28 31

0 Entire first operand processed without finding


a byte equal to the test byte TRANSLATE TWO TO ONE
1 First-operand byte is equal to the test byte
2 -- TRTO R,R [RRE]
3 CPU-determined number of bytes processed

'B991' //////// R R

16 24 28 31

7-152 z/Architecture Principles of Operation


TRANSLATE TWO TO TWO The location of the leftmost byte of the first
operand and second operand is designated by the
TRTT R,R [RRE] contents of general registers R and R, respec-
tively. In the 24-bit or 31-bit addressing mode, the
number of bytes in the second-operand location is
'B99' //////// R R specified by the contents of bit positions 32-63 of

16 24 28 31 general register R + 1, and those contents are


treated as a 32-bit unsigned binary integer. In the
64-bit addressing mode, the number of bytes in
The characters of the second operand are used the second-operand location is specified by the
as arguments to select function characters from a contents of bit positions 0-63 of general register
translation table designated by the address in R + 1, and those contents are treated as a
general register 1. Each function character 64-bit unsigned binary integer. The length of the
selected from the translation table is compared to first-operand location is considered to be the same
a test character in general register 0, and, unless as that of the second operand for TRANSLATE
an equal comparison occurs, is placed at the first- ONE TO ONE and TRANSLATE TWO TO TWO,
operand location. The operation proceeds until a twice that for TRANSLATE ONE TO TWO, and
selected function character equal to the test char- one half that for TRANSLATE TWO TO ONE.
acter is encountered, the end of the second
operand is reached, or a CPU-determined number For TRANSLATE TWO TO ONE and TRANS-
of characters have been processed, whichever LATE TWO TO TWO, the length in general reg-
occurs first. The result is indicated in the condi- ister R + 1 must be an even number of bytes;
tion code. otherwise, a specification exception is recognized.

The lengths of the operand and test characters The translation table is treated as being on a
are as follows: doubleword boundary for TRANSLATE ONE TO
For TRANSLATE ONE TO ONE, the second- ONE and TRANSLATE ONE TO TWO and on a
operand, first-operand, and test characters are 4K-byte boundary for TRANSLATE TWO TO ONE
single bytes. and TRANSLATE TWO TO TWO. The rightmost
bits of the register that are not used to form the
For TRANSLATE ONE TO TWO, the second- address, which are bits 61-63 in the doubleword
operand characters are single bytes, and the case and bits 52-63 in the 4K-byte case, are
first-operand and test characters are double ignored.
bytes.
For TRANSLATE TWO TO ONE, the second- The handling of the addresses in general registers
operand characters are double bytes, and the R, R, and 1 is dependent on the addressing
first-operand and test characters are single mode.
bytes.
In the 24-bit addressing mode, the contents of bit
For TRANSLATE TWO TO TWO, the second- positions 40-63 of general registers R and R
operand, first-operand, and test characters are and 40-60 or 40-51 of 1 constitute the address,
double bytes. and the contents of bit positions 0-39 are ignored.
In the 31-bit addressing mode, the contents of bit
For TRANSLATE ONE TO ONE and TRANSLATE positions 33-63 of registers R and R and 33-60
TWO TO ONE, the test character is in bit posi- or 33-51 of 1 constitute the address, and the con-
tions 56-63 of general register 0. For TRANS- tents of bit positions 0-32 are ignored. In the
LATE ONE TO TWO and TRANSLATE TWO TO 64-bit addressing mode, the contents of bit posi-
TWO, the test character is in bit positions 48-63 of tions 0-63 of registers R and R and 0-60 or 0-51
general register 0. of 1 constitute the address.

The R field designates an even-odd pair of The contents of the registers just described are
general registers and must designate an even- shown in Figure 7-24 on page 7-154.
numbered register; otherwise, a specification
exception is recognized.

Chapter 7. General Instructions 7-153


In the access-register mode, the contents of For TRANSLATE TWO TO ONE, the
access registers R, R, and 1 are used for translation-table length is 65,536 (64K) bytes;
accessing the first operand, second operand, and each of the 64K function characters is a single
translation table, respectively. byte.
For TRANSLATE TWO TO TWO, the
The length of the translation table designated by
translation-table length is 131,072 (128K)
the address contained in general register 1 is as
bytes; each of the 64K function characters is a
follows:
double byte.
For TRANSLATE ONE TO ONE, the
translation-table length is 256 bytes; each of The characters of the second operand are
the 256 function characters is a single byte. selected one by one for translation, proceeding left
to right. Each argument character is added to the
For TRANSLATE ONE TO TWO, the
initial translation-table address. The addition is
translation-table length is 512 bytes; each of
performed following the rules for address arith-
the 256 function characters is a double byte.

For TRANSLATE ONE TO ONE For TRANSLATE ONE TO TWO


and TRANSLATE TWO TO ONE and TRANSLATE TWO TO TWO
/ /
GR /////////////////////////// Test /////////////////// Test
/ /
56 63 48 63


24-Bit Addressing Mode 31-Bit Addressing Mode

/ /
R //////////// First-Operand Address //// First-Operand Address
/ /
4 63 33 63

/ /
R + 1 /// Second-Operand Length /// Second-Operand Length
/ /
32 63 32 63

/ /
R ////////////Second-Operand Address //// Second-Operand Address
/ /
4 63 33 63

For TRANSLATE ONE TO ONE For TRANSLATE ONE TO ONE
and TRANSLATE ONE TO TWO and TRANSLATE ONE TO TWO
/ /
GR1 ////////////Trans.-Table Addr. /// //// Translation-Table Address ///
/ /
4 61 63 33 61 63

For TRANSLATE TWO TO ONE For TRANSLATE TWO TO ONE
and TRANSLATE TWO TO TWO and TRANSLATE TWO TO TWO
/ /
GR1 ////////////Tr.Tab.Adr//////////// ////Trans.-Table Addr.////////////
/ /
4 52 63 33 52 63

Figure 7-24 (Part 1 of 2). Register Contents for TRANSLATE ONE TO ONE, TRANSLATE ONE TO TWO, TRANS-
LATE TWO TO ONE, and TRANSLATE TWO TO TWO

7-154 z/Architecture Principles of Operation


metic, with the argument character treated as The rightmost bits of the translation-table address
follows: that are ignored (61-63 or 52-63) are treated as
zeros during this addition.
For TRANSLATE ONE TO ONE, the argu-
ment character is treated as an eight-bit
The sum is used as the address of the function
unsigned binary integer extended on the left
character.
with 56 zeros.
For TRANSLATE ONE TO TWO, the argu- Each function character selected as described
ment character is treated as an eight-bit above is first compared to the test character in
unsigned binary integer extended on the right general register 0. If the result is an equal com-
with a zero and on the left with 55 zeros. parison, the operation is completed. If the func-
tion character is not equal to the test character,
For TRANSLATE TWO TO ONE, the argu-
the function character is placed in the next avail-
ment character is treated as a 16-bit unsigned
able character position in the first operand, that is,
binary integer extended on the left with 48
the first function character is placed at the begin-
zeros.
ning of the first-operand location, and each suc-
For TRANSLATE TWO TO TWO, the argu- cessive function character is placed immediately
ment character is treated as a 16-bit unsigned to the right of the preceding character. The
binary integer extended on the right with a second operand and the translation table are not
zero and on the left with 47 zeros. altered unless an overlap occurs.


64-Bit Addressing Mode

/
R First-Operand Address
/
63

/
R + 1 Second-Operand Length
/
63

/
R Second-Operand Address
/
63

For TRANSLATE ONE TO ONE
and TRANSLATE ONE TO TWO
/
GR1 Translation-Table Address ///
/
61 63

For TRANSLATE TWO TO ONE
and TRANSLATE TWO TO TWO
/
GR1 Translation-Table Addr.////////////
/
52 63

Figure 7-24 (Part 2 of 2). Register Contents for TRANSLATE ONE TO ONE, TRANSLATE ONE TO TWO, TRANS-
LATE TWO TO ONE, and TRANSLATE TWO TO TWO

Chapter 7. General Instructions 7-155


The operation proceeds until a selected function decremented by the number of second-operand
character equal to the test character is encount- bytes processed, and the contents of general reg-
ered, the second-operand location is exhausted, ister R are incremented by the same number, so
or a CPU-determined number of second-operand that the instruction, when reexecuted, contains the
characters have been processed. address of the next character to be processed.
The contents of general register R are incre-
When a selected function character equal to the mented by the same, twice, or one half the
test character is encountered, condition code 1 is number, as described above for condition code 0.
set. When the second-operand location is
exhausted without finding a selected function char- When general registers R and R are updated in
acter equal to the test character, condition code 0 the 24-bit or 31-bit addressing mode, the bits in bit
is set. When a CPU-determined number of char- positions 32-39 of them that are not part of the
acters have been processed, condition code 3 is address may be set to zeros or may remain
set. Condition code 3 may be set even when the unchanged from their original values. In the 24-bit
next character to be processed results in a func- or 31-bit addressing mode, the contents of bit
tion character equal to the test character or when positions 0-31 of general registers R, R + 1,
the second-operand location is exhausted. In and R always remain unchanged.
these cases, condition code 1 or 0, respectively,
will be set when the instruction is executed again. The contents of general registers 0 and 1 remain
unchanged.
If the operation is completed with condition code
0, the contents of general register R are incre- The amount of processing that results in the
mented by the contents of general register setting of condition code 3 is determined by the
R + 1, and the contents of general register R CPU on the basis of improving system perform-
are incremented as follows: ance, and it may be a different amount each time
the instruction is executed.
For TRANSLATE ONE TO ONE and TRANS-
LATE TWO TO TWO, the same as for general During instruction execution, CPU retry may result
register R. in condition code 3 being set with possibly incor-
For TRANSLATE ONE TO TWO, by twice the rect data having been stored in the first operand
amount for general register R. location at or to the right of the location desig-
nated by the final address in general register R.
For TRANSLATE TWO TO ONE, by one half
The amount of data stored depends on the opera-
the amount for general register R.
tion and the point in time at which CPU retry
occurred. In all cases, the storing will occur
The contents of general register R + 1 are then
again, with correct data stored, when the instruc-
set to zero.
tion is executed again to continue processing the
If the operation is completed with condition code same operands.
1, the contents of general register R + 1 are
When the R register is the same register as the
decremented by the number of second-operand
R register, the R or R register is register 0, or
bytes processed before the character that selected
the R register is register 1, the results are unpre-
a function character equal to the test character
dictable.
was encountered, and the contents of general reg-
ister R are incremented by the same number, so
When any of the first and second operands and
that general register R contains the address of
the translation table overlaps another of them, the
the character that selected a function character
results are unpredictable.
equal to the test character. The contents of
general register R are incremented by the same, Access exceptions for the portion of the first or
twice, or one half the number, as described above second operand to the right of the last character
for condition code 0. processed may or may not be recognized. For an
operand longer than 4K bytes, access exceptions
If the operation is completed with condition code
are not recognized for locations more than 4K
3, the contents of general register R + 1 are
bytes beyond the last character processed.

7-156 z/Architecture Principles of Operation


Access exceptions for all characters of the trans- ences. (See Storage-Operand Consistency
lation table may be recognized even if not all char- on page 5-86.)
acters are used.

Access exceptions are not recognized if the R


UNPACK
field is odd. When the length of the second UNPK D(L,B),D(L,B) [SS]
operand is zero, no access exceptions for the first
or second operand are recognized, and access //
exceptions for the translation table may or may 'F3' L L B D B D
not be recognized. //
8 12 16 2 32 36 47
Resulting Condition Code:
The format of the second operand is changed
0 Entire second operand processed without
from packed to zoned, and the result is placed at
finding a resulting function character equal to
the first-operand location. The packed and zoned
the test character
formats are described in Chapter 8, Decimal
1 Second-operand character found resulting in
Instructions.
a function character equal to the test char-
acter The second operand is treated as having the
2 -- packed format. Its digits and sign are placed
3 CPU-determined number of characters proc- unchanged in the first-operand location, using the
essed zoned format. Zone bits with coding of 1111 are
supplied for all bytes except the rightmost byte,
Program Exceptions:
the zone of which receives the sign of the second
Access (fetch, operand 2 and translation table; operand. The sign and digits are not checked for
store, operand 1) valid codes.
Operation (if the extended-translation facility 2
is not installed) The result is obtained as if the operands were
Specification processed right to left. When necessary, the
second operand is considered to be extended on
Programming Notes: the left with zeros. If the first-operand field is too
short to contain all digits of the second operand,
1. These instructions differ from the TRANS-
the remaining leftmost portion of the second
LATE EXTENDED instruction by having the
operand is ignored. Access exceptions for the
following attributes:
unused portion of the second operand may or may
Depending on the instruction used, the not be indicated.
sets of argument characters and function
characters each can contain single-byte or When the operands overlap, the result is obtained
double-byte characters. as if the operands were processed one byte at a
time and as if the first result byte were stored
The test character is compared to a
immediately after fetching the first operand byte.
resulting function character instead of to
The entire rightmost second-operand byte is used
an argument character.
in forming the first result byte. For the remainder
The argument (source) and function (des- of the field, information for two result bytes is
tination) operands are different operands. obtained from a single second-operand byte, and
2. When condition code 3 is set, the program execution proceeds as if the leftmost four bits of
can simply branch back to the instruction to the byte were to remain available for the next
continue the translation. The program need result byte and need not be refetched. Thus, the
not determine the number of characters that result is as if two result bytes were to be stored
were translated. immediately after fetching a single operand byte.

3. The storage operand references of these Condition Code: The code remains unchanged.
instructions may be multiple-access refer-

Chapter 7. General Instructions 7-157


Program Exceptions: The converted last digit is placed in the rightmost
byte position of the result field, and the other con-
Access (fetch, operand 2; store, operand 1)
verted digits are placed adjacent to the last and to
Programming Notes: each other in the remainder of the result field.

1. An example of the use of the UNPACK The result is obtained as if the operands were
instruction is given in Appendix A, Number processed right to left.
Representation and Instruction-Use
Examples. The length of the second operand is 16 bytes.
The second operand consists of 31 digits and a
2. A field that is to be unpacked can be
sign.
destroyed by improper overlapping. To save
storage space for unpacking by overlapping
The length of the first operand is designated by
the operands, the rightmost byte of the first
the contents of the L field. The first-operand
operand must be to the right of the rightmost
length must not exceed 32 bytes (L must be less
byte of the second operand by the number of
than or equal to 31); otherwise, a specification
bytes in the second operand minus 2. If only
exception is recognized.
one or two bytes are to be unpacked, the
rightmost bytes of the two operands may coin- If the first operand is too short to contain all digits
cide. of the second operand, the remaining leftmost
3. The storage-operand references of UNPACK portion of the second operand is ignored. Access
may be multiple-access references. (See exceptions for the unused portion of the second
Storage-Operand Consistency on operand may or may not be indicated.
page 5-86.)
When the length of the first operand is 32 bytes,
the leftmost byte is set to ASCII zero, 30 hex.
UNPACK ASCII
No test is made for destructive overlap, and the
UNPKA D(L,B),D(B) [SS]
results in the first-operand location are unpredict-
// able when destructive overlap exists. Operands
'EA' L B D B D are said to overlap destructively when the first-
// operand location is used as a source after
8 16 2 32 36 47 unpacked data has been placed into it.

The format of the second operand is changed As observed by other CPUs and by channel pro-
from packed to ASCII, and the result is placed at grams, the first operand is not necessarily stored
the first-operand location. The packed format is into in any particular order and may appear to be
described in Chapter 8, Decimal Instructions. stored into more than once.

The second operand is treated as having the Resulting Condition Code:


packed format. Its digits are converted to ASCII 0 Sign is plus
characters by extending them on the left with 0011 1 Sign is minus
binary, and the ASCII characters are then placed 2 --
at the first operand location. The digits are not 3 Sign is invalid
checked for valid codes.
Program Exceptions:
The sign of the second operand is not transferred
to the first operand but is checked for validity and Access (fetch, operand 2; store, operand 1)
determines the condition code. If the sign is 1010, Operation (if the extended-translation facility 2
1100, 1110 or 1111 binary (plus), condition code 0 is not installed)
is set. If the sign is 1011 or 1101 binary (minus), Specification
condition code 1 is set. If the sign is not one of
the codes for plus or minus, condition code 3 is Programming Note: The following example illus-
set. trates the use of the instruction to unpack to ASCII
digits:

7-158 z/Architecture Principles of Operation


ASDIGITS DS CL31 length must not exceed 32 characters or 64 bytes
PKDIGITS DS PL16 (L must be less than or equal to 63 and must be
DC X'123456789' odd); otherwise a specification exception is recog-
DC X'123456789' nized.
DC X'123456789'
DC X'1C' If the first operand is too short to contain all digits
... of the second operand, the remaining leftmost
UNPKA ASDIGITS(31),PKDIGITS portion of the second operand is ignored. Access
exceptions for the unused portion of the second
UNPACK UNICODE operand may or may not be indicated.

UNPKU D(L,B),D(B) [SS] When the length of the first operand is 32 charac-
ters, the leftmost character is set to Unicode Basic
//
'E2' L B D B D Latin zero, 0030 hex.
//
8 16 2 32 36 47 No test is made for destructive overlap, and the
results in the first-operand location are unpredict-
able when destructive overlap exists. Operands
The format of the second operand is changed
are said to overlap destructively when the first-
from packed to Unicode Basic Latin, and the result
operand location is used as a source after
is placed at the first-operand location. The
unpacked data has been placed into it.
packed format is described in Chapter 8, Decimal
Instructions. As observed by other CPUs and by channel pro-
grams, the first operand is not necessarily stored
The second operand is treated as having the
into in any particular order and may appear to be
packed format. Its digits are converted to two-
stored into more than once.
byte Unicode characters by extending them on the
left with 000000000011 binary (003 hex), and the Resulting Condition Code:
Unicode characters are then placed at the first
operand location. The digits are not checked for 0 Sign is plus
valid codes. The sign of the second operand is 1 Sign is minus
not transferred to the first operand but is checked 2 --
for validity and determines the condition code. If 3 Sign is invalid
the sign is 1010, 1100, 1110 or 1111 binary (plus),
condition code 0 is set. If the sign is 1011 or Program Exceptions:
1101 binary (minus), condition code 1 is set. If Access (fetch, operand 2; store, operand 1)
the sign is not one of the codes for plus or minus, Operation (if the extended-translation facility 2
condition code 3 is set. is not installed)
Specification
The converted last digit is placed in the rightmost
character position of the result field, and the other Programming Note: The following example illus-
converted digits are placed adjacent to the last trates the use of the instruction to unpack to
and to each other in the remainder of the result European numbers:
field.
UNDIGITS DS CL62
PKDIGITS DS PL16
The result is obtained as if the operands were
DC X'123456789'
processed right to left.
DC X'123456789'
DC X'123456789'
The length of the second operand is 16 bytes; the DC X'1C'
second operand consists of 31 digits and a sign. ...
UNPKU UNDIGITS(62),PKDIGITS
The length of the first operand is designated by
the contents of the L field. The first-operand

Chapter 7. General Instructions 7-159


UPDATE TREE general register 1, are conditionally interchanged
with the contents of the nodes so as to give a
UPT [E] unique maximum logical value in bit positions
32-63 of general register 0.

'12' Bit positions 32-63 of general register 4 contain


the base address of the tree, and bit positions
15
32-63 of general register 5 contain the index of a
node whose parent node will be examined first.
The nodes of a tree in storage are examined suc- The base address is eight less than the address
cessively on a path toward the base of the tree, of the root node of the tree. The initial contents of
and contents of general register 0, conceptually bit positions 32-63 of general registers 4 and 5
followed on the right by contents of general reg- must be a multiple of 8; otherwise, a specification
ister 1, are conditionally interchanged with the exception is recognized.
contents of the nodes so as to give a unique
maximum logical value in general register 0. The A unit of operation begins by shifting the contents
first half of a node and general register 0 contain of bit positions 32-63 of general register 5 right
a codeword, which is for use in sort/merge algo- logically one position and then setting bit 61 to
rithms. zero. However, bits 32-63 of general register 5
remain unchanged if the execution of a unit of
If the codeword in general register 0 equals the operation is nullified or suppressed. If after
codeword in a node, the contents of the node are shifting and setting bit 61 to zero, bits 32-63 of
placed in general registers 2 and 3. general register 5 are all zeros, the instruction is
completed, and condition code 1 is set; otherwise,
General register 4 contains the base address of the unit of operation continues.
the tree, and general register 5 contains the index
of a node whose parent node will be examined Bit 32 of general register 0 is tested. If bit 32 of
first. general register 0 is one, the instruction is com-
pleted, and condition code 3 is set.
In the access-register mode, access register 4
specifies the address space containing the tree. If bit 32 of general register 0 is zero, the sum of
bits 32-63 of general registers 4 and 5 is used as
This instruction may be interrupted between units the intermediate value for normal operand address
of operation. The condition code is unpredictable generation. The generated address is the address
if the instruction is interrupted. of a node in storage.

The size of a node, the size of a codeword, and Bits 32-63 of general register 0 are logically com-
the participation of bits 0-31 of general registers pared with the contents of the first word of the cur-
1-5 in the operation depend on the addressing rently addressed node. If the register operand is
mode. In the 24-bit or 31-bit addressing mode, a low, the contents of bit positions 32-63 of general
node is eight bytes, a codeword is four bytes, and registers 0 and 1 are interchanged with those of
bits 0-31 are ignored and remain unchanged. In the node, and a unit of operation is completed. If
the 64-bit addressing mode, a node is 16 bytes, a the register operand is high, no additional action is
codeword is eight bytes, and bits 0-31 are used in taken, and the unit of operation is completed. If
and may be changed by the operation. the compare values are equal, bit positions 32-63
of general register 2, conceptually followed on the
Operation in the 24-Bit or 31-Bit Addressing right by bit positions 32-63 of general register 3,
Mode are loaded from the currently addressed node, the
instruction is completed, and condition code 0 is
In the 24-bit or 31-bit addressing mode, the
set.
doubleword nodes of a tree in storage are exam-
ined successively on a path toward the base of In those cases when the value in the first word of
the tree, and the contents of bit positions 32-63 of the node is less than or equal to the value in bit
general register 0, conceptually followed on the positions 32-63 of the register, the contents of the
right by the contents of bit positions 32-63 of

7-160 z/Architecture Principles of Operation


node remain unchanged. However, in some the instruction is completed, and condition code 0
models, these contents may be fetched and sub- is set.
sequently stored back.
In those cases when the value in the first
Operation in the 64-Bit Addressing Mode doubleword of the node is less than or equal to
the value in the register, the contents of the node
In the 64-bit addressing mode, the quadword remain unchanged. However, in some models,
nodes of a tree in storage are examined succes- these contents may be fetched and subsequently
sively on a path toward the base of the tree, and stored back.
the contents of general register 0, conceptually fol-
lowed on the right by the contents of general reg- Specifications Independent of Addressing
ister 1, are conditionally interchanged with the Mode
contents of the nodes so as to give a unique
maximum logical value in general register 0. Access exceptions are recognized only for one
node at a time. Access exceptions, change-bit
General register 4 contains the base address of action, and PER storage alteration do not occur
the tree, and general register 5 contain the index for subsequent nodes until the previous node has
of a node whose parent node will be examined been successfully compared and updated, and
first. The base address is 16 less than the they also do not occur if a specification-exception
address of the root node of the tree. The initial condition exists.
contents of general registers 4 and 5 must be a
multiple of 16; otherwise, a specification exception Resulting Condition Code:
is recognized. 0 Equal compare values at currently addressed
node
A unit of operation begins by shifting the contents
1 No equal compare values found on path, or
of general register 5 right logically one position
no comparison made
and then setting bit 60 to zero. However, general
2 --
register 5 remains unchanged if the execution of a
3 In 24-bit or 31-bit mode, bits 32-63 of general
unit of operation is nullified or suppressed. If after
register 5 nonzero and bits 32-63 of general
shifting and setting bit 60 to zero, the contents of
register 0 negative; in 64-bit mode, general
general register 5 are zero, the instruction is com-
register 5 nonzero and general register 0 neg-
pleted, and condition code 1 is set; otherwise, the
ative
unit of operation continues.
Program Exceptions:
Bit 0 of general register 0 is tested. If bit 0 of
general register 0 is one, the instruction is com- Access (fetch and store, nodes of tree)
pleted, and condition code 3 is set. Specification

If bit 0 of general register 0 is zero, the sum of the Programming Notes:


contents of general registers 4 and 5 is used as 1. An example of the use of UPDATE TREE is
the intermediate value for normal operand address given in Sorting Instructions in Appendix A,
generation. The generated address is the address Number Representation and Instruction-Use
of a node in storage. Examples.
The contents of general register 0 are logically 2. For use in sorting in the 24-bit or 31-bit
compared with the contents of the first doubleword addressing mode, when equal compare values
of the currently addressed node. If the register have been found, the contents of bit positions
operand is low, the contents of general registers 0 32-63 of general registers 1 and 3 can be
and 1 are interchanged with those of the node, appropriate (depending on the contents of the
and a unit of operation is completed. If the reg- tree) for the subsequent execution of
ister operand is high, no additional action is taken, COMPARE AND FORM CODEWORD. The
and the unit of operation is completed. If the contents of bit positions 32-63 of general reg-
compare values are equal, general registers 2 and ister 2, shifted right 16 bit positions, can be
3 are loaded from the currently addressed node, similarly appropriate, and they can provide for

Chapter 7. General Instructions 7-161


minimal recomparison of partially equal keys. 6. The storage-operand references for UPDATE
The same applies in the 64-bit addressing TREE may be multiple-access references.
mode except to the contents of bit positions (See Storage-Operand Consistency on
0-63 of the registers and with the contents of page 5-86.)
bit positions 0-63 of general register 2 shifted
7. In those cases when the codeword in the
right 48 bit positions. Refer to Sorting
node is less than or equal to the codeword in
Instructions on page A-51 for a discussion of
general register 0, depending on the model,
trees and their use in sorting.
the contents of the node may be fetched and
3. The program should avoid placing a nonzero subsequently stored back. As a result, any of
value in bit positions 32-38 of general register the following may occur for the storage
5 when in the 24-bit addressing mode. If any location containing the node: a PER storage-
bit in bit positions 32-38 is a one, the nodes of alteration event may be recognized; a pro-
the tree will not be examined successively. tection exception for storing may be
recognized; and, provided no access
4. When bits 32-63 of general register 0 are neg-
exceptions exist, the change bit may be set to
ative in the 24-bit or 31-bit addressing mode,
one. Because the contents of storage remain
or when bits 0-63 are negative in the 64-bit
unchanged, the change bit may or may not be
mode, and provided that the tree has been
one when a PER storage-alteration event is
updated properly previously, the node repres-
recognized.
ented by general registers 0 and 1 either is
the node or is equal to the node (equal keys) 8. Special precautions should be taken when
that would be selected if the unit of operation UPDATE TREE is made the target of
continued. In this case, ending the unit of EXECUTE. See the programming note con-
operation and setting condition code 3 is a cerning interruptible instructions under
faster means of selecting an appropriate node EXECUTE.
because it does not require further examina-
9. Further programming notes concerning inter-
tion and updating of the tree.
ruptible instructions are included in Interrup-
5. Setting condition code 3 provides improved tible Instructions on page 5-20.
performance when the replacement record is
10. Figure 7-25 on page 7-163 is a summary of
equal to the old winner and, more importantly
the operation of UPDATE TREE in the 24-bit
(since the first case can be detected by
or 31-bit addressing mode, and Figure 7-26
means of the condition code of CFC), when
on page 7-164 is a summary of the operation
the update path contains a negative
in the 64-bit addressing mode.
codeword, indicating equality with the old
winner.

7-162 z/Architecture Principles of Operation


No
Bits 61-63 of GR4 and GR5 all zeros5 Specification Exception

Yes
Unit-of-
operation5
boundary
6
&
GR5 shifted right one position 5 TEMPWORD1 \

5 Bit 29 of TEMPWORD1


6
Yes
TEMPWORD1 = 5 5 GR5 \

No 1 5 Cond Code

6
Yes
Bit 32 of GR one

No 6

TEMPWORD1 5 GR5 \

6 3 5 Cond Code

GR4 + TEMPWORD1 5 TEMPADDRESS \
%
6
6 End operation

Fetch doubleword from location in
storage designated by TEMPADDRESS;

Bits -31 5 TEMPWORD2

Bits 32-64 5 TEMPWORD3


6 \ Only bits 32-63 of a GR partici-
pate when no bits are mentioned.
TEMPWORD1 5 GR5 \


6
GR high \ GR equal
%Compare GR and TEMPWORD2
&
GR low
6
6
TEMPWORD2 5 GR2 \
Store contents of GR and GR1 in \
doubleword designated by TEMPADDRESS TEMPWORD3 5 GR3 \

5 Cond Code
6

TEMPWORD2 5 GR \ 6
End operation
TEMPWORD3 5 GR1 \



Figure 7-25. Execution of UPDATE TREE in the 24-Bit or 31-Bit Addressing Mode

Chapter 7. General Instructions 7-163


No
Bits 6-63 of GR4 and GR5 all zeros5 Specification Exception

Yes
Unit-of-
operation5
boundary
6
&
GR5 shifted right one position 5 TEMPDWRD1 \

5 Bit 6 of TEMPDWRD1


6
Yes
TEMPDWRD1 = 5 5 GR5 \

No 1 5 Cond Code

6
Yes
Bit of GR one

No 6

TEMPDWRD1 5 GR5 \

6 3 5 Cond Code

GR4 + TEMPDWRD1 5 TEMPADDRESS \
%
6
6 End operation

Fetch quadword from location in
storage designated by TEMPADDRESS;

Bits -63 5 TEMPDWRD2

Bits 64-127 5 TEMPDWRD3


6 \ Bits -63 of a GR participate
when no bits are mentioned.
TEMPDWRD1 5 GR5 \


6
GR high \ GR equal
%Compare GR and TEMPDWRD2
&
GR low
6
6
TEMPDWRD2 5 GR2 \
Store contents of GR and GR1 in \
quadword designated by TEMPADDRESS TEMPDWRD3 5 GR3 \

5 Cond Code
6

TEMPDWRD2 5 GR \ 6
End operation
TEMPDWRD3 5 GR1 \



Figure 7-26. Execution of UPDATE TREE in the 64-Bit Addressing Mode

7-164 z/Architecture Principles of Operation


Chapter 8. Decimal Instructions
Decimal-Number Formats . . . . . . . . . . . 8-1 ADD DECIMAL . . . . . . . . . . . . . . . . 8-5
Zoned Format . . . . . . . . . . . . . . . . . 8-1 COMPARE DECIMAL . . . . . . . . . . . . 8-6
Packed Format . . . . . . . . . . . . . . . . 8-1 DIVIDE DECIMAL . . . . . . . . . . . . . . 8-6
Decimal Codes . . . . . . . . . . . . . . . . 8-2 EDIT . . . . . . . . . . . . . . . . . . . . . . 8-7
Decimal Operations . . . . . . . . . . . . . . . 8-2 EDIT AND MARK . . . . . . . . . . . . . . 8-9
Decimal-Arithmetic Instructions . . . . . . . 8-2 MULTIPLY DECIMAL . . . . . . . . . . . . 8-11
Editing Instructions . . . . . . . . . . . . . . 8-3 SHIFT AND ROUND DECIMAL . . . . . . 8-11
Execution of Decimal Instructions . . . . . 8-3 SUBTRACT DECIMAL . . . . . . . . . . . 8-12
Other Instructions for Decimal Operands . 8-3 TEST DECIMAL . . . . . . . . . . . . . . . 8-13
Decimal-Operand Data Exception . . . . . 8-4 ZERO AND ADD . . . . . . . . . . . . . . . 8-13
Instructions . . . . . . . . . . . . . . . . . . . . 8-4

The decimal instructions of this chapter perform Decimal digits in the zoned format may be part of
arithmetic and editing operations on decimal data. a larger character set, which includes also alpha-
Additional operations on decimal data are pro- betic and special characters. The zoned format is,
vided by several of the instructions in Chapter 7, therefore, suitable for input, editing, and output of
General Instructions. Decimal operands always numeric data in human-readable form. There are
reside in storage, and all decimal instructions use no decimal-arithmetic instructions which operate
the SS instruction format. Decimal operands directly on decimal numbers in the zoned format;
occupy storage fields that can start on any byte such numbers must first be converted to the
boundary. packed format.

The editing instructions produce a result of up to


Decimal-Number Formats 256 bytes; each byte may be a decimal digit in the
zoned format, a message byte, or a fill byte.
Decimal numbers may be represented in either
the zoned or packed format. Both decimal-
number formats are of variable length; the Packed Format
instructions used to operate on decimal data each
specify the length of their operands and results. /
D D D D D D D S
Each byte of either format consists of a pair of /
four-bit codes; the four-bit codes include decimal-
digit codes, sign codes, and a zone code. In the packed format, each byte contains two
decimal digits (D), except for the rightmost byte,
which contains a sign to the right of a decimal
Zoned Format digit. Decimal arithmetic is performed with oper-
/ ands in the packed format and generates results
Z N Z N Z N Z/S N in the packed format.
/
The packed-format operands and results of
In the zoned format, the rightmost four bits of a decimal-arithmetic instructions may be up to 16
byte are called the numeric bits (N) and normally bytes (31 digits and sign), except that the
consist of a code representing a decimal digit. maximum length of a multiplier or divisor is eight
The leftmost four bits of a byte are called the zone bytes (15 digits and sign). In division, the sum of
bits (Z), except for the rightmost byte of a decimal the lengths of the quotient and remainder may be
operand, where these bits may be treated either from two to 16 bytes. The editing instructions can
as a zone or as a sign (S). fetch as many as 256 decimal digits from one or
more decimal numbers of variable length, each in
the packed format.

Copyright IBM Corp. 1990, 2000 8-1



Decimal Codes Recognized As
Code
The decimal digits 0-9 have the binary encoding (Binary) Digit Sign
0000-1001.
Invalid
The preferred sign codes are 1100 for plus and 1 1 Invalid
1101 for minus. These are the sign codes gener- 1 2 Invalid
11 3 Invalid
ated for the results of the decimal-arithmetic 1 4 Invalid
instructions and the CONVERT TO DECIMAL 11 5 Invalid
instruction. 11 6 Invalid
111 7 Invalid
Alternate sign codes are also recognized as valid 1 8 Invalid
in the sign position: 1010, 1110, and 1111 are 11 9 Invalid
11 Invalid Plus
alternate codes for plus, and 1011 is an alternate 111 Invalid Minus
code for minus. Alternate sign codes are 11 Invalid Plus (preferred)
accepted for any decimal source operand, but are 111 Invalid Minus (preferred)
not generated in the completed result of a 111 Invalid Plus
decimal-arithmetic instruction or CONVERT TO 1111 Invalid Plus (zone)

DECIMAL. This is true even when an operand
remains otherwise unchanged, such as when Figure 8-1. Summary of Digit and Sign Codes
adding zero to a number. An alternate sign code
is, however, left unchanged by MOVE Programming Note: Since 1111 is both the
NUMERICS, MOVE WITH OFFSET, MOVE zone code and an alternate code for plus,
ZONES, PACK, and UNPACK. unsigned (positive) decimal numbers may be
represented in the zoned format with 1111 zone
When an invalid sign or digit code is detected, a codes in all byte positions. The result of the
data exception is recognized. For the decimal- PACK instruction converting such a number to the
arithmetic instructions and CONVERT TO packed format may be used directly as an
BINARY, the operation is suppressed. operand for decimal instructions.

For the editing instructions EDIT and EDIT AND


MARK, an invalid sign code is not recognized. Decimal Operations
The operation is terminated for a data exception
The decimal instructions in this chapter consist of
due to an invalid digit code. No validity checking
two classes, the decimal-arithmetic instructions
is performed by MOVE NUMERICS, MOVE WITH
and the editing instructions.
OFFSET, MOVE ZONES, PACK, and UNPACK.

The zone code 1111 is generated in the left four Decimal-Arithmetic Instructions
bit positions of each byte representing a zone and
a decimal digit in zoned-format results. Zoned- The decimal-arithmetic instructions perform addi-
format results are produced by EDIT, EDIT AND tion, subtraction, multiplication, division, compar-
MARK, and UNPACK. For EDIT and EDIT AND ison, and shifting.
MARK, each result byte representing a zoned-
format decimal digit contains the zone code 1111 Operands of the decimal-arithmetic instructions
in the left four bit positions and the decimal-digit are in the packed format and are treated as
code in the right four bit positions. For UNPACK, signed decimal integers. A decimal integer is
zone bits with a coding of 1111 are supplied for all represented in true form as an absolute value with
bytes except the rightmost byte, the zone of which a separate plus or minus sign. It contains an odd
receives the sign. number of decimal digits, from one to 31, and the
sign; this corresponds to an operand length of one
The meaning of the decimal codes is summarized to 16 bytes.
in Figure 8-1.
A decimal zero normally has a plus sign, but multi-
plication, division, and overflow may produce a

8-2 z/Architecture Principles of Operation


zero value with a minus sign. Such a negative operands are not necessarily equal and may,
zero is a valid operand and is treated as equal to depending on the instruction, be prohibited from
a positive zero by COMPARE DECIMAL. being equal.

The lengths of the two operands specified in the


instruction need not be the same. If necessary,
Editing Instructions
the shorter operand is considered to be extended
The editing instructions are EDIT and EDIT AND
with zeros on the left. Results, however, cannot
MARK. For these instructions, only the first
exceed the first-operand length as specified in the
operand (the pattern) has an explicitly specified
instruction.
length. The second operand (the source) is con-
sidered to have as many digits as necessary for
When a carry or leftmost nonzero digits of the
the completion of the operation.
result are lost because the first-operand field is
too short, the result is obtained by ignoring the
Overlapping operands for the editing instructions
overflow digits, condition code 3 is set, and, if the
yield unpredictable results.
decimal-overflow mask bit is one, a program inter-
ruption for decimal overflow occurs. The operand
lengths alone are not an indication of overflow; Execution of Decimal Instructions
nonzero digits must have been lost during the
operation. During the execution of a decimal instruction, all
bytes of the operands are not necessarily
The operands of decimal-arithmetic instructions accessed concurrently, and the fetch and store
should not overlap at all or should have coincident accesses to a single location do not necessarily
rightmost bytes. In ZERO AND ADD, the oper- occur one immediately after the other. Further-
ands may also overlap in such a manner that the more, for decimal instructions, data in source
rightmost byte of the first operand (which becomes fields may be accessed more than once, and
the result) is to the right of the rightmost byte of intermediate values may be placed in the result
the second operand. For these cases of proper field that may differ from the original operand and
overlap, the result is obtained as if operands were final result values. (See Storage-Operand
processed right to left. Because the codes for Consistency on page 5-86.) Thus, in a multiproc-
digits and signs are verified during the perform- essing configuration, an instruction such as ADD
ance of the arithmetic, improperly overlapping DECIMAL cannot be safely used to update a
operands are recognized as data exceptions. shared storage location when the possibility exists
However, in ZERO AND ADD when the rightmost that another CPU may also be updating that
byte of the first operand is to the left of the right- location.
most byte of the second operand, the entire
second operand may be fetched, depending on Other Instructions for Decimal
the model, before any storing occurs, which will Operands
cause a data exception not to be recognized. See
Interlocks within a Single Instruction on In addition to the decimal instructions in this
page 5-80 for how overlap is detected in the chapter, MOVE NUMERICS and MOVE ZONES
access-register mode. are provided for operating on data of lengths up to
Programming Note: A packed decimal number 256 bytes in the zoned format. Two instructions
in storage may be designated as both the first and are provided for converting data between the
second operand of ADD DECIMAL, COMPARE zoned and packed formats: PACK transforms
DECIMAL, DIVIDE DECIMAL, MULTIPLY zoned data of lengths up to 16 bytes into packed
DECIMAL, SUBTRACT DECIMAL, or ZERO AND data, and UNPACK performs the reverse transfor-
ADD. Thus, a decimal number may be added to mation. MOVE WITH OFFSET can operate on
itself, compared with itself, and so forth; SUB- packed data of lengths up to 16 bytes. Two
TRACT DECIMAL may be used to set a decimal instructions are provided for conversion between
field in storage to zero; and, for MULTIPLY the packed-decimal and signed-binary-integer
DECIMAL, a decimal number may be squared in formats. CONVERT TO BINARY converts packed
place. In these cases, the lengths of the two decimal to binary, and CONVERT TO DECIMAL

Chapter 8. Decimal Instructions 8-3


converts binary to packed decimal; the length of ands for ZERO AND ADD is not recognized
the packed decimal operand of these instructions as a decimal-operand data exception; instead,
is eight bytes (15 digits and sign) for CONVERT the operation is performed as if the entire
TO BINARY (CVB) and CONVERT TO DECIMAL second operand were fetched before any byte
(CVD), and sixteen bytes (31 digits and sign) for of the result is stored.
CONVERT TO BINARY (CVBG) and CONVERT
3. The multiplicand in MULTIPLY DECIMAL has
TO DECIMAL (CVDG). These seven instructions
an insufficient number of leftmost zeros.
are not considered to be decimal instructions and
are described in Chapter 7, General Instructions. A decimal-operand data exception causes the
The editing instructions in this chapter may also operation to be suppressed, except that, for EDIT
be used to change data from the packed to the and EDIT AND MARK, the operation may be sup-
zoned format. pressed or terminated. In the case of EDIT and
EDIT AND MARK, an invalid sign code cannot
Decimal-Operand Data Exception occur.

A decimal-operand data exception is recognized


when any of the following is true: Instructions
1. The sign or digit codes of operands in the The decimal instructions and their mnemonics,
decimal instructions or in CONVERT TO formats, and operation codes are listed in
BINARY (described in Chapter 7, General Figure 8-2 on page 8-5. The figure also indicates
Instructions) are invalid. when the condition code is set, the instruction
fields that designate access registers, and the
2. The operand fields in ADD DECIMAL,
exceptional conditions in operand designations,
COMPARE DECIMAL, DIVIDE DECIMAL,
data, or results that cause a program interruption.
MULTIPLY DECIMAL, and SUBTRACT
DECIMAL overlap in a way other than with Note: In the detailed descriptions of the indi-
coincident rightmost bytes; or operand fields in vidual instructions, the mnemonic and the sym-
ZERO AND ADD overlap, and the rightmost bolic operand designation for the assembler
byte of the second operand is to the right of language are shown with each instruction. For
the rightmost byte of the first operand. On ADD DECIMAL, for example, AP is the mnemonic
some models, the improper overlap of oper- and D(L,B),D(L,B) the operand designation.

8-4 z/Architecture Principles of Operation



Mne- Op
Name monic Characteristics Code

ADD DECIMAL AP SS C A Dd DF STB BFA


COMPARE DECIMAL CP SS C A Dd B BF9
DIVIDE DECIMAL DP SS A SPDd DK STB BFD
EDIT ED SS C A Dd STB BDE
EDIT AND MARK EDMK SS C A Dd G1 STB BDF

MULTIPLY DECIMAL MP SS A SPDd STB BFC


SHIFT AND ROUND DECIMAL SRP SS C A Dd DF STB F
SUBTRACT DECIMAL SP SS C A Dd DF STB BFB
TEST DECIMAL TP RSL C E2 A B EBC
ZERO AND ADD ZAP SS C A Dd DF STB BF8

Explanation:

A Access exceptions for logical addresses.
B B field designates an access register in the access-register mode.
B B field designates an access register in the access-register mode.
C Condition code is set.
Dd Decimal-operand data exception.
DF Decimal-overflow exception.
DK Decimal-divide exception.
G1 Instruction execution includes the implied use of general register 1.
SP Specification exception.
SS SS instruction format.
ST PER storage-alteration event.

Figure 8-2. Summary of Decimal Instructions

ADD DECIMAL The sign of the sum is determined by the rules of


algebra. In the absence of overflow, the sign of a
AP D(L,B),D(L,B) [SS] zero result is made positive. If overflow occurs, a
zero result is given either a positive or negative
// sign, as determined by what the sign of the
'FA' L L B D B D
correct sum would have been.
//
8 12 16 2 32 36 47
Resulting Condition Code:

The second operand is added to the first operand, 0 Result zero; no overflow
and the resulting sum is placed at the first- 1 Result less than zero; no overflow
operand location. The operands and result are in 2 Result greater than zero; no overflow
the packed format. 3 Overflow

Addition is algebraic, taking into account the signs Program Exceptions:


and all digits of both operands. All sign and digit Access (fetch, operand 2; fetch and store,
codes are checked for validity. operand 1)
Data
If the first operand is too short to contain all left- Decimal overflow
most nonzero digits of the sum, decimal overflow
occurs. The operation is completed. The result is Programming Note: An example of the use of
obtained by ignoring the overflow digits, and con- the ADD DECIMAL instruction is given in
dition code 3 is set. If the decimal-overflow mask Appendix A, Number Representation and
is one, a program interruption for decimal overflow Instruction-Use Examples.
occurs.

Chapter 8. Decimal Instructions 8-5


COMPARE DECIMAL DIVIDE DECIMAL
CP D(L,B),D(L,B) [SS] DP D(L,B),D(L,B) [SS]

// //
'F9' L L B D B D 'FD' L L B D B D
// //
8 12 16 2 32 36 47 8 12 16 2 32 36 47

The first operand is compared with the second The first operand (the dividend) is divided by the
operand, and the result is indicated in the condi- second operand (the divisor). The resulting quo-
tion code. The operands are in the packed tient and remainder are placed at the first-operand
format. location. The operands and results are in the
packed format.
Comparison is algebraic and follows the procedure
for decimal subtraction, except that both operands The quotient is placed leftmost in the first-operand
remain unchanged. When the difference is zero, location. The number of bytes in the quotient field
the operands are equal. When a nonzero differ- is equal to the difference between the dividend
ence is positive or negative, the first operand is and divisor lengths (L - L). The remainder is
high or low, respectively. placed rightmost in the first-operand location and
has a length equal to the divisor length. Together,
Overflow cannot occur because the difference is the quotient and remainder fields occupy the
discarded. entire first operand; therefore, the address of the
quotient is the address of the first operand.
All sign and digit codes are checked for validity.
The divisor length cannot exceed 15 digits and
Resulting Condition Code: sign (L not greater than seven) and must be less
0 Operands equal than the dividend length (L less than L); other-
1 First operand low wise, a specification exception is recognized.
2 First operand high
3 -- The dividend, divisor, quotient, and remainder are
each signed decimal integers in the packed format
Program Exceptions: and are right-aligned in their fields. All sign and
digit codes of the dividend and divisor are
Access (fetch, operands 1 and 2) checked for validity.
Data
The sign of the quotient is determined by the rules
Programming Notes: of algebra from the dividend and divisor signs.
1. An example of the use of the COMPARE The sign of the remainder has the same value as
DECIMAL instruction is given in Appendix A, the dividend sign. These rules hold even when
Number Representation and Instruction-Use the quotient or remainder is zero.
Examples.
Overflow cannot occur. If the divisor is zero or the
2. The preferred and alternate sign codes for a quotient is too large to be represented by the
particular sign are treated as equivalent for number of digits specified, a decimal-divide excep-
comparison purposes. tion is recognized. This includes the case of divi-
3. A negative zero and a positive zero compare sion of zero by zero. The decimal-divide
equal. exception is indicated only if the sign codes of
both the dividend and divisor are valid, and only if
the digit or digits used in establishing the excep-
tion are valid.

Condition Code: The code remains unchanged.

8-6 z/Architecture Principles of Operation


Program Exceptions: a decimal-digit code (0000-1001); a sign code
(1010-1111) is recognized as a data exception.
Access (fetch, operand 2; fetch and store,
The rightmost four bits may specify either a sign
operand 1)
code or a decimal-digit code. Access and data
Data
exceptions are recognized only for those bytes in
Decimal divide
the second operand which are actually required.
Specification
The result is obtained as if both operands were
Programming Notes:
processed left to right one byte at a time. Over-
1. An example of the use of the DIVIDE lapping pattern and source fields give unpredict-
DECIMAL instruction is given in Appendix A, able results.
Number Representation and Instruction-Use
Examples. During the editing process, each byte of the
pattern is affected in one of three ways:
2. The dividend cannot exceed 31 digits and
sign. Since the remainder cannot be shorter 1. It is left unchanged.
than one digit and sign, the quotient cannot
2. It is replaced by a source digit expanded to
exceed 29 digits and sign.
the zoned format.
3. The condition for a decimal-divide exception
3. It is replaced by the first byte in the pattern,
can be determined by a trial comparison. The
called the fill byte.
leftmost digit of the divisor is aligned one digit
to the right of the leftmost dividend digit, with Which of the three actions takes place is deter-
rightmost zeros appended up to the length of mined by one or more of the following: the type of
the dividend. When the divisor, so aligned, is the pattern byte, the state of the significance indi-
less than or equal to the dividend, ignoring cator, and whether the source digit examined is
signs, a divide exception is indicated. zero.
4. If a data exception does not exist, a decimal- Pattern Bytes: There are four types of pattern
divide exception occurs when the leftmost divi- bytes: digit selector, significance starter, field sep-
dend digit is not zero. arator, and message byte. Their coding is as
follows:
EDIT
Code
ED D(L,B),D(B) [SS] Name (Binary)

// Digit selector 1
'DE' L B D B D Significance starter 1 1
// Field separator 1 1
8 16 2 32 36 47 Message byte Any other

The second operand (the source), which normally The detection of either a digit selector or a signif-
contains one or more decimal numbers in the icance starter in the pattern causes an examina-
packed format, is changed to the zoned format tion to be made of the significance indicator and of
and modified under the control of the first operand a source digit. As a result, either the expanded
(the pattern). The edited result replaces the first source digit or the fill byte, as appropriate, is
operand. selected to replace the pattern byte. Additionally,
encountering a digit selector or a significance
The length field specifies the length of the first starter may cause the significance indicator to be
operand, which may contain bytes of any value. changed.

The length of the source is determined by the The field separator identifies individual fields in a
operation according to the contents of the pattern. multiple-field editing operation. It is always
The source normally consists of one or more replaced in the result by the fill byte, and the sig-
decimal numbers, each in the packed format. The nificance indicator is always off after the field sep-
leftmost four bits of each source byte must specify arator is encountered.

Chapter 8. Decimal Instructions 8-7


Message bytes in the pattern are either replaced nificant message bytes remain unchanged in the
by the fill byte or remain unchanged in the result, result.
depending on the state of the significance indi-
cator. They may thus be used for padding, punc- The significance indicator, by its on or off state,
tuation, or text in the significant portion of a field indicates also the negative or positive value,
or for the insertion of sign-dependent symbols. respectively, of a completed source field and is
used as one factor in the setting of the condition
Fill Byte: The first byte of the pattern is used as code.
the fill byte. The fill byte can have any code and
may concurrently specify a control function. If this The significance indicator is set to off at the start
byte is a digit selector or significance starter, the of the editing operation, after a field separator is
indicated editing action is taken after the code has encountered, or after a source byte is examined
been assigned to the fill byte. that has a plus code in the rightmost four bit posi-
tions.
Source Digits: Each time a digit selector or sig-
nificance starter is encountered in the pattern, a The significance indicator is set to on when a sig-
new source digit is examined for placement in the nificance starter is encountered whose source digit
pattern field. Either the source digit is disre- is a valid decimal digit, or when a digit selector is
garded, or it is expanded to the zoned format, by encountered whose source digit is a nonzero
appending the zone code 1111 on the left, and decimal digit, provided that in both instances the
stored in place of the pattern byte. source byte does not have a plus code in the
rightmost four bit positions.
Execution is as if the source digits were selected
one byte at a time and as if a source byte were In all other situations, the significance indicator is
fetched for inspection only once during an editing not changed. A minus sign code has no effect on
operation. Each source digit is examined only the significance indicator.
once for a zero value. The leftmost four bits of
each byte are examined first, and the rightmost Result Bytes: The result of an editing operation
four bits, when they represent a decimal-digit replaces and is equal in length to the pattern. It is
code, remain available for the next pattern byte composed of pattern bytes, fill bytes, and zoned
that calls for a digit examination. When the left- source digits.
most four bits contain an invalid digit code, a data
exception is recognized, and the operation is ter- If the pattern byte is a message byte and the sig-
minated. nificance indicator is on, the message byte
remains unchanged in the result. If the pattern
At the time the left digit of a source byte is exam- byte is a field separator or if the significance indi-
ined, the rightmost four bits are checked for the cator is off when a message byte is encountered
existence of a sign code. When a sign code is in the pattern, the fill byte replaces the pattern
encountered in the rightmost four bit positions, byte in the result.
these bits are not treated as a decimal-digit code,
and a new source byte is fetched from storage If the digit selector or significance starter is
when the next pattern byte calls for a source-digit encountered in the pattern with the significance
examination. indicator off and the source digit zero, the source
digit is considered nonsignificant, and the fill byte
When the pattern contains no digit selector or sig- replaces the pattern byte. If the digit selector or
nificance starter, no source bytes are fetched and significance starter is encountered with either the
examined. significance indicator on or with a nonzero decimal
source digit, the source digit is considered signif-
Significance Indicator: The significance indi- icant, is changed to the zoned format, and
cator is turned on or off to indicate the significance replaces the pattern byte in the result.
or nonsignificance, respectively, of subsequent
source digits or message bytes. Significant Condition Code: The sign and magnitude of the
source digits replace their corresponding digit last field edited are used to set the condition code.
selectors or significance starters in the result. Sig- The term last field refers to those source digits, if

8-8 z/Architecture Principles of Operation


any, in the second operand selected by digit of all-zero fields. Several fields may be edited
selectors or significance starters after the last field in one operation, and numeric information may
separator; if the pattern contains no field sepa- be combined with text.
rator, there is only one field, which is considered
3. In most cases, the source is shorter than the
to be the last field. If no such source digits are
pattern because each four-bit source digit
selected, the last field is considered to be of zero
produces an eight-bit byte in the result.
length.
4. The total number of digit selectors and signif-
Condition code 0 is set when the last field edited icance starters in the pattern always equals
is zero or of zero length. the number of source digits edited.
5. If the fill byte is a blank, if no significance
Condition code 1 is set when the last field edited
starter exists in the pattern, and if the source
is nonzero and the significance indicator is on.
digit examined for each digit selector is zero,
(This indicates a result less than zero if the last
the editing operation blanks the result field.
source byte examined contained a sign code in
the rightmost four bits.) 6. The resulting condition code indicates whether
or not the last field is all zeros and, if nonzero,
Condition code 2 is set when the last field edited reflects the state of the significance indicator.
is nonzero and the significance indicator is off. The significance indicator reflects the sign of
(This indicates a result greater than zero if the last the source field only if the last source byte
source byte examined contained a sign code in examined contains a sign code in the right-
the rightmost four bits.) most four bits. For multiple-field editing oper-
ations, the condition code reflects the sign and
Figure 8-3 on page 8-10 summarizes the func- value only of the field following the last field
tions of the EDIT and EDIT AND MARK oper- separator.
ations. The leftmost four columns list all the
significant combinations of the four conditions that 7. Significant performance degradation is pos-
can be encountered in the execution of an editing sible when, with DAT on, the second-operand
operation. The rightmost two columns list the address of an EDIT instruction designates a
action taken for each case -- the type of byte location that is closer to the left of a 4K-byte
placed in the result field and the new setting of the boundary than the length of the first operand
significance indicator. of that instruction. This is because the
machine may perform a trial execution of the
Resulting Condition Code: instruction to determine if the second operand
actually crosses the boundary. The second
0 Last field zero or zero length operand of EDIT, while normally shorter than
1 Last field less than zero the first operand, can in the extreme case
2 Last field greater than zero have the same length as the first.
3 --

Program Exceptions: EDIT AND MARK


Access (fetch, operand 2; fetch and store, EDMK D(L,B),D(B) [SS]
operand 1)
Data //
'DF' L B D B D
//
Programming Notes:
8 16 2 32 36 47
1. Examples of the use of the EDIT instruction
are given in Appendix A, Number Represen- The second operand (the source), which normally
tation and Instruction-Use Examples. contains one or more decimal numbers in the
2. Editing includes sign and punctuation control, packed format, is changed to the zoned format
and the suppression and protection of leading and modified under the control of the first operand
zeros by replacing them with blanks or aster- (the pattern). The address of the first significant
isks. It also facilitates programmed blanking result byte is inserted in general register 1. The
edited result replaces the pattern.

Chapter 8. Decimal Instructions 8-9



Results
Conditions
State of
Previous Significance
State of Right Four Indicator at
SignificanceSourceSource Bits End of Digit
Pattern Byte Indicator Digit Are Plus Code Result Byte Examination

Digit selector Off \ Fill byte Off


1-9 No Source digit# On
1-9 Yes Source digit# Off
On -9 No Source digit On
-9 Yes Source digit Off

Significance starter Off No Fill byte On
Yes Fill byte Off
1-9 No Source digit# On
1-9 Yes Source digit# Off
On -9 No Source digit On
-9 Yes Source digit Off

Field separator \ \\ \\ Fill byte Off

Message byte Off \\ \\ Fill byte Off
On \\ \\ Message byte On

Explanation:

\ No effect on result byte or on new state of significance indicator.
\\ Not applicable because source is not examined.
# For EDIT AND MARK only, the address of the rightmost such result byte is
placed in general register 1.

Figure 8-3. Summary of Editing Functions

EDIT AND MARK is identical to EDIT, except for See Figure 8-3 for a summary of the EDIT and
the additional function of inserting the address of EDIT AND MARK operations.
the result byte in general register 1 if the result
byte is a zoned source digit and the significance Resulting Condition Code:
indicator was off before the examination. If no 0 Last field zero or zero length
result byte meets the criteria, general register 1 1 Last field less than zero
remains unchanged; if more than one result byte 2 Last field greater than zero
meets the criteria, the address of the rightmost 3 --
such result byte is inserted.
Program Exceptions:
In the 24-bit addressing mode, the address
replaces bits 40-63 of general register 1, and bits Access (fetch, operand 2; fetch and store,
0-39 of the register are not changed. In the 31-bit operand 1)
addressing mode, the address replaces bits 33-63 Data
of general register 1, bit 32 of the register is set to
zero, and bits 0-31 of the register remain Programming Notes:
unchanged. In the 64-bit addressing mode, the 1. Examples of the use of the EDIT AND MARK
address replaces bits 0-63 of general register 1. instruction are given Appendix A, Number
Representation and Instruction-Use
The contents of access register 1 remain Examples.
unchanged.
2. EDIT AND MARK facilitates the programming
of floating currency-symbol insertion. Using

8-10 z/Architecture Principles of Operation


appropriate source and pattern data, the are right-aligned in their fields. All sign and digit
address inserted in general register 1 is one codes of the multiplicand and multiplier are
greater than the address where a floating checked for validity. The sign of the product is
currency-sign would be inserted. BRANCH determined by the rules of algebra from the multi-
ON COUNT (BCTR, BCTGR), with zero in the plier and multiplicand signs, even if one or both
R field, may be used to reduce the inserted operands are zeros.
address by one.
Condition Code: The code remains unchanged.
3. No address is inserted in general register 1
when the significance indicator is turned on as Program Exceptions:
a result of encountering a significance starter
with the corresponding source digit zero. To Access (fetch, operand 2; fetch and store,
ensure that general register 1 contains a operand 1)
proper address when this occurs, the address Data
of the pattern byte that immediately follows Specification
the appropriate significance starter could be
placed in the register beforehand. Programming Notes:

4. When multiple fields are edited with one exe- 1. An example of the use of the MULTIPLY
cution of the EDIT AND MARK instruction, the DECIMAL instruction is given Appendix A,
address, if any, inserted in general register 1 Number Representation and Instruction-Use
applies to the rightmost field edited for which Examples.
the criteria were met. 2. The product cannot exceed 31 digits and sign.
5. See also the programming note under EDIT The leftmost digit of the product is always
regarding performance degradation due to a zero.
possible trial execution.
SHIFT AND ROUND DECIMAL
MULTIPLY DECIMAL SRP D(L,B),D(B),I [SS]
MP D(L,B),D(L,B) [SS] //
'F' L I B D B D
// //
'FC' L L B D B D 8 12 16 2 32 36 47
//
8 12 16 2 32 36 47
The first operand is shifted in the direction and for
The product of the first operand (the multiplicand) the number of decimal-digit positions specified by
and the second operand (the multiplier) is placed the second-operand address, and, when shifting to
at the first-operand location. The operands and the right is specified, the absolute value of the first
result are in the packed format. operand is rounded by the rounding digit, I. The
first operand and the result are in the packed
The multiplier length cannot exceed 15 digits and format.
sign (L not greater than seven) and must be less
than the multiplicand length (L less than L); oth- The first operand is considered to be in the
erwise, a specification exception is recognized. packed-decimal format. Only its digit portion is
shifted; the sign position does not participate in
The multiplicand must have at least as many the shifting. Zeros are supplied for the vacated
bytes of leftmost zeros as the number of bytes in digit positions. The result replaces the first
the multiplier; otherwise, a data exception is operand. Nothing is stored outside of the speci-
recognized. This restriction ensures that no fied first-operand location.
product overflow occurs.
The second-operand address, specified by the B
The multiplicand, multiplier, and product are each and D fields, is not used to address data; bits
signed decimal integers in the packed format and 58-63 of that address are the shift value, and the
leftmost bits of the address are ignored.

Chapter 8. Decimal Instructions 8-11


The shift value is a six-bit signed binary integer, 2 Result greater than zero; no overflow
indicating the direction and the number of decimal- 3 Overflow
digit positions to be shifted. Positive shift values
specify shifting to the left. Negative shift values, Program Exceptions:
which are represented in two's complement nota- Access (fetch and store, operand 1)
tion, specify shifting to the right. The following are Data
examples of the interpretation of shift values: Decimal overflow

Shift Value Programming Notes:


(Binary) Amount and Direction
1. Examples of the use of the SHIFT AND
11111 31 digits to the left ROUND DECIMAL instruction are given in
1 One digit to the left Appendix A, Number Representation and
No shift Instruction-Use Examples.
111111 One digit to the right
1 32 digits to the right 2. SHIFT AND ROUND DECIMAL can be used
for shifting up to 31 digit positions left and up
For a right shift, the I field, bits 12-15 of the to 32 digit positions right. This is sufficient to
instruction, is used as a decimal rounding digit. clear all digits of any decimal number even
The first operand, which is treated as positive by with rounding.
ignoring the sign, is rounded by decimally adding 3. For right shifts, the rounding digit 5 provides
the rounding digit to the leftmost of the digits to be conventional rounding of the result. The
shifted out and by propagating the carry, if any, to rounding digit 0 specifies truncation without
the left. The result of this addition is then shifted rounding.
right. Except for validity checking and the partic-
ipation in rounding, the digits shifted out of the 4. When the B field is zero, the six-bit shift
rightmost decimal-digit position are ignored and value is obtained directly from bits 42-47 of
are lost. the instruction.

If one or more nonzero digits are shifted out SUBTRACT DECIMAL


during a left shift, decimal overflow occurs. The
operation is completed. The result is obtained by SP D(L,B),D(L,B) [SS]
ignoring the overflow digits, and condition code 3
is set. If the decimal-overflow mask is one, a //
'FB' L L B D B D
program interruption for decimal overflow occurs. //
Overflow cannot occur for a right shift, with or 8 12 16 2 32 36 47
without rounding, or when no shifting is specified.

In the absence of overflow, the sign of a zero The second operand is subtracted from the first
result is made positive. If overflow occurs, the operand, and the resulting difference is placed at
sign of the result is the same as the original sign the first-operand location. The operands and
but with the preferred sign code. result are in the packed format.

A data exception is recognized when the first SUBTRACT DECIMAL is executed the same as
operand does not have valid sign and digit codes ADD DECIMAL, except that the second operand is
or when the rounding digit is not a valid digit code. considered to have a sign opposite to the sign in
The validity of the first-operand codes is checked storage. The second operand in storage remains
even when no shift is specified, and the validity of unchanged.
the rounding digit is checked even when no addi-
Resulting Condition Code:
tion for rounding takes place.
0 Result zero; no overflow
Resulting Condition Code: 1 Result less than zero; no overflow
0 Result zero; no overflow 2 Result greater than zero; no overflow
1 Result less than zero; no overflow 3 Overflow

8-12 z/Architecture Principles of Operation


Program Exceptions: Only the second operand is checked for valid sign
and digit codes. Extra zeros are supplied on the
Access (fetch, operand 2; fetch and store,
left for the shorter operand if needed.
operand 1)
Data
If the first operand is too short to contain all left-
Decimal overflow
most nonzero digits of the second operand,
decimal overflow occurs. The operation is com-
TEST DECIMAL pleted. The result is obtained by ignoring the
overflow digits, and condition code 3 is set. If the
TP D(L,B) [RSL] decimal-overflow mask is one, a program inter-
/ ruption for decimal overflow occurs.
'EB' L //// B D //////// 'C'
/ In the absence of overflow, the sign of a zero
8 12 16 2 32 4 47 result is made positive. If overflow occurs, a zero
result is given the sign of the second operand but
The first operand is tested for valid decimal digits with the preferred sign code.
and a valid sign code, and the result is indicated
The two operands may overlap, provided the right-
in the condition code. The operand is in the
most byte of the first operand is coincident with or
packed format.
to the right of the rightmost byte of the second
Resulting Condition Code: operand. In this case, the result is obtained as if
the operands were processed right to left. When
0 All digit codes and the sign valid the operands overlap and the rightmost byte of the
1 Sign invalid first operand is to the left of the rightmost byte of
2 At least one digit code invalid the second operand, then, depending on the
3 Sign invalid and at least one digit code invalid model, either a data exception is recognized or
the result is obtained as if the entire second
Program Exceptions: operand were fetched before any byte of the result
Access (fetch, operand 1) is stored.
Operation (if the extended-translation facility 2
is not installed) Resulting Condition Code:
0 Result zero; no overflow
ZERO AND ADD 1 Result less than zero; no overflow
2 Result greater than zero; no overflow
ZAP D(L,B),D(L,B) [SS] 3 Overflow
// Program Exceptions:
'F8' L L B D B D
// Access (fetch, operand 2; store, operand 1)
8 12 16 2 32 36 47 Data
Decimal overflow
The second operand is placed at the first-operand Programming Note: An example of the use of
location. The operation is equivalent to an addi- the ZERO AND ADD instruction is given in
tion to zero. The operand and result are in the Appendix A, Number Representation and
packed format. Instruction-Use Examples.

Chapter 8. Decimal Instructions 8-13


8-14 z/Architecture Principles of Operation
Chapter 9. Floating-Point Overview and Support Instructions
Registers And Controls . . . . . . . . . . . . . 9-2 BFP and HFP Number Ranges . . . . . . 9-4
Floating-Point Registers . . . . . . . . . . . 9-2 Equivalent BFP and HFP Number
Additional Floating-Point (AFP) Representations . . . . . . . . . . . . . . 9-4
Registers . . . . . . . . . . . . . . . . 9-2 Instructions . . . . . . . . . . . . . . . . . . . . 9-8
Valid Floating-Point-Register CONVERT BFP TO HFP . . . . . . . . . . 9-10
Designations . . . . . . . . . . . . . . 9-2 CONVERT HFP TO BFP . . . . . . . . . . 9-11
Floating-Point-Control (FPC) Register . . . 9-2 LOAD . . . . . . . . . . . . . . . . . . . . . 9-12
AFP-Register-Control Bit . . . . . . . . . . 9-2 LOAD ZERO . . . . . . . . . . . . . . . . . 9-13
Explicit Rounding Methods . . . . . . . . . 9-3 STORE . . . . . . . . . . . . . . . . . . . . 9-13
Summary of Rounding Action . . . . . . 9-3 Summary of All Floating-Point Instructions . . 9-13
Comparison of BFP and HFP Number
Representations . . . . . . . . . . . . . . . . 9-4

Floating-point instructions are used to perform cal- same for the short, long, and extended formats.
culations on operands having a wide range of The results of most operations on HFP data are
magnitude and to obtain results scaled to preserve truncated to fit into the target format, but there are
precision. instructions available to round the result when
converting to a narrower format. For HFP oper-
Floating-point operands have formats based on ands, the implicit unit digit of the significand is
either the radix 16 or the radix 2. The radix always zero. Since the value of the significand
values 16 and 2 lead to the terminology and fraction are the same, HFP operations are
hexadecimal and binary floating point (HFP and described in terms of the fraction, and the term
BFP). The formats are also based on three significand is not used.
operand lengths: short (32 bits), long (64 bits),
and extended (128 bits). Short operands require Binary-floating-point (BFP) operands have formats
less storage than long or extended operands. On which provide for exponents that specify powers of
the other hand, long and extended operands the radix 2 and significands that are binary
permit greater precision in computation. numbers. The exponent range differs for different
formats, the range being greater for the longer
A floating-point operand may be numeric or, for formats. In the long and extended formats, the
BFP only, nonnumeric (a not-a-number, or NaN). exponent range is significantly greater for BFP
A numeric operand, called a floating-point number, data than for HFP data. The results of operations
has three components: a sign bit, a signed binary performed on BFP data are rounded automatically
exponent, and a significand. The significand con- to fit into the target format; the manner of rounding
sists of an implicit unit digit to the left of an implied is determined by a program-settable rounding
radix point and an explicit fraction field to the right. mode.
The significand digits are based on the radix, 2 or
16. The magnitude (an unsigned value) of the Either normalized or unnormalized numbers may
number is the product of the significand and the be used as operands for any HFP operation,
radix raised to the power of the exponent. The where a normalized number is one having a
number is positive or negative depending on nonzero leftmost fraction digit. Most HFP
whether the sign bit is zero or one, respectively. instructions generate normalized results for
A nonnumeric BFP operand also has a sign bit, greatest precision. HFP add and subtract
signed exponent, and fraction field. instructions that generate unnormalized results are
also available.
Hexadecimal-floating-point (HFP) operands have
formats which provide for exponents that specify There are no unnormalized operands for BFP
powers of the radix 16 and significands that are operations. For normalized BFP numbers, the
hexadecimal numbers. The exponent range is the implicit unit digit of the significand is one. For

Copyright IBM Corp. 1990, 2000 9-1


values too small in magnitude to be represented in A number in the extended (128-bit) format occu-
normalized form, the implicit unit digit is zero. pies a register pair. Register pairs are formed by
These numbers are called denormalized coupling the 16 registers as follows: 0 and 2, 4
numbers. Unlike the HFP format, where the same and 6, 8 and 10, 12 and 14, 1 and 3, 5 and 7,
value can have multiple representations in a given 9 and 11, and 13 and 15.
format because of the possibility of unnormalized
numbers, the BFP format does not allow such Each of the eight pairs is referred to by the
redundancy. number of the lower-numbered register of the pair.

Both BFP and HFP data formats appear in Additional Floating-Point (AFP)
storage in the same left-to-right sequence as all Registers
other data formats. Bits of a data format that are Floating-point registers 0, 2, 4, and 6 are ones
numbered 0-7 constitute the byte in the leftmost that were originally available on ESA/390 models.
(lowest-numbered) byte location in storage, bits The remaining 12 floating-point registers (1, 3, 5,
8-15 form the byte in the next sequential location, and 7-15) were added to ESA/390 and are
and so on. (See also the section Storage referred to as the additional floating-point (AFP)
Addressing on page 3-2.) registers. The AFP registers can be used only if
bit 45 of control register 0, the
Most of the floating-point instructions are defined AFP-register-control bit, is one. Attempting to use
in detail in this publication in Chapter 18, an AFP register when the AFP-register-control bit
Hexadecimal-Floating-Point Instructions, and is zero results in an AFP-register data exception
Chapter 19, Binary-Floating-Point Instructions. (DXC 1).
This chapter, Chapter 9, defines in detail
instructions called floating-point-support (FPS) Valid Floating-Point-Register
instructions. The FPS instructions either have
Designations
operands that may be in either the BFP or the
Any installed register may be designated by an
HFP format or have the function of converting
instruction to specify the register location of a
between the two formats. This chapter also pro-
short or long floating-point operand.
vides summary information about all of the
floating-point instructions. An instruction specifying a floating-point operand
in the extended format must designate register 0,
1, 4, 5, 8, 9, 12, or 13; otherwise, a specification
Registers And Controls exception is recognized.

Floating-Point Registers Floating-Point-Control (FPC)


All floating-point instructions (FPS, BFP, and HFP)
Register
use the same 16 floating-point registers. The
The floating-point-control (FPC) register is a 32-bit
floating-point registers are identified by the
register that contains mask bits, flag bits, a data-
numbers 0-15 and are designated by a four-bit R
exception code, and rounding-mode bits. The
field in floating-point instructions. Each floating-
FPC register is described in the section Floating-
point register is 64 bits long and can contain either
Point-Control (FPC) Register on page 19-2.
a short (32-bit) or a long (64-bit) floating-point
operand.
AFP-Register-Control Bit
A short floating-point number requires only the
leftmost 32 bit positions of a floating-point register. Bit 45 of control register 0 is the
The rightmost 32 bit positions of the register are AFP-register-control bit. The AFP registers and
ignored when the register is the source of an the BFP instructions can be used successfully
operand in the short format, and, unless otherwise only when the AFP-register-control bit is one.
specified, they remain unchanged when a short Attempting to use one of the 12 additional floating-
result is placed in the register. point registers when the AFP-register-control bit is
zero results in an AFP-register data exception
(DXC 1). Attempting to execute any BFP instruc-

9-2 z/Architecture Principles of Operation


tion when the AFP-register-control bit is zero the carry, and discard the bits beyond the last
results in a BFP-instruction data exception (DXC one to be retained. If the difference was
2). If the conditions for both DXC 1 and DXC 2 exactly one-half ulp (a one in the bit position
exist, DXC 1 is reported. If the conditions for both just beyond the last place, with all zeros
a data exception and a specification exception beyond that), the nearest even number is
exist, it is unpredictable which exception is chosen; that is, after the rounding addition,
reported. the last result bit retained is set to zero.
5 Round toward 0:
The initial value of the AFP-register-control bit is
zero. Discard all bits to the right of the last
intermediate-result bit to be retained.
Explicit Rounding Methods 6 Round toward +:
If the intermediate result is positive and there
The floating-point-support instruction CONVERT
are any ones to the right of the last result bit
HFP TO BFP includes an M modifier field which
to be retained, add one to that bit. Then, for
can specify any of five rounding methods. One
either sign, discard the bits beyond the last
HFP instruction (CONVERT TO FIXED) and three
one to be retained.
BFP instructions (CONVERT TO FIXED, DIVIDE
TO INTEGER, and LOAD FP INTEGER) also 7 Round toward :
include either an M modifier field or a similar M
If the intermediate result is negative and there
modifier field. The five rounding methods are as
are any ones to the right of the last result bit
follows:
to be retained, subtract one from that bit (that
is, add one to the magnitude). Then, for
M
either sign, discard the bits beyond the last
or
one to be retained.
M Rounding Method
1 Biased round to nearest: The handling of an M or M value of zero
depends on the type of instruction. For BFP
Round the intermediate result up or down to
instructions, an M or M value of zero causes
the nearest representable value; that is, add,
rounding to be performed according to the current
ignoring the sign, a one to the bit just beyond
rounding mode specified in the FPC register. The
the last result bit to be retained, propagate
floating-point-support and HFP instructions treat
the carry, and discard the bits beyond the last
an M or M of zero the same as 5, that is, round
one to be retained.
toward zero.
4 Round to nearest:
Round the intermediate result up or down to Summary of Rounding Action
the nearest representable value; that is, add, Figure 9-1 on page 9-4 summarizes the rounding
ignoring the sign, a one to the bit just beyond action for floating-point-support (FPS), BFP, and
the last result bit to be retained, propagate HFP instructions.

Chapter 9. Floating-Point Overview and Support Instructions 9-3


Rounding Action Comparison of BFP and HFP
For Number Representations
FPS HFP BFP
Instruction Inst. Inst. Inst. BFP and HFP Number Ranges
ADD CRM
Figure 9-2 shows the range of numbers, in
ADD NORMALIZED GD decimal form, that can be represented in different
ADD UNNORMALIZED GD floating-point formats.
CONVERT BFP TO HFP E
CONVERT FROM FIXED RTZ CRM Type Short Long Extended

CONVERT HFP TO BFP M Nmax BFP 3.410+38 1.810+308 1.210+4932

CONVERT TO FIXED M M HFP 7.210+75 7.210+75 7.210+75


Nmin BFP 1.21038 2.210308 3.4104932
DIVIDE RTZ CRM
HFP 5.51079 5.51079 5.51079
DIVIDE TO INTEGER M
Dmin BFP 1.41045 4.910324 6.5104966
HALVE RTZ
HFP 5.21085 1.21094 1.710111
LOAD FP INTEGER RTZ M
Explanation:
LOAD ROUNDED BR CRM Dmin Smallest (in magnitude) representable
MULTIPLY RTZ CRM denormalized (BFP) or nonzero unnormal-
ized (HFP) number.
MULTIPLY AND ADD CRM Nmax Largest (in magnitude) representable
number.
MULTIPLY AND SUBTRACT CRM Nmin Smallest (in magnitude) representable nor-
SQUARE ROOT BR CRM malized number.

SUBTRACT CRM Values are decimal approximations.

SUBTRACT NORMALIZED GD Figure 9-2. Number Ranges for BFP and HFP
SUBTRACT UNNORMAL- Formats
IZED GD
Explanation: Equivalent BFP and HFP Number
Representations
BR Biased round to nearest.
CRM Rounded according to current rounding The exponent of an HFP number is represented in
mode. the number as an unsigned seven-bit binary
E Result is exact, no rounding is required. integer called the characteristic. The character-
GD Round using a guard digit; see the istic is obtained by adding 64 to the exponent
instruction definition. This is almost, but value (excess-64 notation). The range of the
not quite, round toward 0. characteristic is 0 to 127, which corresponds to an
M Rounding is specified by a modifier field exponent range of 64 to +63.
in the instruction.
RTZ Round toward 0. The exponent of a BFP number is represented in
the number as an unsigned binary integer called
Figure 9-1. Comparison of Rounding Action the biased exponent. The biased exponent is
obtained by adding a bias to the exponent value.
The number of bit positions containing the biased
exponent, the value of the bias, and the exponent
range depend on the number format (short, long,
or extended) and are shown for the three formats
in Figure 19-7 on page 19-5. Biased exponents

9-4 z/Architecture Principles of Operation


are similar to the characteristics of the HFP
Value S BE or C Fraction
format, except that special meanings are attached
to biased exponents of all zeros and all ones, 1.0 B 0 01111111
which are discussed in the section Classes of 00000000000000000000000
BFP Data on page 19-5. H 0 1000001
000100000000000000000000
In each of the three BFP or HFP formats, the 0.5 B 0 01111110
binary or hexadecimal point of a number, respec- 00000000000000000000000
tively, is considered to be to the left of the leftmost
H 0 1000000
fraction digit. To the left of the point there is an
100000000000000000000000
implied unit digit, which is considered to be zero
for HFP numbers or, for BFP numbers, one for 1/64 B 0 01111001
00000000000000000000000
normalized numbers and zero for zeros and
denormalized numbers. H 0 0111111
010000000000000000000000
Figure 9-3 and Figure 9-4 on page 9-6 give +0 B 0 00000000
examples of the closest representation of the 00000000000000000000000
same numbers in the BFP and HFP formats, with
H 0 0000000
BFP values being rounded to nearest and HFP 000000000000000000000000
values being truncated.
0 B 1 00000000
The figures do not necessarily show the results of 00000000000000000000000
BFP/HFP conversions exactly. Rounding errors H 1 0000000
may make a small difference. Also, Figure 9-3 000000000000000000000000
shows corresponding rounded short-format 15.0 B 1 10000010
numbers, not the long HFP results of conversion 11100000000000000000000
from short BFP operands.
H 1 1000001
111100000000000000000000
20/7 B 0 10000000
01101101101101101101110
H 0 1000001
001011011011011011011011
2126 B 0 00000001
00000000000000000000000
H 0 0100001
010000000000000000000000
2149 B 0 00000000
00000000000000000000001
H 0 0011011
100000000000000000000000
2128F B 0 11111110
F=1224 11111111111111111111111
H 0 1100000
111111111111111111111111
2260 B Zero (number too small)
H 0 0000000
000100000000000000000000
2248F B Not representable
F=1224
H 0 1111110
111111111111111111111111

Chapter 9. Floating-Point Overview and Support Instructions 9-5


Explanation: Figure 9-3. Examples of FP and HFP Numbers in
Short Format
B BFP.
BE or C Biased exponent of BFP number or charac-
teristic of HFP number.
H HFP.
S Sign.

9-6 z/Architecture Principles of Operation


Value S BE or C Fraction
1.0 B 0 01111111111 00000000000000000000
00000000000000000000000000000000
H 0 1000001 000100000000000000000000
00000000000000000000000000000000
0.5 B 0 01111111110 00000000000000000000
00000000000000000000000000000000
H 0 1000000 100000000000000000000000
00000000000000000000000000000000
1/64 B 0 01111111001 00000000000000000000
00000000000000000000000000000000
H 0 0111111 010000000000000000000000
00000000000000000000000000000000
+0 B 0 00000000000 00000000000000000000
00000000000000000000000000000000
H 0 0000000 000000000000000000000000
00000000000000000000000000000000
0 B 1 00000000000 00000000000000000000
00000000000000000000000000000000
H 1 0000000 000000000000000000000000
00000000000000000000000000000000
15.0 B 1 10000000010 11100000000000000000
00000000000000000000000000000000
H 1 1000001 111100000000000000000000
00000000000000000000000000000000
20/7 B 0 10000000000 01101101101101101101
10110110110110110110110110110111
H 0 1000001 001011011011011011011011
01101101101101101101101101101101
21022 B 0 00000000001 00000000000000000000
00000000000000000000000000000000
H Zero (number too small)
21074 B 0 00000000000 00000000000000000000
00000000000000000000000000000001
H Zero (number too small)
21024F B 0 11111111110 11111111111111111111
F=1253 11111111111111111111111111111111
H Not representable
2260 B 0 01011111011 00000000000000000000
00000000000000000000000000000000
H 0 0000000 000100000000000000000000
00000000000000000000000000000000
2248F B 0 10011110111 00000000000000000000
F=1256 00000000000000000000000000000000
H 0 1111110 111111111111111111111111
11111111111111111111111111111111

Chapter 9. Floating-Point Overview and Support Instructions 9-7


Explanation:
B BFP.
BE or C Biased exponent of BFP number or characteristic of HFP number.
H HFP.
S Sign.

Figure 9-4. Examples of BFP and HFP Numbers in Long Format

Mnemonics for the floating-point instructions have


Instructions an R as the last letter when the instruction is in
The floating-point-support instructions and their the RR, RRE, or RRF format. Certain letters are
mnemonics and operation codes are listed in used for floating-point instructions to represent
Figure 9-5 on page 9-9. The figure indicates, in operand-format length, as follows:
the column labeled Characteristics, the instruc-
tion format, when the condition code is set, the D Long
instruction fields that designate access registers, E Short
and the exceptional conditions in operand desig- X Extended
nations, data, or results that cause a program
interruption.
Note: In the detailed descriptions of the indi-
All floating-point-support instructions are subject to vidual instructions, the mnemonic and the sym-
the AFP-register-control bit, bit 45 of control reg- bolic operand designation for the assembler
ister 0. The AFP-register-control bit must be one language are shown with each instruction. For a
when an AFP register is specified as an operand register-to-register operation using LOAD (short),
location; otherwise, an AFP-register data excep- for example, LER is the mnemonic and R,R the
tion, DXC 1, is recognized. operand designation.

9-8 z/Architecture Principles of Operation



Mne- Op
Name monic Characteristics Code

CONVERT BFP TO HFP (long) THDR RRE C Da B359


CONVERT BFP TO HFP (short to long) THDERRRE C Da B358
CONVERT HFP TO BFP (long) TBDR RRF C SPDa B351
CONVERT HFP TO BFP (long to short) TBEDRRRF C SPDa B35
LOAD (extended) LXR RRE SPDa B365

LOAD (long) LDR RR Da 28


LOAD (long) LD RX A Da B68
LOAD (short) LER RR Da 38
LOAD (short) LE RX A Da B78
LOAD ZERO (extended) LZXR RRE SPDa B376

LOAD ZERO (long) LZDR RRE Da B375


LOAD ZERO (short) LZER RRE Da B374
STORE (long) STD RX A Da ST B6
STORE (short) STE RX A Da ST B7

Explanation:

A Access exceptions for logical addresses.
B B field designates an access register in the access-register mode.
C Condition code is set.
Da AFP-register data exception.
RR RR instruction format.
RRE RRE instruction format.
RRF RRF instruction format.
RX RX instruction format.
SP Specification exception.
ST PER storage-alteration event.

Figure 9-5. Summary of Floating-Point-Support Instructions

Chapter 9. Floating-Point Overview and Support Instructions 9-9


CONVERT BFP TO HFP Program Exceptions:
Data with DXC 1, AFP register
Mnemonic R,R [RRE]
Programming Notes:

Op Code //////// R R 1. The BFP-to-HFP conversion instructions are


summarized in Figure 9-7 on page 9-11.
16 24 28 31
2. CONVERT BFP TO HFP (THDER) converts
Mnemonic Op Code Operands BFP operands in the short format to HFP
THDER 'B358' Short BFP operand, operands in the long format, rather than con-
long HFP result
THDR 'B359' Long BFP operand, verting short to short, to retain full precision.
long HFP result Using this long HFP result subsequently as a
short operand requires no extra conversion
The second operand (the source operand) is con- steps.
verted from the binary-floating-point (BFP) format
to the hexadecimal-floating-point (HFP) format,
and the normalized result is placed at the first- Source Operand (a) Results
operand location. The sign and magnitude of the
source operand are tested to determine the setting a < Hmax T(Hmax), cc3
of the condition code. Hmax a Hmin T(r), cc1

For numeric operands, the sign of the result is the Hmin < a < 0 T(0), cc1
sign of the source operand. If the source operand 0 T(0), cc0
has a sign bit of one and all other operand bits
+0 T(+0), cc0
are zeros, the result also is a one followed by all
zeros. 0 < a < +Hmin T(+0), cc2
+Hmin a +Hmax T(r), cc2
When, for THDR, the characteristic of the result
would be negative, the result is made all zeros but +Hmax < a + T(+Hmax), cc3
with the same sign as that of the source operand,
NaN T(+Hmax), cc3
and condition code 1 or 2 is set to indicate the
sign of the source operand. Explanation:
Condition code 1 is set to indicate the
When, for THDR, the characteristic of the
source was less than zero.
hexadecimal intermediate result is too large to fit
Condition code 2 is set to indicate the
into the target format, the result is set to all ones
source was greater than zero.
(that is, the largest-in-magnitude representable
ccn Condition code is set to n.
number) but with the same sign as that of the
r The value derived when the BFP source
source operand, and condition code 3 is set.
value a is converted to the HFP format.
This result is always exact.
See Figure 9-6 for a detailed description of the
Hmax Largest (in magnitude) representable
results of this instruction.
number in the target HFP format.
Resulting Condition Code: Hmin Smallest (in magnitude) representable
normalized number in the target HFP
0 Source was zero format.
1 Source was less than zero T(x) The value x is placed at the target
2 Source was greater than zero operand location.
3 Special case
Figure 9-6. Results: CONVERT BFP TO HFP

9-10 z/Architecture Principles of Operation


Source Target
Overflow,
Mne- Significant Significant Underflow
Instruction monic Format Bits Format Bits Result Possible
CONVERT BFP TO THDER BFP short 24 HFP long 53-56 Exact No
HFP
THDR BFP long 53 HFP long 53-56 Exact Yes
CONVERT HFP TO TBEDR HFP long 53-56 BFP short 24 Rounded Yes
BFP
TBDR HFP long 53-56 BFP long 53 Rounded No

Figure 9-7. Summary of BFP-to/from-HFP Conversion Instructions

CONVERT HFP TO BFP The sign of the result is the sign of the second
operand. If the second operand has a sign bit of
Mnemonic R,M,R [RRF] one and all other operand bits are zeros, the
result also is a one followed by all zeros.

Op Code M //// R R See Figure 9-8 on page 9-12 for a detailed

16 2 24 28 31 description of the results of this instruction.

Mnemonic Op Code Operands The M field must designate a valid modifier; oth-
TBEDR 'B35' Long HFP operand, erwise, a specification exception is recognized.
short BFP result
TBDR 'B351' Long HFP operand, Resulting Condition Code:
long BFP result
0 Source was zero
The second operand (the source operand) is con- 1 Source was less than zero
verted from the hexadecimal-floating-point (HFP) 2 Source was greater than zero
format to the binary-floating-point (BFP) format, 3 Special case
and the result rounded according to the rounding
method specified by the M field is placed at the Program Exceptions:
first-operand location. The sign and magnitude of Data with DXC 1, AFP register
the source operand are tested to determine the Specification
setting of the condition code.
Programming Notes:
The M field contains a modifier specifying a
rounding method, as follows: 1. The HFP-to-BFP conversion instructions are
summarized in Figure 9-7.
M Rounding Method 2. Conversion to short BFP numbers requires
0 Round toward 0 HFP operands in the long format; a short HFP
1 Biased round to nearest operand should be extended to long by
4 Round to nearest ensuring that the right half of the register is
5 Round toward 0 cleared. Thus, the entire register should be
6 Round toward + cleared before loading a short HFP operand
7 Round toward into it for conversion to BFP. This avoids
unrepeatable rounding errors in the BFP result
A modifier other than 0, 1, or 4-7 is invalid. due to data left over from previous use.

Chapter 9. Floating-Point Overview and Support Instructions 9-11


Source Operand (a) Results
a < Nmax See Part 2 of this figure.
Nmax a Nmin T(r), cc1
Nmin < a Dmin T(d), cc1
Dmin < a < 0 T(d), cc1
0 T(0), cc0
+0 T(+0), cc0
0 < a < +Dmin T(d), cc2
+Dmin a < +Nmin T(d), cc2
+Nmin a +Nmax T(r), cc2
+Nmax < a See Part 2 of this figure.

Figure 9-8 (Part 1 of 2). Results: CONVERT HFP to BFP

Results for Rounding Method Specified in M


Source Biased Round to Round to Round toward Round toward
Operand (a) Nearest Nearest Round toward 0 +
a < Nmax T(), cc3 T(), cc3 T(Nmax), cc3 T(Nmax), cc3 T(), cc3
+Nmax < a T(+), cc3 T(+), cc3 T(+Nmax), cc3 T(+), cc3 T(+Nmax), cc3
Explanation:
Condition code 1 is set for this case, even when the rounded result is zero.
Condition code 2 is set for this case, even when the rounded result is zero.
ccn Condition code is set to n.
d The denormalized value derived when the HFP source value a is rounded to the format of the
target using the rounding method specified in the M field.
r The value derived when the HFP source value a is rounded to the format of the target using the
rounding method specified in the M field.
Dmin Smallest (in magnitude) representable denormalized number in the target BFP format.
Nmax Largest (in magnitude) representable finite number in the target BFP format.
Nmin Smallest (in magnitude) representable normalized number in the target BFP format.
T(x) The value x is placed at the target operand location.

Figure 9-8 (Part 2 of 2). Results: CONVERT HFP to BFP

LOAD Mnemonic2 R,R [RRE]


Mnemonic1 R,R [RR] Op Code //////// R R

16 24 28 31
Op Code R R
Mnemonic2 Op Code Operands
8 12 15 LXR 'B365' Extended
Mnemonic1 Op Code Operands
LER '38' Short
LDR '28' Long

9-12 z/Architecture Principles of Operation


Mnemonic3 R,D(X,B) [RX] Programming Note: LOAD ZERO sets all bits of
a register to zeros, which produces a positive zero
value in both the HFP and BFP formats.
Op Code R X B D

8 12 16 2 31 STORE
Mnemonic3 Op Code Operands Mnemonic R,D(X,B) [RX]
LE '78' Short
LD '68' Long
Op Code R X B D
The second operand is placed unchanged at the
first-operand location. 8 12 16 2 31

The operation is performed without inspecting the Mnemonic Op Code Operands


STE '7' Short
contents of the second operand; no arithmetic
STD '6' Long
exceptions are recognized.
The first operand is placed unchanged in storage
For LXR, the R fields must designate valid
at the second-operand location.
floating-point-register pairs; otherwise, a specifica-
tion exception is recognized. Condition Code: The code remains unchanged.
Condition Code: The code remains unchanged. Program Exceptions:
Program Exceptions: Access (store, operand 2)
Data with DXC 1, AFP register
Access (fetch, operand 2 of LE and LD only)
Data with DXC 1, AFP register
Specification (LXR only)
Summary of All Floating-Point
Instructions
LOAD ZERO
Figures 9-9 through 9-13 on following pages show
Mnemonic R [RRE] all floating-point instructions arranged in various
categories of operand format and type of opera-
tion (principally, register-and-register and register-
Op Code //////// R ////
and-storage operations). Figure 9-9 on

16 24 28 31 page 9-14 shows the floating-point-support


instructions. Figure 9-10 on page 9-14 shows the
Mnemonic Op Code Operands BFP and HFP instructions with all operands of the
LZER 'B374' Short same length. Figure 9-11 on page 9-15 shows
LZDR 'B375' Long the BFP and HFP instructions in which the result
LZXR 'B376' Extended
is longer than the source operand. Figure 9-12
on page 9-15 shows the BFP and HFP
All bits of the first operand are set to zeros.
instructions in which the result is shorter than the
For LZXR, The R field must designate a valid source operand. Figure 9-13 on page 9-15
floating-point-register pair; otherwise, a specifica- shows the other BFP instructions, including those
tion exception is recognized. instructions which operate on the FPC register.
The instructions CONVERT FROM FIXED and
Condition Code: The code remains unchanged. CONVERT TO FIXED convert between fixed-point
and floating-point formats. In the figures, entries
Program Exceptions: for 32-bit fixed-point operands are combined in the
same column with entries for 32-bit short oper-
Data with DXC 1, AFP register
ands, and entries for 64-bit fixed-point operands
Specification (LZXR only)
are combined in the same column with entries for
64-bit long operands.

Chapter 9. Floating-Point Overview and Support Instructions 9-13


Short (32) Long (64) Ext. (128) 32 to 64 64 to 32
Instruction Name R-R R-S R-R R-S R-R R-R R-R
CONVERT BFP TO HFP THDR THDER
CONVERT HFP TO BFP TBDR TBEDR
LOAD LER LE LDR LD LXR
LOAD ZERO LZER LZDR LZXR
STORE STE STD
Explanation:
R-R Register-and-register operation. .
R-S Register-and-storage operation. .

Figure 9-9. Floating-Point-Support Instructions

HFP Instructions BFP Instructions


Ext. Ext.
Short (32) Long (64) (128) Short (32) Long (64) (128)
Instruction Name R-R R-S R-R R-S R-R R-R R-S R-R R-S R-R
ADD AEBR AEB ADBR ADB AXBR
ADD NORMALIZED AER AE ADR AD AXR
ADD UNNORMALIZED AUR AU AWR AW
COMPARE CER CE CDR CD CXR CEBR CEB CDBR CDB CXBR
COMPARE AND SIGNAL KEBR KEB KDBR KDB KXBR
CONVERT FROM FIXED CEFR CDGR CEFBR CDGBR
CONVERT TO FIXED CFER CGDR CFEBR CGDBR
DIVIDE DER DE DDR DD DXR DEBR DEB DDBR DDB DXBR
DIVIDE TO INTEGER DIEBR DIDBR
HALVE HER HDR
LOAD AND TEST LTER LTDR LTXR LTEBR LTDBR LTXBR
LOAD COMPLEMENT LCER LCDR LCXR LCEBR LCDBR LCXBR
LOAD FP INTEGER FIER FIDR FIXR FIEBR FIDBR FIXBR
LOAD NEGATIVE LNER LNDR LNXR LNEBR LNDBR LNXBR
LOAD POSITIVE LPER LPDR LPXR LPEBR LPDBR LPXBR
MULTIPLY MEER MEE MDR MD MXR MEEBR MEEB MDBR MDB MXBR
MULTIPLY AND ADD MAEBR MAEB MADBR MADB
MULTIPLY AND SUBTRACT MSEBR MSEB MSDBR MSDB
SQUARE ROOT SQER SQE SQDR SQD SQXR SQEBR SQEB SQDBR SQDB SQXBR
SUBTRACT SEBR SEB SDBR SDB SXBR
SUBTRACT NORMALIZED SER SE SDR SD SXR
SUBTRACT UNNORMALIZED SUR SU SWR SW
TEST DATA CLASS TCEB TCDB TCXB
Explanation:
This instruction also has mixed-length operands.
R-R Register-and-register operation. .
R-S Register-and-storage operation. .

Figure 9-10. BFP and HFP Instructions with All Operands of Same Length

9-14 z/Architecture Principles of Operation


HFP Instructions BFP Instructions
32 to 64 64 to 128 32 to 128 32 to 64 64 to 128 32 to 128
Instruction Name R-R R-S R-R R-S R-R R-S R-R R-S R-R R-S R-R R-S
CONVERT FROM CDFR CXGR CXFR CDFBR CXGBR CXFBR
FIXED
CONVERT TO FIXED CGER CGEBR
LOAD LENGTHENED LDER LDE LXDR LXD LXER LXE LDEBR LDEB LXDBR LXDB LXEBR LXEB
MULTIPLY MDER MDE MXDR MXD MDEBR MDEB MXDBR MXDB
Explanation:
R-R Register-and-register operation. .
R-S Register-and-storage operation. .

Figure 9-11. BFP and HFP Instructions with Result Longer than Source

HFP Instructions BFP Instructions


64 to 32 128 to 64 128 to 32 64 to 32 128 to 64 128 to 32
Instruction Name R-R R-R R-R R-R R-R R-R
CONVERT FROM FIXED CEGR CEGBR CGXBR CFXBR
CONVERT TO FIXED CFDR CGXR CFXR CFDBR CGXBR CFXBR
LOAD ROUNDED LEDR LDXR LEXR LEDBR LDXBR LEXBR
Explanation:
R-R Register-and-register operation. .

Figure 9-12. BFP and HFP Instructions with Result Shorter than Source

Instruction Name Mnemonic


EXTRACT FPC EFPC
LOAD FPC LFPC
SET FPC SFPC
SET ROUNDING MODE SRNM
STORE FPC STFPC

Figure 9-13. Other BFP Instructions

Chapter 9. Floating-Point Overview and Support Instructions 9-15


9-16 z/Architecture Principles of Operation
Chapter 10. Control Instructions
BRANCH AND SET AUTHORITY . . . . . 10-6 PURGE ALB . . . . . . . . . . . . . . . . 10-79
BRANCH AND STACK . . . . . . . . . . 10-10 PURGE TLB . . . . . . . . . . . . . . . . 10-80
BRANCH IN SUBSPACE GROUP . . . . 10-13 RESET REFERENCE BIT EXTENDED . 10-80
COMPARE AND SWAP AND PURGE . 10-18 RESUME PROGRAM . . . . . . . . . . . 10-81
DIAGNOSE . . . . . . . . . . . . . . . . . 10-20 SET ADDRESS SPACE CONTROL . . . 10-83
EXTRACT AND SET EXTENDED SET ADDRESS SPACE CONTROL
AUTHORITY . . . . . . . . . . . . . . 10-20 FAST . . . . . . . . . . . . . . . . . . 10-83
EXTRACT PRIMARY ASN . . . . . . . . 10-20 SET CLOCK . . . . . . . . . . . . . . . . 10-85
EXTRACT SECONDARY ASN . . . . . . 10-21 SET CLOCK COMPARATOR . . . . . . 10-86
EXTRACT STACKED REGISTERS . . . 10-21 SET CLOCK PROGRAMMABLE FIELD .10-86
EXTRACT STACKED STATE . . . . . . 10-23 SET CPU TIMER . . . . . . . . . . . . . . 10-86
INSERT ADDRESS SPACE CONTROL .10-26 SET PREFIX . . . . . . . . . . . . . . . . 10-87
INSERT PSW KEY . . . . . . . . . . . . . 10-27 SET PSW KEY FROM ADDRESS . . . . 10-87
INSERT STORAGE KEY EXTENDED . 10-27 SET SECONDARY ASN . . . . . . . . . 10-88
INSERT VIRTUAL STORAGE KEY . . . 10-28 SET STORAGE KEY EXTENDED . . . . 10-91
INVALIDATE PAGE TABLE ENTRY . . . 10-29 SET SYSTEM MASK . . . . . . . . . . . 10-91
LOAD ADDRESS SPACE SIGNAL PROCESSOR . . . . . . . . . . 10-91
PARAMETERS . . . . . . . . . . . . . 10-30 STORE CLOCK COMPARATOR . . . . 10-93
LOAD CONTROL . . . . . . . . . . . . . 10-39 STORE CONTROL . . . . . . . . . . . . 10-93
LOAD PSW . . . . . . . . . . . . . . . . . 10-39 STORE CPU ADDRESS . . . . . . . . . 10-94
LOAD PSW EXTENDED . . . . . . . . . 10-40 STORE CPU ID . . . . . . . . . . . . . . 10-94
LOAD REAL ADDRESS . . . . . . . . . . 10-41 STORE CPU TIMER . . . . . . . . . . . . 10-95
LOAD USING REAL ADDRESS . . . . . 10-46 STORE FACILITY LIST . . . . . . . . . . 10-95
MODIFY STACKED STATE . . . . . . . 10-46 STORE PREFIX . . . . . . . . . . . . . . 10-95
MOVE PAGE . . . . . . . . . . . . . . . . 10-48 STORE REAL ADDRESS . . . . . . . . . 10-96
MOVE TO PRIMARY . . . . . . . . . . . 10-50 STORE SYSTEM INFORMATION . . . . 10-97
MOVE TO SECONDARY . . . . . . . . . 10-50 STORE THEN AND SYSTEM MASK . 10-107
MOVE WITH DESTINATION KEY . . . . 10-52 STORE THEN OR SYSTEM MASK . . 10-107
MOVE WITH KEY . . . . . . . . . . . . . 10-53 STORE USING REAL ADDRESS . . . 10-107
MOVE WITH SOURCE KEY . . . . . . . 10-54 TEST ACCESS . . . . . . . . . . . . . . 10-108
PAGE IN . . . . . . . . . . . . . . . . . . 10-55 TEST BLOCK . . . . . . . . . . . . . . . 10-110
PAGE OUT . . . . . . . . . . . . . . . . . 10-56 TEST PROTECTION . . . . . . . . . . 10-113
PROGRAM CALL . . . . . . . . . . . . . 10-57 TRACE . . . . . . . . . . . . . . . . . . 10-115
PROGRAM RETURN . . . . . . . . . . . 10-70 TRAP . . . . . . . . . . . . . . . . . . . 10-116
PROGRAM TRANSFER . . . . . . . . . . 10-74

This chapter includes all privileged and semiprivi- An attempt to execute a semiprivileged instruction
leged instructions described in this publication, in the problem state when the authority require-
except the input/output instructions, which are ments are not met generates a privileged-
described in Chapter 14, I/O Instructions. operation exception or some other
program-interruption condition depending on the
Privileged instructions may be executed only when particular requirement which is violated. Those
the CPU is in the supervisor state. An attempt to requirements which cause a privileged-operation
execute a privileged instruction in the problem exception to be generated in the problem state are
state generates a privileged-operation exception. not enforced when execution is attempted in the
supervisor state.
The semiprivileged instructions are those
instructions that can be executed in the problem The control instructions and their mnemonics,
state when certain authority requirements are met. formats, and operation codes are listed in

Copyright IBM Corp. 1990, 2000 10-1


Figure 10-1 on page 10-3. The figure also indi- instruction with the same name but with G added
cates which instructions are new in z/Architecture in its mnemonic, the first instruction has (32)
as compared to ESA/390, when the condition after its name, and the other instruction has (64)
code is set, the instruction fields that designate after its name.
access registers, and the exceptional conditions in
operand designations, data, or results that cause For those control instructions which have special
a program interruption. rules regarding the handling of exceptional situ-
ations, a section called Special Conditions is
The instructions that are new in z/Architecture are included. This section indicates the type of ending
indicated in Figure 10-1. by N. (suppression, nullification, or completion) only for
those exceptions for which the ending may vary.
When the operands of an instruction are 32-bit
Note: In the detailed descriptions of the indi-
operands, the mnemonic for the instruction does
vidual instructions, the mnemonic and the sym-
not include a letter indicating the operand length.
bolic operand designation for the assembler
If there is an instruction with the same name but
language are shown with each instruction. For
with 64-bit operands, its mnemonic includes the
LOAD PSW, for example, LPSW is the mnemonic
letter G. In Figure 10-1, when there is an
and D(B) the operand designation.
instruction with 32-bit operands and another

10-2 z/Architecture Principles of Operation



Mne- Op
Name monic Characteristics Code

BRANCH AND SET AUTHORITY BSA RRE Q A SO T B B25A


BRANCH AND STACK BAKR RRE A Z T B ST B24
BRANCH IN SUBSPACE GROUP BSG RRE A SO T B RB258
COMPARE AND SWAP AND PURGE CSP RRE C P A SP $ ST RB25
DIAGNOSE DM P DM MD83

EXTRACT AND SET EXTENDED AUTHORITY ESEA RRE N P B99D


EXTRACT PRIMARY ASN EPAR RRE Q SO B226
EXTRACT STACKED REGISTERS (32) EREG RRE A SE U UB249
EXTRACT STACKED REGISTERS (64) EREGGRRE N A SE U UB9E
EXTRACT STACKED STATE ESTA RRE C A SPSE B24A

EXTRACT SECONDARY ASN ESAR RRE Q SO B227


INSERT ADDRESS SPACE CONTROL IAC RRE C Q SO B224
INSERT PSW KEY IPK S Q G2 B2B
INSERT STORAGE KEY EXTENDED ISKE RRE P A B229
INSERT VIRTUAL STORAGE KEY IVSK RRE Q A SO RB223

INVALIDATE PAGE TABLE ENTRY IPTE RRE P A $ B221


LOAD ADDRESS SPACE PARAMETERS LASP SSE C P A SPSO B E5
LOAD CONTROL (32) LCTL RS P A SP BB7
LOAD CONTROL (64) LCTLGRSE N P A SP BEB2F
LOAD PSW LPSW S L P A SP B82

LOAD PSW EXTENDED LPSWES L N P A SP BB2B2


LOAD REAL ADDRESS (32) LRA RX C P A SO BPB1
LOAD REAL ADDRESS (64) LRAG RXE C N P A BPE33
LOAD USING REAL ADDRESS (32) LURA RRE P A SP B24B
LOAD USING REAL ADDRESS (64) LURAGRRE N P A SP B95

MODIFY STACKED STATE MSTA RRE A SPSE ST B247


MOVE PAGE MVPG RRE C Q A SP G STR RB254
MOVE TO PRIMARY MVCP SS C Q A SO ST DA
MOVE TO SECONDARY MVCS SS C Q A SO ST DB
MOVE WITH DESTINATION KEY MVCDKSSE Q A GM STB BE5F

MOVE WITH KEY MVCK SS C Q A STB BD9


MOVE WITH SOURCE KEY MVCSKSSE Q A GM STB BE5E
PAGE IN PGIN RRE C ESP A B22E
PAGE OUT PGOUTRRE C ESP A B22F
PROGRAM CALL PC S Q A Z T GM B ST B218

Figure 10-1 (Part 1 of 4). Summary of Control Instructions

Chapter 10. Control Instructions 10-3



Mne- Op
Name monic Characteristics Code

PROGRAM RETURN PR E L A SPZ T B ST 11


PROGRAM TRANSFER PT RRE Q A SPZ T B B228
PURGE ALB PALB RRE P $ B248
PURGE TLB PTLB S P $ B2D
RESET REFERENCE BIT EXTENDED RRBE RRE C P A B22A

RESUME PROGRAM RP S L Q A SPWE T B BB277


SET ADDRESS SPACE CONTROL SAC S Q SPSW B219
SET ADDRESS SPACE CONTROL FAST SACF S Q SPSW B279
SET CLOCK SCK S C P A SP BB24
SET CLOCK COMPARATOR SCKC S P A SP BB26

SET CLOCK PROGRAMMABLE FIELD SCKPFE P SP G 17


SET CPU TIMER SPT S P A SP BB28
SET PREFIX SPX S P A SP $ BB21
SET PSW KEY FROM ADDRESS SPKA S Q B2A
SET SECONDARY ASN SSAR RRE A Z T B225

SET STORAGE KEY EXTENDED SSKE RRE P A B22B


SET SYSTEM MASK SSM S P A SPSO B8
SIGNAL PROCESSOR SIGP RS C P $ AE
STORE CLOCK COMPARATOR STCKCS P A SP ST BB27
STORE CONTROL (32) STCTLRS P A SP ST BB6

STORE CONTROL (64) STCTGRSE N P A SP ST BEB25


STORE CPU ADDRESS STAP S P A SP ST BB212
STORE CPU ID STIDPS P A SP ST BB22
STORE CPU TIMER STPT S P A SP ST BB29
STORE FACILITY LIST STFL S N3P B2B1

STORE PREFIX STPX S P A SP ST BB211


STORE REAL ADDRESS STRAGSSE N P A B BPE52
STORE SYSTEM INFORMATION STSI S C P A SP GM ST BB27D
STORE THEN AND SYSTEM MASK STNSMSI P A STB AC
STORE THEN OR SYSTEM MASK STOSMSI P A SP STB AD

STORE USING REAL ADDRESS (32) STURARRE P A SP SU B246


STORE USING REAL ADDRESS (64) STURGRRE N P A SP SU B925
TEST ACCESS TAR RRE C A U B24C
TEST BLOCK TB RRE C P A II $ G B22C
TEST PROTECTION TPROTSSE C P A B E51

TRACE (32) TRACERS P A SP T B99


TRACE (64) TRACGRSE N P A SP T BEBF
TRAP TRAP2E A SO T B ST 1FF
TRAP TRAP4S A SO T B ST B2FF

Figure 10-1 (Part 2 of 4). Summary of Control Instructions

10-4 z/Architecture Principles of Operation



Explanation:

Causes serialization and checkpoint synchronization.
Causes serialization and checkpoint synchronization when the state entry to be unstacked
is a program-call state entry.
$ Causes serialization.
A Access exceptions for logical addresses.
A Access exceptions; not all access exceptions may occur; see instruction description for
details.
B PER branch event.
B B field designates an access register in the access-register mode.
B B field designates an access register in the access-register mode.
BP B field designates an access register when PSW bits 16 and 17 have the value 1 binary.
C Condition code is set.
DM Depending on the model, DIAGNOSE may generate various program exceptions and may change
the condition code.
ES Expanded-storage facility.
FC Designation of access registers depends on the function code of the instruction.
G Instruction execution includes the implied use of general register .
G2 Instruction execution includes the implied use of general register 2.
GM Instruction execution includes the implied use of multiple general
registers:
General registers and 1 for MOVE WITH DESTINATION KEY and MOVE WITH SOURCE KEY.
General registers 3, 4, and 14 for PROGRAM CALL.
General registers and 1 for STORE SYSTEM INFORMATION.
II Interruptible instruction.
L New condition code is loaded.
MD Designation of access registers in the access-register mode is model-dependent.
N Instruction is new in z/Architecture as compared to ESA/39.
N3 Instruction is new in z/Architecture and has been added to ESA/39.
P Privileged-operation exception.
Q Privileged-operation exception for semiprivileged instructions.
R R field designates an access register in the access-register mode.
R R field designates an access register in the access-register mode.
RRE RRE instruction format.
RS RS instruction format.
RSE RSE instruction format.
RX RX instruction format.
S S instruction format.
SE Special-operation, stack-empty, stack-specification, and stack-type exceptions.
SF Special-operation, stack-full, and stack-specification exceptions.
SI SI instruction format.
SO Special-operation exception.
SP Specification exception.
SS SS instruction format.
SSE SSE instruction format.
ST PER storage-alteration event.
SU PER store-using-real-address event.
SW Special-operation exception and space-switch event.
T Trace exceptions (which include trace table, addressing, and low-address protection).

Figure 10-1 (Part 3 of 4). Summary of Control Instructions

Chapter 10. Control Instructions 10-5



Explanation (Continued):

U R field designates an access register unconditionally.
U R field designates an access register unconditionally.
WE Space-switch event.
Z Additional exceptions and events for PROGRAM CALL (which include ASX-translation,
EX-translation, LX-translation, PC-translation-specification, special-operation,
stack-full, and stack-specification exceptions and space-switch event).
Z Additional exceptions and events for PROGRAM TRANSFER (which include AFX-translation,
ASX-translation, primary-authority, and special-operation exceptions and space-switch
event).
Z Additional exceptions for SET SECONDARY ASN (which include AFX translation,
ASX translation, secondary authority, and special operation).
Z Additional exceptions and events for PROGRAM RETURN (which include AFX-translation,
ASX-translation, secondary-authority, special-operation, stack-empty, stack-operation,
stack-specification, and stack-type exceptions and space-switch event).
Z Additional exceptions for BRANCH AND STACK (which include special operation, stack full,
and stack specification).

Figure 10-1 (Part 4 of 4). Summary of Control Instructions

BRANCH AND SET AUTHORITY in general register R if R is not zero; bits 32 and
97-127 of the PSW and the PKM, PSW key, and
BSA R,R [RRE] problem-state bit are replaced by values saved in
the DUCT; and the dispatchable unit is placed in
the base-authority state. In the 64-bit addressing
'B25A' //////// R R
mode, the action is the same except that bits

16 24 28 31 64-127 of the current PSW are saved in general


register R if R is not zero, those bits in the PSW
are replaced from the DUCT, and bit 32 of the
If the dispatchable unit is in the base-authority PSW is neither saved nor replaced.
state and the 24-bit or 31-bit addressing mode:
bits 32 and 97-127 of the current PSW, the basic- Words 5, 8, and 9 of the DUCT are used by this
addressing-mode bit and bits 33-63 of the updated instruction. The contents of those words are as
instruction address, are saved in the dispatchable- follows:
unit control table (DUCT); the PSW-key mask
(PKM), PSW key, and problem-state bit also are
saved in the DUCT; the PKM and PSW key are 5 PSW R
replaced using the contents of general register R; PSW-Key Mask Key A P

the problem-state bit is set to one; bits 32 and
16 24 28 31
97-127 of the PSW are replaced using the con-
tents of general register R; and the dispatchable
unit is placed in the reduced-authority state. In In the 24-Bit or 31-Bit Addressing Mode

the 64-bit addressing mode, the action is the 8 All Zeros
same except that bits 64-127 of the current PSW
are saved in the DUCT and replaced from general 31
register R, and bit 32 of the PSW is neither
saved nor replaced.
9 B
A Bits 33-63 of Return Address
If the dispatchable unit is in the reduced-authority
state and the 24-bit or 31-bit addressing mode: 1 31
bits 32 and 97-127 of the current PSW are saved

10-6 z/Architecture Principles of Operation


In the 64-Bit Addressing Mode The basic-addressing-mode bit is restored to the
PSW from the DUCT by BRANCH AND SET
8 Bits -31 of Return Address AUTHORITY executed in the reduced-authority

31 state.

Return Address: In the 24-bit or 31-bit


9 Bits 32-63 of Return Address addressing mode, bit positions 1-31 of word 9
contain bits 33-63 of the updated instruction
31 address, bits 97-127 of the PSW, saved by
BRANCH AND SET AUTHORITY executed in the
The fields in words 5, 8, and 9 of the DUCT are base-authority state. Bits 1-31 of word 9 of the
allocated as follows: DUCT are restored to bit positions 97-127 of the
PSW by BRANCH AND SET AUTHORITY exe-
PSW-Key Mask: Bit positions 0-15 of word 5 cuted in the reduced-authority state. In the 64-bit
contain the PSW-key mask (PKM), bits 32-47 of addressing mode, words 8 and 9 contain the
control register 3, saved by BRANCH AND SET updated instruction address saved by BRANCH
AUTHORITY executed in the base-authority state. AND SET AUTHORITY executed in the base-
The PKM is restored to control register 3 by authority state. The contents of words 8 and 9
BRANCH AND SET AUTHORITY executed in the are restored to bit positions 64-127 of the PSW by
reduced-authority state. BRANCH AND SET AUTHORITY executed in the
reduced-authority state.
PSW Key: Bit positions 24-27 of word 5 contain
the PSW key, bits 8-11 of the PSW, saved by In the 24-bit or 31-bit addressing mode, all zeros
BRANCH AND SET AUTHORITY executed in the are stored in word 8 when saving occurs in the
base-authority state. The PSW key is restored to base-authority state. In any addressing mode, all
the PSW by BRANCH AND SET AUTHORITY zeros are stored in bit positions 16-23, 29, and 30
executed in the reduced-authority state. of word 5 when saving occurs in the base-
authority state.
Reduced Authority (RA): Bit 28 of word 5 indi-
cates, when zero, that the dispatchable unit asso- All other fields in words 5, 8, and 9 remain
ciated with the DUCT is in the base-authority state unchanged when bit 28 of word 5 is set to zero in
or, when one, that the dispatchable unit is in the the reduced-authority state.
reduced-authority state. Bit 28 is set to one by
BRANCH AND SET AUTHORITY executed in the Base-Authority Operation
base-authority state, and it is set to zero by
BRANCH AND SET AUTHORITY executed in the When BRANCH AND SET AUTHORITY is exe-
reduced-authority state. cuted in the base-authority state, as indicated by
the reduced-authority (RA) bit in the DUCT being
Problem State (P): Bit position 31 of word 5 zero, R must be nonzero; otherwise, a special-
contains the problem-state bit, bit 15 of the PSW, operation exception is recognized. R may be
saved by BRANCH AND SET AUTHORITY exe- zero or nonzero.
cuted in the base-authority state. The problem-
state bit is restored to the PSW by BRANCH AND The contents of bit positions 32-63 of general reg-
SET AUTHORITY executed in the reduced- ister R and of general register R when the exe-
authority state. cution of the instruction begins in the
base-authority state are as follows:
Basic Addressing Mode (BA): In the 24-bit or
31-bit addressing mode, bit position 0 of word 9
contains the basic-addressing-mode bit, bit 32 of R Key Mask Key

the PSW, saved by BRANCH AND SET 32 48 56 6 63
AUTHORITY executed in the base-authority state.

Chapter 10. Control Instructions 10-7


In the 24-Bit or 31-Bit Addressing Mode A branch address is generated from bits 33-63 of
general register R under the control of the new
R Ignored basic addressing mode, and the result is placed in

31 bit positions 64-127 of the PSW as the new
instruction address.

B In the 64-bit addressing mode, a branch address
A Bits 33-63 of Branch Address is generated from bits 0-63 of general register R
and is placed in bit positions 64-127 of the PSW
32 63
as the new instruction address. Bit 32 of the PSW
remains unchanged.
In the 64-Bit Addressing Mode
Bits 48-55 and 60-63 of general register R may
R Bits -31 of Branch Address
be used for future extensions and should be
31 zeros; otherwise, the program may not operate
compatibly in the future.

Bits 32-63 of Branch Address Reduced-Authority Operation

32 63
When BRANCH AND SET AUTHORITY is exe-
cuted in the reduced-authority state, as indicated
In any addressing mode, the contents of bit posi- by the reduced-authority (RA) bit in the DUCT
tions 0-31 of general register R are ignored. In being one, R must be zero; otherwise, a special-
the 24-bit or 31-bit addressing mode, the contents operation exception is recognized. R may be
of bit positions 0-31 of general register R are zero or nonzero. The initial contents of general
ignored. registers R and R are ignored.

In the 24-bit or 31-bit addressing mode, PSW bits If R is nonzero in the 24-bit or 31-bit addressing
32 and 97-127 are saved in word 9 of the DUCT, mode, bits 32 and 97-127 of the current PSW, the
and zeros are stored in word 8. In the 64-bit basic-addressing-mode bit and bits 33-63 of the
addressing mode, PSW bits 64-127 are saved in updated instruction address, are placed in bit posi-
words 8 and 9 of the DUCT. In any addressing tions 32 and 33-63, respectively, of general reg-
mode, the PKM, the PSW key, and the problem- ister R, and bits 0-31 of the register remain
state bit are saved in word 5 of the DUCT, the RA unchanged. If R is nonzero in the 64-bit
bit in word 5 is set to one, and bits 16-23, 29, and addressing mode, bits 64-127 of the current PSW
30 of word 5 are set to zeros. are placed in bit positions 0-63 of general register
R. If R is zero, general register 0 remains
Bits 56-59 of general register R are placed in bit unchanged.
positions 8-11 of the PSW as the new PSW key.
In the problem state, the new PSW key must be In the 24-bit or 31-bit addressing mode, bit 0 of
authorized by the PKM; otherwise, if the new PSW word 9 of the DUCT is placed in PSW bit position
key is not authorized, a privileged-operation 32, and bits 1-31 of word 9, with 33 leftmost zeros
exception is recognized. appended, are placed in PSW bit positions
64-127.
After the new PSW key has been placed in the
PSW, bits 32-47 of general register R are ANDed In the 64-bit addressing mode, the contents of
with the PKM in control register 3, and the result words 8 and 9 of the DUCT are placed in PSW bit
replaces the PKM in control register 3. positions 64-127, and bit 32 of the PSW remains
unchanged.
The problem-state bit in the PSW is set to one.
In any addressing mode, the PKM, the PSW key,
In the 24-bit or 31-bit addressing mode, bit 32 of and the problem-state bit are restored from the
general register R is placed in bit position 32 of DUCT, and the RA bit is set to zero, as previously
the PSW as the new basic-addressing-mode bit. described. There is no test for whether the

10-8 z/Architecture Principles of Operation


restored PSW key is authorized by the restored Program Exceptions:
PKM.
Addressing (dispatchable-unit control table)
Privileged operation (selected PSW-key-mask
Special Conditions
bit is zero in the problem state, base-authority
R must be nonzero in the base-authority state operation only)
and zero in the reduced-authority state. If either Protection (low-address; dispatchable-unit
of these rules is violated, a special-operation control table)
exception is recognized, and the operation is sup- Special operation
pressed. Specification
Trace
In the problem state, the execution of the instruc-
tion in the base-authority state is subject to control Programming Notes:
by the PSW-key mask in control register 3. When 1. BRANCH AND SET AUTHORITY can improve
the bit in the PSW-key mask corresponding to the performance by replacing to-current-primary
PSW-key value to be set is one, the instruction is forms of PROGRAM TRANSFER (PT-cp) and
executed successfully. When the selected bit in basic (nonstacking) PROGRAM CALL (PC-cp)
the PSW-key mask is zero, a privileged-operation instructions. PT-cp and PC-cp are often used
exception is recognized. In the supervisor state, (within a single address space) to reduce the
any value for the PSW key is valid. authority of the PSW-key mask (PKM) or
change from supervisor state to problem state
The fetch, store, and update references to the during a calling linkage made by PT-cp and
DUCT are word-concurrent single-access refer- then to restore the PKM authority or super-
ences. The words of the DUCT are accessed in visor state during a return linkage made by
no particular order. PC-cp. Also, the PSW-key-setting operations
of BRANCH AND SET AUTHORITY can be
Key-controlled protection does not apply to any substituted for SET PSW KEY FROM
access made during the operation. Low-address ADDRESS instructions, and, since BRANCH
protection does apply. AND SET AUTHORITY combines branching
with PSW-key setting, it can be used to
In the 24-bit or 31-bit addressing mode, the con-
change the PSW key when branching from or
tents of word 9 of the DUCT are not checked for
to a fetch-protected program.
validity before they are loaded into the PSW.
However, after loading, a specification exception is 2. Only one base-authority state and one
recognized, and a program interruption occurs, reduced-authority state are available to a
when the newly loaded PSW contains a zero in bit dispatchable unit. Nested use of BRANCH
position 32 and the contents of bit positions AND SET AUTHORITY, that is, use within dif-
97-103 are not all zeros. In this case, the opera- ferent subroutine levels, is not possible. The
tion is completed, and the resulting instruction- requirement that R must be nonzero in the
length code is 0. The specification exception, base-authority state and zero in the reduced-
which in this case is listed as a program exception authority state provides detection of an
in this instruction, is described in Early Exception attempt to use BRANCH AND SET
Recognition on page 6-9. It may be considered AUTHORITY in the base-authority state when
as occurring early in the process of preparing to the dispatchable unit is already in the
execute the following instruction. reduced-authority state because of a previous
use of the instruction in the base-authority
The operation is suppressed on all addressing and state.
protection exceptions.
3. BRANCH AND SET AUTHORITY in the base
authority-state does not save an indication in
The priority of recognition of program exceptions
the DUCT of whether the current addressing
for the instruction is shown in Figure 10-2 on
mode is the extended (64-bit) addressing
page 10-10.
mode or a basic (24-bit or 31-bit) addressing
mode. The instruction, in either the base-
Condition Code: The code remains unchanged.
authority state or the reduced-authority state,

Chapter 10. Control Instructions 10-9



1.-6. Exceptions with the same priority as the priority of program-
interruption conditions for the general case.

7. Access exceptions for second instruction halfword.

8.A Trace exceptions.

8.B Protection exception (low-address protection) for access to
dispatchable-unit control table.

8.C.1 Addressing exception for access to dispatchable-unit control
table.

8.C.2 Special-operation exception due to R being zero in the base-
authority state or R being nonzero in the reduced-authority
state.

8.C.3 Privileged-operation exception due to selected PSW-key-mask
bit being zero (base-authority operation only).

9. Specification exception due to bit 32 of the newly loaded PSW
zero when bits 97-13 are not all zeros (reduced-authority
operation only).

Figure 10-2. Priority of Execution: BRANCH AND SET AUTHORITY

does not cause a switch between the BRANCH AND STACK


extended addressing mode and a basic
addressing mode. In the reduced-authority BAKR R,R [RRE]
state, the contents of words 8 and 9 of the
DUCT are interpreted based only on the
current addressing mode. If saving occurs in 'B24' //////// R R

the 31-bit addressing mode and then restoring 16 24 28 31
occurs in the 64-bit addressing mode, bit 0 of
word 9 of the DUCT will be used as an
address bit instead of as the basic- A linkage-stack branch state entry is formed, and
addressing-mode bit. If saving occurs in the the current PSW, except with an unpredictable
64-bit addressing mode and then restoring PER mask and with the addressing-mode bits and
occurs in the 24-bit addressing mode, an early instruction address replaced from the first
specification exception may be recognized, operand, is placed in the state entry. Subse-
after the instruction execution is completed, quently, the updated instruction address in the
because bits 97-103 of the PSW may be current PSW is replaced from the second
nonzero when bit 32 is zero. operand. Indications of the current addressing-
mode bits and the new instruction address are
4. The instruction may be referred to as BSA-ba placed in the state entry, and the PSW-key mask,
or BSA-ra depending on whether it is exe- PASN, SASN, EAX, and contents of general regis-
cuted in the base-authority state or the ters 0-15 and access registers 0-15 also are
reduced-authority state, respectively. placed in the state entry. The action associated
with an operand is not performed if the R field
designating the operand is zero.

When the R field is nonzero, the contents of


general register R specify an address referred to
as the return address.

When R is nonzero and bit 63 of general register


R is zero, the return address is generated from

10-10 z/Architecture Principles of Operation


the contents of the register under the control of branching) are placed in bit positions 33-63 of
the basic addressing mode specified by bit 32 of bytes 144-151 in the state entry, bit 32 of the
the register: 24-bit mode if bit 32 is zero, or 31-bit current PSW is placed in bit position 32 of those
mode if bit 32 is one. Bit 32 of the register and bytes, and zeros are placed in bit positions 0-31 of
the return address are substituted for the basic- the bytes.
addressing-mode bit, bit 32, and the updated
instruction address, respectively, in the current In the 64-bit addressing mode, bits 0-62 of the
PSW when the contents of that PSW are placed in branch address (or of the updated instruction
the state entry. The extended-addressing-mode address if the operation is performed without
bit, bit 31, is set to zero in the PSW that is placed branching) are placed in bit positions 0-62 of bytes
in the state entry. The contents of the current 144-151 in the state entry, and a one is placed in
PSW are not changed. bit position 63 of those bytes.

When R is nonzero and bit 63 of general register The entry-type code in the state entry is 0001100
R is one, the return address is generated from binary.
the contents of the register under the control of
the 64-bit addressing mode. Bits 0-62 of the Key-controlled protection does not apply to
return address, with a zero appended on the right, accesses to the linkage stack, but low-address
are substituted for the updated instruction address and page protection do apply.
in the current PSW when the contents of that
PSW are placed in the state entry. Bits 31 and 32 Special Conditions
are set to one in the PSW that is placed in the
The CPU must be in the primary-space mode or
state entry. The contents of the current PSW are
access-register mode; otherwise, a special-
not changed.
operation exception is recognized.
When the R field is zero, the current PSW is
A stack-full or stack-specification exception may
placed in the state entry without any change
be recognized during the stacking process.
except for an unpredictable PER mask.
The operation is suppressed on all addressing and
Subsequently, when the R field is nonzero, the
protection exceptions.
instruction address in the current PSW is replaced
by the branch address. The branch address is
The priority of recognition of program exceptions
generated from the contents of general register R
for the instruction is shown in Figure 10-3 on
under the control of the current addressing mode.
page 10-12.
When the R field is zero, the operation is per-
formed without branching.
Condition Code: The code remains unchanged.
The branch state entry is formed and information
Program Exceptions:
is placed in it as described in Stacking Process
on page 5-72. Access (fetch or store, except for key-
controlled protection, linkage-stack entry)
In the 24-bit or 31-bit addressing mode, bits 33-63 Special operation
of the branch address (or of the updated instruc- Stack full
tion address if the operation is performed without Stack specification
Trace

Chapter 10. Control Instructions 10-11



1.-6. Exceptions with the same priority as the priority of program-
interruption conditions for the general case.

7.A Access exceptions for second instruction halfword.

7.B Special-operation exception due to DAT being off or the CPU
being in secondary-space mode or home-space mode.

8.A Trace exceptions (only if R is nonzero).

8.B.1 Access exceptions (fetch) for entry descriptor of the current
linkage-stack entry.

Note: Exceptions 8.B.2-8.B.7 can occur only if there is not
enough remaining free space in the current linkage-stack
section.

8.B.2 Stack-specification exception due to remaining-free-space
value in current linkage-stack entry not being a multiple of
8.

8.B.3 Access exceptions (fetch) for second word of the trailer
entry of the current section. The entry is presumed to be a
trailer entry; its entry-type field is not examined.

8.B.4 Stack-full exception due to forward-section validity bit in
the trailer entry being zero.

8.B.5 Access exceptions (fetch) for entry descriptor of the header
entry of the next section. This entry is presumed to be a
header entry; its entry-type field is not examined.

8.B.6 Stack-specification exception due to not enough remaining
free space in the next section.

8.B.7 Access exceptions (store) for second word of the header entry
of the next section. If there is no exception, the header is
now called the current entry.

8.B.8 Access exceptions (store) for entry descriptor of the current
entry and for the new state entry.

Figure 10-3. Priority of Execution: BRANCH AND STACK

Programming Notes: 4. BRANCH AND STACK with a nonzero R


field is intended for use at or near the entry
1. Examples of the use of the BRANCH AND
point of a called program. The program may
STACK instruction are given in Appendix A,
be called by means of BRANCH AND LINK
Number Representation and Instruction-Use
(BALR) or BRANCH AND SAVE (BAS or
Examples.
BASR) from a program being executed in the
2. In no case does BRANCH AND STACK 24-bit or 31-bit addressing mode, by means of
change the current addressing mode. BRANCH AND SAVE AND SET MODE from a
3. The effect when the R field is zero is that the program being executed in any addressing
return address, which would otherwise be mode, or by means of a BRANCH AND SET
specified by the R general register, is the MODE instruction located in a glue module
address of the next sequential instruction. In and being executed in any addressing mode.
this case, BRANCH AND STACK provides a In all of these cases when the nonzero R
program-linkage function that is comparable to field of the calling instruction is the same as
the function of BRANCH AND SAVE. the R field of BRANCH AND STACK, and

10-12 z/Architecture Principles of Operation


even when the addressing mode was changed new PASCE in control register 1. Also, the sec-
during the calling linkage, BRANCH AND ondary ASN (SASN), bits 48-63 of control register
STACK correctly saves the addressing mode 3, is set equal to the primary ASN (PASN), bits
and return address of the calling program so 48-63 of control register 4. General register 0
that the subsequent execution of PROGRAM remains unchanged if the R field is zero.
RETURN will return correctly to the calling
program. The current primary address space is in the sub-
space group for the dispatchable unit if the current
primary-ASTE origin (PASTEO), bits 33-57 of
BRANCH IN SUBSPACE GROUP control register 5, designates the ASTE for the
BSG R,R [RRE] base space of the group. The PASTEO desig-
nates the base-space ASTE if the PASTEO is
equal to the base-ASTE origin (BASTEO), bits
'B258' //////// R R 1-25 of word 0 of the dispatchable-unit control
table (DUCT). For determining whether the
16 24 28 31
PASTEO equals the BASTEO, either the PASTEO
may be compared to the BASTEO or the entire
Provided that the current primary address space is contents of bit positions 32-63 of control register 5
in the subspace group, if any, associated with the may be compared to the entire contents of word 0
current dispatchable unit, the access-list-entry of the DUCT.
token (ALET) in access register R is translated
by means of a special form of access-register Ordinary ART is described in Access-Register-
translation (ART) to locate a destination Translation Process on page 5-48. The special
ASN-second-table entry (DASTE). If the DASTE ART performed by this instruction is contrasted to
specifies the base space of the subspace group, ordinary ART as follows:
the primary ASCE (PASCE) in control register 1 is
1. The special ART is performed regardless of
replaced by the ASCE in the DASTE. If the
whether the CPU is in the access-register
DASTE specifies a subspace of the group, bits
mode.
0-55 and 58-63 of the PASCE are replaced by the
same bits of the ASCE in the DASTE. In either 2. If the ALET being translated is 00000000 hex,
case, the the following actions also occur. called ALET 0, the DASTE is the ASTE for the
base space. Bit 0 of the DASTE is ignored.
In the 24-bit or 31-bit addressing mode, bits 32
3. If the ALET is 00000001 hex, called ALET 1,
and 97-127 of the current PSW, the basic-
the DASTE is the ASTE for the last subspace
addressing-mode bit and bits 33-63 of the updated
entered by the dispatchable unit by means of
instruction address, are saved in bit positions 32
BRANCH IN SUBSPACE GROUP. That
and 33-63, respectively, of general register R,
ASTE is designated by the subspace-ASTE
and bits 0-31 of the register remain unchanged.
origin (SSASTEO), bits 1-25 of word 1 of the
Subsequently, the basic-addressing-mode bit and
DUCT. A special-operation exception is
bits 33-63 of the instruction address in the current
recognized if a subspace has not previously
PSW are replaced from bit positions 32-63 of
been entered, as indicated by that the
general register R, and bits 0-31 of the register
SSASTEO is all zeros. An ASTE-validity
are ignored.
exception is recognized if bit 0 of the DASTE
In the 64-bit addressing mode, bits 64-127 of the is one. An ASTE-sequence exception is
current PSW, the updated instruction address, are recognized if the ASTE sequence number
saved in bit positions 0-63 of general register R. (ASTESN) in the DASTE does not equal the
Subsequently, the instruction address in the subspace ASTESN (SSASTESN) in word 3 of
current PSW is replaced from bit positions 0-63 of the DUCT. The DASTE located because of
general register R. Bit 32 of the PSW remains ALET 1 is considered to specify a subspace
unchanged. even if, due to an error, the DASTE is the
ASTE for the base space. That is, there is no
In any addressing mode, the secondary ASCE comparison of the SSASTEO to the BASTEO.
(SASCE) in control register 7 is set equal to the

Chapter 10. Control Instructions 10-13


4. If the ALET is other than ALET 0 and ALET 1, If the DASTE specifies the base space of the sub-
an ASTE is located by obtaining its origin from space group, the PASCE in control register 1 is
an access-list entry (ALE) in a way similar to replaced by the ASCE in the DASTE. If the
ordinary ART, and the DASTE is that located DASTE specifies a subspace, bits 0-55 and 58-63
ASTE. In this case, as in ordinary ART: of the PASCE are replaced by the same bits of
the ASCE in the DASTE, and bits 56 and 57 of
An ALET-specification exception is recog-
the PASCE, the storage-alteration-event bit and
nized if bits 0-6 of the ALET are not zeros.
space-switch-event-control bit, remain unchanged.
An ALEN-translation exception is recog-
nized if the ALE is outside the effective If R is nonzero in the 24-bit or 31-bit addressing
access list or bit 0 of the ALE is one. mode, bits 32 and 97-127 of the current PSW, the
basic-addressing-mode bit and bits 33-63 of the
An ASTE-validity exception is recognized
updated instruction address, are placed in bit posi-
if bit 0 of the DASTE is one.
tions 32 and 33-63, respectively, of general reg-
An ASTE-sequence exception is recog- ister R, and bits 0-31 of the register remain
nized if the ASTE sequence number unchanged. If R is nonzero in the 64-bit
(ASTESN) in the DASTE does not equal addressing mode, bits 64-127 of the current PSW,
the ASTESN in the ALE. the updated instruction address, are placed in bit
The operation differs from ordinary ART in positions 0-63 of general register R. If R is
that the ALE sequence number (ALESN) in zero, general register 0 remains unchanged.
the ALE is not compared to the ALESN in the
Whether R is nonzero or zero, in the 24-bit or
ALET, and the private bit in the ALE is treated
31-bit addressing mode, bits 32-63 of general reg-
as zero. Thus, ALE-sequence and extended-
ister R specify the new basic addressing mode
authority exceptions cannot occur.
and designate the branch address. Bit 32 of the
The fetch-only bit in the ALE is ignored. register specifies the new basic addressing mode
and replaces bit 32 of the current PSW, and the
When the ALET is other than ALET 0 and ALET branch address is generated from the contents of
1, the special ART may be performed by using the bit positions 33-63 of the register under the control
ART-lookaside buffer (ALB). of the new basic addressing mode.

The DASTE located due to an ALET other than When R is nonzero or zero in the 64-bit
ALET 0 and ALET 1 may be the ASTE for the addressing mode, the contents of general register
base space of the subspace group associated with R designate the branch address. The branch
the dispatchable unit. The DASTE is the base- address is generated from the contents of the reg-
space ASTE if the DASTE origin (DASTEO) ister under the control of the 64-bit addressing
obtained from an ALE by ART equals the mode. Bit 32 of the PSW remains unchanged.
BASTEO in the DUCT. For determining whether
the DASTEO equals the BASTEO, either the Regardless of the addressing mode, the new
DASTEO may be compared to the BASTEO, or value for the PSW is computed before general
the DASTEO with one leftmost and six rightmost register R is changed.
zeros appended may be compared to the entire
contents of word 0 of the DUCT. If the DASTE is The secondary ASCE (SASCE) in control register
not the base-space ASTE, the DASTE is treated 7 is set equal to the new PASCE in control reg-
as the ASTE for a subspace of the dispatchable ister 1. The secondary ASN (SASN), bits 48-63 of
unit's subspace group provided that (1) the control register 3, is set equal to the primary ASN
subspace-group bit, bit 54, in the ASCE in the (PASN), bits 48-63 of control register 4.
DASTE is one, and (2) the DASTE does not
specify the base space of another subspace If the DASTE specifies the base space, the
group. The DASTE specifies the base space of subspace-active bit, bit 0 of word 1 of the DUCT,
another subspace group if the base-space bit, bit is set to zero, and bits 1-31 of word 1 remain
31 of word 0 of the DASTE, is one. A special- unchanged. If the DASTE specifies a subspace
operation exception is recognized if either of those by means of ALET 1, then (1) the subspace-active
two provisions is not met.

10-14 z/Architecture Principles of Operation


bit is set to one, (2) the SSASTEO in bit positions does not specify the base space or a subspace of
1-25 of word 1 remains unchanged, and (3) bits the subspace group.
26-31 of word 1 either are set to zeros or remain
unchanged. If the DASTE specifies a subspace The primary space-switch-event-control bit, bit 57
by means of an ALET other than ALET 1, then (1) of control register 1 either before or after the oper-
the subspace-active bit is set to one, (2) the ation, does not cause a space-switch-event
DASTEO is stored in bit positions 1-25 of word 1 program interruption to occur.
as the SSASTEO, (3) zeros are stored in bit posi-
tions 26-31 of word 1, and (4) the ASTESN in the Key-controlled protection does not apply to any
DASTE is stored in word 3 of the DUCT as the access made during the operation. Low-address
SSASTESN. protection does apply.

The fetch, store, and update references to the The operation is suppressed on all addressing and
DUCT are word-concurrent single-access refer- protection exceptions.
ences. The words of the DUCT are accessed in
no particular order. The priority of recognition of program exceptions
for the instruction is shown in the figure Priority of
The operation, since it changes a translation Execution: BRANCH IN SUBSPACE GROUP.
parameter in control register 1, causes all copies
of prefetched instructions to be discarded, except Condition Code: The code remains unchanged.
when in the home-space mode.
Program Exceptions:
Special Conditions Addressing (dispatchable-unit control table,
effective access-list designation, access-list
DAT must be on; otherwise, a special-operation entry, destination ASN-second-table entry)
exception is recognized. A special-operation ALET specification
exception is also recognized if the current primary ALEN translation
address space is not in a subspace group associ- ASTE sequence
ated with the current dispatchable unit, if the ALET ASTE validity
in access register R is ALET 1 but a subspace Protection (low-address; dispatchable-unit
has not previously been entered by the control table)
dispatchable unit by means of BRANCH IN SUB- Special operation
SPACE GROUP, or if the ALET used is other than Trace
ALET 0 and ALET 1 and the destination ASTE

Chapter 10. Control Instructions 10-15



1.-6. Exceptions with the same priority as the priority of program-
interruption conditions for the general case.

7.A Access exceptions for second instruction halfword.

7.B Special-operation exception due to DAT being off.

8.A Trace exceptions.

8.B Protection exception (low-address protection) for access to
dispatchable-unit control table.

8.C.1 Addressing exception for access to dispatchable-unit control
table.

8.C.2 Special-operation exception due to current primary address
space not being in a subspace group associated with the
current dispatchable unit (primary-ASTE origin in control
register 5 not equal to base-ASTE origin in dispatchable-unit
control table).

Note: Exception 8.C.3.A can occur only if the access-list-
entry token (ALET) in access register R is ALET .

8.C.3.A Addressing exception for access to base ASTE (ASTE designated
by base-ASTE origin in dispatchable-unit control table).

Note: Exceptions 8.C.3.B.1-8.C.3.B.4 can occur only if the
access-list-entry token (ALET) in access register R is
ALET 1.

8.C.3.B.1 Special-operation exception due to subspace-ASTE origin in
dispatchable-unit control table being zero.

8.C.3.B.2 Addressing exception for access to subspace ASTE.

8.C.3.B.3 ASTE-validity exception due to bit in subspace ASTE being
one.

8.C.3.B.4 ASTE-sequence exception due to ASTE sequence number in
subspace ASTE not being equal to subspace-ASTE sequence
number in dispatchable-unit control table.

Note: Exceptions 8.C.3.C.1-8.C.3.C.9 can occur only if the
access-list-entry token (ALET) in access register R is other
than ALET and ALET 1.

8.C.3.C.1 ALET-specification exception due to bits -6 of ALET not being
all zeros.

8.C.3.C.2 Addressing exception for access to effective access-list
designation.

8.C.3.C.3 ALEN-translation exception due to access-list entry being
outside the list.

Figure 10-4 (Part 1 of 2). Priority of Execution: BRANCH IN SUBSPACE GROUP

10-16 z/Architecture Principles of Operation



8.C.3.C.4 Addressing exception for access to access-list entry.

8.C.3.C.5 ALEN-translation exception due to I bit in access-list entry
being one.

8.C.3.C.6 Addressing exception for access to destination ASTE.

8.C.3.C.7 ASTE-validity exception due to bit in destination ASTE being
one.

8.C.3.C.8 ASTE-sequence exception due to ASTE sequence number (ASTESN)
in access-list entry not being equal to ASTESN in destination
ASTE.

8.C.3.C.9 Special-operation exception due to destination-ASTE origin not
equal to base-ASTE origin in dispatchable-unit control table
and (1) subspace-group bit, bit 54 in address-space-control
element in destination ASTE being zero or (2) base-space bit
bit 31, in destination ASTE being one.

Figure 10-4 (Part 2 of 2). Priority of Execution: BRANCH IN SUBSPACE GROUP

Programming Notes: setting the secondary ASN in control register


3 equal to the primary ASN in control register
1. See the discussion of BRANCH IN SUB-
4), the program in an address space given
SPACE GROUP in Subroutine Linkage
control by BRANCH IN SUBSPACE GROUP
without the Linkage Stack on page 5-10. It is
does not have access to the calling program's
intended that there be a separate
address space by means of that address
ASN-second-table entry (ASTE) for each of
space being the secondary address space.
the base space and each subspace of a sub-
space group. The ASTEs for the subspaces 4. When a dispatchable unit has used BRANCH
can be pseudo ASTEs as described in the IN SUBSPACE GROUP to enter a subspace
programming note in Address-Space and has not subsequently used BRANCH IN
Number on page 3-17. A subspace can SUBSPACE GROUP to return to the base
contain a subset of the storage in the base space, the dispatchable unit is said to be
space by having the DAT tables for the sub- subspace active. When PROGRAM CALL,
space designate a subset of the pages that PROGRAM TRANSFER, PROGRAM
are designated by the DAT tables for the base RETURN, SET SECONDARY ASN, or LOAD
space. A dispatchable unit has access to a ADDRESS SPACE PARAMETERS places an
subspace if an access-list entry designating ASCE in control register 1 as the primary
the ASTE for the subspace is in the primary- ASCE or in control register 7 as the sec-
space or dispatchable-unit access list of the ondary ASCE, and if (1) the ASCE has the
dispatchable unit. subspace-group bit on in it, (2) the
dispatchable unit is subspace active, and
2. BRANCH IN SUBSPACE GROUP can be
(3) the ASCE was obtained from the
used to give control from the base space to a
ASN-second-table entry (ASTE) for the base
subspace, from a subspace to another sub-
space of the current dispatchable unit, then
space, and from a subspace to the base
the instruction (any of the five named
space. The instruction can also be used to
instructions) replaces bits 0-55 and 58-63 of
give control from the base space to the base
the ASCE in the control register with the same
space or from a subspace to the same sub-
bits of the ASCE in the ASTE for the sub-
space.
space in which the dispatchable unit last had
3. Since BRANCH IN SUBSPACE GROUP sets control. Further details about the effects of
the secondary address-space-control element the subspace-group facility on the five named
(ASCE) in control register 7 equal to the new instructions are given in Subspace-
primary ASCE in control register 1 (along with

Chapter 10. Control Instructions 10-17


Replacement Operations on page 5-59 and The first and second operands are compared. If
in the definitions of the instructions. they are equal, the contents of bit positions 32-63
of general register R + 1 are stored at the
5. The use of BRANCH IN SUBSPACE GROUP
second-operand location, and a purging operation
(BSG) along with PROGRAM CALL (PC) and
is performed. If they are unequal, the second
either PROGRAM TRANSFER (PT) or
operand is loaded into the first-operand location.
PROGRAM RETURN (PR) can produce
The result of the comparison is indicated in the
results that may be unexpected. Consider the
condition code.
following sequence of operations:
a. Start in the base space The first operand is the contents of bit positions
32-63 of general register R. The second
b. BSG to a subspace
operand is a word in storage. The location of the
c. PC (the first PC) to an address space that leftmost byte of the second operand is designated
is not in the subspace group. by the contents of general register R.
d. PC (the second PC) to the base space.
The purging operation applies to ART-lookaside
Since the dispatchable unit is subspace
buffers (ALBs) and translation-lookaside buffers
active, control is given to the subspace.
(TLBs) in all CPUs in the configuration. Either
e. BSG back to the base space. ALBs or TLBs, or both ALBs and TLBs, may be
f. PT or PR (paired with the second PC) selected for purging. All entries are cleared from
back to the address space that is not in the selected buffers.
the subspace group.
The purging operation is specified by means of
g. PT or PR (paired with the first PC) back to bits 62 and 63 of general register R. When bit
the subspace group. Since the 62 is one, entries are cleared from ALBs. When
dispatchable unit is no longer subspace bit 63 is one, entries are cleared from TLBs.
active, control is given to the base space When bits 62 and 63 both are ones, entries are
even though the first PC was issued in the cleared from ALBs and TLBs. When bits 62 and
subspace. 63 both are zeros, no entries are cleared.
6. BRANCH IN SUBSPACE GROUP does not
The handling of the address in general register R
perform the serialization or checkpoint-
is dependent on the addressing mode. In the
synchronization functions, but it does cause all
24-bit addressing mode, the contents of bit posi-
copies of prefetched instructions to be dis-
tions 40-61 of general register R, with two zeros
carded except when in the home-space mode.
appended on the right, constitute the address, and
7. When the R field designates access register the contents of bit positions 0-39 are ignored. In
0, the access register is treated as containing the 31-bit addressing mode, the contents of bit
ALET 0 regardless of the contents of the positions 33-61 of the register, with two zeros
access register. appended on the right, constitute the address, and
the contents of bit positions 0-33 are ignored. In
COMPARE AND SWAP AND the 64-bit addressing mode, the contents of bit
positions 0-61 of the register, with two zeros
PURGE appended on the right, constitute the address.
CSP R,R [RRE]
The contents of the registers just described are
shown in Figure 10-5 on page 10-19.
'B25' //////// R R

16 24 28 31

10-18 z/Architecture Principles of Operation


A serialization function is performed before the
operand is fetched and again after the operation is
/ completed.
R /// First Operand
/
32 63 When an equal comparison occurs, this CPU
clears entries from its ALB and TLB, as specified
/ by bits 62 and 63 of general register R, and
R + 1 /// Swap Value signals all CPUs in the configuration to clear the
/ same specified entries from their ALBs and TLBs.
32 63
The ALB entries that are cleared are all ALB
24-Bit Addressing Mode access-list designations, access-list entries,
/ ASN-second-table entries, and authority-table
R /////////// Second-Op. Adr.AT entries. The TLB entries that are cleared are all
/ combined region-and-segment-table entries, page-
4 62 63
table entries, and real-space entries.
31-Bit Addressing Mode
/ The execution of COMPARE AND SWAP AND
R ////Second-Operand Address AT PURGE is not completed on the CPU which exe-
/ cutes it until (1) all specified entries have been
33 62 63 cleared from the ALB and TLB on this CPU and

(2) all other CPUs in the configuration have com-
64-Bit Addressing Mode
/ pleted any storage accesses, including the
R Second-Operand Address AT updating of the change and reference bits, by
/ using the specified ALB and TLB entries.
62 63
Special Conditions

Figure 10-5. Register Contents for COMPARE AND The R field must designate an even register; oth-
SWAP AND PURGE erwise, a specification exception is recognized.

When an equal comparison occurs, the contents Resulting Condition Code:


of bit positions 32-63 of general register R + 1
0 First and second operands equal, second
are stored at the second-operand location. The
operand replaced by bits 32-63 of general
fetch of the second operand for purposes of com-
register R + 1
parison and the store into the second-operand
1 First and second operands unequal, first
location appear to be a block-concurrent
operand replaced by second operand
interlocked-update reference as observed by other
2 --
CPUs.
3 --
When the result of the comparison is unequal, the
Program Exceptions:
second-operand is loaded into the first-operand
location, bits 0-31 of general register R remain Access (fetch and store, operand 2)
unchanged, and the second-operand location Privileged operation
remains unchanged. However, on some models, Specification
the second operand may be fetched and subse-
Programming Note: COMPARE AND SWAP
quently stored back unchanged at the second-
AND PURGE provides a broadcast form of the
operand location. This update appears to be a
PURGE ALB and PURGE TLB instructions, thus
block-concurrent interlocked-update reference as
making it possible to avoid uses of SIGNAL
observed by other CPUs.
PROCESSOR.

Chapter 10. Control Instructions 10-19


DIAGNOSE function must be performed. Since the func-
tion performed by DIAGNOSE may differ from
model to model and between versions of a
'83' model, the program should avoid issuing
DIAGNOSE unless the program recognizes
8 31 both the model number and version code
stored by STORE CPU ID.
The CPU performs built-in diagnostic functions, or
other model-dependent functions. The purpose of EXTRACT AND SET EXTENDED
the diagnostic functions is to verify proper func-
tioning of equipment and to locate faulty compo-
AUTHORITY
nents. Other model-dependent functions may ESEA R [RRE]
include disabling of failing buffers, reconfiguration
of CPUs, storage, and channel paths, and modifi-
cation of control storage. 'B99D' //////// R ////

Bits 8-31 may be used as in the SI or RS formats, 16 24 28 31
or in some other way, to specify the particular
diagnostic function. The use depends on the The extended authorization index (EAX), bits
model. 32-47 of control register 8, is saved in bit positions
32-47 of the first operand, and then the EAX in
The execution of the instruction may affect the control register 8 is replaced by the contents of bit
state of the CPU and the contents of a register or positions 48-63 of the first operand. Bits 0-31 of
storage location, as well as the progress of an I/O the first operand are ignored and remain
operation. Some diagnostic functions may cause unchanged.
the test indicator to be turned on.
Condition Code: The code remains unchanged.
Resulting Condition Code: The code is unpre-
dictable. Program Exceptions:
Privileged operation
Program Exceptions:
Privileged operation
Depending on the model, other exceptions
EXTRACT PRIMARY ASN
may be recognized. EPAR R [RRE]

Programming Notes:
'B226' //////// R ////
1. Since the instruction is not intended for
problem-state-program or control-program 16 24 28 31
use, DIAGNOSE has no mnemonic.
2. DIAGNOSE, unlike other instructions, does The 16-bit PASN, bits 48-63 of control register 4,
not follow the rule that programming errors are is placed in bit positions 48-63 of general register
distinguished from equipment errors. R. Bits 32-47 of the general register are set to
Improper use of DIAGNOSE may result in zeros, and bits 0-31 remain unchanged.
false machine-check indications or may cause
actual machine malfunctions to be ignored. It Special Conditions
may also alter other aspects of system opera-
tion, including instruction execution and The instruction must be executed with DAT on;
channel-program operation, to an extent that otherwise, a special-operation exception is recog-
the operation does not comply with that speci- nized.
fied in this publication. As a result of the
improper use of DIAGNOSE, the system may In the problem state, the extraction-authority
be left in such a condition that the power-on control, bit 36 of control register 0, must be one;
reset or initial-microprogram-loading (IML) otherwise, a privileged-operation exception is

10-20 z/Architecture Principles of Operation


recognized. In the supervisor state, the recognized. In the supervisor state, the
extraction-authority-control bit is not examined. extraction-authority-control bit is not examined.

The priority of recognition of program exceptions The priority of recognition of program exceptions
for the instruction is shown in Figure 10-6. for the instruction is shown in Figure 10-7.

Condition Code: The code remains unchanged. Condition Code: The code remains unchanged.

Program Exceptions: Program Exceptions:


Privileged operation (extraction-authority Privileged operation (extraction-authority
control is zero in the problem state) control is zero in the problem state)
Special operation Special operation


1.-6. Exceptions with the same priority as 1.-6. Exceptions with the same priority as
the priority of program-interruption the priority of program-interruption
conditions for the general case. conditions for the general case.

7.A Access exceptions for second instruc- 7.A Access exceptions for second instruc-
tion halfword. tion halfword.

7.B Special-operation exception due to 7.B Special-operation exception due to
DAT being off. DAT being off.

8. Privileged-operation exception due to 8. Privileged-operation exception due to
extraction-authority control, bit 36 extraction-authority control, bit 36
of control register , being zero in of control register , being zero in
problem state. problem state.

Figure 10-6. Priority of Execution: EXTRACT Figure 10-7. Priority of Execution: EXTRACT SEC-
PRIMARY ASN ONDARY ASN

EXTRACT SECONDARY ASN EXTRACT STACKED REGISTERS


ESAR R [RRE] EREG R,R [RRE]


'B227' //////// R //// 'B249' //////// R R

16 24 28 31 16 24 28 31

The 16-bit SASN, bits 48-63 of control register 3, EREGG R,R [RRE]
is placed in bit positions 48-63 of general register

R. Bits 32-47 of the general register are set to 'B9E' //////// R R
zeros, and bits 0-31 remain unchanged.
16 24 28 31
Special Conditions

The instruction must be executed with DAT on; Contents of a set of general registers and a set of
otherwise, a special-operation exception is recog- access registers that were saved in the last state
nized. entry in the linkage stack are restored to the regis-
ters. Each set of registers begins with register R
In the problem state, the extraction-authority and ends with register R.
control, bit 36 of control register 0, must be one;
otherwise, a privileged-operation exception is For EXTRACT STACKED REGISTERS (EREG),
the contents of bit positions 32-63 of the general
registers are restored, and the contents of bit posi-

Chapter 10. Control Instructions 10-21


tions 0-31 of the registers remain unchanged. For Special Conditions
EXTRACT STACKED REGISTERS (EREGG), the
contents of bit positions 0-63 of the general regis- The CPU must be in the primary-space mode,
ters are restored. In either case, the contents of access-register mode, or home-space mode; oth-
bit positions 0-31 of the access registers are erwise, a special-operation exception is recog-
restored. nized.

For each of the general registers and the access A stack-empty, stack-specification, or stack-type
registers, the registers are loaded in ascending exception may be recognized during the
order of their register numbers, starting with reg- unstacking process.
ister R and continuing up to and including reg-
ister R, with register 0 following register 15. The The operation is suppressed on all addressing
bit positions of each register are loaded from the exceptions.
position in the state entry where the contents of
the bit positions were saved when the state entry The priority of recognition of program exceptions
was created. The contents of the state entry for the instruction is shown in Figure 10-8 on
remain unchanged. page 10-23.

The last state entry is located as described in Condition Code: The code remains unchanged.
Unstacking Process on page 5-75. The state
entry remains in the linkage stack, and the
Program Exceptions:
linkage-stack-entry address in control register 15 Access (fetch, except for protection, linkage-
remains unchanged. stack entry)
Special operation
Key-controlled protection does not apply to refer- Stack empty
ences to the linkage stack. Stack specification
Stack type

10-22 z/Architecture Principles of Operation



1.-6. Exceptions with the same priority as the priority of program-
interruption conditions for the general case.

7.A Access exceptions for second instruction halfword.

7.B Special-operation exception due to DAT being off or the CPU
being in secondary-space mode.

8. Access exceptions (fetch) for entry descriptor of the current
linkage-stack entry.

9. Stack-type exception due to current entry not being a state
entry or header entry.

Note: Exceptions 1-14 can occur only if the current entry
is a header entry.

1. Access exceptions (fetch) for second word of the header entry.

11. Stack-empty exception due to backward stack-entry validity
bit in the header entry being zero.

12. Access exceptions (fetch) for entry descriptor of preceding
entry, which is the entry designated by the backward
stack-entry address in the current (header) entry.

13. Stack-specification exception due to preceding entry being a
header entry.

14. Stack-type exception due to preceding entry not being a state
entry.

15. Access exceptions (fetch) for the selected contents of the
state entry.

Figure 10-8. Priority of Execution: EXTRACT STACKED REGISTERS

EXTRACT STACKED STATE state-entry byte positions, or byte and bit posi-
tions, from which information is to be extracted, as
ESTA R,R [RRE] follows:

State-Entry Byte Posi-


'B24A' //////// R R Code (Bits 56-63 of tions, or Byte and Bit

16 24 28 31 Gen. Reg. R) Positions, Selected


0 128-135
Sixty-four or 128 bits of status information in the 1 136-139, 140.0, and
last state entry in the linkage stack are placed in 168-175.33-63 (see text)
the pair of general registers designated by the R 2 144-151
field. The condition code is set to indicate 3 152-159
whether the state entry is a branch state entry or 4 136-143 and 168-175
a program-call state entry.
For a code of 0, 2, or 3 in bit positions 56-63 of
The R field designates the even-numbered reg- general register R, the contents of the leftmost
ister of an even-odd pair of general registers. four bytes of the eight bytes of status information
are placed in bit positions 32-63 of general reg-
Bits 56-63 of general register R are an unsigned ister R, and the contents of the rightmost four
binary integer that is used as a code to select the bytes of the status information are placed in bit
positions 32-63 of general register R + 1. The

Chapter 10. Control Instructions 10-23


contents of bit positions 0-31 of general registers In a Branch State Entry Made in
R and R + 1 remain unchanged. 64-Bit Mode

Bits -62 of Branch Address 1
For a code of one in bit positions 56-63 of general

register R, the contents of bytes 136-139 of the 144 151
state entry, which are bits 0-31 of the PSW in the
state entry, are placed in bit positions 32-63 of
In a Program-Call State Entry Made
general register R; the contents of bit position 0 when Resulting Mode is 24-Bit or 31-Bit
of byte 140 of the entry, which is bit 32 of that
PSW, are placed in bit position 32 of general reg- Called-Space Id. PC Number
ister R + 1; and the contents of bit positions
33-63 of bytes 168-175 of the entry, which are bits 144 148 151
97-127 of the PSW, are placed in bit positions
33-63 of general register R + 1. However, bit 44 In a Program-Call State Entry Made
of general register R, which corresponds to bit 12 when Resulting Mode is 64-Bit

of the PSW in the state entry, is set to one, indi-
Called-Space Id.1 PC Number
cating the ESA/390 mode. Also, if bits 0-32 of
bytes 168-175 of the state entry are not all zeros, 144 148 151
bit 63 of general register R + 1 is set to one;
otherwise, bit 63 remains with the value loaded
from bit position 63 of bytes 168-175 of the state Modifiable Area
entry. The contents of bit positions 0-31 of
general registers R and R + 1 remain 152 159
unchanged.

For a code of 4 in bit positions 56-63 of general All Zeros
register R, the contents of bytes 136-143 of the
state entry, which are bits 0-63 of the PSW in the 16 167
state entry, are placed in bit positions 0-63 of
general register R, and the contents of bytes
168-175 of the state entry, which are bits 64-127 PSW Bits 64-127

of that PSW, are placed in bit positions 0-63 of 168 175
general register R + 1.

The format of byte positions 128-175 of the state The contents of the state entry remain unchanged.
entry is as follows:
The last state entry is located as described in
Unstacking Process on page 5-75. The state
PKM SASN EAX PASN entry remains in the linkage stack, and the
linkage-stack-entry address in control register 15
128 13 132 134 135
remains unchanged.

When the entry-type code in the entry descriptor


PSW Bits -63 of the state entry is 0001100 binary, indicating a

136 143 branch state entry, the condition code is set to 0.


When the entry-type code is 0001101 binary, indi-
cating a program-call state entry, the condition
In a Branch State Entry Made in
code is set to 1.
24-Bit or 31-Bit Mode

Bits 33-63 of Key-controlled protection does not apply to refer-


A Branch Address ences to the linkage stack.

144 148 151 Bits 0-55 of general register R are ignored.

10-24 z/Architecture Principles of Operation


Special Conditions 0 Branch state entry
1 Program-call state entry
A specification exception is recognized when R is 2 --
odd or the code in bit positions 56-63 of general 3 --
register R is greater than 4.
Program Exceptions:
The CPU must be in the primary-space mode,
Access (fetch, except for protection, linkage-
access-register mode, or home-space mode; oth-
stack entry)
erwise, a special-operation exception is recog-
Special operation
nized.
Specification
A stack-empty, stack-specification, or stack-type Stack empty
exception may be recognized during the Stack specification
unstacking process. Stack type
Programming Note: The results for a code of
The operation is suppressed on all addressing one in bit positions 56-63 of general register R
exceptions. are intended to provide compatibility with
ESA/390. (It may be that only values of bits in bit
The priority of recognition of program exceptions positions 0-31 of the PSW are required.) Bit 63 of
for the instruction is shown in Figure 10-9 on general register R + 1 is set to one if the instruc-
page 10-26. tion address in the PSW in the state entry is larger
than a 31-bit address.
Resulting Condition Code:

Chapter 10. Control Instructions 10-25



1.-6. Exceptions with the same priority as the priority of program-
interruption conditions for the general case.

7.A Access exceptions for second instruction halfword.

7.B Special-operation exception due to DAT being off or the CPU
being in secondary-space mode.

8.A Specification exception due to R being odd or bits 56-63 of
general register R having a value greater than 4.

8.B.1 Access exceptions (fetch) for entry descriptor of the current
linkage-stack entry.

8.B.2 Stack-type exception due to current entry not being a state
entry or header entry.

Note: Exceptions 8.B.3-8.B.7 can occur only if the current
entry is a header entry.

8.B.3 Access exceptions (fetch) for second word of the header entry.

8.B.4 Stack-empty exception due to backward stack-entry validity
bit in the header entry being zero.

8.B.5 Access exceptions (fetch) for entry descriptor of preceding
entry, which is the entry designated by the backward
stack-entry address in the current (header) entry.

8.B.6 Stack-specification exception due to preceding entry being a
header entry.

8.B.7 Stack-type exception due to preceding entry not being a state
entry.

8.B.8 Access exceptions (fetch) for the selected contents of the
state entry.

Figure 10-9. Priority of Execution: EXTRACT STACKED STATE

INSERT ADDRESS SPACE Special Conditions


CONTROL The instruction must be executed with DAT on;
IAC R [RRE] otherwise, a special-operation exception is recog-
nized.

'B224' //////// R //// In the problem state, the extraction-authority


control, bit 36 of control register 0, must be one;
16 24 28 31 otherwise, a privileged-operation exception is
recognized. In the supervisor state, the
The address-space-control bits, bits 16 and 17 of extraction-authority-control bit is not examined.
the current PSW, are placed in reversed order in
bit positions 54 and 55 of general register R; that The priority of recognition of program exceptions
is, bit 16 is placed in bit position 55, and bit 17 is for the instruction is shown in Figure 10-10 on
placed in bit position 54. Bits 48-53 of the register page 10-27.
are set to zeros, and bits 0-47 and 56-63 of the
register remain unchanged. The address-space- Resulting Condition Code:
control bits are also used to set the condition
code.

10-26 z/Architecture Principles of Operation


0 PSW bits 16 and 17 zeros (indicating primary- INSERT PSW KEY
space mode)
1 PSW bit 16 one and bit 17 zero (indicating IPK [S]
secondary-space mode)
2 PSW bit 16 zero and bit 17 one (indicating
access-register mode) 'B2B' ////////////////

3 PSW bits 16 and 17 ones (indicating home- 16 31
space mode)

Program Exceptions: The four-bit PSW-key, bits 8-11 of the current


PSW, is inserted in bit positions 56-59 of general
Privileged operation (extraction-authority register 2, and bits 60-63 of that register are set to
control is zero in the problem state) zeros. Bits 0-55 of general register 2 remain
Special operation unchanged.

1.-6. Exceptions with the same priority as Special Conditions


the priority of program-interruption
conditions for the general case. In the problem state, the extraction-authority
control, bit 36 of control register 0, must be one;
7.A Access exceptions for second instruc- otherwise, a privileged-operation exception is
tion halfword. recognized. In the supervisor state, the

7.B Special-operation exception due to extraction-authority-control bit is not examined.
DAT being off.
Condition Code: The code remains unchanged.
8. Privileged-operation exception due to
extraction-authority control, bit 36 Program Exceptions:
of control register , being zero in
problem state. Privileged operation (extraction-authority
control is zero in the problem state)
Figure 10-10. Priority of Execution: INSERT
ADDRESS SPACE CONTROL INSERT STORAGE KEY
EXTENDED
Programming Notes:
1. Bits 48-53 of general register R are reserved ISKE R,R [RRE]
for expansion for use with possible future facil-

ities. The program should not depend on 'B229' //////// R R
these bits being set to zeros.
16 24 28 31
2. INSERT ADDRESS SPACE CONTROL and
SET ADDRESS SPACE CONTROL are
defined to operate on the seventh byte of a The storage key for the block that is addressed by
general register so that the address-space- the contents of general register R is inserted in
control bits can be saved in the same general general register R.
register as the PSW key, which is placed in
the eight byte of general register 2 by INSERT In the 24-bit addressing mode, bits 40-51 of
PSW KEY. general register R designate a 4K-byte block in
real storage, and bits {0-7} and 52-63 of the reg-
ister are ignored. In the 31-bit addressing mode,
bits 33-51 of general register R designate a
4K-byte block in real storage, and bits 0-32 and
52-63 of the register are ignored. In the 64-bit
addressing mode, bits 0-51 of general register R
designate a 4K-byte block in real storage, and bits
52-63 of the register are ignored.

Chapter 10. Control Instructions 10-27


The address designating the storage block, being Bits 0-4 of the storage key, which are the access-
a real address, is not subject to dynamic address control bits and the fetch-protection bit, are placed
translation. The reference to the storage key is in bit positions 56-60 of general register R, with
not subject to a protection exception. bits 61-63 set to zeros. The contents of bit posi-
tions 0-55 of the register remain unchanged. The
The seven-bit storage key is inserted in bit posi- change and reference bits in the storage key are
tions 56-62 of general register R, and bit 63 is not inspected. The change bit is not affected by
set to zero. The contents of bit positions 0-55 of the operation. The reference bit, depending on
the register remain unchanged. the model, may or may not be set to one as a
result of the operation.
Condition Code: The code remains unchanged.
The following diagram shows the storage key and
Program Exceptions: the register positions just described.
Addressing (address specified by general reg- Storage Key
ister R) for the
Privileged operation Location

ACC FRC
INSERT VIRTUAL STORAGE KEY

IVSK R,R [RRE]
Zeros
6
'B223' //////// R R 6
/
16 24 28 31 R ACC F
/
56 6 63
The storage key for the location designated by the
virtual address in general register R is inserted in Special Conditions
general register R.
The instruction must be executed with DAT on;
Selected bits of general register R are used as a otherwise, a special-operation exception is recog-
virtual address. In the 24-bit addressing mode, nized.
the address is designated by bits 40-63 of the reg-
ister, and bits 0-39 are ignored. In the 31-bit In the problem state, the extraction-authority
addressing mode, the address is designated by control, bit 36 of control register 0, must be one;
bits 33-63, and bits 0-32 is ignored. In the 64-bit otherwise, a privileged-operation exception is
addressing mode, the address is designated by recognized. In the supervisor state, the
bits 0-63 of the register. extraction-authority-control bit is not examined.

The address is a virtual address and is subject to The priority of recognition of program exceptions
the address-space-control bits, bits 16 and 17 of for the instruction is shown in Figure 10-11 on
the current PSW. The address is treated as a page 10-29.
primary virtual address in the primary-space
mode, as a secondary virtual address in the Condition Code: The code remains unchanged.
secondary-space mode, as an AR-specified virtual
address in the access-register mode, or as a Program Exceptions:
home virtual address in the home-space mode. Access (except for protection, address speci-
The reference to the storage key is not subject to fied by general register R)
a protection exception. Privileged operation (extraction-authority
control is zero in the problem state)
Special operation

10-28 z/Architecture Principles of Operation


/
1.-6. Exceptions with the same priority as R Page-Table Origin ///////////
the priority of program-interruption /
conditions for the general case. 53 63

7.A Access exceptions for second instruc-
tion halfword. /
R /////////////// PX ////////////
7.B Special-operation exception due to DAT /
being off. 44 52 63

8. Privileged-operation exception due to The page-table origin and the page index desig-
extraction-authority control, bit 36 of
control register , being zero. nate a page-table entry, following the dynamic-
address-translation rules for page-table lookup.
9. Access exceptions (except for protec- The page-table origin is treated as a 64-bit
tion) for address specified by general address, and the addition is performed by using
register R. the rules for 64-bit address arithmetic, regardless

of the current addressing mode, which is specified


Figure 10-11. Priority of Execution: INSERT VIRTUAL by bits 31 and 32 of the current PSW. A carry out
STORAGE KEY of bit position 0 as a result of the addition of the
page index and page-table origin cannot occur.
Programming Notes: The address formed from these two components
1. Since all bytes in a 4K-byte block are associ- is a real or absolute address. The page-invalid bit
ated with the same page and the same of this page-table entry is set to one. During this
storage key, bits 52-63 of general register R procedure, the page-table entry is not inspected
essentially are ignored. for availability of the page or for format errors.
Additionally, the page-frame real address con-
2. In the access-register mode, access register 0 tained in the entry is not checked for an
designates the primary address space regard- addressing exception.
less of the contents of access register 0.
The entire page-table entry is fetched concurrently
INVALIDATE PAGE TABLE from storage. Subsequently, the byte containing
ENTRY the page-invalid bit is stored. The fetch access to
the page-table entry is subject to key-controlled
IPTE R,R [RRE] protection, and the store access is subject to key-
controlled protection and low-address protection.

'B221' //////// R R A serialization function is performed before the


operation begins and again after the operation is
16 24 28 31
completed. As is the case for all serialization
operations, this serialization applies only to this
The designated page-table entry is invalidated, CPU; other CPUs are not necessarily serialized.
and the translation-lookaside buffers (TLBs) in all
CPUs in the configuration are cleared of the asso- If it is successful in setting the page-invalid bit to
ciated entries. one, this CPU clears selected entries from its TLB
and signals all CPUs in the configuration to clear
The contents of general register R have the selected entries from their TLBs. Each TLB is
format of a segment-table entry with only the cleared of at least those entries that have been
page-table origin used. The contents of general formed using all of the following:
register R have the format of a virtual address
with only the page index used. The contents of The page-table origin designated by the first
fields that are not part of the page-table origin or operand
page index are ignored. The page index designated by the second
operand
The contents of the general registers just
described are as follows:

Chapter 10. Control Instructions 10-29


The page-frame real address contained in the another CPU or a channel program may also
designated page-table entry be updating the location.
The execution of INVALIDATE PAGE TABLE
ENTRY is not completed on the CPU which exe- LOAD ADDRESS SPACE
cutes it until (1) all entries corresponding to the PARAMETERS
specified parameters have been cleared from the
TLB on this CPU and (2) all other CPUs in the LASP D(B),D(B) [SSE]
configuration have completed any storage
accesses, including the updating of the change //
'E5' B D B D
and reference bits, by using TLB entries corre- //
sponding to the specified parameters. 16 2 32 36 47

Special Conditions
The contents of the doubleword at the first-
The operation is suppressed on all addressing and operand location contain values to be loaded into
protection exceptions. control registers 3 and 4, including a secondary
ASN (SASN) and a primary ASN (PASN). Exe-
Condition Code: The code remains unchanged. cution of the instruction consists in performing four
major steps: PASN translation, SASN translation,
Program Exceptions: SASN authorization, and control-register loading.
Each of these steps may or may not be per-
Addressing (page-table entry)
formed, depending on the outcome of certain tests
Privileged operation
and on the setting of bits 61-63 of the second-
Protection (fetch and store, page-table entry,
operand address. These steps, when successful,
key-controlled protection, and low-address
obtain additional values, which are loaded into
protection)
control registers 1, 5, and 7. When the steps are
not successful, no control registers are changed,
Programming Notes:
and the reason is indicated in the condition code.
1. The selective clearing of entries may be
implemented in different ways, depending on The doubleword first operand contains a PSW-key
the model, and, in general, more entries may mask (PKM), a secondary ASN (SASN), an
be cleared than the minimum number authorization index (AX), and a primary ASN
required. Some models may clear all entries (PASN). The primary ASN is translated by means
which contain the page-frame real address of the ASN-translation tables to obtain a
obtained from the page-table entry in storage. primary-ASTE (PASTE) origin (PASTEO) and,
Others may clear all entries which contain the from the PASTE, a primary ASCE (PASCE). An
designated page index, and some implemen- AX is optionally obtained from the PASTE. The
tations may clear precisely the minimum secondary ASN is translated by means of the
number of entries required. Therefore, in ASN-translation tables to obtain a secondary
order for a program to operate on all models, ASCE (SASCE), and, optionally, an authority
the program should not take advantage of any check is made to ensure that the new AX is
properties obtained by a less selective authorized to establish the new SASN.
clearing on a particular model.
The doubleword at the first-operand location has
2. The clearing of TLB entries may make use of
the following format:
the page-frame real address in the page-table
entry. Therefore, if the page-table entry, when
in the attached state, ever contained a page- PKM-d SASN-d AX-d PASN-d
frame real address that is different from the
current value, copies of the previous values 16 32 48 63
may remain in the TLB.
3. INVALIDATE PAGE TABLE ENTRY cannot be The d stands for designated doubleword and is
safely used to update a shared location in used to distinguish these fields from other fields
main storage if the possibility exists that with similar names which are referred to in the

10-30 z/Architecture Principles of Operation


definition. The current contents of the corre- PASTEO-old are left unchanged in the control reg-
sponding fields in the control registers are referred isters and become the PASCE-new and the
to as PKM-old, SASN-old, etc. The updated con- PASTEO-new, respectively. In this case, if bit 62
tents of the control registers are referred to as is zero, then the AX-old is left unchanged in the
PKM-new, SASN-new, etc. control register and becomes the AX-new.

The second-operand address is not used to The PASN translation follows the normal rules for
address data; instead, the rightmost three bits are ASN translation, except that the invalid bits, bit 0
used to control portions of the operation. The in the ASN-first-table entry and bit 0 in the ASTE,
remainder of the second-operand address is when ones, do not result in an ASN-translation
ignored. Bits 61-63 of the second-operand exception, and the space-switch-event-control bit
address are used as follows: in the ASTE, when one, does not result in a
space-switch event. When either of the invalid
Function Specified in bits is one, condition code 1 is set. When the
Second-Operand Address ASTE is valid and either the current primary
space-switch-event-control bit in control register 1
BitWhen Bit Is Zero When Bit Is One is one or the space-switch-event-control bit in the

61 ASN translation per-ASN translation per- ASTE is one, condition code 3 is set. When con-
formed only when newformed.\ dition code 1 or 3 is set, the control registers
ASN and old ASN are remain unchanged.
different.
The contents of the AX and ASCE fields in the
62 AX associated with AX from first oper- ASTE which is accessed as a result of the PASN
PASN used. and used.
translation are referred to as AX-p and ASCE-p,
63 SASN authorization SASN authorization respectively. The origin of the ASTE is referred to
performed.\ not performed. as PASTEO-p.

\ SASN translation and SASN authorization The description in this paragraph applies to use of
are performed only when SASN-d is not the subspace-group facility. After ASCE-p has
equal to PASN-d. When SASN-d is equal to
been obtained, if (1) the subspace-group-control
PASN-d, the SASCE is loaded from the
PASCE, and no authorization is performed. bit, bit 54 in ASCE-p, is one, (2) the dispatchable
unit is subspace active, and (3) PASTEO-p desig-
nates the ASTE for the base space of the
The operation of LOAD ADDRESS SPACE
dispatchable unit, then a copy of ASCE-p, called
PARAMETERS is depicted in Figure 10-15 on
ASCE-rp, is made, 0-55 and 58-63 of ASCE-rp
page 10-38.
are replaced by the same bits of the ASCE in the
ASTE for the subspace in which the dispatchable
PASN Translation
unit last had control. Further details are in
In the PASN-translation process, the PASN-d is Subspace-Replacement Operations on
translated by means of the ASN first table and the page 5-59. If bit 0 in the subspace ASTE is one,
ASN second table. The ASCE field, and or if the ASTE sequence number (ASTESN) in the
optionally the AX field, obtained from the ASTE subspace ASTE does not equal the subspace
are subsequently used to update the corre- ASTESN in the dispatchable-unit control table, an
sponding control registers. The PASTEO resulting exception is not recognized; instead, condition
from PASN translation is used to update control code 1 is set, and the control registers remain
register 5. unchanged.

When bit 61 of the second-operand address is SASN Translation


one, PASN translation is always performed.
In the SASN-translation process, the SASN-d is
When bit 61 is zero, PASN translation is per-
translated by means of the ASN first table and the
formed only when PASN-d is not equal to
ASN second table. The ASCE field obtained from
PASN-old. When bit 61 is zero and PASN-d is
the ASTE is subsequently used to update the sec-
equal to PASN-old, the PASCE-old and the
ondary ASCE (SASCE) in control register 7. The

Chapter 10. Control Instructions 10-31


ATO and ATL fields obtained are used in the SASN authorization is performed by using ATO-s,
SASN authorization, if it occurs. ATL-s, and the intended value for AX-new. When
bit 62 of the second-operand address is zero and
SASN translation is performed only when SASN-d PASN translation was performed, the intended
is not equal to PASN-d. When SASN-d is equal value for AX-new is AX-p. When bit 62 of that
to PASN-d, the SASCE-new is set to the same address is zero and PASN translation was not
value as PASCE-new. When SASN-d is equal to performed, the AX is not changed, and AX-new is
SASN-old, bit 61 (force ASN translation) is zero, the same as AX-old. When bit 62 of that address
and bit 63 (skip SASN authorization) is one, SASN is one, the intended value for AX-new is AX-d.
translation is not performed, and SASCE-old SASN authorization follows the rules for sec-
becomes SASCE-new. ondary authorization as described in
ASN-Authorization Process on page 3-24. If the
The SASN translation follows the normal rules for SASN is not authorized (that is, the authority-table
ASN translation, except that the invalid bits, bit 0 length is exceeded, or the selected bit is zero),
in the ASN-first-table entry and bit 0 in the ASTE, condition code 2 is set, and none of the control
when ones, do not result in an ASN-translation registers is updated.
exception. When either of the invalid bits is one,
condition code 2 is set, and the control registers Control-Register Loading
remain unchanged.
When the PASN-translation, SASN-translation,
The contents of the ASCE, ATO, and ATL fields in and SASN-authorization functions and subspace-
the ASTE which is accessed as a result of the replacement operations, if called for in the instruc-
SASN translation are referred to as ASCE-s, tion execution, are performed without encountering
ATO-s, and ATL-s, respectively. The origin of the any exceptions or exception situations, the exe-
ASTE is referred to as SASTEO-s. cution is completed by replacing the contents of
control registers 1, 3, 4, 5, and 7 with the new
The description in this paragraph applies to use of values, and condition code 0 is set. The control
the subspace-group facility. After ASCE-s has registers are loaded as follows.
been obtained, if (1) the subspace-group-control
bit, bit 54 in ASCE-s, is one, (2) the dispatchable The PSW-key-mask and SASN fields in control
unit is subspace active, and (3) SASTEO-s desig- register 3 are replaced by the PKM-d and SASN-d
nates the ASTE for the base space of the fields from the first-operand location.
dispatchable unit, then a copy of ASCE-s, called
ASCE-rs, is made, 0-55 and 58-63 of ASCE-rs are The PASN, bits 48-63 of control register 4, is
replaced by the same bits of the ASCE in the replaced by the PASN-d field from the first-
ASTE for the subspace in which the dispatchable operand location.
unit last had control. Further details are in
Subspace-Replacement Operations on The authorization index, bits 32-47 of control reg-
page 5-59. If bit 0 in the subspace ASTE is one, ister 4, is replaced as follows:
or if the ASTE sequence number (ASTESN) in the When bit 62 of the second-operand address is
subspace ASTE does not equal the subspace one, from AX-d.
ASTESN in the dispatchable-unit control table, an
exception is not recognized; instead, condition When bit 62 of the second-operand address is
code 2 is set, and the control registers remain zero and PASN translation is performed, from
unchanged. AX-p.
When bit 62 of the second-operand address is
SASN Authorization zero and PASN translation is not performed,
the authorization index is not changed.
SASN authorization is performed when bit 63 of
the second-operand address is zero and SASN-d The primary address-space-control element
is not equal to PASN-d. When SASN-d is equal (PASCE) in control register 1 and the
to PASN-d or when bit 63 of the second-operand primary-ASN-second-table-entry origin (PASTEO)
address is one, SASN authorization is not per- in control register 5 are replaced as follows:
formed.

10-32 z/Architecture Principles of Operation


When PASN translation is performed, the code 3 is set, and the control registers are not
PASCE in control register 1 is replaced from changed.
the ASCE-p field, which is obtained during
PASN translation, except that it is replaced by When SASN translation is called for and the trans-
ASCE-rp if a subspace-replacement operation lation cannot be completed because (1) bit 0 is
was performed on ASCE-p. Also, the one in either the ASN-first-table entry or the
PASTEO in control register 5 is replaced by ASTE, (2) SASN authorization is called for and
the PASTEO-p. the SASN is not authorized, or (3) a subspace-
replacement-exception condition exists due to bit 0
The PASTEO-p is placed in bit positions
or the ASTE sequence number in the subspace
33-57 of control register 5, and zeros are
ASTE during a subspace-replacement operation
placed in bit positions 32 and 58-63. Bits
on the ASCE-s, condition code 2 is set, and the
0-31 of the register remain unchanged.
control registers are not changed.
When PASN translation is not performed, the
contents of control registers 1 and 5 remain Special Conditions
unchanged.
The instruction can be executed only when the
The secondary address-space-control element ASN-translation control, bit 44 of control register
(SASCE) in control register 7 is replaced as 14, is one. If the ASN-translation-control bit is
follows: zero, a special-operation exception is recognized.
When SASN-d equals PASN-d, by the new
contents of control register 1, the PASCE. The first operand must be designated on a
The new contents may be PASCE-old, doubleword boundary; otherwise, a specification
ASCE-p, or ASCE-rp. exception is recognized.

When SASN translation is performed, by the The operation is suppressed on all addressing and
ASCE-s, or by ASCE-rs if a subspace- protection exceptions.
replacement operation was performed on
ASCE-s. Figure 10-13 on page 10-35 and Figure 10-12 on
page 10-34 summarize the functions of the
When SASN-d does not equal PASN-d and SASN instruction and the priority of recognition of
translation is not performed, the SASCE remains exceptions and condition codes.
unchanged.
Resulting Condition Code:
Other Condition-Code Settings
0 Translation and authorization complete;
When PASN translation is called for and cannot parameters loaded
be completed because bit 0 is one in either the 1 Primary ASN or subspace not available;
ASN-first-table entry or the ASTE, or if it can be parameters not loaded
completed but a subspace-replacement-exception 2 Secondary ASN not available or not author-
condition exists due to bit 0 or the ASTE ized, or secondary subspace not available;
sequence number in the subspace ASTE during a parameters not loaded
subspace-replacement operation on the ASCE-p, 3 Space-switch event specified; parameters not
condition code 1 is set, and the control registers loaded
are not changed.
Program Exceptions:
When PASN translation is called for and com- Access (fetch, operand 1)
pleted and any required subspace-replacement Addressing (ASN-first-table entry, ASN-
operation on the ASCE-p is also completed, and second-table entry, authority-table entry,
then either (1) the current primary space-switch- dispatchable-unit control table)
event-control bit, bit 57 of control register 1, is one Privileged operation
or (2) the space-switch-event-control bit in the Special operation
ASTE designated by PASTEO-p is one, condition Specification

Chapter 10. Control Instructions 10-33



1.-6. Exceptions with the same priority as the priority of program-
interruption conditions for the general case.

7.A Access exceptions for second and third instruction halfwords.

7.B.1 Privileged-operation exception.

7.B.2 Special-operation exception due to the ASN-translation control,
bit 34 of control register 14, being zero.

8. Specification exception.

9. Access exceptions for the first operand.

1. Execution of PASN translation (when performed).

1.1 Addressing exception for access to ASN-first-table entry.

1.2 Condition code 1 due to I bit (bit ) in ASN-first-table entry
being one.

1.3 Addressing exception for access to ASN-second-table entry.

1.4 Condition code 1 due to I bit (bit ) in ASN-second-table entry
being one.

1.5 Addressing exception for access to dispatchable-unit control
table.

1.6 Addressing exception for access to subspace ASN-second-table
entry.

1.7 Condition code 1 due to I bit (bit ) in subspace ASN-second-table
entry being one.

1.8 Condition code 1 due to subspace ASN-second-table-entry sequence
number (SSASTESN) in dispatchable-unit control table not being
equal to ASTESN in subspace ASN-second-table entry.

1.9 Condition code 3 due to either the old or new space-switch-event-
control bit being one.

11. Execution of SASN translation (when performed).

11.1 Addressing exception for access to ASN-first-table entry.

11.2 Condition code 2 due to I bit (bit ) in ASN-first-table entry
being one.

11.3 Addressing exception for access to ASN-second-table entry.

11.4 Condition code 2 due to I bit (bit ) in ASN-second-table entry
being one.

Figure 10-12 (Part 1 of 2). Priority of Execution: LOAD ADDRESS SPACE PARAMETERS

10-34 z/Architecture Principles of Operation



12.A Execution of secondary authorization (when performed).

12.A.1 Condition code 2 due to authority-table entry being outside table.

12.A.2 Addressing exception for access to authority-table entry.

12.A.3 Condition code 2 due to S bit in authority-table entry being zero.

12.B.1 Addressing exception for access to dispatchable-unit control
table.

12.B.2 Addressing exception for access to subspace ASN-second-table
entry.

12.B.3 Condition code 2 due to I bit (bit ) in subspace ASN-second-table
entry being one.

12.B.4 Condition code 2 due to subspace ASN-second-table-entry sequence
number (SSASTESN) in dispatchable-unit control table not being
equal to ASTESN in subspace ASN-second-table entry.

Figure 10-12 (Part 2 of 2). Priority of Execution: LOAD ADDRESS SPACE PARAMETERS

Second-
Operand-
Address
PASN-d Bits PASN Result Field
Equals Translation
PASN-old 61 62 Performed PASCE-newAX-newPASTEO-newPKM-newSASN-newPASN-new

Yes No PASCE-oldAX-oldPASTEO-oldPKM-d SASN-d PASN-d


Yes 1 No PASCE-oldAX-d PASTEO-oldPKM-d SASN-d PASN-d
Yes 1 Yes ASCE-p AX-p PASTEO-p PKM-d SASN-d PASN-d
Yes 1 1 Yes ASCE-p AX-d PASTEO-p PKM-d SASN-d PASN-d
No - Yes ASCE-p AX-p PASTEO-p PKM-d SASN-d PASN-d
No - 1 Yes ASCE-p AX-d PASTEO-p PKM-d SASN-d PASN-d

Figure 10-13 (Part 1 of 2). Summary of Actions: LOAD ADDRESS SPACE PARAMETERS

Chapter 10. Control Instructions 10-35



Second-Operand-
SASN-d SASN-d Address Bits SASN SASN
Equals Equals TranslationAuthorizationResult Field
PASN-d SASN-old 61 63 Performed Performed SASCE-new

Yes - - - No No PASCE-new
No Yes 1 No No SASCE-old
No Yes 1 1 Yes No ASCE-s
No Yes - Yes Yes ASCE-s
No No - 1 Yes No ASCE-s
No No - Yes Yes ASCE-s

Explanation:

- Action in this case is the same regardless of the outcome of this
comparison or of the setting of this bit.

Second-operand-address bits:
61 Force ASN translation.
62 Use AX from first operand.
63 Skip secondary authority test.

PASCE-new is ASCE-rp (a copy of ASCE-p except with bits -55 and
58-63 replaced from the ASCE in the subspace ASTE), if subspace
replacement is performed.

SASN authorization is performed using ATO-s, ATL-s, and AX-new.

SASCE-new is ASCE-rs (a copy of ASCE-s except with bits -55 and
58-63 replaced from the ASCE in the subspace ASTE), if subspace
replacement is performed.

Figure 10-13 (Part 2 of 2). Summary of Actions: LOAD ADDRESS SPACE PARAMETERS

Programming Notes: be able to determine in certain cases that the


SASN is authorized, either because of prior
1. Bits 61 and 63 in the second-operand address
use or because the AX being loaded is
are intended primarily to provide improved
authorized to access all address spaces.
performance for those cases where the asso-
ciated action is unnecessary. 2. The SASN-translation and SASN-authorization
steps are not performed when SASN-d is
When bit 61 is set to zero, the action of the
equal to PASN-d. This is consistent with the
instruction is based on the assumption that
action in SET SECONDARY ASN to current
the current values for PASCE-old,
primary (SSAR-cp), which does not perform
PASTEO-old, and AX-old are consistent with
the translation or ASN authorization.
PASN-old and that SASCE-old is consistent
with SASN-old. When this is not the case, bit 3. See Figure 10-14 on page 10-37 for a listing
61 should be set to one. of abbreviations used in this instruction
description.
Bit 63, when one, eliminates the
SASN-authorization test. The program may

10-36 z/Architecture Principles of Operation



Abbreviation for
Control-
Register Previous Subsequent
Number.Bit Contents Contents

1.-63 PASCE-old PASCE-new


3.32-47 PKM-old PKM-new
3.48-63 SASN-old SASN-new
4.32-47 AX-old AX-new
4.48-63 PASN-old PASN-new
5.33-57 PASTEO-old PASTEO-new
7.-63 SASCE-old SASCE-new

First-Operand
Bit Positions Abbreviation

-15 PKM-d
16-31 SASN-d
32-47 AX-d
48-63 PASN-d

Abbreviation Used for


the Field When Accessed
as Part of
Field in ASN-
Second-Table PASN SASN
Entry Translation Translation

1-29 - ATO-s
32-47 AX-p -
48-59 - ATL-s
64-127 ASCE-p ASCE-s

Explanation:

- The field is not used in this case.

ASCE-rp is formed from ASCE-p, and ASCE-rs
is formed from ASCE-s, by a subspace-
replacement operation.

Figure 10-14. Summary of Abbreviations for LOAD


ADDRESS SPACE PARAMETERS

Chapter 10. Control Instructions 10-37



Fetch op-1 doubleword 5PASN translation


6
No
ASN available ?51 5 Cond Code
6
Yes
PASN-d = PASN-old 6
AND No
Op-2-addr bit 61 = Subspace available No
? if required ? 51 5 Cond Code

Yes Yes
6 6

PASCE-old 5 PASCE-tmp Either old or new
PASTEO-old 5 PASTEO-tmp space-switch-event- Yes
AX-old 5 AX-tmp control bit = 1 ? 53 5 Cond Code

No
6

ASCE-p 5 PASCE-tmp \
PASTEO-p 5 PASTEO-tmp
6 AX-p 5 AX-tmp
Yes
SASN-d = PASN-d ? %

No
6
5SASN translation
SASN-d = SASN-old
AND
Op-2-addr bit 61 = No 6
AND No
Op-2-addr bit 63 = 1 ASN available ?52 5 Cond Code
?
Yes
Yes 6

Subspace available No
if required ? 52 5 Cond Code


6 6 6

PASCE-tmp 5 SASCE-tmp SASCE-old 5 SASCE-tmp ASCE-s 5 SASCE-tmp \\


6
% 6
6 No
No %Op-2-addr bit 63 = ?
Op-2-addr bit 62 = 1 ?
Yes
Yes 6
6 6
SASN authorization
AX-d 5 AX-new AX-tmp 5 AX-new

6
5 Yes No
%Authorized ?52 5 Cond Code

6

PASCE-tmp 5 PASCE-new 5 PKM-d 5 PKM-new
PASTEO-tmp 5 PASTEO-new SASN-d 5 SASN-new
SASCE-tmp 5 SASCE-new PASN-d 5 PASN-new5 5 Cond Code

\: PASCE-tmp is ASCE-rp if subspace replacement occurred.
\\: SASCE-tmp is ASCE-rs if subspace replacement occurred.
Figure 10-15. Execution of LOAD ADDRESS SPACE PARAMETERS

10-38 z/Architecture Principles of Operation


LOAD CONTROL Specification

Programming Notes:
LCTL R,R,D(B) [RS] 1. To ensure that existing programs operate cor-
rectly if and when new facilities using addi-
'B7' R R B D tional control-register positions are defined,
only zeros should be loaded in unassigned
8 12 16 2 31 control-register positions.
2. Loading of control registers on some models
LCTLG R,R,D(B) [RSE] may require a significant amount of time. This
/ is particularly true for changes in significant
'EB' R R B D //////// '2F' parameters.
/ For example, the TLB may be cleared of
8 12 16 2 32 4 47
entries as a result of changing or enabling the
program-event-recording parameters in control
Bit positions of the set of control registers starting registers 9-11. Where possible, the program
with control register R and ending with control should avoid unnecessary loading of control
register R are loaded from storage beginning at registers. In loading control registers 9-11,
the location designated by the second-operand most models attempt to optimize for the case
address and continuing through as many locations when the bits of control register 9 are zeros.
as needed.

For LOAD CONTROL (LCTL), bit positions 32-63 LOAD PSW


of the control registers are loaded from successive
LPSW D(B) [S]
words beginning at the second-operand address,
and bits 0-31 of the registers remain unchanged.
For LOAD CONTROL (LCTLG), bit positions 0-63 '82' //////// B D
of the control registers are loaded from successive
doublewords beginning at the second-operand 8 16 2 31
address. The control registers are loaded in
ascending order of their register numbers, starting The current PSW is replaced by a 16-byte PSW
with control register R and continuing up to and formed from the contents of the doubleword at the
including control register R, with control register 0 location designated by the second-operand
following control register 15. address.

The information loaded into the control registers Bit 12 of the doubleword must be one; otherwise,
becomes active when instruction execution has a specification exception may be recognized,
ended. depending on the model.

Special Conditions Bits 0-32 of the doubleword, except with bit 12


inverted, are placed in bit positions 0-32 of the
The second operand must be designated on a current PSW. Bits 33-63 of the doubleword are
word boundary for LCTL or on a doubleword placed in bit positions 97-127 of the current PSW.
boundary for LCTLG; otherwise, a specification Bits 33-96 of the current PSW are set to zeros.
exception is recognized.
A serialization and checkpoint-synchronization
Condition Code: The code remains unchanged. function is performed before or after the operand
is fetched and again after the operation is com-
Program Exceptions: pleted.
Access (fetch, operand 2)
Privileged operation

Chapter 10. Control Instructions 10-39


Special Conditions LOAD PSW EXTENDED
The operand must be designated on a doubleword LPSWE D(B) [S]
boundary; otherwise, a specification exception is
recognized. A specification exception may be
recognized if bit 12 of the operand is zero, 'B2B2' B D
depending on the model.
16 2 31
The PSW fields which are to be loaded by the
instruction are not checked for validity before they The current PSW is replaced by the contents of
are loaded, except for the optional checking of bit the 16-byte second operand.
12. However, immediately after loading, a specifi-
cation exception is recognized, and a program A serialization and checkpoint-synchronization
interruption occurs, when any of the following is function is performed before or after the operand
true for the newly loaded PSW: is fetched and again after the operation is com-
pleted.
Any of bits 0, 2-4, 12, or 24-30 is a one.
Bits 31 and 32 are both zero, and bits 97-103 Special Conditions
are not all zeros.
The operand must be designated on a doubleword
Bits 31 and 32 are one and zero, respectively. boundary; otherwise, a specification exception is
In these cases, the operation is completed, and recognized.
the resulting instruction-length code is 0.
The value which is to be loaded by the instruction
The test for a specification exception after the is not checked for validity before it is loaded.
PSW is loaded is described in Early Exception However, immediately after loading, a specification
Recognition on page 6-9. It may be considered exception is recognized, and a program inter-
as occurring early in the process of preparing to ruption occurs, when any of the following is true
execute the subsequent instruction. for the newly loaded PSW:

The operation is suppressed on all addressing and Any of the unassigned bits (0, 2-4, 24-30, or
protection exceptions. 33-63) is a one.
Bit 12 is a one.
Resulting Condition Code: The code is set as
specified in the new PSW loaded. Bits 31 and 32 are zero and one, respectively,
and bits 64-96 are not all zeros.
Program Exceptions: Bits 31 and 32 are both zero, and bits 64-103
Access (fetch, operand 2) are not all zeros.
Privileged operation Bits 31 and 32 are one and zero, respectively.
Specification
In these cases, the operation is completed, and
Programming Note: The second operand should the resulting instruction-length code is zero.
have the format of an ESA/390 PSW. A specifica-
tion exception will be recognized during or after The test for a specification exception after the
the execution of LOAD PSW if bit 12 of the PSW is loaded is described in Early Exception
operand is zero. Recognition on page 6-9. It may be considered
as occurring early in the process of preparing to
execute the subsequent instruction.

The operation is suppressed on all addressing and


protection exceptions.

Resulting Condition Code: The code is set as


specified in the new PSW loaded.

10-40 z/Architecture Principles of Operation


Program Exceptions: PSW
Access (fetch, operand 2) Bits 16 Address-Space-Control Element
Privileged operation and 17 Used by DAT
Specification 00 Contents of control register 1
10 Contents of control register 7
LOAD REAL ADDRESS
01 The address-space-control element
LRA R,D(X,B) [RX] obtained by applying the access-
register-translation (ART) process to the
access register designated by the B
'B1' R X B D field

8 12 16 2 31 11 Contents of control register 13

LRAG R,D(X,B) [RXE] ART and DAT may be performed with the use of
the ART-lookaside buffer (ALB) and translation-
/
'E3' R X B D //////// '3' lookaside buffer (TLB), respectively.
/
8 12 16 2 32 4 47 The virtual-address computation is performed
according to the current addressing mode, speci-
fied by bits 31 and 32 of the current PSW.
For LOAD REAL ADDRESS (LRA) in the 24-bit or
31-bit addressing mode, if bits 0-32 of the 64-bit
The addresses of the region-table entry or entries,
real address corresponding to the second-operand
if used, and of the segment-table entry and page-
virtual address are all zeros, bits 32-63 of the real
table entry are treated as 64-bit addresses regard-
address are placed in bit positions 32-63 of
less of the current addressing mode. It is
general register R, and bits 0-31 of the register
unpredictable whether the addresses of these
remain unchanged. If bits 0-32 of the real
entries are treated as real or absolute addresses.
address are not all zeros, a special-operation
exception is recognized. Condition code 0 is set when both ART, if appli-
cable, and DAT can be completed and a special-
For LRA in the 64-bit addressing mode, and for
operation exception is not recognized, that is,
LOAD REAL ADDRESS (LRAG) in any
when an address-space-control element can be
addressing mode, the 64-bit real address corre-
obtained, the entry in each DAT table lies within
sponding to the second-operand virtual address is
the table and has a zero I bit, and, for LRA in the
placed in general register R.
24-bit or 31-bit addressing mode, bits 0-32 of the
resulting real address are zeros. The translated
The virtual address specified by the X, B, and
address is not inspected for boundary alignment
D fields is translated by means of the dynamic-
or for addressing or protection exceptions.
address-translation facility, regardless of whether
DAT is on or off.
When PSW bits 16 and 17 are 01 binary and an
address-space-control element cannot be obtained
DAT is performed by using an address-space-
because of a condition that would normally cause
control element that depends on the current value
one of the exceptions shown in the following table,
of the address-space-control bits, bits 16 and 17
(1) the interruption code assigned to the exception
of the PSW, as shown in the following table:
is placed in bit positions 48-63 of general register
R, bit 32 of this register is set to one, bits 33-47
are set to zeros, and bits 0-31 remain unchanged,
and (2) the instruction is completed by setting
condition code 3.

Chapter 10. Control Instructions 10-41


Code For LRA in the 64-bit addressing mode or LRAG
Exception (in in any addressing mode, when the I bit in the
Name Cause Hex) segment-table entry is one, condition code 1 is
set, and the 64-bit real or absolute address of the
ALET specifi- Access-list-entry-token 0028
segment-table entry is placed in general register
cation (ALET) bits 0-6 not all
R. In this case except that LRA is in the 24-bit
zeros
or 31-bit addressing mode, if bits 0-32 of the
ALEN trans- Access-list entry (ALE) 0029 address of the segment-table entry are all zeros,
lation outside list or invalid (bit 0 the result is the same except that bits 0-31 of
is one) general register R remain unchanged. If bits
0-32 of the address are not all zeros, the result is
ALE ALE sequence number 002A
as shown in the next table below.
sequence (ALESN) in ALET not equal
to ALESN in ALE
For LRA in the 64-bit addressing mode or LRAG
ASTE validity ASN-second-table entry 002B in any addressing mode, when the I bit in the
(ASTE) invalid (bit 0 is page-table entry is one, condition code 2 is set,
one) and the 64-bit real or absolute address of the
page-table entry is placed in general register R.
ASTE ASTE sequence number 002C
In this case except that LRA is in the 24-bit or
sequence (ASTESN) in ALE not
31-bit addressing mode, if bits 0-32 of the address
equal to ASTESN in ASTE
of the page-table entry are all zeros, the result is
Extended ALE private bit not zero, 002D the same except that bits 0-31 of general register
authority ALE authorization index R remain unchanged. If bits 0-32 of the address
(ALEAX) not equal to are not all zeros, the result is as shown in the next
extended authorization table below.
index (EAX), and sec-
ondary bit selected by EAX A segment-table-entry or page-table-entry address
either outside authority placed in general register R is real or absolute in
table or zero accordance with the type of address that was
used during the attempted translation,
When ART is completed normally, the operation is
If a condition exists that would normally cause one
continued through the performance of DAT.
of the exceptions shown in the following table,
When the segment-table entry is outside the table (1) the interruption code assigned to the exception
and bits 0-32 of the real or absolute address of is placed in bit positions 48-63 of general register
the entry are all zeros, condition code 3 is set, bits R, bit 32 of this register is set to one, bits 33-47
32-63 of the entry address are placed in bit posi- are set to zeros, and bits 0-31 remain unchanged,
tions 32-63 of general register R, and bits 0-31 of and (2) the instruction is completed by setting
the register remain unchanged. If bits 0-32 of the condition code 3.
address are not all zeros, the result is as shown in
the next table below.

10-42 z/Architecture Principles of Operation


Code Special Conditions
Exception (in
Name Cause Hex) A special-operation exception is recognized when,
for LRA in the 24-bit or 31-bit addressing mode,
ASCE type Address-space-control 0038 bits 0-32 of the resultant 64-bit real address are
element (ASCE) being not all zeros.
used is a region-second-
table designation, and bits An addressing exception is recognized when the
0-10 of virtual address not address used by ART to fetch the effective
all zeros; ASCE is a access-list designation or the ALE, ASTE, or
region-third-table desig- authority-table entry designates a location which is
nation, and bits 0-21 of not available in the configuration or when the
virtual address not all address used to fetch the region-table entry or
zeros; or ASCE is a entries, if any, segment-table entry, or page-table
segment-table designation, entry designates a location which is not available
and bits 0-32 of virtual in the configuration.
address not all zeros.
Region first Region-first-table entry 0039 A translation-specification exception is recognized
translation selected by region-first- when an accessed region-table entry or the
index portion of virtual segment-table entry or page-table entry has a
address outside table or zero I bit and a format error, that is, when any of
invalid. the reasons listed in Translation-Specification
Exception on page 6-35 applies.
Region Region-second-table entry 003A
second selected by region-second- A carry out of bit position 0 as a result of the addi-
translation index portion of virtual tion done to compute the address of a region-table
address outside table or entry or the segment-table entry may be ignored
invalid. or may result in an addressing exception.
Region third Region-third-table entry 003B
The operation is suppressed on all addressing
translation selected by region-third-
exceptions.
index portion of virtual
address outside table or
Resulting Condition Code:
invalid.
0 Translation available
Segment Segment-table entry 0010
1 Segment-table entry invalid (I bit one)
translation selected by segment-index
2 Page-table entry invalid (I bit one)
portion of virtual address
3 Address-space-control element not available,
outside table (only when
region-table entry outside table or invalid (I bit
bits 0-32 of entry address
one), segment-table entry outside table, or,
not all zeros); or segment-
for LRA only, and only in 24-bit or 31-bit
table entry invalid (LRA
addressing mode when bits 0-32 of entry
only, and only in 24-bit or
address not all zeros, segment-table entry or
31-bit addressing mode
page-table entry invalid (I bit one)
when bits 0-32 of entry
address not all zeros). Program Exceptions:
Page trans- Page-table entry selected 0011 Addressing (effective access-list designation,
lation by page-index portion of access-list entry, ASN-second-table entry,
virtual address invalid (LRA authority-table entry, region-table entry,
only, and only in 24-bit or segment-table entry, or page-table entry)
31-bit addressing mode Privileged operation
when bits 0-32 of entry Special operation (LRA only)
address not all zeros). Translation specification

Chapter 10. Control Instructions 10-43


Programming Notes: be invalid (condition code 2) even though the
corresponding TLB entry has not yet been
1. Caution must be exercised in the use of
cleared, and the TLB entry may remain in the
LOAD REAL ADDRESS in a multiprocessing
TLB until the completion of INVALIDATE
configuration. Since INVALIDATE PAGE
PAGE TABLE ENTRY on the other CPU.
TABLE ENTRY may set the I bit in storage to
There is no guaranteed limit to the number of
one before causing the corresponding entries
instructions which may be executed between
in TLBs of other CPUs to be cleared, the
the completion of LOAD REAL ADDRESS and
simultaneous execution of LOAD REAL
the TLB being cleared of the entry.
ADDRESS on this CPU and INVALIDATE
PAGE TABLE ENTRY on another CPU may 2. Figure 10-16 on page 10-45 summarizes the
produce inconsistent results. Because LOAD resulting contents of general register R and
REAL ADDRESS may access the tables in the condition code.
storage, the page-table entry may appear to

10-44 z/Architecture Principles of Operation



General Register R Contents and Condition Code
Exception/Cause/
Entry-Address Size LRA in 24-Bit or 31-Bit LRA in 64-Bit Addressing Mode or
or Addressing Mode LRAG in Any Addressing Mode
Resultant-Real-
Address Size -31 32 33-47 48-63 CC -31 32 33-47 48-63 CC

ALET specification U 1 s 28 3 U 1 s 28 3

ALEN translation U 1 s 29 3 U 1 s 29 3

ALE sequence U 1 s 2A 3 U 1 s 2A 3

ASTE validity U 1 s 2B 3 U 1 s 2B 3

ASTE sequence U 1 s 2C 3 U 1 s 2C 3

Extended authority U 1 s 2D 3 U 1 s 2D 3

ASCE type U 1 s 38 3 U 1 s 38 3

Region first trans. U 1 s 39 3 U 1 s 39 3

Region second trans. U 1 s 3A 3 U 1 s 3A 3

Region third trans. U 1 s 3B 3 U 1 s 3B 3

Segment translation/ U EA3 EA4 3 U EA3 EA4 3
entry outside table/
entry address < 2GB

Segment translation/ U 1 s 1 3 U 1 s 1 3
entry outside table/
entry address >= 2GB

Segment translation/ U EA3 EA4 1 EA1 EA2 EA3 EA4 1
I bit one/
entry address < 2GB

Segment translation/ U 1 s 1 3 EA1 EA2 EA3 EA4 1
I bit one/
entry address >= 2GB

Page translation/ U EA3 EA4 2 EA1 EA2 EA3 EA4 2
I bit one/
entry address < 2GB

Page translation/ U 1 s 11 3 EA1 EA2 EA3 EA4 2
I bit one/
entry address >= 2GB

Real Address < 2GB U RA3 RA4 RA1 RA2 RA3 RA4

Real Address >= 2GB Special-Operation Exception RA1 RA2 RA3 RA4

Figure 10-16 (Part 1 of 2). Summary of Results: LOAD REAL ADDRESS

Chapter 10. Control Instructions 10-45



Explanation:

EA1 Bits -31 of the entry address.
EA2 Bit 32 of the entry address.
EA3 Bits 33-47 of the entry address.
EA4 Bits 48-63 of the entry address.
RA1 Bits -31 of the resultant real address.
RA2 Bit 32 of the resultant real address.
RA3 Bits 33-47 of the resultant real address.
RA4 Bits 48-63 of the resultant real address.
U Unchanged.

Figure 10-16 (Part 2 of 2). Summary of Results: LOAD REAL ADDRESS

LOAD USING REAL ADDRESS Special Conditions

LURA R,R [RRE] The contents of general register R must desig-


nate a location on a word boundary for LURA or
on a doubleword boundary for LURAG; otherwise,
'B24B' //////// R R a specification exception is recognized.

16 24 28 31
Condition Code: The code remains unchanged.

LURAG R,R [RRE] Program Exceptions:


Addressing (address specified by general reg-
'B95' //////// R R ister R)
Privileged operation
16 24 28 31
Protection (fetch, operand 2, key-controlled
protection)
For LOAD USING REAL ADDRESS (LURA), the Specification
word at the real-storage location addressed by the
contents of general register R is placed in bit
positions 32-63 of general register R, and the
MODIFY STACKED STATE
contents of bit positions 0-31 remain unchanged. MSTA R [RRE]
For LOAD USING REAL ADDRESS (LURAG), the
doubleword at that real-storage location is placed
in bit positions 0-63 of general register R. 'B247' //////// R ////

16 24 28 31
In the 24-bit addressing mode, bits 40-63 of
general register R designate the real-storage
location, and bits 0-39 of the register are ignored. The contents of bit positions 32-63 of the pair of
In the 31-bit addressing mode, bits 33-63 of general registers designated by the R field are
general register R designate the real-storage placed in the modifiable area, byte positions
location, and bits 0-33 of the register are ignored. 152-159, of the last state entry in the linkage
In the 64-bit addressing mode, bits 0-63 of general stack.
register R designate the real-storage location.
The R field designates the even-numbered reg-
Because it is a real address, the address desig- ister of an even-odd pair of general registers.
nating the storage word or doubleword is not
subject to dynamic address translation. The last state entry is located as described in
Unstacking Process on page 5-75. The state
entry remains in the linkage stack, and the
linkage-stack-entry address in control register 15
remains unchanged.

10-46 z/Architecture Principles of Operation


Key-controlled protection does not apply to the ref- The operation is suppressed on all addressing and
erences to the linkage stack, but low-address and protection exceptions.
page protection do apply.
The priority of recognition of program exceptions
Special Conditions for the instruction is shown in Figure 10-17.

A specification exception is recognized when R is Condition Code: The code remains unchanged.
odd.
Program Exceptions:
The CPU must be in the primary-space mode,
Access (fetch and store, except for key-
access-register mode, or home-space mode; oth-
controlled protection, linkage-stack entry)
erwise, a special-operation exception is recog-
Special operation
nized.
Specification
Stack empty
A stack-empty, stack-specification, or stack-type
Stack specification
exception may be recognized during the
Stack type
unstacking process.

1.-6. Exceptions with the same priority as the priority of program-


interruption conditions for the general case.

7.A Access exceptions for second instruction halfword.

7.B Special-operation exception due to DAT being off or the CPU
being in secondary-space mode.

8.A Specification exception due to R being odd.

8.B.1 Access exceptions (fetch) for entry descriptor of the current
linkage-stack entry.

8.B.2 Stack-type exception due to current entry not being a state
entry or header entry.

Note: Exceptions 8.B.3-8.B.7 can occur only if the current
entry is a header entry.

8.B.3 Access exceptions (fetch) for second word of the header entry.

8.B.4 Stack-empty exception due to backward stack-entry validity
bit in the header entry being zero.

8.B.5 Access exceptions (fetch) for entry descriptor of preceding
entry, which is the entry designated by the backward
stack-entry address in the current (header) entry.

8.B.6 Stack-specification exception due to preceding entry being a
header entry.

8.B.7 Stack-type exception due to preceding entry not being a state
entry.

8.B.8 Access exceptions (store) for the modifiable area of the state
entry.

Figure 10-17. Priority of Execution: MODIFY STACKED STATE

MOVE PAGE

Chapter 10. Control Instructions 10-47


MVPG R,R [RRE] When bit 52 of general register 0 is one, the fetch
accesses to the second-operand location are per-
formed by using the PSW key, and the store
'B254' //////// R R
accesses to the first-operand location are per-
16 24 28 31 formed by using the key specified in general reg-
ister 0. When bit 53 of general register 0 is one,
the fetch accesses to the second-operand location
The first operand is replaced by the second
are performed by using the key specified in
operand. The first and second operands both are
general register 0, and the store accesses to the
4K bytes on 4K-byte boundaries. The results are
first-operand location are performed by using the
indicated in the condition code. The accesses to
PSW key. When bits 52 and 53 are both zeros,
the first-operand location or the second-operand
the PSW key is used for accessing both operands.
location, but not to both locations, may be per-
formed by using the key specified in general reg-
When 4K bytes have been moved, condition code
ister 0; otherwise, the accesses to an operand
0 is set.
location are performed by using the PSW key.
When a page-translation-exception condition
The location of the leftmost byte of the first
exists, the exception is not recognized if the
operand and second operand is designated by the
condition-code-option bit, bit 55 in general register
contents of general registers R and R, respec-
0, is one; instead, condition code 1 or 2 is set.
tively.
Condition code 1 is set if a page-translation-
exception condition exists for the first operand and
The handling of the addresses in general registers
not for the second operand. Condition code 2 is
R and R depends on the addressing mode. In
set if a page-translation-exception condition exists
the 24-bit addressing mode, the contents of bit
for the second operand, regardless of whether the
positions 40-51 of a general register, with 12 right-
condition exists for the first operand.
most zeros appended, are the address, and bits
0-39 and 52-63 in the register are ignored. In the
When an access exception can be recognized for
31-bit addressing mode, the contents of bit posi-
both operands, it is unpredictable for which
tions 33-51 of a general register, with 12 rightmost
operand an exception is recognized. If one of the
zeros appended, are the address, and bits 0-32
exceptions is a page-translation exception that
and 52-63 in the register are ignored. In the
would cause condition code 1 or 2 to be set, it is
64-bit addressing mode, the contents of bit posi-
unpredictable whether the access exception for
tions 0-51 of a general register, with 12 rightmost
the other operand is recognized or condition code
zeros appended, are the address, and bits 52-63
1 or 2 is set.
in the register are ignored.
The references to main storage are not neces-
Bits 56-59 of general register 0 are used as the
sarily single-access references and are not neces-
specified access key. Bit 52 of general register 0,
sarily performed in a left-to-right direction, as
when one, specifies that the specified access key
observed by other CPUs and by channel pro-
is to be used for accessing the first operand, and
grams.
bit 53 specifies the same for the second operand.
A specification exception is recognized if bits 52 Special Conditions
and 53 are both ones. Bit 54 of general register 0
is a destination-reference-intention bit, and bit 55 In the problem state, when either bit 52 or bit 53
is a condition-code-option bit. Bits 48-51 of in general register 0 is one, the operation is per-
general register 0 must be zeros; otherwise, a formed only if the access key specified in general
specification exception is recognized. Bits 0-47 register 0 is valid, that is, if the corresponding
and 60-63 of general register 0 are ignored. PSW-key-mask bit in control register 3 is one.
Otherwise, a privileged-operation exception is
The contents of the registers just described are recognized. In the supervisor state, any value for
shown in Figure 10-18 on page 10-49 the specified access key is valid. When bits 52
and 53 are both zeros, the access key in general
register 0 is not tested for validity.

10-48 z/Architecture Principles of Operation




/
DC
GR RC
/////////////////FSIOKey ////
/
48 52 54 56 6 63

24-Bit Addressinssing Mode

/ /
R ////////////Op1 Address //////////// R ////////////Op2 Address ////////////
/ /
4 52 63 4 52 63

31-Bit Addressinssing Mode

/ /
R ///// Op1 Address //////////// R ///// Op2 Address ////////////
/ /
33 52 63 33 52 63


64-Bit Addressinssing Mode

/ /
R Op1 Address //////////// R Op2 Address ////////////
/ /
52 63 52 63

Explanation:

CCO Condition-code-option bit.
DRI Destination-reference-intention bit.
F When one, specified access key applies to first operand. A specification exception is
recognized if F and S are both ones.
Key Specified access key.
S When one, specified access key applies to second operand. A specification exception is
recognized if F and S are both ones.

Figure 10-18. Register Contents for MOVE PAGE

In the problem state, when bits 52 and 53 in Program Exceptions:


general register 0 are both ones and the access
Access (fetch, operand 2; store, operand 1)
key in general register 0 is not permitted by the
Privileged operation (access key specified,
PSW-key mask, it is unpredictable whether a
and selected PSW-key-mask bit is zero in the
specification exception or a privileged-operation
problem state)
exception is recognized.
Specification
Resulting Condition Code:
Programming Notes:
0 Data moved
1. MOVE PAGE, or a loop of MOVE PAGE
1 Condition-code-option bit one, page-table
instructions that moves multiple pages, may
entry for first operand invalid, and page-table
provide, on most models, better performance
entry for second operand valid
than a MOVE LONG instruction or a loop of
2 Condition-code-option bit one and page-table
MOVE (MVC) instructions that performs the
entry for second operand invalid
same function. Whether MOVE PAGE pro-
3 --
vides better performance depends on control-

Chapter 10. Control Instructions 10-49


program specifications and the method by The addresses of the first and second operands
which the control program handles page- are virtual, one operand address being translated
translation exceptions. by means of the primary address-space-control
element and the other by means of the secondary
2. The destination-reference-intention bit should
address-space-control element. Operand-address
be set to one when there is an intention to ref-
translation is performed in the same way when the
erence the first operand by means of an
address-space-control bits in the current PSW
instruction other than MOVE PAGE. The bit
specify either the primary-space mode or the
may allow the control program to process a
secondary-space mode.
page-translation exception more efficiently.
3. The condition-code-option bit provides com- For MOVE TO PRIMARY, movement is to the
patibility with the MOVE PAGE instruction of primary space from the secondary space. The
the ESA/390 move-page facility 1. The bit is first-operand address is translated by using the
for use by the MVS/ESA HSPSERV macro primary address-space-control element, and the
expansion. second-operand address is translated by using the
secondary address-space-control element.
4. The condition code set by the instruction
normally need not be examined if the
For MOVE TO SECONDARY, movement is to the
condition-code-option bit is zero.
secondary space from the primary space. The
5. See the definitions of real locations 162 and first-operand address is translated by using the
168-175 under Assigned Storage Locations secondary address-space-control element, and the
in Chapter 3, Storage, for a description of second-operand address is translated by using the
information stored during a program inter- primary address-space-control element.
ruption due to a page-translation exception
recognized by MOVE PAGE. Bit positions 56-59 of general register R are used
as the secondary-space access key. Bit positions
0-55 and 60-63 of the register are ignored.
MOVE TO PRIMARY
MVCP D(R,B),D(B),R [SS] General register R contains an unsigned binary
integer called the true length. In the 24-bit or
// 31-bit addressing mode, the true length is in bit
'DA' R R B D B D positions 32-63 of the register, and the contents of
// bit positions 0-31 of the register are ignored. In
8 12 16 2 32 36 47
the 64-bit addressing mode, the true length is in
bit positions 0-63 of the register.
MOVE TO SECONDARY The contents of the general registers just
MVCS D(R,B),D(B),R [SS] described are as follows:

// 24-Bit or 31-Bit Addressing Mode


'DB' R R B D B D /
// R /// True Length
8 12 16 2 32 36 47 /
32 63

The first operand is replaced by the second


64-Bit Addressing Mode
operand. One operand is in the primary address /
space, and the other is in the secondary address R True Length
space. The accesses to the operand in the /
primary space are performed by using the PSW 63
key; the accesses to the operand in the secondary
space are performed by using the key specified by /
the third operand. R ////////////////////////////Key ////
/
56 6 63

10-50 z/Architecture Principles of Operation


The first and second operands are the same Resulting Condition Code:
length, called the effective length. The effective
0 True length less than or equal to 256
length is equal to the true length or 256, which-
1 --
ever is less. Access exceptions for the first and
2 --
second operands are recognized only for that
3 True length greater than 256
portion of the operand within the effective length.
When the effective length is zero, no access Program Exceptions:
exceptions are recognized for the first and second
operands, and no movement takes place. Access (fetch, primary virtual address,
operand 2, MVCS; fetch, secondary virtual
Each storage operand is processed left to right. address, operand 2, MVCP; store, secondary
The storage-operand-consistency rules are the virtual address, operand 1, MVCS; store,
same as for MOVE (MVC), except that when the primary virtual address, operand 1, MVCP)
operands overlap in real storage, the use of the Privileged operation (selected PSW-key-mask
common real-storage locations is not necessarily bit is zero in the problem state)
recognized. Special operation

As part of the execution of the instruction, the


1.-6. Exceptions with the same priority as
value of the true length is used to set the condi-
the priority of program-interruption
tion code. If the true length is 256 or less, conditions for the general case.
including zero, the true length and effective length
are equal, and condition code 0 is set. If the true 7.A Access exceptions for second and third
length is greater than 256, the effective length is instruction halfwords.
256, and condition code 3 is set.
7.B Special-operation exception due to the
secondary-space control, bit 37 of con-
For both MOVE TO PRIMARY and MOVE TO trol register , being zero, to DAT
SECONDARY, a serialization and checkpoint- being off, or to the CPU being in the
synchronization function is performed before the access-register or home-space mode.
operation begins and again after the operation is
completed. 8. Privileged-operation exception due to
selected PSW-key-mask bit being zero
in the problem state.
Special Conditions
9. Completion due to length zero.
Since the secondary space is accessed, the oper-
ation is performed only when the secondary-space 1. Access exceptions for operands.
control, bit 37 of control register 0, is one and
DAT is on. When either the secondary-space Figure 10-19. Priority of Execution: MOVE TO
control is zero or DAT is off, a special-operation PRIMARY and MOVE TO SECONDARY
exception is recognized. A special-operation
exception is also recognized when the address- Programming Notes:
space-control bits in the current PSW specify the 1. MOVE TO PRIMARY and MOVE TO SEC-
access-register or home-space mode. ONDARY can be used in a loop to move a
variable number of bytes of any length. See
In the problem state, the operation is performed
the programming note under MOVE WITH
only if the secondary-space access key is valid,
KEY.
that is, if the corresponding PSW-key-mask bit in
control register 3 is one. Otherwise, a privileged- 2. MOVE TO PRIMARY and MOVE TO SEC-
operation exception is recognized. In the super- ONDARY should be used only when move-
visor state, any value for the secondary-space ment is between different address spaces.
access key is valid. The performance of these instructions on most
models may be significantly slower than that
The priority of the recognition of exceptions and of MOVE WITH KEY, MOVE (MVC), or MOVE
condition codes is shown in Figure 10-19 on LONG. In addition, the definition of overlap-
page 10-52.

Chapter 10. Control Instructions 10-51


ping operands for MOVE TO PRIMARY and Each of the operands is processed left to right.
MOVE TO SECONDARY is not compatible When the operands overlap destructively in real
with the more precise definitions for MOVE storage, the results in the first-operand location
(MVC), MOVE WITH KEY, and MOVE LONG. are unpredictable. Except for this unpredictability
in the case of destructive overlap, the storage-
MOVE WITH DESTINATION KEY operand-consistency rules are the same as for the
MOVE (MVC) instruction.
MVCDK D(B),D(B) [SSE]
Special Conditions
//
'E5F' B D B D In the problem state, the operation is performed
// only if the access key specified in general register
16 2 32 36 47
1 is valid, that is, if the corresponding
PSW-key-mask bit in control register 3 is one.
The first operand is replaced by the second Otherwise, a privileged-operation exception is
operand. The accesses to the destination- recognized. In the supervisor state, any value for
operand location are performed by using the key the specified access key is valid.
specified in general register 1, and the accesses
to the source-operand location are performed by Condition Code: The code remains unchanged.
using the PSW key.
Program Exceptions:
The first and second operands are of the same
Access (fetch, operand 2; store, operand 1)
length, which is specified by bits 56-63 of general
Privileged operation (selected PSW-key-mask
register 0. Bits 0-55 of general register 0 are
bit is zero in the problem state)
ignored.
Programming Note: See the programming notes
Bits 56-59 of general register 1 are used as the for the MOVE WITH SOURCE KEY instruction.
specified access key. Bits 0-55 and 60-63 of
general register 1 are ignored. MOVE WITH KEY
The contents of general registers 0 and 1 are as MVCK D(R,B),D(B),R [SS]
follows:
//
/ 'D9' R R B D B D
GR //////////////////////////// L //
/ 8 12 16 2 32 36 47
56 63
The first operand is replaced by the second
/ operand. The fetch accesses to the second-
GR1 ////////////////////////////Key ////
/ operand location are performed by using the key
56 6 63 specified in the third operand, and the store
accesses to the first-operand location are per-
formed by using the PSW key.
L specifies the number of bytes to the right of the
first byte of each operand. Therefore, the length Bit positions 56-59 of general register R are used
in bytes of each operand is 1-256, corresponding as the source access key. Bit positions 0-55 and
to a length code in L of 0-255. 60-63 of the register are ignored.
The fetch accesses to the second-operand General register R contains an unsigned binary
location are performed by using the PSW key, and integer called the true length. In the 24-bit or
the store accesses to the first-operand location 31-bit addressing mode, the true length is in bit
are performed by using the key specified in positions 32-63 of the register, and the contents of
general register 1. bit positions 0-31 of the register are ignored. In

10-52 z/Architecture Principles of Operation


the 64-bit addressing mode, the true length is in ister 3 is one. Otherwise, a privileged-operation
bit positions 0-63 of the register. exception is recognized. In the supervisor state,
any value for the source access key is valid.
The contents of the general registers just
described are as follows: The priority of the recognition of exceptions and
condition codes is shown in Figure 10-20 on
24-Bit or 31-Bit Addressing Mode page 10-54.
/
R /// True Length
/ Resulting Condition Code:
32 63 0 True length less than or equal to 256
1 --
64-Bit Addressing Mode 2 --
/ 3 True length greater than 256
R True Length
/ Program Exceptions:
63
Access (fetch, operand 2; store, operand 1)
/ Privileged operation (selected PSW-key-mask
R ////////////////////////////Key //// bit is zero in the problem state)
/
56 6 63
1.-6. Exceptions with the same priority as
the priority of program-interruption
The first and second operands are of the same conditions for the general case.
length, called the effective length. The effective
length is equal to the true length or 256, which- 7.A Access exceptions for second and third
ever is less. Access exceptions for the first and instruction halfwords.

second operands are recognized only for that
8. Privileged-operation exception due to
portion of the operand within the effective length. selected PSW-key-mask bit being zero
When the effective length is zero, no access in the problem state.
exceptions are recognized for the first and second
operands, and no movement takes place. 9. Completion due to length zero.

1. Access exceptions for operands.
Each storage operand is processed left to right.

When the storage operands overlap, the result is
obtained as if the operands were processed one Figure 10-20. Priority of Execution: MOVE WITH KEY
byte at a time and each result byte were stored
immediately after the necessary operand byte was Programming Notes:
fetched. The storage-operand-consistency rules 1. MOVE WITH KEY can be used in a loop to
are the same as for the MOVE (MVC) instruction. move a variable number of bytes of any
length, as follows:
As part of the execution of the instruction, the
LA RW,256
value of the true length is used to set the condi-
LOOP MVCK D(R,B),D(B),R
tion code. If the true length is 256 or less,
BC 8,END
including zero, the true length and effective length AR B,RW
are equal, and condition code 0 is set. If the true AR B,RW
length is greater than 256, the effective length is SR R,RW
256, and condition code 3 is set. B LOOP
END [Any instruction]
Special Conditions
The above program is for execution in the
In the problem state, the operation is performed 24-bit or 31-bit addressing mode. In the 64-bit
only if the source access key is valid, that is, if the addressing mode, AGR and SGR instructions
corresponding PSW-key-mask bit in control reg- should be substituted for the AR and SR
instructions.

Chapter 10. Control Instructions 10-53


2. The performance of MOVE WITH KEY on Each of the operands is processed left to right.
most models may be significantly slower than When the operands overlap destructively in real
that of the MOVE (MVC) and MOVE LONG storage, the results in the first-operand location
instructions. Therefore, MOVE WITH KEY are unpredictable. Except for this unpredictability
should not be used if the keys of the source in the case of destructive overlap, the storage-
and the target are the same. operand-consistency rules are the same as for the
MOVE (MVC) instruction.
MOVE WITH SOURCE KEY Special Conditions
MVCSK D(B),D(B) [SSE]
In the problem state, the operation is performed
// only if the access key specified in general register
'E5E' B D B D 1 is valid, that is, if the corresponding
// PSW-key-mask bit in control register 3 is one.
16 2 32 36 47
Otherwise, a privileged-operation exception is
recognized. In the supervisor state, any value for
The first operand is replaced by the second the specified access key is valid.
operand. The accesses to the source-operand
location are performed by using the key specified Condition Code: The code remains unchanged.
in general register 1, and the accesses to the
destination-operand location are performed by Program Exceptions:
using the PSW key. Access (fetch, operand 2; store, operand 1)
Privileged operation (selected PSW-key-mask
The first and second operands are of the same
bit is zero in the problem state)
length, which is specified by bits 56-63 of general
register 0. Bits 0-55 of general register 0 are Programming Notes:
ignored.
1. When data is to be moved alternately in both
Bits 56-59 of general register 1 are used as the directions between two storage areas that are
specified access key. Bits 0-55 and 60-63 of fetch protected by means of different keys,
general register 1 are ignored. then MOVE WITH SOURCE KEY and MOVE
WITH DESTINATION KEY can be used while
The contents of general registers 0 and 1 are as leaving the PSW key unchanged; and this
follows: may be, on most models, significantly faster
than using MOVE WITH KEY along with SET
/ PSW KEY FROM ADDRESS to change the
GR //////////////////////////// L PSW key.
/
56 63 2. MOVE WITH SOURCE KEY and MOVE WITH
DESTINATION KEY should be used only
/ when movement is between storage areas
GR1 ////////////////////////////Key //// having different keys. The performance of
/ these instructions on most models may be sig-
56 6 63
nificantly slower than that of the MOVE (MVC)
instruction.
L specifies the number of bytes to the right of the
3. MOVE WITH SOURCE KEY or MOVE WITH
first byte of each operand. Therefore, the length
DESTINATION KEY can be used in a loop to
in bytes of each operand is 1-256, corresponding
move a variable number of bytes as shown in
to a length code in L of 0-255.
the following example. In the example, the
The fetch accesses to the second-operand specified access key, the first-operand
location are performed by using the key specified address, the second-operand address, and
in general register 1, and the store accesses to the length of each operand are assumed to be
the first-operand location are performed by using in general registers 1-4, respectively, at the
the PSW key.

10-54 z/Architecture Principles of Operation


beginning of the example. The length of each subject to key-controlled storage protection, but
operand is treated as a 32-bit signed value, low-address protection does apply. PAGE IN is
and a negative value is treated as zero. not subject to program-event recording for storage
LTR 4,4 alteration.
BC 12,END
S 4,=F'256' A serialization and checkpoint-synchronization
BC 12,LAST function is performed before the operation begins
LA ,255 and again after the operation is completed.
LOOP MVCSK (2),(3)
LA 2,256(2) If the page-in operation is completed with no
LA 3,256(3) errors, condition code 0 is set.
S 4,=F'256'
BC 2,LOOP If the page-in operation encounters an expanded-
LAST LA ,255(4) storage data error, condition code 1 is set. For an
MVCSK (2),(3) expanded-storage data-error condition, the con-
END [Any instruction] tents of the entire 4K-byte block in real storage is
unpredictable, but this condition does not result in
PAGE IN generation of invalid checking-block codes in real
storage.
PGIN R,R [RRE]
If the expanded-storage block is not available, that
is, the block is not provided or is not currently in
'B22E' //////// R R
the configuration, then condition code 3 is set, and

16 24 28 31 no other action is taken.

Operation of PAGE IN in a Multiple-CPU Con-


A page-in operation is performed which transfers a figuration
4K-byte block to the real-storage location desig-
nated by general register R from the expanded- The accesses to main storage and to expanded
storage block designated by general register R. storage by PAGE IN are not necessarily single-
access references and are not necessarily per-
Bits 32-63 of general register R are a 32-bit formed in a left-to-right direction, as observed by
unsigned binary integer called the expanded- other CPUs and by channel programs.
storage-block number. This number designates
the 4K-byte block of expanded storage which is to See also the description under PAGE OUT.
be transferred. If the expanded-storage-block
number designates an inaccessible block in Resulting Condition Code:
expanded storage, condition code 3 is set.
0 Page-in operation completed
The contents of general register R are a real 1 Expanded-storage data error
address which designates a 4K-byte block in main 2 --
storage. In the 24-bit-addressing mode, bits 40-51 3 Expanded-storage block not available
designate the block, and bits 0-39 are ignored. In
Program Exceptions:
the 31-bit-addressing mode, bits 33-51 designate
the block, and bits 0-32 are ignored. In the Addressing (block designated by general reg-
64-bit-addressing mode, bits 0-51 designate the ister R)
block. In all modes, bits 52-63 of the address are Operation (if the expanded-storage facility is
ignored. not installed)
Privileged operation
Because it is a real address, the address desig- Protection (block designated by general reg-
nating the main-storage block is not subject to ister R; low-address protection)
dynamic address translation. PAGE IN is not

Chapter 10. Control Instructions 10-55


PAGE OUT Regardless of whether condition code 0 or condi-
tion code 1 is set, the entire 4K-byte block is
PGOUT R,R [RRE] written. Errors, if any, in the block after the block
is written are preserved. Thus, if a subsequent
execution of PAGE IN addresses the same
'B22F' //////// R R expanded-storage block, the expanded-storage

16 24 28 31 data error will be detected and condition code 1


will be indicated.

A page-out operation is performed which transfers If the expanded-storage block is not available, that
a 4K-byte block from the real-storage location des- is, the block is not provided or is not currently in
ignated by general register R to the expanded- the configuration, then condition code 3 is set, and
storage block designated by general register R. no other action is taken.

Bits 32-63 of general register R are a 32-bit Operation of PAGE OUT in a Multiple-CPU
unsigned binary integer called the expanded- Configuration
storage-block number. This number designates
the 4K-byte block of expanded storage which is to The accesses to main storage and to expanded
be replaced. If the expanded-storage-block storage by PAGE OUT are not necessarily single-
number designates an inaccessible block in access references and are not necessarily per-
expanded storage, condition code 3 is set. formed in a left-to-right direction, as observed by
other CPUs and by channel programs.
The contents of general register R are a real
address which designates a 4K-byte block in main If two or more CPUs issue PAGE IN or PAGE
storage. In the 24-bit-addressing mode, bits 40-51 OUT instructions at approximately the same
designate the block, and bits 0-39 are ignored. In instant in time, depending on the model, the oper-
the 31-bit-addressing mode, bits 33-51 designate ations may be performed one at a time, or the
the block, and bits 0-32 is ignored. In the operations may be performed concurrently. Con-
64-bit-addressing mode, bits 0-51 designate the current operation may occur even if the
block. In all modes, bits 52-63 of the address are instructions address the same expanded-storage
ignored. block.

Because it is a real address, the address desig- When two or more PAGE OUT instructions
nating the main-storage block is not subject to addressing the same expanded-storage block are
dynamic address translation. PAGE OUT is not executed concurrently, the resulting values in the
subject to key-controlled protection. expanded-storage block for each group of bytes
transferred may be from any of the instructions
A serialization and checkpoint-synchronization being executed simultaneously. The number of
function is performed before the operation begins bytes transferred as a group depends on the
and again after the operation is completed. model.

Depending on the model, after the data has been Similarly, for concurrent execution of a PAGE IN
written to the expanded-storage block, a read- and a PAGE OUT instruction for the same
back-check operation may be performed to deter- expanded-storage block, the resulting values for
mine whether the data was written correctly. If the each group of bytes transferred as a result of the
read-back-check operation determines that the execution of the PAGE IN instruction may be
data has been written correctly, condition code 0 either the old or new values from the expanded-
is set. If the read-back-check operation storage block.
encounters an expanded-storage data error, con-
dition code 1 is set. Concurrent operation of paging instructions does
not result in expanded-storage data errors.
Most models do not perform the read-back-check
operation, and, after the page-out operation is Resulting Condition Code:
completed, condition code 0 is set.
0 Page-out operation completed

10-56 z/Architecture Principles of Operation


1 Expanded-storage data error cation of whether the resulting addressing mode is
2 -- the 64-bit mode, the program-call number, and the
3 Expanded-storage block not available contents of general registers 0-15 and access reg-
isters 0-15 also are placed in the state entry.
Program Exceptions:
For basic PROGRAM CALL, the extended-
Addressing (block designated by general reg-
addressing-mode bit, bit 31 of the PSW, must
ister R)
have the same value as the entry-extended-
Operation (if the expanded-storage facility is
addressing-mode bit, bit 129 of the ETE; other-
not installed)
wise, a special-operation exception is recognized.
Privileged operation
Basic PROGRAM CALL does not change bit 31 of
the PSW and, therefore, does not switch between
PROGRAM CALL a basic addressing mode (the 24-bit or 31-bit
mode) and the extended addressing mode (the
PC D(B) [S]
64-bit mode). In the 24-bit or 31-bit addressing
mode, basic PROGRAM CALL sets the basic-
'B218' B D addressing-mode bit, bit 32 of the PSW, with the
value of the entry-basic-addressing-mode bit, bit
16 2 31 32 of the ETE, and, thus, it may switch between
the 24-bit and 31-bit addressing modes. In the
A program-call number specified by the second- 64-bit addressing mode, bit 32 of the PSW
operand address is used %pr in a two-level lookup remains unchanged.
%epr to locate an entry-table entry (ETE). The
program is authorized to use the ETE when the Stacking PROGRAM CALL, when bit 129 of the
AND of the PSW-key mask in control register 3 ETE is zero, sets bit 31 of the PSW to zero and
and the authorization key mask in the ETE is sets bit 32 of the PSW with the value of bit 32 of
nonzero or when the CPU is in the supervisor the ETE. When bit 129 of the ETE is one,
state. stacking PROGRAM CALL sets bits 31 and 32 of
the PSW to one. Thus, stacking PROGRAM
When the PC-type bit, bit 128 of the ETE, is zero, CALL can set the 24-bit, 31-bit, or 64-bit
an operation called basic PROGRAM CALL is per- addressing mode.
formed. When the PC-type bit is one, an opera-
tion called stacking PROGRAM CALL is When the resulting addressing mode is the 24-bit
performed. or 31-bit mode, both basic and stacking
PROGRAM CALL place bits 33-62 of the entry
Basic PROGRAM CALL, in the 24-bit or 31-bit instruction address in the ETE, which are bits
addressing mode, loads the basic-addressing- 33-62 of the ETE, with 33 leftmost and one right-
mode bit, bits 33-62 of the updated instruction most zeros appended, in bit positions 64-127 of
address, and the problem-state bit from the PSW the PSW as the new instruction address, and they
into bit positions 32-63 of general register 14, and place the entry-problem-state bit, bit 63 of the
it leaves bits 0-31 of this register unchanged. In ETE, in bit position 15 of the PSW as the new
the 64-bit addressing mode, bits 0-62 of the problem-state bit. Bits 32-63 of the entry param-
updated instruction address and the problem-state eter in the ETE are placed in bit positions 32-63 of
bit are placed in bit positions 0-63 of general reg- general register 4, and bits 0-31 of this register
ister 14. In any addressing mode, the PSW-key remain unchanged.
mask and PASN are placed in bit positions 32-63
of general register 3, and bits 0-31 of this register When the resulting addressing mode is the 64-bit
remain unchanged. mode, both basic and stacking PROGRAM CALL
place bits 0-62 of the entry instruction address,
Stacking PROGRAM CALL places the entire PSW bits 0-62 of the ETE, with with one rightmost zero
contents, except with an unpredictable PER mask, appended, in bit positions 64-127 of the PSW, and
and also the PSW-key mask, PASN, SASN, and they place bit 63 of the ETE in bit position 15 of
EAX in a linkage-stack program-call state entry the PSW. Bits 0-63 of the entry parameter in the
that it forms. A called-space identification, an indi- ETE are placed in general register 4.

Chapter 10. Control Instructions 10-57


Basic PROGRAM CALL ORs the entry key mask Second-Operand Address
from the ETE into the PSW-key mask in control
register 3. Stacking PROGRAM CALL does the PC Number
/
same, or it replaces the PSW-key mask with the /////////////// LX EX
entry key mask, as determined by the /
PSW-key-mask control in the ETE. 44 56 63

Stacking PROGRAM CALL optionally replaces the


Linkage Index (LX): Bits 44-55 of the second-
PSW key in the PSW and the EAX in control reg-
operand address are the linkage index and are
ister 8 from the ETE, and it sets the address-
used to select an entry from the linkage table des-
space-control bits in the PSW, as determined by
ignated by the linkage-table designation in the
control bits in the ETE.
primary ASTE.
The ETE causes a space-switching operation to
Entry Index (EX): Bits 56-63 of the second-
occur if it contains a nonzero ASN. When the
operand address are the entry index and are used
ETE contains a zero ASN, the operation is called
to select an entry from the entry table designated
PROGRAM CALL to current primary (PC-cp);
by the linkage-table entry.
when the ETE contains a nonzero ASN, the oper-
ation is called PROGRAM CALL with space Bits 0-43 of the second-operand address are
switching (PC-ss). When space switching is spec- ignored.
ified, the new PASN is loaded into control register
4 from the ETE, and a new primary-ASTE origin The linkage-table and entry-table lookup process
(PASTEO) is loaded into control register 5, also is depicted in part 1 of Figure 10-22 on
from the ETE. From the PASTE, a new primary page 10-65. The detailed definition of this table-
ASCE (PASCE) and AX are loaded into control lookup process is in PC-Number Translation on
registers 1 and 4, respectively. page 5-29.

In both PC-cp and PC-ss, the SASN and sec- The 32-byte entry-table entry (ETE) has the fol-
ondary ASCE (SASCE) are set equal to the ori- lowing format:
ginal PASN and PASCE, respectively. However,
the space-switching stacking PROGRAM CALL When Resulting Addressing Mode Is the
operation may instead set the SASN and SASCE 24-Bit or 31-Bit Mode
equal to the new PASN and PASCE, respectively,
A EIA P
as determined by a control bit in the ETE.
32 63
In a PC-ss to the base space of the dispatchable
unit when the dispatchable unit is subspace
When Resulting Addressing Mode Is the
active, bits 0-55 and 58-63 of the new PASCE are 64-Bit Mode
replaced by the same bits of the ASCE in the
ASTE for the subspace in which the dispatchable EIA P
unit last had control. This occurs before the pos-
sible setting of the SASCE equal to the PASCE. 63

PROGRAM CALL PC-Number Translation


AKM ASN EKM
The second-operand address is not used to
address data; instead, the rightmost 20 bits of the 64 8 96 112 127
address are used as a PC number and have the
following format:
Cntrl/EK EEAX ASTE Adr

128 144 16 186 191

10-58 z/Architecture Principles of Operation


instruction address) are placed in bit positions
Entry Parameter 33-62 of general register 14, bit 32 of the PSW
(the basic-addressing-mode bit) is placed in bit
192 255
position 32 of the register, and bit 15 of the PSW
(the problem-state bit) is placed in bit position 63
Bits 128-143 of the ETE have the following of the register. Bits 0-31 of the register remain
detailed format: unchanged.
In the 64-bit addressing mode, bits 64-126 of the
TG KMECS EK
PSW (bits 0-62 of the updated instruction address)
128 131 136 143 are placed in bit positions 0-62 of general register
14, and bit 15 of the PSW (the problem-state bit)
is placed in bit position 63 of the register.
For basic PROGRAM CALL in the 24-bit or 31-bit
addressing mode when bit 32 of the ETE (A) is In the 24-bit or 31-bit addressing mode, bits 32
zero (specifying the 24-bit mode), and for stacking and 33-62 of the ETE (A and the EIA), with a zero
PROGRAM CALL when bits 32 (A) and 129 (G) appended on the right of bits 33-62, are placed in
are zeros (specifying the 24-bit mode), bits 33-39 PSW bit positions 32 and 97-127, respectively (the
must be zeros; otherwise, a PC-translation- basic-addressing-mode bit and bits 33-63 of the
specification exception is recognized. instruction address). In the 64-bit addressing
mode, bits 0-62 of the ETE, with a zero appended
After the ETE has been fetched, if the current
on the right, are placed in PSW bit positions
PSW specifies the problem state, the current
64-127 (the instruction address), and PSW bit 32
PSW-key mask in control register 3 is tested
remains unchanged. In any addressing mode, bit
against the AKM field in the ETE to determine
63 of the ETE (P) is placed in PSW bit position 15
whether the program is authorized to access this
(the problem-state bit).
entry. The AKM and PSW-key mask are ANDed,
and, if the result is zero, a privileged-operation The PSW-key mask, bits 32-47 of control register
exception is recognized. The PSW-key mask in 3, is placed in bit positions 32-47 of general reg-
control register 3 remains unchanged. When ister 3, and the current PASN, bits 48-63 of
PROGRAM CALL is executed in the supervisor control register 4, is placed in bit positions 48-63
state, the AKM field is ignored. of general register 3. Bits 0-31 of general register
3 remain unchanged.
If the result of the AND of the AKM and the
PSW-key mask is not zero, or if the CPU is in the Bits 96-111 of the ETE (the EKM) are ORed with
supervisor state, the execution of the instruction the PSW-key mask, bits 32-47 of control register
continues. 3, and the result replaces the PSW-key mask in
control register 3.
If bit 128 of the ETE (T) is zero, the basic
PROGRAM CALL operation is specified. If bit 128 In the 24-bit or 31-bit addressing mode, bits
of the ETE is one, the stacking PROGRAM CALL 224-255 of the ETE (bits 32-63 of the entry
operation is specified. parameter) are loaded into bit positions 32-63 of
general register 4, and bits 0-31 of the register
Basic PROGRAM CALL
remain unchanged. In the 64-bit addressing
mode, bits 192-255 of the ETE (the entry param-
The following operations are performed when
eter), are loaded into bit positions 0-63 of general
basic PROGRAM CALL is specified.
register 4.
Bit 31 of the current PSW (the extended-
Stacking PROGRAM CALL
addressing-mode bit) must equal bit 129 (G) of the
ETE; otherwise, a special-operation exception is
The following operations are performed when
recognized.
stacking PROGRAM CALL is specified.
In the 24-bit or 31-bit addressing mode, bits
97-126 of the PSW (bits 33-62 of the updated

Chapter 10. Control Instructions 10-59


The stacking process is performed to form a the ETE (the EEAX) replace the EAX in control
linkage-stack program-call state entry and place register 8.
the following information in the state entry:
current PSW (with an unpredictable PER mask), When bit 134 of the ETE (C) is zero, bits 16 and
PSW-key mask, PASN, SASN, EAX, called-space 17 of the PSW (the address-space-control bits)
identification, an indication of whether the resulting are set to 00 binary (primary-space mode). When
addressing mode is the 64-bit mode, program-call bit 134 of the ETE is one, the address-space-
number, contents of general registers 0-15, and control bits in the PSW are set to 01 binary
contents of access registers 0-15. This is (access-register mode).
described in Stacking Process on page 5-72.
The entry-type code in the state entry is 0001101 When the resulting addressing mode is the 24-bit
binary. or 31-bit mode, bits 224-255 of the ETE (bits
32-63 of the entry parameter) are loaded into bit
When bit 129 of the ETE (G) is zero, bit 31 of the positions 32-63 of general register 4, and bits 0-31
PSW (the extended-addressing-mode bit) is set to of this register remain unchanged. When the
zero, and bit 32 of the ETE (A) is placed in bit resulting addressing mode is the 64-bit mode, bits
position 32 of the PSW (the basic-addressing- 192-255 of the ETE (the entry parameter), are
mode bit). (The addressing mode is set to the loaded into bit positions 0-63 of general register 4.
24-bit mode if bit 32 is zero or to the 31-bit mode
if bit 32 is one.) When bit 129 of the ETE is one, Key-controlled protection does not apply to refer-
bits 31 and 32 of the PSW are set to one. (The ences to the linkage stack, but low-address and
64-bit addressing mode is set.) page protection do apply.

When the resulting addressing mode is the 24-bit PROGRAM CALL to Current Primary (PC-cp)
or 31-bit mode, bits 33-62 of the ETE (the EIA),
with 33 leftmost and one rightmost zeros If bits 80-95 of the ETE (the ASN), are zeros,
appended, are placed in PSW bit positions 64-127 PROGRAM CALL to current primary (PC-cp) is
(the instruction address). When the resulting specified, and the execution of the instruction is
addressing mode is the 64-bit mode, bits 0-62 of completed after the operations described in
the ETE (the EIA), with one rightmost zero PROGRAM CALL PC-Number Translation and
appended, are placed in PSW bit positions either Basic PROGRAM CALL or Stacking
64-127. PROGRAM CALL have been performed and the
following operations have been performed.
Bit 63 of the ETE (P) is placed in PSW bit position
15 (the problem-state bit). The current PASN, bits 48-63 of control register 4,
is placed in bit positions 48-63 of control register 3
When bit 131 of the ETE (K) is zero, bits 8-11 of to become the current SASN.
the PSW (the PSW key) remain unchanged.
When bit 131 of the ETE is one, bits 136-139 of The current PASCE in control register 1 is placed
the ETE (the EK) replace the PSW key in the in control register 7 to become the current
PSW. SASCE.

When bit 132 of the ETE (M) is zero, bits 96-111 The basic PC-cp operation is depicted in parts 1-3
of the ETE (the EKM) are ORed with the PSW-key of Figure 10-22 on page 10-65. The stacking
mask, bits 32-47 of control register 3, and the PC-cp operation is depicted in parts 1, 4, and 5 of
result replaces the PSW-key mask in control reg- the figure.
ister 3. When bit 132 of the ETE is one, bits
PROGRAM CALL with Space Switching (PC-ss)
96-111 of the ETE replace the PSW-key mask in
control register 3.
If the ASN in the ETE is nonzero, PROGRAM
CALL with space switching (PC-ss) is specified,
When bit 133 of the ETE (E) is zero, the EAX, bits
and the execution of the instruction is completed
32-47 of control register 8, remains unchanged.
after the operations described in PROGRAM
When bit 133 of the ETE is one, bits 144-159 of
CALL PC-Number Translation and either Basic
PROGRAM CALL or Stacking PROGRAM CALL

10-60 z/Architecture Principles of Operation


have been performed and the following operations the dispatchable unit, then bits 0-55 and 58-63 of
have been performed. the PASCE are replaced by the same bits of the
ASCE in the ASTE for the subspace in which the
Bits 80-95 of the ETE (the ASN) are placed in bit dispatchable unit last had control. This replace-
positions 48-63 of control register 4 as the new ment occurs before a replacement of the SASCE
PASN. in control register 7 by the PASCE. Further
details are in Subspace-Replacement Operations
Bits 161-185 of the ETE, with six zeros appended on page 5-59.
on the right, are used as the real address of the
ASTE designated by the new PASN. An The PC-ss operation is depicted in parts 1 and 4-6
ASX-translation exception is recognized if bit 0 of of Figure 10-22 on page 10-65.
the ASTE is one.
PROGRAM CALL Serialization
Bits 64-127 of the ASTE (the ASCE) are placed in
control register 1 as the new PASCE. For both the PC-cp and PC-ss operations, a
serialization and checkpoint-synchronization func-
Bits 32-47 of the ASTE (the AX) are placed in bit tion is performed before the operation begins and
positions 32-47 of control register 4 as the new again after the operation is completed.
authorization index.
Special Conditions
Bits 33-57 of the ASTE address are placed in bit
positions 33-57 of control register 5 as the new The basic PROGRAM CALL operation can be per-
primary-ASTE origin, and zeros are placed in bit formed successfully only when (1) the CPU is in
positions 32 and 58-63. Bits 0-31 of the register the primary-space mode at the beginning of the
remain unchanged. operation, (2) the subsystem-linkage control, bit 0
of the linkage-table designation, is one, and
In basic PROGRAM CALL, or in stacking (3) the extended-addressing-mode bit, bit 31 of
PROGRAM CALL when bit 135 of the ETE (S) is the current PSW, equals the entry-extended-
zero, the PASN existing before the PASN is addressing-mode bit, bit 129 of the entry-table
replaced from the ETE is placed in bit positions entry. Stacking PROGRAM CALL can be per-
48-63 of control register 3 to become the current formed successfully only when the CPU is in the
SASN, and the PASCE existing before the PASCE primary-space mode or access-register mode at
is replaced from the ASTE is placed in control reg- the beginning of the operation and the subsystem-
ister 7 to become the current SASCE. (The SASN linkage control is one. In addition, PC-ss can be
and SASCE are set equal to the old PASN and performed successfully only when the
PASCE, respectively.) ASN-translation control, bit 44 of control register
14, is one. If any of these rules is violated, a
In stacking PROGRAM CALL when bit 135 of the special-operation exception is recognized.
ETE (S) is one, the SASN is replaced by the
PASN after the PASN is replaced from the ETE, A stack-full or stack-specification exception may
and the SASCE is replaced by the PASCE after be recognized during the stacking process.
the PASCE is replaced from the ASTE. (The
SASN and SASCE are set equal to the new PASN When, for PC-ss, the primary space-switch-event-
and PASCE, respectively.) control bit, bit 57 of control register 1, is one either
before or after the execution of the instruction, a
The description in this paragraph applies to use of space-switch-event program interruption occurs
the subspace-group facility. After the new PASCE after the operation is completed. A space-switch-
has been placed in control register 1 and the new event program interruption also occurs after the
primary-ASTE origin has been placed in control completion of a PC-ss operation if a PER event is
register 5, if (1) the subspace-group-control bit, bit reported.
54, in the PASCE is one, (2) the dispatchable unit
is subspace active, and (3) the primary-ASTE The operation is suppressed on all addressing and
origin designates the ASTE for the base space of protection exceptions.

Chapter 10. Control Instructions 10-61


The priority of recognition of program exceptions ASX translation (PC-ss only)
for the instruction is shown in Figure 10-21 on EX translation
page 10-63. LX translation
PC-translation specification
Condition Code: The code remains unchanged. Privileged operation (AND of AKM and
PSW-key mask is zero in the problem state)
Program Exceptions: Space-switch event (PC-ss only)
Access (fetch or store, except for key- Special operation
controlled protection, linkage-stack entry) Stack full (stacking PC only)
Addressing (linkage-table designation in Stack specification (stacking PC only)
primary ASN-second-table entry; linkage-table Subspace replacement (PC-ss only)
entry; entry-table entry; ASN-second-table Trace
entry, PC-ss only)

10-62 z/Architecture Principles of Operation



1.-6. Exceptions with the same priority as the priority of program-
interruption conditions for the general case.

7.A Access exceptions for second instruction halfword.

7.B Special-operation exception due to DAT being off or the CPU
being in secondary-space mode or home-space mode.

8.A Trace exceptions.

8.B.1 Addressing exception for access to linkage-table designation
in primary ASN-second-table entry.

8.B.2 Special-operation exception due to subsystem-linkage control
in linkage-table designation being zero.

8.B.3 LX-translation exception due to linkage-table entry being
outside table.

8.B.4 Addressing exception for access to linkage-table entry.

8.B.5 LX-translation exception due to I bit (bit ) in
linkage-table entry being one.

8.B.6 EX-translation exception due to entry-table entry being
outside table.

8.B.7 Addressing exception for access to entry-table entry.

8.B.8 Special-operation exception due to the CPU being in access-
register mode or extended-addressing-mode bit, bit 31 of PSW,
not equal to entry-extended-addressing-mode bit, bit 129 of
entry-table entry (basic PC only).

8.B.9 PC-translation-specification exception due to invalid combi-
nation (bits 33-39 not zeros when resulting addressing mode
is 24 bit) in entry-table entry.

8.B.1 Privileged-operation exception due to zero result from ANDing
PSW-key mask and AKM in the problem state.

8.B.11 Special-operation exception due to ASN-translation control,
bit 44 of control register 14, being zero (PC-ss only).

8.B.12 Addressing exception for access to ASN-second-table entry
(PC-ss only).

8.B.13 ASX-translation exception due to I bit (bit ) in ASN-second-
table entry being one (PC-ss only).

Figure 10-21 (Part 1 of 2). Priority of Execution: PROGRAM CALL

Chapter 10. Control Instructions 10-63



Note: Subspace-replacement exceptions, which are not shown
in detail in this figure, can occur with any priority after
8.B.13 and before 9.

8.B.14 Access exceptions (fetch) for entry descriptor of the current
linkage-stack entry (stacking PC only).

Note: Exceptions 8.B.15-8.B.2 can occur only if there is
not enough remaining free space in the current linkage-stack
section.

8.B.15 Stack-specification exception due to remaining-free-space
value in current linkage-stack entry not being a multiple of
8.

8.B.16 Access exceptions (fetch) for second word of the trailer
entry of the current section. The entry is presumed to be a
trailer entry; its entry-type field is not examined
(stacking PC only).

8.B.17 Stack-full exception due to forward-section validity bit in
the trailer entry being zero (stacking PC only).

8.B.18 Access exceptions (fetch) for entry descriptor of the header
entry of the next section (stacking PC only). This entry is
presumed to be a header entry; its entry-type field is not
examined.

8.B.19 Stack-specification exception due to not enough remaining
free space in the next section (stacking PC only).

8.B.2 Access exceptions (store) for second word of the header entry
of the next section. If there is no exception, the header is
now called the current entry.

8.B.21 Access exceptions (store) for entry descriptor of the current
entry and for the new state entry (stacking PC only).

9. Space-switch event (PC-ss only).

Figure 10-21 (Part 2 of 2). Priority of Execution: PROGRAM CALL

10-64 z/Architecture Principles of Operation


PC-Number Translation

PROGRAM CALL Instruction



'B218' B D



Primary ASTE Bits 192-223 Operand-2
6 Address
V LTO LTL

(x128) //////////////////// LX EX \

(x4) (x32)

6
Linkage Table
5+


5
R I ETO ETL

(x64)






6
Entry Table
5+


5
R \\ A EIA P AKM ASN EKM

TGKMECSEKEEAX ASTE Adr. EP



R: Address is real.
\: In stacking PC, PC number is placed in linkage stack.
\\: First word and A of ETE are bits -32 of EIA if resulting addressing
mode is the 64-bit mode.
Figure 10-22 (Part 1 of 6). Execution of PROGRAM CALL

Chapter 10. Control Instructions 10-65


Basic PC-cp and PC-ss in 24- or 31-Bit Addressing Mode
Entry-Table Entry
/
A EIA P AKM ASN EKM TG ASTE Adr. EP 32-63
/
Shown again below T=
6
No
With 33 Zeros on Left =?5Special-Op.
Exception
6 6 6 6
PSW GR4
after P EA IA -62 32-63 EP 32-63
after
E=
From above

AKM ASN EKM



6
Priviledged-Op.
AND5Exception if
Zero in Problem
& State
6
CR3 CR4 / \
32-63 PKM SASN 32-63 AX PASN / \
before before Yes / \ No
ASN
% \ = /
6 \ / 6
6 PC-cp \_/ PC-ss
Instruction Operations
OR% Complete on ASTE (See
Part 6)

6 6 CR1
CR3 before PASCE
32-63 PKM SASN
after


6
6 6 CR7
GR3 after SASCE
32-63 PKM PASN
after

PSW
before P EA IA -62

E= IA 33-62




6 6 6
GR14
32-63AIA 33-62 P
after
Figure 10-22 (Part 2 of 6). Execution of PROGRAM CALL

10-66 z/Architecture Principles of Operation


Basic PC-cp and PC-ss in 64-Bit Addressing Mode
Entry-Table Entry
/
EIA P AKM ASN EKM TG ASTE Adr. EP
/
Shown again below T=
6
No
=1?5Special-Op.
Exception
6 6 6
PSW GR4
after P EA IA -62 after EP

E=1 A=1
From above

AKM ASN EKM




6
Priviledged-Op.
AND5Exception if
Zero in Problem
& State
6
CR3 CR4 / \
32-63 PKM SASN 32-63 AX PASN / \
before before Yes / \ No
ASN
% \ = /
6 \ / 6
6 PC-cp \_/ PC-ss
Instruction Operations
OR% Complete on ASTE (See
Part 6)

6 6
CR3 CR1
32-63 PKM SASN before PASCE
after



6 6 6
GR3 CR7
32-63 PKM PASN after SASCE
after

PSW
before P EA IA -62

E=1 A=1



6 6
GR14
after IA -62 P

Figure 10-22 (Part 3 of 6). Execution of PROGRAM CALL

Chapter 10. Control Instructions 10-67


Stacking PC-cp and PC-ss from 24- or 31-Bit Addressing Mode to 64-Bit Mode
Entry-Table Entry
//
EIA P AKM ASN EKM TGKMECSEKEEAXASTE Adr. EP
//
Shown again below T=1
G=1 GR4 after 6

EP


E=1
K=1
1 1 6
6 6 6 6 6 6 CR8
PSW // 32-63 EAX
after KeyPC EA IA -62 after
//

From above 5LS


CR8
AKM ASN EKM 32-63 EAX
before



6 Priviledged-Op.
Exception if
AND5Zero in Problem
State
& LS
& 6
CR3 CR4 / \
32-63 PKM SASN 32-63 AX PASN 5LS / \
before before Yes / \ No
ASN
%5LS \ = /
6 \ / 6
PC-cp \_/ PC-ss
6 Instruction Operations
Complete on ASTE (See
OR% Part 6)


M= M=1 PC-cp, or
PC-ss and S= \

6 6 6
CR3 CR1
32-63 PKM SASN before PASCE
after
PC-cp, or
PC-ss and S= \
PSW /
before PSW 5LS 6
/ CR7
after SASCE

\: If PC-ss and S=1, SASN is replaced by new PASN, and SASCE is replaced by new PASCE.
Figure 10-22 (Part 4 of 6). Execution of PROGRAM CALL

10-68 z/Architecture Principles of Operation


Stacking PC-cp and PC-ss from 64-Bit to 24- or 31-Bit Addressing Mode
Entry-Table Entry
//
A EIA P AKM ASN EKM TGKMECSEKEEAXASTE Adr. EP 32-63
//
Shown again below T=1
G=
6
With 33 Zeros on Left GR4
32-63 EP 32-63
after


E=1
K=1
6
6 6 6 6 6 6 CR8
PSW // 32-63 EAX
after KeyPC EA IA -62 after
//

From above 5LS


CR8
AKM ASN EKM 32-63 EAX
before



6 Priviledged-Op.
Exception if
AND5Zero in Problem
State
& LS
& 6
CR3 CR4 / \
32-63 PKM SASN 32-63 AX PASN 5LS / \
before before Yes / \ No
ASN
%5LS \ = /
6 \ / 6
PC-cp \_/ PC-ss
6 Instruction Operations
Complete on ASTE (See
OR% Part 6)


M= M=1 PC-cp, or
PC-ss and S= \

6 6 6
CR3 CR1
32-63 PKM SASN before PASCE
after
PC-cp, or
PC-ss and S= \
PSW /
before PSW 5LS 6
/ CR7
after SASCE

\: If PC-ss and S=1, SASN is replaced by new PASN, and SASCE is replaced by new PASCE.
Figure 10-22 (Part 5 of 6). Execution of PROGRAM CALL

Chapter 10. Control Instructions 10-69


Operations on ASN-Second-Table Entry for PC-ss

Entry-Table Entry

\ A EIA P AKM ASN EKM

TGKMECSEKEEAX ASTE Adr. EP





ASN-Second-Table Entry
R5
I ATO B AX ATL ASCE \\







6 6 6
CR1 CR4
after PASCE 32-63 AX PASN
\\\ after





6 6 6
CR5
32-63 PASTEO
after

R: Address is real.
\: First word and A of ETE are bits -32 of EIA if resulting addressing mode is the 64-bit mode.
\\: ASTE is 64 bytes; last 48 bytes are not shown.
\\\: Bits -55 and 58-63 of PASCE may be replaced from a subspace ASCE.
Figure 10-22 (Part 6 of 6). Execution of PROGRAM CALL

PROGRAM RETURN also are restored from the state entry. When the
entry-type code is 0001100 binary, indicating a
PR [E] branch state entry, the current PASN, SASN,
PKM, and EAX remain unchanged.

'11' The last state entry is located, and information in it

15 is restored, as described in Unstacking Process


on page 5-75. The state entry is logically deleted
from the linkage stack, and the linkage-stack-entry
The PSW, except for the PER-mask bit, saved in address in control register 15 is replaced by the
the last linkage-stack state entry is restored as the address of the next preceding state or header
current PSW. The PER mask in the current PSW entry. This also is described in Unstacking
remains unchanged. The contents of general reg- Process.
isters 2-14 and access registers 2-14 also are
restored from the state entry. When the entry- When the state entry is a program-call state entry,
type code in the entry descriptor of the state entry it causes a space-switching operation to occur if it
is 0001101 binary, indicating a program-call state contains a PASN that is not equal to the current
entry, the primary ASN (PASN), secondary ASN PASN. When the state entry contains a PASN
(SASN), PSW-key mask (PKM), and extended that is equal to the current PASN, the operation is
authorization index (EAX) in the control registers

10-70 z/Architecture Principles of Operation


called PROGRAM RETURN to current primary The description in this paragraph applies to use of
(PR-cp); when the state entry contains a PASN the subspace-group facility when PASN translation
that is not equal to the current PASN, the opera- has occurred. If (1) the subspace-group-control
tion is called PROGRAM RETURN with space bit, bit 54, in the new PASCE is one, (2) the
switching (PR-ss). PASN translation occurs in dispatchable unit is subspace active, and (3) the
PR-ss. SASN translation and authorization may new primary-ASTE origin designates the ASTE for
occur in either PR-cp or PR-ss. The terms PR-cp the base space of the dispatchable unit, then bits
and PR-ss do not apply when the state entry is a 0-55 and 58-63 of the new PASCE in control reg-
branch state entry. ister 1 are replaced by the same bits of the ASCE
in the ASTE for the subspace in which the
Key-controlled protection does not apply to dispatchable unit last had control. This replace-
accesses to the linkage stack, but low-address ment occurs, in the case when the new SASN is
and page protection do apply. equal to the new PASN, before the SASCE is set
equal to the PASCE. Further details are in
The sections PASN Translation, SASN Subspace-Replacement Operations on
Translation, SASN Authorization, and page 5-59.
PROGRAM RETURN Serialization apply only
when the unstacked state entry is a program-call SASN Translation
state entry. The functions described in those
sections are not performed when the state entry is If the new SASN is equal to the new PASN, the
a branch state entry. SASCE in control register 7 is set equal to the
new PASCE in control register 1. If the new
PASN Translation SASN is not equal to the new PASN, the new
SASN is translated to locate a 64-byte ASTE. Bits
If the new PASN is equal to the old PASN in bit 64-127 of the ASTE are placed in control register
positions 48-63 of control register 4, PASN trans- 7 as the new SASCE.
lation is not performed, and the authorization
index (AX), PASN, PASCE, and primary-ASN- SASN Authorization
second-table-entry (primary-ASTE) origin in the
control registers are not changed. If the new SASN is not equal to the new PASN,
the authority-table origin (ATO) from the ASTE for
If the new PASN is not equal to the old PASN, the the new SASN is used as the base for a third
new PASN is translated to locate a 64-byte ASTE. table lookup. The new authorization index, bits
The ASN table-lookup process is described in 32-47 of control register 4, is used, after it has
ASN Translation on page 3-18. The exceptions been checked against the authority-table length,
associated with ASN translation are collectively as the index to locate the entry in the authority
called ASN-translation exceptions. These table. The authority-table lookup is described in
exceptions and their priority are described in ASN Authorization on page 3-23.
Chapter 6, Interruptions.
The description in this paragraph applies to use of
Bits 64-127 of the ASTE are placed in control reg- the subspace-group facility when SASN translation
ister 1 as the new PASCE. and authorization have occurred. If (1) the
subspace-group-control bit, bit 54, in the new
Bits 32-47 of the ASTE are placed in bit positions SASCE is one, (2) the dispatchable unit is sub-
32-47 of control register 4 as the new AX. space active, and (3) the ASTE origin obtained by
SASN translation designates the ASTE for the
Bits 33-57 of the ASTE address are placed in bit base space of the dispatchable unit, then bits 0-55
positions 33-57 of control register 5 as the new and 58-63 are replaced by the same bits of the
primary-ASTE origin, and zeros are placed in bit ASCE of the ASCE in the ASTE for the subspace
positions 32 and 58-63. Bits 0-31 of this register in which the dispatchable unit last had control.
remain unchanged. Further details are in Subspace-Replacement
Operations on page 5-59.

Chapter 10. Control Instructions 10-71


PROGRAM RETURN Serialization code is 0. The specification exception, which in
this case is listed as a program exception in this
When the unstacked state entry is a program-call instruction, is described in Early Exception
state entry, a serialization and checkpoint- Recognition on page 6-9. It may be considered
synchronization function is performed before the as occurring early in the process of preparing to
operation begins and again after the operation is execute the following instruction.
completed.
If a space-switch event is indicated and the PSW
Special Conditions that was loaded by the instruction is invalid
because of a reason described in the preceding
The instruction can be executed successfully only paragraph, it is unpredictable whether the resulting
when the CPU is in the primary-space mode or instruction-length code is 0 or 1, or 0 or 2 if
access-register mode at the beginning of the oper- EXECUTE was used.
ation. In addition, the ASN-translation process
can be performed, for either the PASN or the The operation is suppressed on all addressing and
SASN, only when the ASN-translation control, bit protection exceptions.
44 of control register 14, is one. If either of these
rules is violated, a special-operation exception is The priority of recognition of program exceptions
recognized. for the instruction is shown in Figure 10-23 on
page 10-73.
A stack-empty, stack-operation, stack-
specification, or stack-type exception may be Resulting Condition Code: The code is set as
recognized during the unstacking process. specified in the new PSW loaded.

When, for PR-ss, the primary space-switch-event Program Exceptions:


control, bit 57 of control register 1, is one either
Access (fetch and store, except key-controlled
before or after the execution of the instruction, a
protection, linkage-stack entry)
space-switch-event program interruption occurs
Addressing (authority-table entry, if SASN
after the operation is completed. A space-switch-
translation occurs)
event program interruption also occurs after the
ASN translation (if PASN or SASN translation
completion of a PR-ss operation if a PER event is
occurs)
reported.
Secondary authority (if SASN translation
occurs)
The PSW which is to be loaded by the instruction
Space-switch event
is not checked for validity before it is loaded.
Special operation
However, after loading, a specification exception is
Specification
recognized, and a program interruption occurs, if
Stack empty
any of bits 0, 2-4, 12, 24-30, and 33-63 of the
Stack operation
PSW is a one, if bits 31 and 32 are zero and one,
Stack specification
respectively, and bits 64-96 are not all zeros, if
Stack type
bits 31 and 32 are both zero and bits 64-103 are
Subspace replacement (if PASN or SASN
not all zeros, or if bits 31 and 32 are one and
translation occurs)
zero, respectively. In these cases, the operation
Trace
is completed, and the resulting instruction-length

10-72 z/Architecture Principles of Operation



1.-6. Exceptions with the same priority as the priority of program-
interruption conditions for the general case.

7. Special-operation exception due to DAT being off or the CPU
being in secondary-space mode or home-space mode.

8.A Trace exceptions.

8.B.1 Access exceptions (fetch) for entry descriptor of the current
linkage-stack entry.

8.B.2 Stack-type exception due to current entry not being a state
entry or header entry.

Note: Exceptions 8.B.3-8.B.7 can occur only if the current
entry is a header entry.

8.B.3 Stack-operation exception due to unstack-suppression bit
in the header entry being one.

8.B.4 Access exceptions (fetch) for second word of the header
entry.

8.B.5 Stack-empty exception due to backward stack-entry validity
bit in the header entry being zero.

8.B.6 Access exceptions (fetch) for entry descriptor of preceding
entry, which is the entry designated by the backward
stack-entry address in the current (header) entry.

8.B.7 Stack-specification exception due to preceding entry being a
header entry.

8.B.8 Stack-type exception due to preceding entry not being a
state entry.

8.B.9 Stack-operation exception due to unstack-suppression bit
being one in the state entry.

8.B.1 Access exceptions (fetch) for the state entry, and access
exceptions (store) for entry descriptor of the entry .
preceding the state entry.

Figure 10-23 (Part 1 of 2). Priority of Execution: PROGRAM RETURN

Chapter 10. Control Instructions 10-73



Note: Exceptions 8.B.11-8.B.15 and the event 9 can occur
only if the state entry is a program-call state entry.

8.B.11 Special-operation exception due to the ASN-translation con-
trol, bit 54 of control register 14, being zero (if PASN or
SASN translation occurs).

8.B.12 ASN-translation exceptions (if PASN or SASN translation
occurs).

Note: Subspace-replacement exceptions for replacement of
bits in either the PASCE or the SASCE, which are not shown in
detail in this figure, can occur with any priority after
8.B.12 and before 9.

8.B.13 Secondary-authority exception due to authority-table entry
being outside table (if SASN translation occurs).

8.B.14 Addressing exception for access to authority-table entry (if
SASN translation occurs).

8.B.15 Secondary-authority exception due to S bit in authority-
table entry being zero (if SASN translation occurs).

9. Space-switch event (PR-ss only).

1. Specification exception due to any PSW error of the type that
causes an immediate interruption.

Figure 10-23 (Part 2 of 2). Priority of Execution: PROGRAM RETURN

Programming Note: Because PROGRAM CALL General registers R and R have the following
cannot be executed successfully in the secondary- format:
space or home-space mode, PROGRAM /
RETURN is not intended to load a PSW specifying R /// PSW-Key Mask ASN
one of these translation modes. PROGRAM /
RETURN, unlike SET ADDRESS SPACE 32 48 63
CONTROL and SET ADDRESS SPACE In 24-Bit or 31-Bit Addressing Mode
CONTROL FAST, does not recognize a space- /
switch event because of loading a PSW that spec- R ///A Instruction Address P
ifies the home-space mode. /
32 63
In 64-Bit Addressing Mode
PROGRAM TRANSFER /
R Instruction Address P
PT R,R [RRE] /
63

'B228' //////// R R When the contents of bit positions 48-63 of


general register R are equal to the current PASN,
16 24 28 31 the operation is called PROGRAM TRANSFER to
current primary (PT-cp); when the fields are not
The contents of general register R are used as equal, the operation is called PROGRAM
the new values for the PSW-key mask, the PASN, TRANSFER with space switching (PT-ss).
and the SASN. The contents of general register
R are used as the new values for the problem- The contents of general register R are used to
state bit, basic-addressing-mode bit, and instruc- update the problem-state bit and the instruction
tion address in the current PSW. address in the current PSW and, in the 24-bit or

10-74 z/Architecture Principles of Operation


31-bit addressing mode, also the basic- The PT-ss operation is depicted in parts 1 and 2
addressing-mode bit in the current PSW. Bit 63 of of Figure 10-25 on page 10-78. The PT-ss oper-
general register R is placed in the problem-state ation is completed as follows.
bit position, PSW bit position 15, unless the opera-
tion would cause PSW bit 15 to change from one For a PT-ss, the contents of bit positions 48-63 of
to zero (problem state to supervisor state). If such general register R are used as an ASN, which is
a change would occur, a privileged-operation translated by means of a two-level table lookup.
exception is recognized.
Bits 48-57 of general register R are a 10-bit AFX
In the 24-bit or 31-bit addressing mode, bit 32 of which is used to select an entry from the ASN first
general register R replaces the basic-addressing- table. Bits 58-63 are a six-bit ASX which is used
mode bit, bit 32 of the current PSW, and bits to select an entry from the ASN second table.
33-62 of the register, with one rightmost zero The ASN table-lookup process is described in
appended, replace bits 33-63 of the instruction ASN Translation on page 3-18. The exceptions
address in the PSW, bits 97-127 of the PSW. In associated with ASN translation are collectively
the 64-bit addressing mode, bits 0-62 of general called ASN-translation exceptions. These
register R, with one rightmost zero appended, exceptions and their priority are described in
replace the instruction address, and the basic- Chapter 6, Interruptions.
addressing-mode bit remains unchanged.
The authority-table origin from the
Bits 32-47 of general register R are ANDed with ASN-second-table entry (ASTE) is used as the
the PSW-key mask, bits 32-47 of control register base for a third table lookup. The current authori-
3, and the result replaces the PSW-key mask. zation index, bits 32-47 of control register 4, is
Bits 0-31 of general register R are ignored. used, after it has been checked against the
authority-table length, as the index to locate the
In both the PT-ss and PT-cp operations, the ASN entry in the authority table. The authority-table
specified by bits 48-63 of general register R lookup is described in ASN Authorization on
replaces the SASN in control register 3, and the page 3-23.
SASCE in control register 7 is replaced by the
final contents of control register 1. The PT-ss operation is completed by placing bits
64-127 of the ASTE in control register 1 as the
PROGRAM TRANSFER to Current Primary new PASCE and in control register 7 as the new
(PT-cp) SASCE. The contents of bit positions 32-47 of the
ASTE replace the authorization index in bit posi-
The PROGRAM TRANSFER to current primary tions 32-47 of control register 4. Bits 33-57 of the
(PT-cp) operation is depicted in part 1 of ASTE address are placed in bit positions 33-57 of
Figure 10-25 on page 10-78. The PT-cp opera- control register 5 as the new primary-ASTE origin,
tion is completed when the common portion of the and zeros are placed in bit positions 32 and
PROGRAM TRANSFER operation, described 58-63. Bits 0-31 of this register remain
above, is completed. The authorization index, unchanged. The ASN, bits 48-63 of general reg-
PASN, primary ASCE, and contents of control reg- ister R, replaces the SASN and PASN in bit posi-
ister 5 (primary-ASN-second-table-entry origin) are tions 48-63 of control registers 3 and 4.
not changed by PT-cp.
The description in this paragraph applies to use of
PROGRAM TRANSFER with Space Switching the subspace-group facility. After the new PASCE
(PT-ss) has been placed in control register 1 and the new
primary-ASTE origin has been placed in control
If the ASN in bit positions 48-63 of general reg- register 5, if (1) the subspace-group-control bit, bit
ister R is not equal to the current PASN, a 54, in the PASCE is one, (2) the dispatchable unit
PROGRAM TRANSFER with space switching is subspace active, and (3) the primary-ASTE
(PT-ss) operation is specified, and the ASN is origin designates the ASTE for the base space of
translated by means of a two-level table lookup. the dispatchable unit, then bits 0-55 and 58-63 of
the PASCE in control register 1 are replaced by
the same bits of the ASCE in the ASTE for the

Chapter 10. Control Instructions 10-75


subspace in which the dispatchable unit last had In addition to the above requirements, when a
control. This replacement occurs before a PT-ss instruction is specified, the ASN-translation
replacement of the SASCE in control register 7 by control, bit 44 of control register 14, must be one;
the PASCE. Further details are in Subspace- otherwise, a special-operation exception is recog-
Replacement Operations on page 5-59. nized.

PROGRAM TRANSFER Serialization When, for PT-ss, the primary space-switch-event-


control bit, bit 57 of register 1, is one either before
For both the PT-cp and PT-ss operations, a serial- or after the execution of the instruction, a space-
ization and checkpoint-synchronization function is switch-event program interruption occurs after the
performed before the operation begins and again operation is completed. A space-switch-event
after the operation is completed. program interruption also occurs after the com-
pletion of a PT-ss operation if a PER event is
Special Conditions reported.

The instruction can be executed only when the The operation is suppressed on all addressing
CPU is in the primary-space mode and the exceptions.
subsystem-linkage control, bit 0 of the linkage-
table designation, is one. If the CPU is in the real The priority of recognition of program exceptions
mode, secondary-space mode, access-register for the instruction is shown in Figure 10-24 on
mode, or home-space mode, or if the subsystem- page 10-77.
linkage control is zero, a special-operation excep-
tion is recognized. Condition Code: The code remains unchanged.

Bit 63 of general register R is placed in the Program Exceptions:


problem-state bit position, PSW bit position 15,
Addressing (linkage-table designation in
unless the operation would cause PSW bit 15 to
primary ASN-second-table entry; authority-
change from one to zero (problem state to super-
table entry, PT-ss only)
visor state). If such a change would occur, a
ASN translation (PT-ss only)
privileged-operation exception is recognized.
Primary authority (PT-ss only)
Privileged operation (attempt to set the super-
In the 24-bit or 31-bit addressing mode, the
visor state when in the problem state)
instruction is completed only if bits 32-39 of
Space-switch event (PT-ss only)
general register R specify a valid combination of
Special operation
PSW bits 32 and 97-103. If bit 32 of general reg-
Specification
ister R is zero and bits 33-39 are not all zeros, a
Subspace replacement (PT-ss only)
specification exception is recognized.
Trace

10-76 z/Architecture Principles of Operation



1.-6. Exceptions with the same priority as the priority of program-
interruption conditions for the general case.

7.A Access exceptions for second instruction halfword.

7.B Special-operation exception due to DAT being off or the CPU
being in secondary-space mode, access-register mode, or home-
space mode.

8.A Trace exceptions.

8.B.1 Addressing exception for access to linkage-table designation
in primary ASN-second-table entry.

8.B.2 Special-operation exception due to subsystem-linkage control
in linkage-table designation being zero.

8.B.3 Privileged-operation exception due to attempt to set the
supervisor state when in the problem state.

8.B.4 Specification exception due to invalid combination (bit 32 is
zero and bits 33-39 not zeros) in general register R in
24-bit or 31-bit addressing mode.

8.B.5 Special-operation exception due to the ASN-translation con-
trol, bit 44 of control register 14, being zero (PT-ss only).

8.B.6 ASN-translation exceptions (PT-ss only).

Note: Subspace-replacement exceptions, which are not shown
in detail in this figure, can occur with any priority after
8.B.6 and before 9.

8.B.7 Primary-authority exception due to authority-table entry
being outside table (PT-ss only).

8.B.8 Addressing exception for access to authority-table entry
(PT-ss only).

8.B.9 Primary-authority exception due to P bit in authority-table
entry being zero (PT-ss only).

9. Space-switch event (PT-ss only).

Figure 10-24. Priority of Execution: PROGRAM TRANSFER

Programming Notes: the 24-bit or 31-bit addressing mode, the


basic-addressing-mode bit also is restored.
1. The operation of PROGRAM TRANSFER (PT)
is such that it may be used to restore the CPU 2. With proper authority, and while executing in a
to the state saved by a previous basic common area, PROGRAM TRANSFER may
PROGRAM CALL operation. This restoration be used to change the primary address space
is accomplished by issuing PT 3,14. Though to any desired space. The secondary address
general registers 3 and 14 are not restored to space is also changed to be the same as the
their original values, the PASN, PSW-key new primary address space.
mask, problem-state bit, and instruction
3. Unlike the RR-format branch instructions, a
address are restored, and the authorization
value of zero in the R field for PROGRAM
index, PASCE, and
TRANSFER designates general register 0,
primary-ASN-second-table-entry origin are
and branching occurs.
made consistent with the restored PASN. In

Chapter 10. Control Instructions 10-77


PT-cp and PT-ss

PROGRAM TRANSFER
Instruction

'B228' ////RR




6 6
In 24-Bit Mode
R R
32-63 PKM ASN 32-63A IA 33-62 P




With 33
Zeros on
CR3 6 6 6 Left
32-63 PKM SASN PSW ///
before after P EA IA -62
///
E=
6

5AND 6 6
In 64-Bit Mode

R IA -62 P
6 6
CR3
32-63 PKM SASN
after
6 6
PSW ///
CR4 after P EA IA -62
32-63 AX PASN ///
before E=1 A=1


6 6 CR1
YesNo before PASCE
=

6 6 (PT-cp only)
PT-cp PT-ss 6
Instruction (See Part 2) CR7
Complete after SASCE

Figure 10-25 (Part 1 of 2). Execution of PROGRAM TRANSFER

10-78 z/Architecture Principles of Operation


PT-ss


6
CR14
32-63 T AFTO AFX ASX

(x496) (x4) (x64)


R
32-63 PKM ASN

6
ASN First Table 6
5+ %5



5
R I ASTO

(x16)







6
ASN Second Table
5+



R5
I ATO B AX ATL ASCE \

(x4)






CR4
32-63 AX PASN
before
(x1/4)

6
Authority Table %
5+ 6 6 6
CR1 CR4
after PASCE 32-63 AX PASN
\\ after
5
R PS
6
CR7
after SASCE
\\
6 6 6
5Primary-authority exception if P bit CR5
is zero or table length is exceeded 32-63 PASTEO
after

R: Address is real.
\: ASTE is 64 bytes; last 48 bytes are not shown.
\\: Bits -55 and 58-63 of PASCE and SASCE may be replaced from a subspace ASCE.

Figure 10-25 (Part 2 of 2). Execution of PROGRAM TRANSFER

PURGE ALB

Chapter 10. Control Instructions 10-79


PALB [RRE]
RESET REFERENCE BIT
EXTENDED
'B248' ////////////////
RRBE R,R [RRE]
16 31

'B22A' //////// R R
The ART-lookaside buffer (ALB) of this CPU is
cleared of entries. No change is made to the con- 16 24 28 31
tents of addressable storage or registers.
The reference bit in the storage key for the
The ALB appears cleared of its original contents
4K-byte block that is addressed by the contents of
beginning with the execution of the next sequential
general register R is set to zero. The contents of
instruction. The operation is not signaled to any
general register R are ignored.
other CPU.
In the 24-bit addressing mode, bits 40-51 of
A serialization function is performed.
general register R designate a 4K-byte block in
Condition Code: The code remains unchanged. real storage, and bits 0-39 and 52-63 of the reg-
ister are ignored. In the 31-bit addressing mode,
Program Exceptions: bits 33-51 of general register R designate a
4K-byte block in real storage, and bits 0-32 and
Privileged operation 52-63 of the register are ignored. In the 64-bit
addressing mode, bits 0-51 of general register R
PURGE TLB designate a 4K-byte block in real storage, and bits
52-63 of the register are ignored.
PTLB [S]
Because it is a real address, the address desig-
nating the storage block is not subject to dynamic
'B2D' ////////////////
address translation. The reference to the storage
16 31 key is not subject to a protection exception.

The remaining bits of the storage key, including


The translation-lookaside buffer (TLB) of this CPU the change bit, are not affected.
is cleared of entries. No change is made to the
contents of addressable storage or registers. The condition code is set to reflect the state of the
reference and change bits before the reference bit
The TLB appears cleared of its original contents is set to zero.
beginning with the fetching of the next sequential
instruction. The operation is not signaled to any Resulting Condition Code:
other CPU.
0 Reference bit zero; change bit zero
A serialization function is performed. 1 Reference bit zero; change bit one
2 Reference bit one; change bit zero
Condition Code: The code remains unchanged. 3 Reference bit one; change bit one

Program Exceptions: Program Exceptions:


Privileged operation Addressing (address specified by general reg-
ister R)
Privileged operation

10-80 z/Architecture Principles of Operation


RESUME PROGRAM is four bytes, from which bits 32-63 of general
register B will be replaced, there is not a
RP D(B) [S] general-register field 2 in the second operand,
and bits 0-31 of general register B will
remain unchanged.
'B277' B D
When bit 14 is one and bit 15 is zero, then the
16 2 31 general-register field 1 is eight bytes, from
which bits 0-63 of general register B will be
Certain contents of the current PSW and of replaced, and there is not a general-register
access register and general register B are field 2.
replaced from three or four corresponding fields in When bits 14 and 15 are both one, then the
the second operand. The size of the PSW field in general-register fields 1 and 2 are both four
the second operand, the size or number of bytes, bits 32-63 of general register B will be
general-register fields in the second operand, and replaced from field 1, and bits 0-31 of the reg-
the offsets of the fields in the second operand are ister will be replaced from field 2. (The letter
specified in a parameter list that immediately D stands for disjoint.)
follows the instruction in the instruction address
space. Bits 16-31 of the parameter list are an unsigned
binary integer that is the offset in bytes from the
The first 64 bits of the parameter list have the fol- beginning of the second operand to a field that
lowing format: has the format of an eight-byte or 16-byte PSW,
depending on bit 13, and from which fields in the

current PSW will be replaced. Bits 32-47 similarly


PRD Offset of PSW Fld
are an offset to a four-byte field from which the
13 16 31 contents of access register B will be replaced.
Bits 48-63 similarly are an offset to a four-byte or
eight-byte field, depending on bits 14 and 15, from
Offset of AR Fld Offset of GR Fld 1 which bits 32-63 or 0-63, respectively, of general

32 48 63 register B will be replaced. If bits 64-79 of the


parameter list exist, they similarly are an offset to
a four-byte field from which bits 0-31 of general
When bits 14 (R) and 15 (D) of the parameter list register B will be replaced.
are both one, the list is an additional 16 bits in
length, as follows: Bits 0-12 of the parameter list must be zeros; oth-
erwise, a specification exception is recognized.

Offset of GR Fld 2
An eight-byte second-operand PSW field has the
64 79 ESA/390 PSW format, as follows:

IE Prog
Bit 13 of the parameter list (P) specifies the size R TOX Key 1MWPA SC C Mask

of the PSW field in the second operand. The field 5 8 12 16 18 2 24 31
is eight bytes if bit 13 is zero or 16 bytes if bit 13
is one.
A Instruction Address

32 63
Bits 14 and 15 of the parameter list (R and D)
provide specifications about one or two general-
register fields in the second operand, as follows: A 16-byte second-operand PSW field has the
z/Architecture PSW format, as follows:
When bit 14 is zero, then bit 15 is ignored, the
general-register field 1 in the second operand

Chapter 10. Control Instructions 10-81



IE Prog E When RESUME PROGRAM is the target of an
RTOX Key MWPA SC C Mask A EXECUTE instruction, the parameter list imme-

5 8 12 16 18 2 24 31 diately follows the RESUME PROGRAM instruc-


tion, not the EXECUTE instruction.
B
A
The references to the parameter list are storage-
32 63
operand fetches, not instruction fetches.


Instruction Address Special Conditions

64 95
The instruction is completed only if the bits 31, 32,

and 64-127 that are to be placed in the current


Instruction Address (Continued) PSW are valid for placement in the PSW. If of

96 127 the second operand are valid for placement in the


current PSW. If bits 31 and 32 are both zero and
Fields in the current PSW are replaced from the bits 64-103 are not all zeros, if bits 31 and 32 are
corresponding fields in the PSW field in the zero and one, respectively, and bits 64-96 are not
second operand. The PSW fields that are all zeros, if bits 31 and 32 are one and zero,
replaced are as follows: respectively, or if bit 127 is one, a specification
exception is recognized.

PSW Bits Field Name The CPU must be in the supervisor state when
the operation is to set the home-space mode; oth-
16 and 17 Address-space control (AS)
erwise, a privileged-operation exception is recog-
18 and 19 Condition code (CC)
2-23 Program mask nized. When DAT is off, the values of bits 16 and
31 Extended addressing mode (EA) 17 of the PSW field in the second operand are not
32 Basic addressing mode (BA) tested.
64-127 Instruction address
When the CPU is in the home-space mode either
before or after the operation, but not both before
The remaining fields in the PSW field in the and after the operation, a space-switch-event
second operand are ignored. Specifically, there is program interruption occurs after the operation is
no test for whether bit 12 is one in an eight-byte completed if any of the following is true: (1) the
PSW or zero in a 16-byte PSW. There is also no primary space-switch-event control, bit 57 of the
test for whether bit 31 is zero in an eight-byte primary address-space-control element (ASCE) in
PSW. control register 1, is one; (2) the home space-
switch-event control, bit 57 of the home ASCE in
Unassigned fields in the PSW may be assigned in control register 13, is one; or (3) a PER event is
the future and may then be among those restored to be indicated.
by RESUME PROGRAM. Therefore, these fields
in the PSW field in the second operand should The operation is suppressed on all addressing and
contain zeros; otherwise, the program may not protection exceptions.
operate compatibly in the future.
The priority of recognition of program exceptions
When PSW bits 64-127 are replaced from an for the instruction is shown in Figure 10-26 on
eight-byte PSW field in the second operand, they page 10-83.
are replaced with bits 33-63 of the field, with 33
zeros appended on the left. Resulting Condition Code: The code is set as
specified by the new condition code loaded.
The fields in the second operand are fetched
before the contents of access register B and Program Exceptions:
general register B are changed. Access (fetch, parameter list and operand 2)
Privileged operation (attempt to set the home-
space mode when in the problem state)

10-82 z/Architecture Principles of Operation



1.-6. Exceptions with the same priority as the priority of program-
interruption conditions for the general case.

7. Access exceptions for second instruction halfword.

8.A Trace exceptions.

8.B.1 Access exceptions for bits -63 of parameter list.

8.B.2 Specification exception due to bits -12 of parameter list not
being all zeros.

8.B.3 Access exceptions for bits 64-79 of parameter list, if these
bits exist.

8.B.4 Access exceptions for second operand.

8.B.5 Privileged-operation exception due to attempt to set the
home-space mode when in the problem state.

8.B.6 Specification exception due to invalid values in bit positions
31, 32, and 64-127 of PSW in second operand.

9. Space-switch event.

Figure 10-26. Priority of Execution: RESUME PROGRAM

Space-switch event SET ADDRESS SPACE CONTROL


Specification
Trace SAC D(B) [S]

Programming Note: As described in Instruction


Fetching on page 5-81, the bytes of an instruc- 'B219' B D
tion may be fetched piecemeal, and the instruction
16 2 31
may be fetched multiple times for a single exe-
cution. Therefore, the results are unpredictable
when instructions are fetched for execution from SET ADDRESS SPACE CONTROL
storage that is being changed by another CPU or
a channel program. This warning is particularly
FAST
applicable when RESUME PROGRAM is the SACF D(B) [S]
target of EXECUTE since the EXECUTE instruc-
tion may be refetched in order to generate, from
its B, X, and D fields, the address of the param- 'B279' B D
eter list used by RESUME PROGRAM. If
16 2 31
EXECUTE is refetched, there is not necessarily a
test for whether storage still contains either the
EXECUTE instruction or the RESUME PROGRAM Bits 52-55 of the second-operand address are
instruction. used as a code to set the address-space-control
bits in the PSW. The second-operand address is
not used to address data; instead, bits 52-55 form
the code. Bits 0-51 and 56-63 of the second-
operand address are ignored. Bits 52 and 53 of
the second-operand address must be zeros; other-
wise, a specification exception is recognized.

Chapter 10. Control Instructions 10-83


The following figure summarizes the operation of The priority of recognition of program exceptions
SET ADDRESS SPACE CONTROL and SET for the instructions is shown in Figure 10-27.
ADDRESS SPACE CONTROL FAST:
Condition Code: The code remains unchanged.
Second-Operand Address
Program Exceptions:
/
Privileged operation (attempt to set the home-
///////////////////////Code////////
/ space mode in the problem state)
52 56 63 Space-switch event
Special operation
Result in Specification
PSW Bits
Code Name of Mode 16 and 17
1.-6. Exceptions with the same priority as
Primary space the priority of program-interruption
1 Secondary space 1 conditions for the general case.
1 Access register 1
11 Home space 11 7.A Access exceptions for second instruc-
All others Invalid Unchanged tion halfword.

The CPU must be in the supervisor state when 7.B Special-operation exception due to
DAT being off.
the operation is to set the home-space mode; oth-
erwise, a privileged-operation exception is recog- 7.C Special-operation exception due to
nized. the secondary-space control, bit 37 of
control register , being zero. May
For SET ADDRESS SPACE CONTROL, a serial- be omitted for SET ADDRESS SPACE
ization and checkpoint-synchronization function is CONTROL FAST.

performed before the operation begins and again 8. Privileged-operation exception due to
after the operation is completed. This function is attempt to set home-space mode when
not performed for SET ADDRESS SPACE in problem state.
CONTROL FAST.
9. Specification exception due to non-
Special Conditions zero value in bit positions 52 and 53
of second-operand address.

For SET ADDRESS SPACE CONTROL, the oper- 1. Space-switch event.
ation is performed only when the secondary-space
control, bit 37 of control register 0, is one and
Figure 10-27. Priority of Execution: SET ADDRESS
DAT is on. When either the secondary-space
SPACE CONTROL and SET ADDRESS SPACE
control is zero or DAT is off, a special-operation CONTROL FAST
exception is recognized. The same rules apply
also to SET ADDRESS SPACE CONTROL FAST, Programming Notes:
except that whether the secondary-space control
is tested is unpredictable. 1. SET ADDRESS SPACE CONTROL and SET
ADDRESS SPACE CONTROL FAST are
When the CPU is in the home-space mode either defined in such a way that the mode to be set
before or after the operation, but not both before can be placed directly in the displacement
and after the operation, a space-switch-event field of the instruction or can be specified from
program interruption occurs after the operation is the same bit positions of a general register as
completed if any of the following is true: (1) the those in which the mode is saved by INSERT
primary space-switch-event control, bit 57 of the ADDRESS SPACE CONTROL.
primary address-space-control element (ASCE) in 2. SET ADDRESS SPACE CONTROL FAST
control register 1, is one; (2) the home space- may provide better performance than SET
switch-event control, bit 57 of the home ASCE in ADDRESS SPACE CONTROL, depending on
control register 13, is one; or (3) a PER event is the model.
to be indicated.

10-84 z/Architecture Principles of Operation


3. Because SET ADDRESS SPACE CONTROL tion 52, the rightmost bits of the second operand
FAST does not perform the serialization func- are ignored, and the corresponding positions of
tion, it does not cause copies of prefetched the clock which are implemented are set to zeros.
instructions to be discarded. To ensure pre- Zeros are also placed in positions to the right of
dictable results after SET ADDRESS SPACE bit position 63 of the clock.
CONTROL FAST is used to switch to or from
the home-space mode, the program must After the clock value is set, the clock enters the
cause prefetched instructions to be discarded stopped state. The clock leaves the stopped state
before an instruction is executed in a location to enter the set state and resume incrementing
that does not contain the same instruction in under control of the TOD-clock-sync control, bit 34
both the primary and home address spaces. of control register 0. When the bit is zero, the
The operations that cause prefetched clock enters the set state at the completion of the
instructions to be discarded are described in instruction. When the bit is one, the clock remains
Instruction Fetching on page 5-81. in the stopped state until the bit is set to zero, until
another CPU executes a SET CLOCK instruction
4. If a program stores into the instruction stream
affecting the clock, or until any other running TOD
at a location following a subsequent SET
clock in the configuration is incremented to a
ADDRESS SPACE CONTROL FAST instruc-
value of all zeros in bit positions 32 through the
tion, and the SET ADDRESS SPACE
rightmost bit position that is incremented when the
CONTROL FAST instruction changes the
clock is running. If an external time reference
translation mode either from or to either the
(ETR) is installed, a signal from the ETR may be
access-register mode or the home-space
used to set the set state from the stopped state.
mode, a copy of a prefetched instruction may
be executed instead of the value that was The value of the clock is changed and the clock is
stored. To avoid this situation, either SET placed in the stopped state only if the manual
ADDRESS SPACE CONTROL must be used TOD-clock control of any CPU in the configuration
instead of SET ADDRESS SPACE CONTROL is set to the enable-set position or the
FAST or some other means must be used to TOD-clock-control-override control, bit 42 of
cause prefetched instructions to be discarded control register 14, is one. If the TOD-clock
after the conceptual store occurs. control of all CPUs is set to the secure position
and the TOD-clock-control-override control is zero,
SET CLOCK the value and state of the clock are not changed.
Whether the clock is set or remains unchanged is
SCK D(B) [S] distinguished by condition codes 0 and 1, respec-
tively.

'B24' B D
When the clock is not operational, the value and
16 2 31 state of the clock are not changed, regardless of
the settings of the TOD-clock control and the
TOD-clock-control-override control, and condition
The current value of the TOD clock is replaced by
code 3 is set.
the contents of the doubleword designated by the
second-operand address, and the clock enters the
Special Conditions
stopped state.
The operand must be designated on a doubleword
The doubleword operand replaces the contents of
boundary; otherwise, a specification exception is
the clock, as determined by the resolution of the
recognized.
clock. Only those bits of the operand are set in
the clock that correspond to the bit positions which Resulting Condition Code:
are updated by the clock; the contents of the
remaining rightmost bit positions of the operand 0 Clock value set
are ignored and are not preserved in the clock. In 1 Clock value secure
some models, starting at or to the right of bit posi- 2 --
3 Clock in not-operational state

Chapter 10. Control Instructions 10-85


Program Exceptions: ister. Zeros are placed in bit positions 0-15 of the
TOD programmable register.
Access (fetch, operand 2)
Privileged operation
Special Conditions
Specification
Bits 32-47 of general register 0 must be zeros;
SET CLOCK COMPARATOR otherwise, a specification exception is recognized.
Bits 0-31 of general register 0 are ignored.
SCKC D(B) [S]
Condition Code: The code remains unchanged.

'B26' B D
Program Exceptions:
16 2 31 Privileged operation
Specification
The current value of the clock comparator is Programming Note: The values in the TOD
replaced by the contents of the doubleword desig- programmable registers of a configuration should
nated by the second-operand address. be the same and should be unique within a
multiple-configuration system.
Only those bits of the operand are set in the clock
comparator that correspond to the bit positions to
be compared with the TOD clock; the contents of SET CPU TIMER
the remaining rightmost bit positions of the
SPT D(B) [S]
operand are ignored and are not preserved in the
clock comparator.
'B28' B D
Special Conditions
16 2 31
The operand must be designated on a doubleword
boundary; otherwise, a specification exception is The current value of the CPU timer is replaced by
recognized. the contents of the doubleword designated by the
second-operand address.
The operation is suppressed on all addressing and
protection exceptions. Only those bits of the operand are set in the CPU
timer that correspond to the bit positions to be
Condition Code: The code remains unchanged.
updated; the contents of the remaining rightmost
bit positions of the operand are ignored and are
Program Exceptions:
not preserved in the CPU timer.
Access (fetch, operand 2)
Privileged operation Special Conditions
Specification
The operand must be designated on a doubleword
boundary; otherwise, a specification exception is
SET CLOCK PROGRAMMABLE recognized.
FIELD
The operation is suppressed on all addressing and
SCKPF [E]
protection exceptions.

'17' Condition Code: The code remains unchanged.

15 Program Exceptions:
Access (fetch, operand 2)
Bits 48-63 of general register 0 are placed in bit Privileged operation
positions 16-31 of the TOD programmable reg- Specification

10-86 z/Architecture Principles of Operation


SET PREFIX Special Conditions

SPX D(B) [S] The second operand must be designated on a


word boundary; otherwise, a specification excep-
tion is recognized.
'B21' B D
The operation is suppressed on all addressing and
16 2 31
protection exceptions.

The contents of bit positions 33-50 of the prefix Condition Code: The code remains unchanged.
register are replaced by the contents of bit posi-
tions 1-18 of the word at the location designated Program Exceptions:
by the second-operand address. The Access (fetch, operand 2)
ART-lookaside buffer (ALB) and translation- Addressing (new prefix area)
lookaside buffer (TLB) of this CPU are cleared of Privileged operation
entries. Specification
After the second operand is fetched, the value is
tested for validity before it is used to replace the SET PSW KEY FROM ADDRESS
contents of the prefix register. Bits 1-18 of the
SPKA D(B) [S]
operand with 13 zeros appended on the right and
33 zeros appended on the left are used as an
absolute address of the 8K-byte new prefix area in 'B2A' B D
storage. This address is treated as a 64-bit
address regardless of the addressing mode speci- 16 2 31
fied by the current PSW. The two 4K-byte blocks
within the new prefix area are accessed; if either The four-bit PSW key, bits 8-11 of the current
is not available in the configuration, an addressing PSW, is replaced by bits 56-59 of the second-
exception is recognized, and the operation is sup- operand address.
pressed. The accesses to the blocks are not
subject to protection; however, the accesses may The second-operand address is not used to
cause the reference bits for the blocks to be set to address data; instead, bits 56-59 of the address
ones. form the new PSW key. Bits 0-55 and 60-63 of
the second-operand address are ignored.
If the operation is completed, the new prefix is
used for any interruptions following the execution Special Conditions
of the instruction and for the execution of subse-
quent instructions. The contents of bit positions 0 In the problem state, the execution of the instruc-
and 19-31 of the second operand are ignored. tion is subject to control by the PSW-key mask in
control register 3. When the bit in the PSW-key
The ART-lookaside buffer (ALB) and translation- mask corresponding to the PSW-key value to be
lookaside buffer (TLB) are cleared of entries. The set is one, the instruction is executed successfully.
ALB and TLB appear cleared of their original con- When the selected bit in the PSW-key mask is
tents, beginning with the fetching of the next zero, a privileged-operation exception is recog-
sequential instruction. nized. In the supervisor state, any value for the
PSW key is valid.
A serialization function is performed before or after
the second operand is fetched and again after the Condition Code: The code remains unchanged.
operation is completed.
Program Exceptions:
Privileged operation (selected PSW-key-mask
bit is zero in the problem state)

Chapter 10. Control Instructions 10-87


Programming Notes: ations are depicted in Figure 10-29 on
page 10-90.
1. The format of SET PSW KEY FROM
ADDRESS permits the program to set the
SET SECONDARY ASN to Current Primary
PSW key either from the general register des-
(SSAR-cp)
ignated by the B field or from the D field in
the instruction itself. The new ASN replaces the SASN, bits 48-63 of
2. When one program requests another program control register 3; the PASCE in control register 1
to access a location designated by the replaces the SASCE in control register 7; and the
requesting program, SET PSW KEY FROM operation is completed.
ADDRESS can be used by the called program
to verify that the requesting program is author- SET SECONDARY ASN with Space Switching
ized to make this access, provided the storage (SSAR-ss)
location of the called program is not protected
against fetching. The called program can The new ASN is translated by means of the ASN
perform the verification by replacing the PSW translation tables, and then the current authori-
key with the requesting-program PSW key zation index, bits 32-47 of control register 4, is
before making the access and subsequently used to test whether the program is authorized to
restoring the called-program PSW key to its use the specified ASN.
original value. Caution must be exercised,
The new ASN is translated by means of a two-
however, in handling any resulting protection
level table lookup. Bits 0-9 of the new ASN (bits
exceptions since such exceptions may cause
48-57 of the register) are a 10-bit AFX which is
the operation to be terminated. See TEST
used to select an entry from the ASN first table.
PROTECTION and the associated program-
Bits 10-15 of the new ASN (bits 58-63 of the reg-
ming notes for an alternative approach to the
ister) are a six-bit ASX which is used to select an
testing of addresses passed by a calling
entry from the ASN second table. The two-level
program.
lookup is described in ASN Translation on
page 3-18. The exceptions associated with ASN
SET SECONDARY ASN translation are collectively called ASN-translation
exceptions. These exceptions and their priority
SSAR R [RRE]
are described in Chapter 6, Interruptions.

'B225' //////// R //// The ASN-second-table entry (ASTE) obtained as a


result of the second lookup contains the address-
16 24 28 31 space-control element and the authority-table
origin and length associated with the ASN.
The ASN specified in bit positions 48-63 of
general register R replaces the secondary ASN The authority-table origin from the ASTE is used
in control register 3, and the address-space- as a base for a third table lookup. The current
control element corresponding to that ASN authorization index, bits 32-47 of control register
replaces the SASCE in control register 7. 4, is used, after it has been checked against the
authority-table length, as the index to locate the
The contents of bit positions 48-63 of general reg- entry in the authority table. The authority-table
ister R are called the new ASN. The contents of lookup is described in ASN Authorization on
bit positions 0-47 of the register are ignored. page 3-23.

First the new ASN is compared with the current The new ASN, bits 48-63 of general register R,
PASN. If the new ASN is equal to the PASN, the replaces the SASN, bits 48-63 of control register
operation is called SET SECONDARY ASN to 3. The address-space-control element in the
current primary (SSAR-cp). If the new ASN is not ASTE replaces the SASCE in control register 7.
equal to the current PASN, the operation is called
SET SECONDARY ASN with space switching The description in this paragraph applies to use of
(SSAR-ss). The SSAR-cp and SSAR-ss oper- the subspace-group facility. After the new SASCE

10-88 z/Architecture Principles of Operation


has been placed in control register 7, if (1) the The operation is performed only when the
subspace-group-control bit, bit 54, in the SASCE ASN-translation control, bit 44 of control register
is one, (2) the dispatchable unit is subspace 14, is one and DAT is on. When either the
active, and (3) the ASTE obtained by ASN trans- ASN-translation-control bit is zero or DAT is off, a
lation is the ASTE for the base space of the special-operation exception is recognized.
dispatchable unit, then bits 0-55 and 58-63 of the
SASCE are replaced by the same bits of the The priority of recognition of program exceptions
ASCE in the ASTE for the subspace in which the for the instruction is shown in Figure 10-28.
dispatchable unit last had control. Further details
are in Subspace-Replacement Operations on Condition Code: The code remains unchanged.
page 5-59.
Program Exceptions:
SET SECONDARY ASN Serialization Addressing (authority-table entry, SSAR-ss
only)
For both the SSAR-cp and SSAR-ss operations, a ASN translation (SSAR-ss only)
serialization and checkpoint-synchronization func- Secondary authority (SSAR-ss only)
tion is performed before the operation begins and Special operation
again after the operation is completed. Subspace replacement (SSAR-ss only)
Trace
Special Conditions

1.-6. Exceptions with the same priority as the priority of program-


interruption conditions for the general case.

7.A Access exceptions for second instruction halfword.

7.B Special-operation exception due to DAT being off, or the ASN-
translation control, bit 44 of control register 14, being
zero.

8.A Trace exceptions.

8.B.1 ASN-translation exceptions (SSAR-ss only).

Note: Subspace-replacement exceptions, which are not shown
in detail in this figure, can occur with any priority after
8.B.1.

8.B.2 Secondary-authority exception due to authority-table entry
being outside table (SSAR-ss only).

8.B.3 Addressing exception for access to authority-table entry
(SSAR-ss only).

8.B.4 Secondary-authority exception due to S bit in authority-
table entry being zero (SSAR-ss only).

Figure 10-28. Priority of Execution: SET SECONDARY ASN

Chapter 10. Control Instructions 10-89




ASN 6
CR14 SET SECONDARY ASN
32-63 T AFTO AFX ASX Instruction

(x496) (x4) (x16) 'B225' ////R//


6

ASN First Table R
6 (accessed for 32-63 ASN
SSAR-ss only)
5+
6
%5

5 6
R I ASTO
CR4
(x16) 32-63 AX PASN
before
(x1/4)

6 6
YesNo
=

% 6 6
SSAR-cp SSAR-ss
6 ASN Second Table
(accessed for SSAR-ss only)
5+



5
6 R I ATO B AX ATL ASCE \

(x4)





Authority Table
6 (accessed for
SSAR-ss only)
5+
CR1 CR3
before PASCE 32-63 PKM SASN
before
5
R PS
(SSAR-cp only) (SSAR-ss only)
6 6 6 6
CR7 CR3
after SASCE 32-63 PKM SASN
\\ after

5Secondary-authority exception if S bit is
zero or if table length is exceeded
(SSAR-ss only)

R: Address is real.
\: ASTE is 64 bytes; last 48 bytes are not shown.
\\: For SSAR-ss only, bits -55 and 58-63 of SASCE may be replaced from a
subspace ASCE.
Figure 10-29. Execution of SET SECONDARY ASN

10-90 z/Architecture Principles of Operation


SET STORAGE KEY EXTENDED Bits 0-7 of the current PSW are replaced by the
byte at the location designated by the second-
SSKE R,R [RRE] operand address.

Special Conditions
'B22B' //////// R R
When the SSM-suppression-control bit, bit 33 of
16 24 28 31
control register 0, is one and the CPU is in the
supervisor state, a special-operation exception is
The storage key for the 4K-byte block that is recognized.
addressed by the contents of general register R
is replaced by bits from general register R. The value to be loaded into the PSW is not
checked for validity before loading. However,
In the 24-bit addressing mode, bits 40-51 of immediately after loading, a specification excep-
general register R designate a 4K-byte block in tion is recognized, and a program interruption
real storage, and bits 0-39 and 52-63 of the reg- occurs, if the contents of bit positions 0 and 2-4 of
ister are ignored. In the 31-bit addressing mode, the PSW are not all zeros. In this case, the
bits 33-51 of general register R designate a instruction is completed, and the instruction-length
4K-byte block in real storage, and bits 0-32 and code is set to 2. The specification exception,
52-63 of the register are ignored. In the 64-bit which is listed as a program exception for this
addressing mode, bits 0-51 of general register R instruction, is described in Early Exception
designate a 4K-byte block in real storage, and bits Recognition on page 6-9. This exception may be
52-63 of the register are ignored. considered as caused by execution of this instruc-
tion or as occurring early in the process of pre-
Because it is a real address, the address desig- paring to execute the subsequent instruction.
nating the storage block is not subject to dynamic
address translation. The reference to the storage The operation is suppressed on all addressing and
key is not subject to a protection exception. protection exceptions.

The new seven-bit storage-key value is obtained Condition Code: The code remains unchanged.
from bit positions 56-62 of general register R.
The contents of bit positions 0-55 and 63 of the Program Exceptions:
register are ignored.
Access (fetch, operand 2)
Privileged operation
A serialization and checkpoint-synchronization
Special operation
function is performed before the operation begins
Specification
and again after the operation is completed.

Condition Code: The code remains unchanged. SIGNAL PROCESSOR


Program Exceptions: SIGP R,R,D(B) [RS]
Addressing (address specified by general reg-
ister R) 'AE' R R B D
Privileged operation
8 12 16 2 31

SET SYSTEM MASK


An eight-bit order code and, if called for, a 32-bit
SSM D(B) [S] parameter are transmitted to the CPU designated
by the CPU address contained in the third
operand. The result is indicated by the condition
'8' //////// B D code and may be detailed by status assembled in

8 16 2 31 bit positions 32-63 of the first-operand location.

Chapter 10. Control Instructions 10-91


The second-operand address is not used to When the order code is accepted and no nonzero
address data; instead, bits 56-63 of the address status is returned, condition code 0 is set. When
contain the eight-bit order code. Bits 0-55 of the status information is generated by this CPU or
second-operand address are ignored. The order returned by the addressed CPU, the status is
code specifies the function to be performed by the placed in bit positions 32-63 of general register
addressed CPU. The assignment and definition of R, bits 0-31 of the register remain unchanged,
order codes appear in CPU Signaling and and condition code 1 is set.
Response on page 4-49.
When the access path to the addressed CPU is
The 16-bit binary number contained in bit positions busy, or the addressed CPU is operational but in
48-63 of general register R forms the CPU a state where it cannot respond to the order code,
address. Bits 0-47 of the register are ignored. condition code 2 is set.
When the specified order is the set-architecture
order, the CPU address is ignored; all other CPUs When the addressed CPU is not operational (that
in the configuration are considered to be is, it is not provided in the installation, it is not in
addressed. the configuration, it is in any of certain customer-
engineer test modes, or its power is off), condition
The general register containing the 32-bit param- code 3 is set.
eter in bit positions 32-63 is R or R+1, which-
ever is the odd-numbered register. It depends on Resulting Condition Code:
the order code whether a parameter is provided 0 Order code accepted
and for what purpose it is used. 1 Status stored
2 Busy
The operands just described have the following
3 Not operational
formats:
Program Exceptions:
General register designated by R:
/ Privileged operation
/// Status
/ Programming Notes:
32 63
1. A more detailed discussion of the condition-
code settings for SIGNAL PROCESSOR is
General register designated by R or R + 1,
contained in CPU Signaling and Response
whichever is the odd-numbered register:
/ on page 4-49.
/// Parameter 2. To ensure that presently written programs will
/
be executed properly when new facilities using
32 63
additional bits are installed, only zeros should
appear in the unused bit positions of the
General register designated by R: second-operand address and in bit positions
/ 32-47 of general register R.
/////////////////// CPU Address
/ 3. Certain SIGNAL PROCESSOR orders are
48 63 provided with the expectation that they will be
used primarily in special circumstances. Such
Second-operand address: orders may be implemented with the aid of an
/ auxiliary maintenance or service processor,
Order and, thus, the execution time may take
/////////////////////////// Code
several seconds. Unless all of the functions
/
56 63 provided by the order are required, combina-
tions of other orders, in conjunction with
appropriate programming support, can be
A serialization function is performed before the expected to provide a specific function more
operation begins and again after the operation is rapidly. The emergency-signal, external-call,
completed.

10-92 z/Architecture Principles of Operation


and sense orders are the only orders which STORE CONTROL
are intended for frequent use. The following
orders are intended for infrequent use, and STCTL R,R,D(B) [RS]
performance therefore may be much slower
than for frequently used orders: restart, set
prefix, store status at address, start, stop, stop 'B6' R R B D

and store status, and all the reset orders. An 8 12 16 2 31
alternative to the set-prefix order, for faster
performance when the receiving CPU is not
STCTG R,R,D(B) [RSE]
already stopped, is the use of the emergency-
signal or external-call order, followed by the /
execution of a SET PREFIX instruction on the 'EB' R R B D //////// '25'
addressed CPU. Clearing the TLB of entries /
is ordinarily accomplished more rapidly 8 12 16 2 32 4 47
through the use of the emergency-signal or
external-call order, followed by execution of Bits of the set of control registers starting with
the PURGE TLB instruction on the addressed control register R and ending with control register
CPU, than by use of the set-prefix order. R are stored at the locations designated by the
second-operand address.
STORE CLOCK COMPARATOR
For STORE CONTROL (STCTL), bits 32-63 of the
STCKC D(B) [S] control registers are stored in successive words
beginning at the second-operand address, and
bits 0-31 of the registers are ignored. For STORE
'B27' B D CONTROL (STCTG), bits 0-63 of the control reg-

16 2 31 isters are stored in successive doublewords begin-


ning at the second-operand address.

The current value of the clock comparator is The storage area where the contents of the
stored at the doubleword location designated by control registers are placed starts at the location
the second-operand address. designated by the second-operand address and
continues through as many storage words, for
Zeros are provided for the rightmost bit positions STCTL, or doublewords, for STCTG, as the
of the clock comparator that are not compared number of control registers specified. The con-
with the TOD clock. tents of the control registers are stored in
ascending order of their register numbers, starting
Special Conditions
with control register R and continuing up to and
including control register R, with control register 0
The operand must be designated on a doubleword
following control register 15. The contents of the
boundary; otherwise, a specification exception is
control registers remain unchanged.
recognized.
Special Conditions
Condition Code: The code remains unchanged.
The second operand must be designated on a
Program Exceptions:
word boundary for STCTL or on a doubleword
Access (store, operand 2) boundary for STCTG; otherwise, a specification
Privileged operation exception is recognized.
Specification
Condition Code: The code remains unchanged.

Program Exceptions:
Access (store, operand 2)
Privileged operation
Specification

Chapter 10. Control Instructions 10-93


STORE CPU ADDRESS Bit positions 0-7 contain the version code. The
format and significance of the version code
STAP D(B) [S] depend on the model.

Bit positions 8-31 contain the CPU identification


'B212' B D number, consisting of six four-bit digits. Some or
all of these digits are selected from the physical
16 2 31
serial number stamped on the CPU. The contents
of the CPU-identification-number field, in conjunc-
The CPU address by which this CPU is identified tion with the machine-type number, permit unique
in a multiprocessing configuration is stored at the identification of the CPU.
halfword location designated by the second-
operand address. Bit positions 32-47 contain the machine-type
number of the CPU. Bit positions 48-63 contain
Special Conditions zeros.

The operand must be designated on a halfword Special Conditions


boundary; otherwise, a specification exception is
recognized. The operand must be designated on a doubleword
boundary; otherwise, a specification exception is
Condition Code: The code remains unchanged. recognized.

Program Exceptions: Condition Code: The code remains unchanged.


Access (store, operand 2)
Privileged operation Program Exceptions:
Specification Access (store, operand 2)
Privileged operation
STORE CPU ID Specification

STIDP D(B) [S] Programming Notes:


1. The program should allow for the possibility

'B22' B D that the CPU identification number may


contain the digits A-F as well as the digits 0-9.
16 2 31
2. The CPU identification number, in conjunction
with the machine-type number, provides a
Information identifying the CPU is stored at the unique CPU identification that can be used in
doubleword location designated by the second- associating results with an individual machine.
operand address.
3. In versions of Enterprise Systems
The information stored has the following format: Architecture/390 Principles of Operation prior
to SA22-7201-03, the machine-type-number
field was called the model-number field.
Version CPU Identification
Code Number 4. When the version code is nonzero, it is
usually indicative of the model number of the
8 31 model and the number of CPUs contained in
the model. The version-code values for a
machine type are described in the Functional
Machine-Type Characteristics or System Overview manual
Number for the machine type.

32 48 63 The STORE SYSTEM INFORMATION instruc-


tion can be used to determine the model
number and the number of CPUs in the
model.

10-94 z/Architecture Principles of Operation


5. For current machine types, the CPU identifica- STORE FACILITY LIST
tion number has the hex format:
Annnnn in the basic mode, or STFL D(B) [S]
LPnnnn in the LPAR (logically-
partitioned) mode. 'B2B1' B D
Where:
16 2 31
A is the CPU address of the CPU.
L is a logical CPU address. A list of bits providing information about facilities is
P is a logical-partition identifier. stored in the word at real address 200.
n is a digit derived from the serial number
of the CPU. Bit 0 indicates, when one, that the z/Architecture
The terminology above that is not defined in instructions marked N3 in the instruction-
this publication is defined in the machine summary figures in Chapters 7 and 10 are avail-
manuals. able on the CPU in the ESA/390 mode.

Bit 1 indicates, when one, that the z/Architecture


STORE CPU TIMER architectural mode is installed on the CPU.
STPT D(B) [S]
Bit 2 indicates, when one, that the z/Architecture
architectural mode is active.
'B29' B D
Bit 16 indicates, when one, that the extended-
16 2 31 translation facility 2 is installed on the CPU.

The current value of the CPU timer is stored at Bits 3-15 and 17-31 are unassigned and are
the doubleword location designated by the stored as zeros.
second-operand address.
The second-operand address is ignored but
Zeros are provided for the rightmost bit positions should be zero to permit possible future exten-
that are not updated by the CPU timer. sions.

Special Conditions Key-controlled and low-address protection do not


apply.
The operand must be designated on a doubleword
boundary; otherwise, a specification exception is Condition Code: The code remains unchanged.
recognized.
Program Exceptions:
Condition Code: The code remains unchanged. Privileged operation

Program Exceptions:
STORE PREFIX
Access (store, operand 2)
Privileged operation STPX D(B) [S]
Specification

'B211' B D

16 2 31

The contents of bit positions 33-50 of the prefix


register are stored in bit positions 1-18 of the word
location designated by the second-operand
address, and zeros are stored in bit positions 0
and 19-31 of the word.

Chapter 10. Control Instructions 10-95


Special Conditions The resultant 64-bit real address is stored at the
first-operand location.
The operand must be designated on a word
boundary; otherwise, a specification exception is The translated address is not inspected for
recognized. boundary alignment or for addressing or protection
exceptions.
Condition Code: The code remains unchanged.
The address computations for the operands are
Program Exceptions: performed according to the current addressing
Access (store, operand 2) mode, specified by bits 31 and 32 of the current
Privileged operation PSW.
Specification
The addresses of the region-table entry or entries,
if used, and of the segment-table entry and page-
STORE REAL ADDRESS table entry are treated as 64-bit addresses regard-
less of the current addressing mode. It is
STRAG D(B),D(B) [SSE]
unpredictable whether the addresses of these
// entries are treated as real or absolute addresses.
'E52' B D B D
// Special Conditions
16 2 32 36 47
The first operand must be designated on a
The 64-bit real address corresponding to the doubleword boundary; otherwise, a specification
second-operand virtual address is stored in the exception is recognized.
doubleword at the location designated by the first-
The operation is suppressed on all addressing
operand address.
exceptions.
The virtual address specified by the B and D
Condition Code: The code remains unchanged.
fields is translated by means of the dynamic-
address-translation facility, regardless of whether
Program Exceptions:
DAT is on or off.
Access (fetch, operand 2, except for an
DAT is performed by using an address-space- addressing or protection exception for the des-
control element that depends on the current value ignated location; store, operand 1)
of the address-space-control bits, bits 16 and 17 Privileged operation
of the PSW, as shown in the following table: Specification
Programming Note: STORE REAL ADDRESS
PSW
is contrasted to LOAD REAL ADDRESS as
Bits 16 Address-Space-Control Element
follows:
and 17 Used by DAT
In the 24-bit or 31-bit addressing mode, LOAD
00 Contents of control register 1
REAL ADDRESS (LRA) loads bits 33-63 of
10 Contents of control register 7 the real address if bits 0-32 of the address are
01 The address-space-control element all zeros or recognizes a special-operation
obtained by applying the access- exception if bits 0-32 are not all zeros. LRA in
register-translation (ART) process to the the 64-bit addressing mode, and LOAD REAL
access register designated by the B ADDRESS (LRAG) in any addressing mode,
field loads bits 0-63 of the real address. STORE
REAL ADDRESS stores bits 0-63 of the real
11 Contents of control register 13 address in any addressing mode.
LOAD REAL ADDRESS, for most access-
ART and DAT may be performed with the use of exception conditions, does not recognize the
the ART-lookaside buffer (ALB) and translation- conditions as exceptions but instead sets the
lookaside buffer (TLB), respectively.

10-96 z/Architecture Principles of Operation


condition code to indicate the occurrence of not defined in this publication; they are defined in
the conditions. STORE REAL ADDRESS the machine manuals.
recognizes all access-exception conditions as
exceptions, resulting in a program interruption. A program being executed by a level-1 configura-
tion (the basic machine) can request information
about that configuration. A program being exe-
STORE SYSTEM INFORMATION cuted by a level-2 configuration (in a logical parti-
STSI D(B) [S] tion) can request information about the logical
partition and about the underlying basic machine.
'B27D' B D A program being executed by a level-3 configura-
tion (a virtual machine) can request information
16 2 31 about the virtual machine and about the one or
two underlying levels; a basic machine is always
Depending on a function code in general register underlying, and a logical partition may or may not
0, either an identification of the level of the config- be between the basic machine and the virtual
uration executing the program is placed in general machine. When information about a virtual
register 0 or information about a component or machine is requested, information is provided
components of a configuration is stored in a about the configuration executing the program and
system-information block (SYSIB). When informa- about any underlying level or levels of virtual
tion about a component or components is machine. In any of these cases, information is
requested, the information is specified by further provided about a level only if the level implements
contents of general register 0 and by contents of the instruction.
general register 1. The SYSIB, if any, is desig-
nated by the second-operand address. The function code determining the operation is an
unsigned binary integer in bit positions 32-35 of
The machine is considered to provide one, two, or general register 0 and is as follows:
three levels of configuration. The levels are:
Func-
1. The basic machine, which is the machine as if
tion
it were operating in the basic mode.
Code Information Requested
2. A logical partition, which is provided if the
0 Current-configuration-level number
machine is operating in the LPAR, or logically-
1 Information about level 1 (the basic
partitioned, mode. A logical partition is pro-
machine)
vided by the LPAR hypervisor, which is a part
2 Information about level 2 (a logical parti-
of the machine. A basic machine exists even
tion)
when the machine is operating in the LPAR
3 Information about level 3 (a virtual
mode.
machine)
3. A virtual machine, which is provided by a 4-15 None; codes are reserved
virtual-machine (VM) control program that is
executed either by the basic machine or in a Invalid Function Code
logical partition. A virtual machine may itself
execute a VM control program that provides a The level of the configuration executing the
higher-level (more removed from the basic program is called the current level. The configura-
machine) virtual machine, which also is con- tion level specified by a nonzero function code is
sidered a level-3 configuration. called the specified level. When the specified
level is higher numbered than the current level,
The terms basic mode, LPAR mode, logical parti- then the function code is called invalid, the condi-
tion, hypervisor, and virtual machine, and any tion code is set to 3, and no other action
other terms related specifically to those terms, are (including checking) is performed.

Chapter 10. Control Instructions 10-97


Valid Function Code at a 4K-byte boundary; otherwise, a specification
exception may be recognized, depending on
When the function code is equal to or less than selector 1 and selector 2 and on whether access
the number of the current level, it is called valid. exceptions are recognized due to references to
In this case, bits 36-55 of general register 0 and the SYSIB (see Special Conditions).
bits 32-47 of general register 1 must be zero; oth-
erwise, a specification exception is recognized. Selector 1 can have values as follows:
Bits 0-31 of general registers 0 and 1 always are
ignored. Selec-
tor 1 Information Requested
When the function code is 0, an unsigned binary
0 None; selector is reserved
integer identifying the current configuration level (1
1 Information about the specified configura-
for basic machine, 2 for logical partition, or 3 for
tion level
virtual machine) is placed in bit positions 32-35 of
2 Information about one or more CPUs in
general register 0, the condition code is set to 0,
the specified configuration level
and no further action is performed.
3-255 None; selectors are reserved
When the function code is valid and nonzero,
When selector 1 is 1, selector 2 can have values
general registers 0 and 1 contain additional spec-
as follows:
ifications about the information requested, as
follows: Selector
Bit positions 56-63 of general register 0 2 when
contain an unsigned binary integer, called Selector
selector 1, that specifies a component or com- 1 Is 1 Information Requested
ponents of the specified configuration. 0 None; selector is reserved
Bit positions 48-63 of general register 1 1 Information about the specified config-
contain an unsigned binary integer, called uration level
selector 2, that specifies the type of informa- 2-65,535 None; selectors are reserved
tion requested.
When selector 1 is 2, selector 2 can have values
The contents of general registers 0 and 1 are as as follows:
follows:
Selector
GR 2 when
/ Selector
/// FC Selector1 1 Is 2 Information Requested
/
32 36 56 63 0 None; selector is reserved
1 Information about the CPU executing
GR 1
the program in the specified configura-
/
/// Selector 2 tion level
/ 2 Information about all CPUs in the spec-
32 48 63 ified configuration level
3-65,535 None; selectors are reserved
When the function code is valid and nonzero,
Only certain combinations of the function code,
information may be stored in a system-information
selector 1, and selector 2 are valid, as shown in
block (SYSIB) beginning at the second-operand
Figure 10-30 on page 10-99.
location. The SYSIB is 4K bytes and must begin

10-98 z/Architecture Principles of Operation


SYSIB 1.1.1 (Basic-Machine Configuration)
Func-
tion Selec-Selec-Information SYSIB 1.1.1 has the following format:
Code tor 1 tor 2 Requested about
SYSIB 1.1.1
- - Current-configuration-
level number
/ Reserved /
1 1 1 Basic-machine configura- 7
tion
1 2 1 Basic-machine CPU 8
1 2 2 Basic-machine CPUs / Manufacturer /
11
2 2 1 Logical-partition CPU
2 2 2 Logical-partition CPUs 12 Type

3 2 2 Virtual-machine CPUs 13
/ Reserved /
Explanation: 15

- Ignored. 16
/ Model /
Figure 10-30. Valid Function-Code, Selector-1, and 19
Selector-2 Combinations for STORE SYSTEM INFOR-
MATION 2
/ Sequence Code /
23
When the specified function-code, selector-1, and
selector-2 combination is invalid (is other than as 24 Plant of Manufacture
shown in Figure 10-30), or if it is valid but the
requested information is not available because the 25
specified level does not implement or does not / Reserved /
123
fully implement the instruction or because a nec-

essary part of the level is uninstalled or not initial- 31
ized, and provided that an exception is not
recognized (see Special Conditions), the condi-
tion code is set to 3. When the function code is Reserved: The contents of words 0-7, 13-15,
nonzero, the combination is valid, the requested and 25-63 are reserved and are stored as zeros.
information is available, and there is no exception, The contents of words 64-1023 are reserved and
the requested information is stored in a system- may be stored as zeros or may remain
information block (SYSIB) at the second-operand unchanged.
address.
Manufacturer: Words 8-11 contain the
Some or all of the SYSIB may be fetched before it 16-character (0-9 or uppercase A-Z) EBCDIC
is stored. name of the manufacturer of the configuration.
The name is left justified with trailing blanks if nec-
A SYSIB may be identified in references by essary.
means of SYSIB fc.s1.s2, where fc, s1, and
s2 are the values of a function code, selector 1, Type: Word 12 contains the four-character (0-9)
and selector 2, respectively. EBCDIC type number of the configuration. (This
is called the machine-type number in the definition
Following sections describe the defined SYSIBs of STORE CPU ID.)
by means of figures and related text. In the
figures, the offsets shown on the left are word Model: Words 16-19 contain the 16-character
values. The configuration refers to the config- (0-9 or uppercase A-Z) EBCDIC model identifica-
uration level specified by the function code (the tion of the configuration. The model identification
configuration level about which information is is left justified with trailing blanks if necessary.
requested).

Chapter 10. Control Instructions 10-99


(This is called the model number in programming Reserved: The contents of words 0-19, bytes 0
note 4 on page 10-94 of STORE CPU ID.) and 1 of word 25, and words 26-63 are reserved
and are stored as zeros. The contents of words
Sequence Code: Words 20-23 contain the 64-1023 are reserved and may be stored as zeros
16-character (0-9 or uppercase A-Z) EBCDIC or may remain unchanged.
sequence code of the configuration. The
sequence code is right justified with leading Sequence Code: Words 20-23 contain the
EBCDIC zeros if necessary. 16-character (0-9 or uppercase A-Z) EBCDIC
sequence code of the CPU. The code is right jus-
Plant of Manufacture: Word 24 contains the tified with leading EBCDIC zeros if necessary.
four-character (0-9 or uppercase A-Z) EBCDIC
code that identifies the plant of manufacture for The sequence code is not equivalent to the CPU
the configuration. The code is left justified with identification number stored by STORE CPU ID.
trailing blanks if necessary. The sequence code is the portion of the CPU
serial number that remains when the plant-of-
Programming Note: The fields of the SYSIB
manufacture portion of the serial number is
1.1.1 are similar to those of the node descriptor
excluded.
described in the publication Common I/O-Device
Commands and Self Description, SA22-7204.
Plant of Manufacture: Word 24 contains the
However, the contents of the SYSIB fields may
four-character (0-9 or uppercase A-Z) EBCDIC
not be identical to the contents of the corre-
code that identifies the plant of manufacture for
sponding node-descriptor fields because the
the CPU. The code is left justified with trailing
SYSIB fields:
blanks if necessary.
Allow more characters.
CPU Address: Bytes 2 and 3 of word 25 contain
Are more flexible regarding the type of charac-
the CPU address by which this CPU is identified
ters allowed.
in a multiprocessing configuration. The CPU
Provide information that is justified differently address is a 16-bit unsigned binary integer.
within the field.
The CPU address is the same as is stored by
May not use the same method to determine
STORE CPU ADDRESS when the program is
the contents of fields such as the sequence-
executed by a machine operating in the basic
code field.
mode.
SYSIB 1.2.1 (Basic-Machine CPU) Programming Note: Multiple CPUs in the same
configuration may have the same sequence code,
SYSIB 1.2.1 has the following format: and it may be necessary to use other information,
such as the CPU address, to establish a unique
SYSIB 1.2.1 CPU identity. In contrast, the CPU identification

number stored by STORE CPU ID is derived from
/ Reserved / some undescribed portion of the serial number
19 along with values which make the number unique
for a CPU.
2
/ Sequence Code / SYSIB 1.2.2 (Basic-Machine CPUs)
23

24 Plant of Manufacture SYSIB 1.2.2 has the following format:

25 Reserved CPU Address

26
/ Reserved /
123

16 31

10-100 z/Architecture Principles of Operation


SYSIB 1.2.2 figured state. A CPU is in the configured state
when it is in the configuration and available to be
used to execute programs.
/ Reserved /
7
Standby CPU Count: Bytes 0 and 1 of word 10
8 CPU Capability contain a 16-bit unsigned binary integer that speci-
fies the number of CPUs that are in the standby
9 Total CPU Count Conf. CPU Count state. A CPU is in the standby state when it is in
the configuration, is not available to be used to
1 SB CPU Count Resv. CPU Count
execute programs, and can be made available by
11 issuing instructions to place it in the configured
Multiprocessing state.
/ CPU-Capability /
Adjustment Factors Reserved CPU Count: Bytes 2 and 3 of word 10
123 contain a 16-bit unsigned binary integer that speci-

16 31 fies the number of CPUs that are in the reserved
state. A CPU is in the reserved state when it is in
the configuration, is not available to be used to
execute programs, and cannot be made available
Reserved: The contents of words 0-7 and the
by issuing instructions to place it in the configured
portion of the SYSIB following the adjustment-
state. (It may be possible to place a reserved
factor list up to word 64 are reserved and are
CPU in the standby or configured state by means
stored as zeros. The contents of words 64-1023
of manual actions.)
are reserved and may be stored as zeros or may
remain unchanged. Multiprocessing CPU-Capability Adjustment
Factors: Beginning with bytes 0 and 1 of word
CPU Capability: Word 8 contains a 32-bit
11, the SYSIB contains a series of contiguous
unsigned binary integer that specifies the capa-
two-byte fields, each containing a 16-bit unsigned
bility of one of the CPUs in the configuration.
binary integer that is an adjustment factor (per-
There is no formal description of the algorithm
centage) for the value contained in the
used to generate this integer. The integer is used
CPU-capability field.
as an indication of the capability of the CPU rela-
tive to the capability of other CPU models. The number of adjustment-factor fields is one less
than the number of CPUs specified in the
The capability value applies to each of the CPUs
total-CPU-count field. The adjustment-factor fields
in the configuration. That is, all CPUs in the con-
correspond to configurations with increasing
figuration have the same capability.
numbers of CPUs in the configured state. The
first adjustment-factor field corresponds to a con-
Total CPU Count: Bytes 0 and 1 of word 9
figuration with two CPUs in the configured state.
contain a 16-bit unsigned binary integer that speci-
Each successive adjustment-factor field corre-
fies the total number of CPUs in the configuration.
sponds to a configuration with a number of CPUs
This number includes all CPUs in the configured
in the configured state that is one more than that
state, the standby state, or the reserved state.
for the preceding field.
Configured CPU Count: Bytes 2 and 3 of word
SYSIB 2.2.1 (Logical-Partition CPU)
9 contain a 16-bit unsigned binary integer that
specifies the number of CPUs that are in the con-
SYSIB 2.2.1 has the following format:

Chapter 10. Control Instructions 10-101


SYSIB 2.2.1 uration. The logical-CPU address is a 16-bit
unsigned binary integer.

/ Reserved /
The logical-CPU-address field contains the same
19
information as is stored by STORE CPU
2 ADDRESS when the machine is operating in the
/ Logical-CPU Sequence Code / LPAR mode.
23
Programming Note: Multiple logical CPUs in the
24 Logical-CPU Plant of Manufacture same level-2 configuration may have the same
logical-CPU sequence code, and it may be neces-
25 LCPU ID LCPU Address sary to use other information, such as the

logical-CPU address, to establish a unique
26
/ Reserved / logical-CPU identity. In contrast, the logical-CPU
123 identification number stored by STORE CPU ID is
derived from some undescribed portion of the
16 31 logical-CPU serial number along with values which
make the number unique for a logical CPU.
Reserved: The contents of words 0-19 and
26-63 are reserved and are stored as zeros. The SYSIB 2.2.2 (Logical-Partition CPUs)
contents of words 64-1023 are reserved and may
be stored as zeros or may remain unchanged. SYSIB 2.2.2 has the following format:

SYSIB 2.2.2
Logical-CPU Sequence Code: Words 20-23
contain the 16-character (0-9 or uppercase A-Z)
EBCDIC sequence code of the logical CPU. The / Reserved /
code is right justified with leading EBCDIC zeros if 7
necessary.
8 LPAR Number Resv. LCPUC

The contents of the logical-CPU sequence-code 9 Total LCPU Count Conf. LCPU Count
field is not equivalent to the logical-CPU identifica-
tion number stored by STORE CPU ID. The 1 SB LCPU Count Resv. LCPU Count
logical-CPU sequence code is the portion of the
logical-CPU serial number that remains when the 11
Logical-Partition Name
logical-CPU plant-of-manufacture portion of the
12
serial number is excluded.
13 Logical-Partition CAF
Logical-CPU Plant of Manufacture: Word 24
contains the four-character (0-9 or uppercase A-Z) 14
EBCDIC code that identifies the plant of manufac- / Reserved /
ture for the logical CPU. The code is left justified 17

with trailing blanks if necessary. 18 Ded. LCPU Count Shr. LCPU Count

Logical-CPU ID: Bytes 0 and 1 of word 25 19
contain a 16-bit unsigned binary integer that can / Reserved /
be used in conjunction with the logical-CPU 123
address to distinguish the logical CPU from the
16 31
other logical CPUs provided by the same LPAR
hypervisor.
Reserved: The contents of words 0-7, byte 2 of
Logical-CPU Address: Bytes 2 and 3 of word word 8, words 14-17, and words 19-63 are
25 contain the logical-CPU address by which this reserved and are stored as zeros. The contents
logical CPU is identified within the level-2 config- of words 64-1023 are reserved and may be stored
as zeros or may remain unchanged.

10-102 z/Architecture Principles of Operation


Logical-Partition Number: Bytes 0 and 1 of Total Logical-CPU Count: Bytes 0 and 1 of
word 8 contain a 16-bit unsigned binary integer word 9 contain a 16-bit unsigned binary integer
which is the number of the level-2 configuration. that specifies the total number of logical CPUs
This number distinguishes the configuration from that are provided for this level-2 configuration.
all other level-2 configurations provided by the This number includes all of the logical CPUs that
same LPAR hypervisor. are in the configured state, the standby state, or
the reserved state.
Logical-CPU Characteristics (LCPUC): The
contents of byte 3 of word 8 describe the charac- Configured Logical-CPU Count: Bytes 2 and 3
teristics of the logical CPUs that are provided for of word 9 contain a 16-bit unsigned binary integer
the level-2 configuration. The bits and their that specifies the number of logical CPUs for this
meanings are as follows: level-2 configuration that are in the configured
state.
Bit Meaning
0 Dedicated: When one, bit 0 indicates that A logical CPU is in the configured state when it is
one or more of the logical CPUs for this in the level-2 configuration and is available to be
level-2 configuration are provided using used to execute programs.
level-1 CPUs that are dedicated to this
level-2 configuration and are not used to Standby Logical-CPU Count: Bytes 0 and 1 of
provide logical CPUs for any other level-2 word 10 contain a 16-bit unsigned binary integer
configuration. The number of logical CPUs that specifies the number of logical CPUs for this
that are provided using dedicated level-1 level-2 configuration that are in the standby state.
CPUs is specified by the dedicated-LCPU-
count value in bytes 0 and 1 of word 18. A logical CPU is in the standby state when it is in
the level-2 configuration, is not available to be
When zero, bit 0 indicates that none of the used to execute programs, and can be made
logical CPUs for this level-2 configuration are available by issuing instructions to place it in the
provided using level-1 CPUs that are dedi- configured state.
cated to this level-2 configuration.
1 Shared: When one, bit 1 indicates that one or Reserved Logical-CPU Count: Bytes 2 and 3 of
more of the logical CPUs for this level-2 con- word 10 contain a 16-bit unsigned binary integer
figuration are provided using level-1 CPUs that specifies the number of CPUs for this level-2
that can be used to provide logical CPUs for configuration that are in the reserved state.
other level-2 configurations. The number of
logical CPUs that are provided using shared A logical CPU is in the reserved state when it is in
level-1 CPUs is specified by the the level-2 configuration, is not available to be
shared-LCPU-count value in bytes 2 and 3 of used to execute programs, and cannot be made
word 18. available by issuing instructions to place it in the
configured state. (It may be possible to place the
When zero, bit 1 indicates that none of the reserved CPU in the standby or configured state
logical CPUs for this level-2 configuration are through manual actions.)
provided using shared level-1 CPUs.
2 Utilization Limit: When one, bit 2 indicates Logical-Partition Name: Words 11-12 contain
that the amount of use of the level-1 CPUs the 8-character EBCDIC name of this level-2 con-
that are used to provide the logical CPUs for figuration. The name is left justified with trailing
this level-2 configuration is limited. blanks if necessary.

When zero, bit 2 indicates that the amount of Logical-Partition Capability Adjustment Factor
use of the level-1 CPUs that are used to (CAF): Word 13 contains a 32-bit unsigned
provide the logical CPUs for this level-2 con- binary integer, called an adjustment factor, with a
figuration is unlimited. value of 1000 or less. The adjustment factor
3-7 Reserved. specifies the amount of the underlying
level-1-configuration capability that is allowed to
be used for this level-2 configuration by the LPAR

Chapter 10. Control Instructions 10-103


hypervisor. The fraction of level-1-configuration Virtual-Machine Description Blocks: Words
capability is determined by dividing the CAF value 8-135 contain from one to eight 64-byte virtual-
by 1000. machine description blocks, depending on the
number of nested level-3 configurations, if any,
Dedicated Logical-CPU Count: Bytes 0 and 1 and their processing characteristics.
of word 18 contain a 16-bit unsigned binary
integer that specifies the number of configured- When a level-3 configuration is provided by a
state logical CPUs for this level-2 configuration virtual-machine control program and the control
that are provided using dedicated level-1 CPUs. program is being executed by a level-3 configura-
(See the description of bit 0 of the tion provided by another virtual-machine control
logical-CPU-characteristics field.) program, the level-3 configurations are said to be
nested. Level-3 configurations can be nested in
Shared Logical-CPU Count: Bytes 2 and 3 of this way for several levels.
word 18 contain a 16-bit unsigned binary integer
that specifies the number of configured-state The collection of nested level-3 configurations that
logical CPUs for this level-2 configuration that are is in the path between a program being executed
provided using shared level-1 CPUs. (See the by a level-3 configuration and the basic machine
description of bit 1 of the logical-CPU- is called a level-3-configuration stack. The
characteristics field.) level-3 configurations in a stack are consecutively
numbered. The level-3 configuration provided by
SYSIB 3.2.2 (Virtual-Machine CPUs) a virtual-machine control program being executed
by either a level-2 configuration or a level-1 con-
SYSIB 3.2.2 has the following format: figuration is the lowest-numbered (0) level-3 con-
figuration in the stack. The level-3 configuration
SYSIB 3.2.2
that is executing the program containing this
instruction is the highest numbered (N) level-3
/ Reserved / configuration in the stack.
6
If more than one virtual-machine description block
7 Reserved DBCT is stored in words 8-135 of the SYSIB, the blocks

are stored according to the following rules:
8
/ Virtual-Machine Description Block / The collection of level-3 configurations
23 described is a contiguous subset of the total

24 . collection of level-3 configurations in the
/ . / level-3-configuration stack. The subset
135 . always includes the highest-numbered level-3
configuration in the stack. One or more
136 level-3 configurations at the bottom of the
/ Reserved /
stack may not be described because STORE
123
SYSTEM INFORMATION is not implemented
28 31 by the highest of those configurations or the
limit of eight description blocks would be
exceeded.
Reserved: The contents of words 0-6, bits 0-27
of word 7, and words 136-1023 are reserved and The highest-numbered level-3 configuration in
are stored as zeros. the level-3-configuration stack is always
described by the first description block in the
Description-Block Count (DBCT): Bits 28-31 of SYSIB. The lowest-numbered level-3 config-
word 7 contain a four-bit unsigned binary integer uration in the stack, of those that are included
that specifies the number (up to eight) of virtual- in the subset that is described, is described by
machine description blocks that are stored in the the last description block in the SYSIB.
SYSIB beginning at word 8.

10-104 z/Architecture Principles of Operation


The contents of the SYSIB subsequent to the A logical CPU is in the standby state when it is in
virtual-machine description blocks and prior to the level-3 configuration, is not available to be
word 136 are reserved and are stored as zeros. used to execute programs, and can be made
available by issuing instructions to place it in the
The virtual-machine description block has the fol- configured state.
lowing format:
Reserved Logical-CPU Count: Bytes 2 and 3 of
Virtual-Machine Description Block word 2 contain a 16-bit unsigned binary integer

that specifies the number of CPUs for this level-3
Reserved
configuration that are in the reserved state.
1 Total LCPU Count Conf. LCPU Count
A logical CPU is in the reserved state when it is in
2 SB LCPU Count Resv. LCPU Count the level-3 configuration, is not available to be
used to execute programs, and cannot be made
3 available by issuing instructions to place it in the
Virtual-Machine Name
4 configured state. (It may be possible to place the
logical CPU in the standby or configured state
5 Virtual-Machine CAF through manual actions.)

6 Virtual-Machine Name: Words 3-4 contain the
/ Control-Program Identifier / eight-character EBCDIC name of this level-3 con-
9
figuration. The name is left justified with trailing
1 blanks if necessary.
/ Reserved /
15 Virtual-Machine Capability Adjustment Factor
(CAF): Word 5 contains a 32-bit unsigned binary
31 integer, called an adjustment factor, with a value
of 1000 or less. The adjustment factor specifies
Reserved: The contents of words 0 and 10-15 the amount of the underlying level-1-, level-2-, or
are reserved and are stored as zeros. level-3-configuration capability that is allowed to
be used for this level-3 configuration by the virtual-
Total Logical-CPU Count: Bytes 0 and 1 of machine control program. The fraction of the
word 1 contain a 16-bit unsigned binary integer underlying capability is determined by dividing the
that specifies the total number of logical CPUs CAF value by 1000.
that are provided for this level-3 configuration.
This number includes all of the logical CPUs that Control-Program Identifier: Words 6-9 contain
are in the configured state, the standby state, and the 16-character EBCDIC identifier of the virtual-
the reserved state. machine control program that provides this level-3
configuration. This identifier may include qualifiers
Configured Logical-CPU Count: Bytes 2 and 3 such as version number and release level. The
of word 1 contain a 16-bit unsigned binary integer identifier is left justified with trailing blanks if nec-
that specifies the number of logical CPUs for this essary.
level-3 configuration that are in the configured
state. Special Conditions

A logical CPU is in the configured state when it is The condition code is set to 3 if the function code
in the level-3 configuration and is available to be in bit positions 32-35 of general register 0 is
used to execute programs. greater than the current-level number.

Standby Logical-CPU Count: Bytes 0 and 1 of Bits 36-55 of general register 0 and 32-47 of
word 2 contain a 16-bit unsigned binary integer general register 1 must be zero; otherwise, a
that specifies the number of logical CPUs for this specification exception is recognized.
level-3 configuration that are in the standby state.

Chapter 10. Control Instructions 10-105


When the function code is valid and nonzero, the Resulting Condition Code:
following special conditions apply in an unpredict-
0 Requested configuration-level number placed
able order:
in general register 0 or requested SYSIB
The second operand must be designated on a information stored
4K-byte boundary; otherwise, a specification 1 --
exception is recognized. 2 --
3 Requested SYSIB information not available
If the function-code, selector-1, and selector-2
combination is invalid, or if it is valid but the
Program Exceptions:
requested information is not available, the
condition code is set to 3. Access (store, operand 2, only if function code
nonzero)
The priority of the recognition of exceptions and Privileged operation
condition codes is shown in Figure 10-31. Specification

1.-6. Exceptions with the same priority as the priority of program-


interruption conditions for the general case.

7.A Access exceptions for second instruction halfword.

7.B.1 Operation exception if the store-system-information facility
is not installed.

7.B.2 Privileged-operation exception for privileged instruction.

8. Condition code 3 due to function code greater than current-
level number.

9. Specification exception due to bits 36-55 of general register
or bits 32-47 of general register 1 not zero.

1. Condition code due to function code .

11.A Specification exception due to second-operand address not
designating a 4K-byte boundary.

11.B Condition code 3 due to invalid function-code, selector-1,
and selector-2 combination or requested information not
available.

12. Access exceptions (store) for system-information block.

13. Condition code due to information stored in system-
information block.

Figure 10-31. Priority of Execution: STORE SYSTEM INFORMATION

10-106 z/Architecture Principles of Operation


STORE THEN AND SYSTEM Special Conditions
MASK The value to be loaded into the PSW is not
checked for validity before loading. However,
STNSM D(B),I [SI]
immediately after loading, a specification excep-
tion is recognized, and a program interruption
'AC' I B D occurs, if the contents of bit positions 0 and 2-4 of
the PSW are not all zeros. In this case, the
8 16 2 31 instruction is completed, and the instruction-length
code is set to 2. The specification exception,
Bits 0-7 of the current PSW are stored at the first- which is listed as a program exception for this
operand location. Then the contents of bit posi- instruction, is described in Early Exception
tions 0-7 of the current PSW are replaced by the Recognition on page 6-9. It may be considered
logical AND of their original contents and the as occurring early in the process of preparing to
second operand. execute the following instruction.

Special Conditions The operation is suppressed on addressing and


protection exceptions.
The operation is suppressed on addressing and
protection exceptions. Condition Code: The code remains unchanged.

Condition Code: The code remains unchanged. Program Exceptions:


Access (store, operand 1)
Program Exceptions:
Privileged operation
Access (store, operand 1) Specification
Privileged operation
Programming Note: STORE THEN OR
Programming Note: STORE THEN AND SYSTEM MASK permits the program to set
SYSTEM MASK permits the program to set selected bits in the system mask to ones while
selected bits in the system mask to zeros while retaining the original contents for later restoration.
retaining the original contents for later restoration. For example, the program may enable the CPU
For example, it may be necessary that a program, for I/O interruptions without having available the
which has no record of the present status, disable current status of the external-mask bit.
program-event recording for a few instructions.
STORE USING REAL ADDRESS
STORE THEN OR SYSTEM MASK
STURA R,R [RRE]
STOSM D(B),I [SI]

'B246' //////// R R
'AD' I B D
16 24 28 31
8 16 2 31
STURG R,R [RRE]
Bits 0-7 of the current PSW are stored at the first-

operand location. Then the contents of bit posi-
'B925' //////// R R
tions 0-7 of the current PSW are replaced by the
logical OR of their original contents and the 16 24 28 31
second operand.
For STORE USING REAL ADDRESS (STURA),
bits 32-63 of general register R are stored in the
word at the real-storage location addressed by the
contents of general register R. For STORE
USING REAL ADDRESS (STURG), bits 0-63 of

Chapter 10. Control Instructions 10-107


general register R are stored in the doubleword Bits 0-31 and 48-63 of general register R are
at that real-storage location. ignored.

In the 24-bit addressing mode, bits 40-63 of The operation does not depend on the translation
general register R designate the real-storage modebits 5, 16, and 17 of the PSW are ignored.
location, and bits 0-39 of the register are ignored.
In the 31-bit addressing mode, bits 33-63 of When the ALET specified by means of the R field
general register R designate the real-storage is other than 00000000 or 00000001 hex, the ART
location, and bits 0-33 of the register are ignored. process is applied to the ALET. The EAX speci-
In the 64-bit addressing mode, bits 0-63 of general fied by means of the R field is called the effective
register R designate the real-storage location. EAX, and it is the EAX which is used by ART.
When a condition exists that would normally cause
Because it is a real address, the address desig- one of the exceptions shown in the following table,
nating the storage word or doubleword is not the instruction is completed by setting condition
subject to dynamic address translation. code 3.

Special Conditions Exception Name Cause


ALET specification ALET bits 0-6 not all
The contents of general register R must desig-
zeros
nate a location on a word boundary for STURA or
on a doubleword boundary for STURG; otherwise, ALEN translation Access-list entry (ALE)
a specification exception is recognized. outside list or invalid (bit 0
is one)
Condition Code: The code remains unchanged.
ALE sequence ALE sequence number
Program Exceptions: (ALESN) in ALET not
equal to ALESN in ALE
Addressing (address specified by general reg-
ister R) ASTE validity ASN-second-table entry
Privileged operation (ASTE) invalid (bit 0 is
Protection (store, operand 2, key-controlled one)
protection and low-address protection) ASTE sequence ASTE sequence number
Specification (ASTESN) in ALE not
equal to ASTESN in
TEST ACCESS ASTE
Extended authority ALE private bit not zero,
TAR R,R [RRE]
ALE authorization index
(ALEAX) not equal to
'B24C' //////// R R effective EAX, and sec-
ondary bit selected by
16 24 28 31 effective EAX either
outside authority table or
The access-list-entry token (ALET) in access reg- zero
ister R is tested for exceptions recognized during
access-register translation (ART). The extended When ART is completed without one of the above
authorization index (EAX) used is bits 32-47 of conditions being present, the instruction is com-
general register R. The ALET is also tested for pleted by setting condition code 1 or 2, depending
whether it designates the dispatchable-unit access on whether the effective access list is the
list or the primary-space access list and for dispatchable-unit access list or the primary-space
whether it is 00000000 or 00000001 hex. access list, respectively. The effective access list
is the dispatchable-unit access list if bit 7 of the
When R is 0, the actual contents of access reg- ALET is zero, or it is the primary-space access list
ister 0 are used in ART, instead of the 00000000 if bit 7 is one. ART, including the obtaining of the
hex that is usually used.

10-108 z/Architecture Principles of Operation


effective access-list designation, is described in 2. When an ALET equal to 00000000 hex is
Access-Register-Translation Process on passed during a program linkage performed
page 5-48. by PROGRAM CALL with space switching
(PC-ss), and the ALET conceptually desig-
When the ALET is 00000000 hex, the instruction nates the calling program's primary address
is completed by setting condition code 0. When space and the called program's secondary
the ALET is 00000001 hex, the instruction is com- address space, the ALET must be changed to
pleted by setting condition code 3. 00000001 hex before it is used by the called
program. Condition code 0 of TEST ACCESS
Special Conditions indicates a 00000000 hex ALET so that the
ALET can be changed to 00000001 hex by
An addressing exception is recognized when the the called program.
address used by ART to fetch the effective
access-list designation or the ALE, ASTE, or 3. PROGRAM CALL to current primary (PC-cp)
authority-table entry designates a location which is sets the secondary address space equal to
not available in the configuration. the primary address space. PC-ss sets the
secondary address space equal to the calling
The operation is suppressed on all addressing program's primary address space, except that
exceptions. stacking PC-ss sets it equal to the called pro-
gram's primary address space when the
The priority of recognition of program exceptions secondary-ASN control in the entry-table entry
for the instruction is shown in Figure 10-32 on used is one. In all these cases, a passed
page 10-110. 00000001 hex ALET that conceptually desig-
nates the calling program's secondary address
Resulting Condition Code: space is not usable by the called program,
even after any transformation (unless the
0 Access-list-entry token (ALET) is 00000000
operation was PC-cp and the calling pro-
hex
gram's PASN and SASN are equal). This is
1 ALET designates the dispatchable-unit access
why TEST ACCESS sets condition code 3
list and does not cause exceptions in access-
when the tested ALET is 00000001 hex.
register translation (ART)
2 ALET designates the primary-space access 4. After a PC-ss, a passed ALET that conceptu-
list and does not cause exceptions in ART ally designates an entry in the primary-space
3 ALET is 00000001 hex or causes exceptions access list of the calling program is not usable
in ART by the called program. This is why TEST
ACCESS sets condition code 2, instead of
Program Exceptions: condition code 1, when the tested ALET des-
Addressing (effective access-list designation, ignates the primary-space access list.
access-list entry, ASN-second-table entry, or 5. The control program may manage the
authority-table entry) ASN-second-table entry in a way that causes
a correctable ASTE-validity or
Programming Notes: ASTE-sequence exception situation to exist;
1. TEST ACCESS permits a called program to that is, a situation which, if it were to cause a
check whether an ALET passed from the program interruption during access-register
calling program is authorized for use by translation, would be corrected by the control
means of the calling program's EAX. The program so that access-register translation
calling program's EAX can be obtained from could be completed successfully. In this case,
the last linkage-stack state entry by means of the program should not use TEST ACCESS
EXTRACT STACKED STATE. The called directly but should instead use a control-
program can thus avoid performing an opera- program service that uses TEST ACCESS
tion for the calling program, through the use of and that corrects the situation, if possible,
the called program's EAX, which the calling when condition code 3 is set. MVS/ESA pro-
program is not authorized to perform by vides the TESTART macro instruction for use
means of its own EAX. instead of the direct use of TEST ACCESS.

Chapter 10. Control Instructions 10-109



1.-6. Exceptions with the same priority as the priority of program-
interruption conditions for the general case.

7. Access exceptions for second instruction halfword.

8. Condition code due to access-list-entry-token (ALET) being
hex.

9. Condition code 3 due to ALET being 1 hex or ALET bits
-6 not being all zeros.

1. Addressing exception for access to effective access-list des-
ignation.

11. Condition code 3 due to access-list entry (ALE) being outside
the list.

12. Addressing exception for access to ALE.

13. Condition code 3 due to ALE being invalid (bit is 1) or
access-list-entry sequence number (ALESN) in the ALET not
being equal to the ALESN in the ALE.

14. Addressing exception for access to ASN-second-table entry
(ASTE).

15. Condition code 3 due to ASTE being invalid (bit is one) or
ASTE sequence number (ASTESN) in the ALE not being equal to
the ASTESN in the ASTE.

16. Condition code 3 due to authority-table entry being outside
table.

17. Addressing exception for access to authority-table entry.

18. Condition code 3 due to ALE private bit not being zero, ALE
authorization index (ALEAX) not being equal to effective ex-
tended authorization index (EAX), and secondary bit selected
by effective EAX being zero.

19. Condition code 1 if ALET bit 7 is zero; otherwise, condition
code 2.

Figure 10-32. Priority of Execution: TEST ACCESS

TEST BLOCK of the block to the occurrence of invalid checking-


block code.
TB R,R [RRE]
The block tested is addressed by the contents of
general register R.
'B22C' //////////// R
A complete testing operation is necessarily per-
16 28 31
formed only when the initial contents of bit posi-
tions 32-63 of general register 0 are zero in the
The storage locations and storage key of a 24-bit or 31-bit addressing mode, or the initial con-
4K-byte block are tested for usability, and the tents of bit positions 0-63 of that register are zero
result of the test is indicated in the condition code. in the 64-bit addressing mode. In the 24-bit or
The test for usability is based on the susceptibility 31-bit addressing mode, the contents of bit posi-
tions 32-63 of general register 0 are set to zero at

10-110 z/Architecture Principles of Operation


the completion of the operation, and bits 0-31 of on the criteria, attempts to store may or may not
the register always are ignored and remain occur. Thus, if block 0 is not usable, and no store
unchanged. In the 64-bit addressing mode, the occurs, low-address protection may or may not be
contents of bit positions 0-63 of the register are indicated.
set to zero at the completion of the operation.
In models in which test patterns are used, TEST
If the block is found to be usable, the 4K bytes of BLOCK may be interruptible. When an inter-
the block are cleared to zeros, the contents of the ruption occurs after a unit of operation, other than
storage key are unpredictable, and condition code the last one, the condition code is unpredictable,
0 is set. If the block is found to be unusable, the and the contents of bit positions 32-63 of general
data and the storage key are set, as far as is pos- register 0 may contain a record of the state of
sible by the model, to a value such that subse- intermediate steps in the 24-bit or 31-bit
quent fetches to the area do not cause a addressing mode, or the contents of bit positions
machine-check condition, and condition code 1 is 0-63 may contain that record in the 64-bit
set. addressing mode. When execution is resumed
after an interruption, the condition code is ignored,
In the 24-bit addressing mode, bits 40-51 of but the record in general register 0 may be used
general register R designate a 4K-byte block in to determine the resumption point.
real storage, and bits 0-39 and 52-63 of the reg-
ister are ignored. In the 31-bit addressing mode, If (1) TEST BLOCK is executed with an initial
bits 33-51 of the register designate the block, and value other than zero in bit positions 32-63 of
bits 0-32 and 52-63 are ignored. In the 64-bit general register 0 in the 24-bit or 31-bit
addressing mode, bits 0-51 of the register desig- addressing mode or bit positions 0-63 in the 64-bit
nate the block, and bits 52-63 are ignored. addressing mode, or (2) the interrupted instruction
is resumed after an interruption with a value in bit
The address of the block is a real address, and positions 32-63 or 0-63 (depending on the
the accesses to the block designated by the addressing mode) of general register 0 or a value
second-operand address are not subject to key- in the storage block or its associated storage key
controlled, access-list-controlled, and page pro- other than the corresponding value which was
tection. Low-address protection does apply. The present at the time of the interruption, or (3) the
operation is terminated on addressing and pro- block or its associated storage key is accessed by
tection exceptions. If termination occurs, the con- another CPU or by the channel subsystem during
dition code and the contents of bit positions 32-63 the execution of the instruction, then the contents
of general register 0 are unpredictable in the of the storage block, its associated storage key,
24-bit or 31-bit addressing mode, or the condition and bit positions 32-63 or 0-63 of general register
code and bits 0-63 of the register are unpredict- 0 are unpredictable, along with the resultant
able in the 64-bit addressing mode. The contents condition-code setting.
of the storage block and its associated storage
key are not changed when these exceptions Invalid checking-block-code errors initially found in
occur. the block or encountered during the test do not
normally result in machine-check conditions. The
Depending on the model, the test for usability may test-block function is implemented in such a way
be performed (1) by alternately storing and that the frequency of machine-check interruptions
reading out test patterns to the data and storage due to the instruction execution is not significant.
key in the block or (2) by reference to an internal However, if, during the execution of TEST BLOCK
record of the usability of the blocks which are for an unusable block, that block is accessed by
available in the configuration, or (3) by using a another CPU (or by the channel subsystem), error
combination of both mechanisms. conditions may be reported both to this CPU and
to the other CPU (or to the channel subsystem).
In models in which an internal record is used, the
block is indicated as unusable if a solid failure has A serialization function is performed before the
been previously detected, or if intermittent failures block is accessed and again after the operation is
in the block have exceeded the threshold imple- completed (or partially completed).
mented by the model. In such models, depending

Chapter 10. Control Instructions 10-111


The priority of the recognition of exceptions and 2. The program should use TEST BLOCK at
condition codes is shown in Figure 10-33 on initial program loading and as part of the vary-
page 10-112. storage-online procedure to determine if
blocks of storage exist which should not be
Resulting Condition Code: used.
0 Block usable 3. The program should use TEST BLOCK when
1 Block not usable an uncorrected error is reported in either the
2 -- data or storage key of a block. This is
3 -- because in the execution of TEST BLOCK the
attempt is made, as far as is possible on the
Program Exceptions: model, to leave the contents of a block in a
Addressing (fetch and store, operand 2) state such that subsequent prefetches or unin-
Privileged operation tended references to the block do not cause
Protection (store, operand 2, low-address pro- machine-check conditions. The program may
tection only) use the resulting condition code in this case to
determine if the block can be reused. (The
block could be indicated as usable if, for
1.-6. Exceptions with the same priority as example, the error were an externally gener-
the priority of program-interruption ated error or an indirect storage error.) This
conditions for the general case.
procedure should be followed regardless of
7.A Access exceptions for second instruc- whether the indirect-storage-error indication is
tion halfword. reported.

7.B Privileged-operation exception. 4. The model may or may not be successful in
removing the errors from a block when TEST
8. Addressing exception due to block not BLOCK is executed. The program therefore
being available in the configuration.\ should take every reasonable precaution to
avoid referencing an unusable block. For
9.A Condition code 1, block not usable.
example, the program should not place the
9.B Protection exception due to low-address page-frame real address of an unusable block
protection.\ in an attached and valid page-table entry.

1. Condition code , block usable and set 5. On some models, machine checks may be
to zeros. reported for a block even though the block is
not referenced by the program. When a
Explanation: machine check is reported for a storage-key
error in a block which has been marked as
\ The operation is terminated on addressing
and protection exceptions, and the condi- unusable by the program, it is possible that
tion code may be unpredictable. SET STORAGE KEY EXTENDED may be
more effective than TEST BLOCK in validating
the storage key.
Figure 10-33. Priority of Execution: TEST BLOCK
6. The storage-operand references for TEST
Programming Notes: BLOCK may be multiple-access references.
1. The execution of TEST BLOCK on most (See Storage-Operand Consistency on
models is significantly slower than that of the page 5-86.)
MOVE LONG instruction with padding; there-
fore, the instruction should not be used for the
normal case of clearing storage.

10-112 z/Architecture Principles of Operation


TEST PROTECTION Exception Name Cause
ALET specification Access-list-entry-token
TPROT D(B),D(B) [SSE]
(ALET) bits 0-6 not all
// zeros
'E51' B D B D ALEN translation Access-list entry (ALE)
//
16 2 32 36 47 outside list or invalid (bit 0
is one)

The location designated by the first-operand ALE sequence ALE sequence number
address is tested for protection exceptions by (ALESN) in ALET not
using the access key specified in bits 56-59 of the equal to ALESN in ALE
second-operand address. ASTE validity ASN-second-table entry
(ASTE) invalid (bit 0 is
The second-operand address is not used to one)
address data; instead, bits 56-59 of the address
form the access key to be used in testing. Bits ASTE sequence ASTE sequence number
0-55 and 60-63 of the second-operand address (ASTESN) in ALE not
are ignored. equal to ASTESN in
ASTE
The first-operand address is a logical address. Extended authority ALE private bit not zero,
When the CPU is in the access-register mode ALE authorization index
(when DAT is on and PSW bits 16 and 17 are 01 (ALEAX) not equal to
binary), the first-operand address is subject to extended authorization
translation by means of both the access-register- index (EAX), and sec-
translation (ART) and the dynamic-address- ondary bit selected by
translation (DAT) processes. ART applies to the EAX either outside
access register designated by the B field, and it authority table or zero
obtains the address-space-control element to be
used by DAT. When DAT is on but the CPU is
not in the access-register mode, the first-operand When the access register contains 00000000 hex
address is subject to translation by DAT. In this or 00000001 hex, ART obtains the address-space-
case, DAT uses the address-space-control control element from control register 1 or 7,
element contained in control register 1, 7, or 13 respectively, without accessing the access list.
when the CPU is in the primary-space, secondary- When the B field designates access register 0,
space, or home-space mode, respectively. When ART treats the access register as containing
DAT is off, the first-operand address is a real 00000000 hex and does not examine the actual
address not subject to translation by either ART or contents of the access register.
DAT.
When ART is completed successfully, the opera-
When the CPU is in the access-register mode and tion is continued through the performance of DAT.
an address-space-control element cannot be
When DAT is on and the first-operand address
obtained by ART because of a condition that
cannot be translated because of a condition that
would normally cause one of the exceptions
would normally cause one of the exceptions
shown in the following table, the instruction is
shown in the following table, the instruction is
completed by setting condition code 3.
completed by setting condition code 3.

Chapter 10. Control Instructions 10-113


Exception Name Cause Special Conditions
ASCE type Address-space-control When the CPU is in the access-register mode, an
element (ASCE) being addressing exception is recognized when the
used is a region-second- address used by ART to fetch the effective
table designation, and bits access-list designation or the ALE, ASTE, or
0-10 of first-operand authority-table entry designates a location which is
address not all zeros; not available in the configuration.
ASCE is a region-third-
table designation, and bits When DAT is on, an addressing exception is
0-21 of first-operand recognized when the address of the region-table
address not all zeros; or entry or entries, segment-table entry, or page-
ASCE is a segment-table table entry or the operand real address after trans-
designation, and bits 0-32 lation designates a location which is not available
of first-operand address in the configuration. Also, a translation-
not all zeros. specification exception is recognized when a
Region first translation Region-first-table entry region-table entry or the segment-table entry or
outside table or invalid. page-table entry has a format error, that is, when
any of the reasons listed in Translation-
Region second trans- Region-second-table entry Specification Exception on page 6-35 applies.
lation outside table or invalid. When DAT is off, only the addressing exception
Region third trans- Region-third-table entry due to the operand real address applies.
lation outside table or invalid.
For all of the above cases, the operation is sup-
Segment translation Segment-table entry pressed.
outside table or invalid
Page translation Page-table entry invalid Resulting Condition Code:
0 Fetching permitted; storing permitted
When translation of the first-operand address can 1 Fetching permitted; storing not permitted
be completed, or when DAT is off, the storage key 2 Fetching not permitted; storing not permitted
for the block designated by the first-operand 3 Translation not available
address is tested against the access key specified
in bits 56-59 of the second-operand address, and Program Exceptions:
the condition code is set to indicate whether store Addressing (effective access-list designation,
and fetch accesses are permitted, taking into con- access-list entry, ASN-second-table entry,
sideration all applicable protection mechanisms. authority-table entry, region-table entry,
Thus, for example, if low-address protection is segment-table entry, page-table entry, or
active and the first-operand effective address is in operand 1)
the range 0-511 or 4096-4607, then a store Privileged operation
access is not permitted. Access-list-controlled Translation specification
protection, page protection, storage-protection
override, and fetch-protection override also are Programming Notes:
taken into account.
1. TEST PROTECTION permits a program to
The contents of storage, including the change bit, check the validity of an address passed from
are not affected. Depending on the model, the a calling program without incurring program
reference bit for the first-operand address may be exceptions. The instruction sets a condition
set to one, even for the case in which the location code to indicate whether fetching or storing is
is protected against fetching. permitted at the location designated by the
first-operand address of the instruction. The
instruction takes into consideration all of the
protection mechanisms in the machine:
access-list controlled, page, key-controlled,
and low-address protection, storage-protection

10-114 z/Architecture Principles of Operation


override, and fetch-protection override. Addi- address of LOAD REAL ADDRESS is a virtual
tionally, since ASCE-type, region-translation, address which is always translated.
segment-translation, and page-translation-
Access-register translation applies to TEST
exception conditions may be a program sub-
PROTECTION only when the CPU is in the
stitute for a protection violation, these
access-register mode (DAT is on), whereas it
conditions are used to set the condition code
applies to LOAD REAL ADDRESS when PSW
rather than cause a program exception.
bits 16 and 17 are 01 binary regardless of
When the CPU is in the access-register mode, whether DAT is on or off. When condition
TEST PROTECTION additionally permits the code 3 is set because of an exception condi-
program to check the usability of an access- tion in access-register translation, LOAD
list-entry token (ALET) in an access register REAL ADDRESS, but not TEST PRO-
without incurring program exceptions. The TECTION, returns in a general register the
ALET is checked for validity (absence of an program-interruption code assigned to the
ALET-specification, ALEN-translation, and exception.
ALE-sequence-exception condition) and for
being authorized for use by the program TRACE
(absence of an ASTE-validity,
ASTE-sequence, and extended-authority- TRACE R,R,D(B) [RS]
exception condition).

An ASCE-type-exception condition also '99' R R B D
causes setting of the condition code.
8 12 16 2 31
2. See the programming notes under SET PSW
KEY FROM ADDRESS for more details and
for an alternative approach to testing validity TRACG R,R,D(B) [RSE]
of addresses passed by a calling program. /
The approach using TEST PROTECTION has 'EB' R R B D //////// 'F'
the advantage of a test which does not result /
in interruptions; however, the test and use are 8 12 16 2 32 4 47
separated in time and may not be accurate if
the possibility exists that the storage key of When explicit tracing is on (bit 63 of control reg-
the location in question can change between ister 12 is one), the second operand, which is a
the time it is tested and the time it is used. 32-bit word in storage, is fetched, and bit 0 of the
3. In the handling of dynamic address trans- word is examined. If bit 0 of the second operand
lation, TEST PROTECTION is similar to LOAD is zero, a trace entry is formed at the real-storage
REAL ADDRESS in that the instructions do location designated by control register 12.
not cause ASCE-type, region-translation,
segment-translation, and page-translation If explicit tracing is off (bit 63 of control register 12
exceptions. Instead, these exception condi- is zero), or if bit 0 of the second operand is one,
tions are indicated by means of a condition- no trace entry is formed, and no trace exceptions
code setting. Similarly, access-register are recognized.
translation sets a condition code for certain
The trace entry is composed of an entry-type iden-
exception conditions when performed during
tifier, a count of the number of general registers
either of the two instructions. Conditions
whose partial or entire contents are placed in the
which result in condition codes 1, 2, and 3 for
entry, a field whose contents indicate whether the
LOAD REAL ADDRESS result in condition
entry was formed by TRACE (TRACE) or TRACE
code 3 for TEST PROTECTION. The
(TRACG), selected bits of the TOD clock, the
instructions also differ in several other
second operand, and the partial or entire contents
respects. The first-operand address of TEST
of a range of general registers. For TRACE
PROTECTION is a logical address and thus is
(TRACE), bits 16-63 of the TOD clock and bits
not subject to dynamic address translation
32-63 of the general registers are placed in the
when DAT is off. The second-operand
trace entry. For TRACE (TRACG), bits 0-79 of

Chapter 10. Control Instructions 10-115


the clock and bits 0-63 of the registers are placed TRAP
in the entry.
TRAP2 [E]
The general registers are stored in ascending
order of their register numbers, starting with
general register R and continuing up to and '1FF'
including general register R, with general register
15
0 following general register 15. The trace table
and the trace-entry formats are described in TRAP4 D(B) [S]
Tracing on page 4-10.

'B2FF' B D
When a trace entry is made, a serialization and
checkpoint-synchronization function is performed 16 2 31
before the operation begins and again after the
operation is completed. A trap operation is performed if the CPU is in the
primary-space or access-register mode and the
Special Conditions TRAP-enabled bit in byte 47 of the dispatchable-
unit control table (DUCT) is one. Otherwise, a
A privileged-operation exception is recognized in special-operation exception is recognized.
the problem state, even when explicit tracing is off
or bit 0 of the second operand is one. The trap operation obtains a trap-control-block
address from the DUCT and then a trap-save-area
The second operand must be designated on a address and a trap-program address from the trap
word boundary; otherwise, a specification excep- control block. State information is stored in the
tion is recognized. It is unpredictable whether the trap save area. Then the trap-control-block
specification exception is recognized when explicit address is loaded into general register 15. Finally,
tracing is off. the current PSW is updated by setting the basic-
addressing-mode bit to one (which will leave the
It is unpredictable whether access exceptions are addressing mode as either the 31-bit mode or the
recognized for the second operand when explicit 64-bit mode or will change the addressing mode
tracing is off. from the 24-bit mode to the 31-bit mode) and the
address-space-control bits to zeros (primary-space
Condition Code: The code remains unchanged. mode) and by replacing the instruction address
with the trap-program address. Compatibility with
Program Exceptions:
the ESA/390 operation of TRAP optionally is pro-
Access (fetch, operand 2) vided.
Privileged operation
Specification For TRAP4, the second-operand address is not
Trace used to address data; instead, bits 33-63 of the
address are stored in the trap save area.
Programming Note: Bits 1-15 of the second
operand are reserved for model-dependent func-
Dispatchable-Unit Control Table
tions and should therefore be set to zeros.
Bytes 44-47 (word 10) of the dispatchable-unit-
control table (DUCT) are used by this instruction.
The contents of those bytes are as follows:

DUCT Bytes 44-47



Trap-Control-Block Address E

1 29 31

The fields in bytes 44-47 of the DUCT are allo-


cated as follows:

10-116 z/Architecture Principles of Operation


Trap-Control-Block Address: Bits 1-28, with Bit 31 of the current PSW, the extended-
three zeros appended on the right, form the 31-bit addressing-mode bit, must be zero; otherwise,
home virtual address of the trap control block. a special-operation exception is recognized.
This address is treated as a 31-bit home virtual
A one is stored in bit position 12 of the
address regardless of the current addressing
PSW-values field even though bit 12 of the
mode and regardless of the current value of the
current PSW is zero.
address-space-control bits. This address, with a
zero appended on the left, is placed in bit posi- Bits 97-127 of the current PSW are stored in
tions 32-63 of general register 15 after the con- bit positions 33-63 of the PSW-values field,
tents of that register have been saved in the trap bits 33-96 of the current PSW are not stored,
save area. If the current addressing mode is the and zeros are stored in bit positions 64-127 of
64-bit mode, bits 0-31 of general register 15 are the PSW-values field.
set to zeros. When bit 13 is one:
TRAP-Enabled Bit (E): Bit 31 specifies, when Bit 31 of the current PSW may be zero or
one, that the trap operation is to be performed. one.
TRAP recognizes a special-operation exception if Bit 12 of the current PSW is stored in bit posi-
bit 31 is zero. tion 12 of the PSW-values field.
Bits 0, 29, and 30 of bytes 44-47 are ignored, but Bits 64-127 of the current PSW are stored in
they should be zeros to permit possible future bit positions 64-127 of the PSW-values field.
extensions.
General-Registers Control (R): Bit 14 of bytes 0
Trap Control Block and 1 controls how the contents of the general
registers are stored in the general-registers 0-15
The trap control block is 64 bytes aligned on a field in the trap save area. When R is zero, bits
doubleword boundary. The format of the trap 32-63 of the general registers are stored in con-
control block is: secutive four-byte locations beginning at the
Hex Dec beginning of the general-registers 0-15 field, bits
0-31 of the registers are not stored, and the last
PR (P is 64 bytes of the general-registers 0-15 field remain
bit 13) unchanged. When R is one, bits 0-63 of the
4 4 general registers are stored in consecutive eight-
8 8
byte locations in the general-registers 0-15 field.
C 12 Trap-Save-Area Address
Trap-Save-Area Address: Bits 1-28 of bytes
1 16 12-15, with three zeros appended on the right,
form the 31-bit home virtual address of the trap
14 2 Trap-Program Address save area. This address is treated as a 31-bit

18 24 /////////////////////////// home virtual address regardless of the current


1C 28 /////////////////////////// addressing mode and regardless of the current
value of the address-space-control bits. Bits 0
2 32 and 29-31 of bytes 12-15 are ignored.
/ /
3C 6 Trap-Program Address: Bits 1-31 of bytes

20-23 form the 31-bit primary virtual address of


the trap program. This address is treated as a
The fields in the trap control block are allocated as
31-bit primary virtual address regardless of the
follows:
current addressing mode.
PSW Control (P): Bit 13 of bytes 0 and 1 con-
Bit positions 0-12 and 15-31 of bytes 0-3 and
trols the allowed value of bit 31 of the current
bytes 4-11 and 16-19 of the trap control block are
PSW and how bits 12 and 33-127 of the current
reserved and should contain zeros. Bytes 24-31
PSW are stored in the PSW-values field in the
are available for use by programming.
trap save area. When bit 13 is zero:

Chapter 10. Control Instructions 10-117


Trap Save Area Bits 13 and 14 are the instruction-length code
(ILC) that specifies the length of the TRAP instruc-
The trap save area is 256 bytes aligned on a tion, or the length of the EXECUTE instruction if
doubleword boundary. TRAP was the target of EXECUTE.

The trap operation stores information into the trap Bits 2-12 and 15-31 are reserved and are stored
save area as follows: as zeros.
Hex Dec
Bits 33-63 of Second-Operand Address of
Trap Flags TRAP4: For TRAP4, bits 33-63 of the second-
operand address, generated under the control of
4 4 Reserved (Zeros Stored) the current addressing mode and with a zero

8 8 Bits 33-63 of Second-Op appended on the left, are stored in byte positions
Address of TRAP4 8-11. Only bits 33-63 of the second-operand
address are stored even when the current
C 12 Access Register 15 addressing mode is the 64-bit mode. For TRAP2,
all zeros are stored in byte positions 8-11.
1 16
14 2 PSW Values
18 24 Access Register 15: The contents of access
1C 28 register 15 are stored in byte positions 12-15.

2 32 PSW Values: The following description applies


24 36 when the PSW control, bit 13 of bytes 0 and 1 of
/ General Registers -15 / the trap control block, is one.
98 152
9C 156
Certain information from the current PSW is stored
A 16 /////////////////////////// in byte positions 16-31. The PSW has the fol-
A4 164 /////////////////////////// lowing format:

A8 168 IE Prog E
AC 172 RTOX Key MWPA SC C Mask A

/ Reserved (Unchanged) / 5 8 12 16 18 2 24 31
F8 248

FC 252 B
A

32 63
The fields in the trap save area are allocated as

follows:
Instruction Address

Trap Flags: Information identifying the 64 95
instruction(s) causing the trap operation is stored

in byte positions 0-3. The detailed format of bytes Instruction Address (Continued)
0-3 is as follows:
96 127
Flag Bits Meaning
0 TRAP was target of EXECUTE Bits 0-127 of bytes 16-31 correspond one-to-one
1 TRAP is TRAP4 (not TRAP2) with bits 0-127 of the PSW. For some bit posi-
2-12 Reserved, zeros stored tions of bytes 16-31, the corresponding PSW bits
13-14 Instruction-length code (ILC) are stored. For the other bit positions of bytes
15-31 Reserved, zeros stored 16-31, unpredictable values are stored. Informa-
tion is stored in bytes 16-31 as follows:
Bit 0 of bytes 0-3 is set to one if TRAP was the
target of an EXECUTE instruction. Bits Value
0 Zero
Bit 1 of bytes 0-3 is set to one if TRAP is TRAP4 1 Unpredictable
(not TRAP2).

10-118 z/Architecture Principles of Operation



Bits Value IE Prog
2-4 Zero R TOX Key 1MWPA SC C Mask

5-11 Unpredictable 5 8 12 16 18 2 24 31
12 Zero

13 Unpredictable A Instruction Address
14 Wait state (W)
32 63
15 Problem state (P)
16-17 Address-space control (AS)
18-19 Condition code (CC) General Registers 0-15: Contents of general
20-23 Program mask registers 0-15 are stored in byte positions 32-159
24-30 Zero as described in General-Registers Control (R) on
31 Extended addressing mode (EA) page 10-117. When bits 32-63 or 0-63 of the
32 Basic addressing mode (BA) general registers are stored, they are stored in
33-63 Zero ascending order of register numbers, starting with
64-127 Instruction address register 0 and continuing up to and including reg-
ister 15.
In summary, bits 0, 2-4, 12, 24-30, and 33-63 are
zero, bits 1, 5-11, and 13 are unpredictable, and Bytes 160-255 always remain unchanged. Bytes
the other bits are set with variable information 168-255 are reserved. Bytes 160-167 are avail-
from the PSW. able for use by programming.

The wait-state, problem-state, address-space- Special Conditions


control, condition-code, program-mask, extended-
The CPU must be in the primary-space mode or
addressing-mode, and basic-addressing-mode
access-register mode, and bit 31 in bytes 44-47 of
values specify the state of the CPU before the
the dispatchable-unit control table must be one;
TRAP instruction was executed. The instruction-
otherwise, a special-operation exception is recog-
address value is the updated instruction address,
nized. A special-operation exception is also
which is the address of the instruction following
recognized if the PSW control, bit 6 of byte 1 of
TRAP, or the address of the instruction following
the trap control block is zero and bit 31 of the the
EXECUTE if TRAP was the target of EXECUTE.
current PSW, the extended-addressing-mode bit,
When the PSW control in the trap control block is is one.
zero, the operation is as described above except
All protection mechanisms apply in the usual way
as follows:
to the accesses to the trap control block and trap
Bit 31 of the current PSW must be zero; oth- save area.
erwise, a special-operation exception is recog-
nized. The trap-program address in the trap control block
is not tested before it replaces the instruction
A one is stored in bit position 12 of bytes
address in the PSW. An odd address will cause a
16-31.
specification exception to be recognized as part of
Bits 97-127 of the current PSW are stored in the execution of the next instruction.
bit positions 33-63 of bytes 16-31, bits 33-96
of the current PSW are not stored, and zeros The operation is suppressed on all addressing and
are stored in bit positions 64-127 of bytes protection exceptions.
16-31 (bytes 24-31).
The priority of recognition of program exceptions
In this case, bytes 16-23 have the format of an
for the instruction is shown in Figure 10-34 on
ESA/390 PSW, which is as follows:
page 10-120.

Condition Code: The code remains unchanged.

Chapter 10. Control Instructions 10-119


Program Exceptions: program can restore the contents of all regis-
ters except access and general registers 15,
Access (fetch, trap control block; store, trap
and then, using those registers (or at least the
save area)
general register) to address the trap save
Addressing (dispatchable-unit control table)
area, can restore the contents of those regis-
Special operation
ters and also PSW fields from the trap save
Trace
area. RESUME PROGRAM has control bits
Programming Notes: in its parameter list that allow it to restore
PSW fields from a field having either the
1. It is intended that TRAP instructions will ESA/390 PSW format or the z/Architecture
overlay instructions in an application program PSW format and to restore either bits 32-63 or
in order to give control to a trap program, 0-63 of a general register.
which might be a program for performing
fix-ups of data used by the application 3. The trap control block and trap save area are
program, such as dates that may be a in the home address space, and the trap
Year-2000 problem. TRAP2 can overlay a program is in the primary address space. The
two-byte instruction, and TRAP4 can overlay a trap-control-block address placed in general
four-byte instructions or the first four bytes of register 15 by TRAP can be useful to the trap
a six-byte instruction. The trap program is to program if (1) the primary address space and
simulate the overlaid instruction and perform home address space are the same address
fix-ups as appropriate, and it is then to return space, (2) the trap control block and trap save
control to the application program. area are at the same locations in the primary
address space as in the home address space,
2. The trap program can use the RESUME or (3) the trap program can use access regis-
PROGRAM instruction to return control to the ters to access the home address space.
application program. For example, the trap

1.-6. Exceptions with the same priority as the priority of program-


interruption conditions for the general case.

7.A Access exceptions for second instruction halfword (TRAP4
only).

7.B Special-operation exception due to the CPU not being in the
primary-space mode or access-register mode.

7.C.1 Addressing exception for access to dispatchable-unit control
table.

7.C.2 Special-operation exception due to bit 31 in bytes 44-47 of
dispatchable-unit control table being zero.

8.A Trace exceptions.

8.B.1 Access exceptions (fetch) for trap control block.

8.B.2 Special-operation exception due to PSW control in trap control
block being zero and PSW bit 31 being one.

8.B.3 Access exceptions (store) for trap save area.

Figure 10-34. Priority of Execution: TRAP

10-120 z/Architecture Principles of Operation


Chapter 11. Machine-Check Handling
Machine-Check Detection . . . . . . . . . . . 11-2 Storage Errors . . . . . . . . . . . . . . . 11-19
Correction of Machine Malfunctions . . . . . . 11-2 Storage Error Uncorrected . . . . . . . 11-19
Error Checking and Correction . . . . . . . 11-2 Storage Error Corrected . . . . . . . . 11-20
CPU Retry . . . . . . . . . . . . . . . . . . . 11-2 Storage-Key Error Uncorrected . . . . 11-20
Effects of CPU Retry . . . . . . . . . . . 11-3 Storage Degradation . . . . . . . . . . 11-20
Checkpoint Synchronization . . . . . . . 11-3 Indirect Storage Error . . . . . . . . . . 11-20
Handling of Machine Checks during Machine-Check Interruption-Code
Checkpoint Synchronization . . . . . 11-3 Validity Bits . . . . . . . . . . . . . . . 11-21
Checkpoint-Synchronization Operations 11-3 PSW-MWP Validity . . . . . . . . . . . 11-21
Checkpoint-Synchronization Action . . . 11-4 PSW Mask and Key Validity . . . . . . 11-21
Channel-Subsystem Recovery . . . . . . . 11-4 PSW Program-Mask and
Unit Deletion . . . . . . . . . . . . . . . . . 11-4 Condition-Code Validity . . . . . . 11-21
Handling of Machine Checks . . . . . . . . . 11-5 PSW-Instruction-Address Validity . . . 11-21
Validation . . . . . . . . . . . . . . . . . . . 11-5 Failing-Storage-Address Validity . . . 11-21
Invalid CBC in Storage . . . . . . . . . . . 11-6 External-Damage-Code Validity . . . . 11-21
Programmed Validation of Storage . . . 11-7 Floating-Point-Register Validity . . . . 11-21
Invalid CBC in Storage Keys . . . . . . . . 11-7 General-Register Validity . . . . . . . . 11-21
Invalid CBC in Registers . . . . . . . . . 11-10 Control-Register Validity . . . . . . . . 11-21
Check-Stop State . . . . . . . . . . . . . . . 11-11 Storage Logical Validity . . . . . . . . 11-22
System Check Stop . . . . . . . . . . . 11-11 Access-Register Validity . . . . . . . . 11-22
Machine-Check Interruption . . . . . . . . . 11-11 TOD-Programmable-Register Validity .11-22
Exigent Conditions . . . . . . . . . . . . . 11-11 Floating-Point-Control-Register
Repressible Conditions . . . . . . . . . . 11-12 Validity . . . . . . . . . . . . . . . . 11-22
Interruption Action . . . . . . . . . . . . . 11-12 CPU-Timer Validity . . . . . . . . . . . 11-22
Point of Interruption . . . . . . . . . . . . 11-14 Clock-Comparator Validity . . . . . . . 11-22
Machine-Check-Interruption Code . . . . . . 11-15 Machine-Check Extended Interruption
Subclass . . . . . . . . . . . . . . . . . . . 11-16 Information . . . . . . . . . . . . . . . . . 11-22
System Damage . . . . . . . . . . . . 11-16 Register-Save Areas . . . . . . . . . . . . 11-22
Instruction-Processing Damage . . . . 11-16 External-Damage Code . . . . . . . . . . 11-23
System Recovery . . . . . . . . . . . . 11-16 Failing-Storage Address . . . . . . . . . . 11-23
Timing-Facility Damage . . . . . . . . 11-16 Handling of Machine-Check Conditions . . 11-23
External Damage . . . . . . . . . . . . 11-17 Floating Interruption Conditions . . . . . 11-23
Degradation . . . . . . . . . . . . . . . 11-17 Floating Machine-Check-Interruption
Warning . . . . . . . . . . . . . . . . . 11-17 Conditions . . . . . . . . . . . . . . 11-24
Channel Report Pending . . . . . . . . 11-17 Floating I/O Interruptions . . . . . . . . 11-24
Service-Processor Damage . . . . . . 11-18 Machine-Check Masking . . . . . . . . . . . 11-24
Channel-Subsystem Damage . . . . . 11-18 Channel-Report-Pending Subclass
Subclass Modifiers . . . . . . . . . . . . . 11-18 Mask . . . . . . . . . . . . . . . . . 11-24
Backed Up . . . . . . . . . . . . . . . . 11-18 Recovery Subclass Mask . . . . . . . 11-25
Delayed Access Exception . . . . . . . 11-18 Degradation Subclass Mask . . . . . . 11-25
Ancillary Report . . . . . . . . . . . . . 11-18 External-Damage Subclass Mask . . . 11-25
Synchronous Warning Subclass Mask . . . . . . . . 11-25
Machine-Check-Interruption Conditions 11-18 Machine-Check Logout . . . . . . . . . . . . 11-25
Processing Backup . . . . . . . . . . . 11-18 Summary of Machine-Check Masking . . . 11-25
Processing Damage . . . . . . . . . . 11-19

The machine-check-handling mechanism provides permit automatic recovery from some malfunc-
extensive equipment-malfunction detection to tions. Equipment malfunctions and certain
ensure the integrity of system operation and to external disturbances are reported by means of a

Copyright IBM Corp. 1990, 2000 11-1


machine-check interruption to assist in program-
damage assessment and recovery. The inter- Correction of Machine
ruption supplies the program with information Malfunctions
about the extent of the damage and the location Four mechanisms may be used to provide
and nature of the cause. Equipment malfunctions, recovery from machine-detected malfunctions:
errors, and other situations which can cause error checking and correction, CPU retry, channel-
machine-check interruptions are referred to as subsystem recovery, and unit deletion.
machine checks.
Machine failures which are corrected successfully
may or may not be reported as machine-check
Machine-Check Detection interruptions. If reported, they are system-
Machine-check-detection mechanisms may take recovery conditions, which permit the program to
many forms, especially in control functions for note the cause of CPU delay and to keep a log of
arithmetic and logical processing, addressing, such incidents.
sequencing, and execution. For program-
addressable information, detection is normally Error Checking and Correction
accomplished by encoding redundancy into the
information in such a manner that most failures in When sufficient redundancy is included in circuitry
the retention or transmission of the information or in a checking block, failures can be corrected.
result in an invalid code. The encoding normally For example, circuitry can be triplicated, with a
takes the form of one or more redundant bits, voting circuit to determine the correct value by
called check bits, appended to a group of data selecting two matching results out of three, thus
bits. Such a group of data bits and the associated correcting a single failure. An arrangement for
check bits are called a checking block. The size correction of failures of one order and for
of the checking block depends on the model. detection of failures of a higher order is called
error checking and correction (ECC). Commonly,
The inclusion of a single check bit in the checking ECC allows correction of single-bit failures and
block allows the detection of any single-bit failure detection of double-bit failures.
within the checking block. In this arrangement,
the check bit is sometimes referred to as a parity Depending on the model and the portion of the
bit. In other arrangements, a group of check bits machine in which ECC is applied, correction may
is included to permit detection of multiple errors, to be reported as system recovery, or no report may
permit error correction, or both. be given.

For checking purposes, the contents of the entire Uncorrected errors in storage and in the storage
checking block, including the redundancy, are key may be reported, along with a failing-storage
called the checking-block code (CBC). When a address, to indicate where the error occurred.
CBC completely meets the checking requirements Depending on the situation, these errors may be
(that is, no failure is detected), it is said to be reported along with system recovery or with the
valid. When both detection and correction are damage or backup condition resulting from the
provided and a CBC is not valid but satisfies the error.
checking requirements for correction (the failure is
correctable), it is said to be near-valid. When a
CBC does not satisfy the checking requirements
CPU Retry
(the failure is uncorrectable), it is said to be
In some models, information about some portion
invalid.
of the state of the machine is saved periodically.
The point in the processing at which this informa-
tion is saved is called a checkpoint. The informa-
tion saved is referred to as the checkpoint
information. The action of saving the information
is referred to as establishing a checkpoint. The
action of discarding previously saved information
is called invalidation of the checkpoint information.

11-2 z/Architecture Principles of Operation


The length of the interval between establishing Handling of Machine Checks during
checkpoints is model-dependent. Checkpoints Checkpoint Synchronization
may be established at the beginning of each When, in the process of completing all previous
instruction or several times within a single instruc- stores as part of the checkpoint-synchronization
tion, or checkpoints may be established less fre- action, the machine is unable to complete all
quently. stores successfully but can successfully restore
the machine to a previous checkpoint, processing
Subsequently, this saved information may be used backup is reported.
to restore the machine to the state that existed at
the time when the checkpoint was established. When, in the process of completing all stores as
After restoring the appropriate portion of the part of the checkpoint-synchronization action, the
machine state, processing continues from the machine is unable to complete all stores success-
checkpoint. The process of restoring to a check- fully and cannot successfully restore the machine
point and then continuing is called CPU retry. to a previous checkpoint, the type of machine-
check-interruption condition reported depends on
CPU retry may be used for machine-check the origin of the store. Failure to successfully
recovery, to effect nullification and suppression of complete stores associated with instruction exe-
instruction execution when certain program inter- cution may be reported as instruction-processing
ruptions occur, and in other model-dependent situ- damage, or some less critical machine-check-
ations. interruption condition may be reported with the
storage-logical-validity bit set to zero. A failure to
Effects of CPU Retry successfully complete stores associated with the
CPU retry is, in general, performed so that there is execution of an interruption, other than program or
no effect on the program. However, change bits supervisor call, is reported as system damage.
which have been changed from zeros to ones are
not necessarily set back to zeros. As a result, When the machine check occurs as part of a
change bits may appear to be set to ones for checkpoint-synchronization action before the exe-
blocks which would have been accessed if cution of an instruction, the execution of the
restoring to the checkpoint had not occurred. If instruction is nullified. When it occurs before the
the path taken by the program is dependent on execution of an interruption, the interruption condi-
information that may be changed by another CPU tion, if the interruption is external, I/O, or restart, is
or by a channel program or if an interruption held pending. If the checkpoint-synchronization
occurs, then the final path taken by the program operation was a machine-check interruption, then
may be different from the earlier path; therefore, along with the originating condition, either the
change bits may be ones because of stores along storage-logical-validity bit is set to zero or
a path apparently never taken. instruction-processing damage is also reported.
Program interruptions, if any, are lost.
Checkpoint Synchronization
Checkpoint synchronization consists in the fol- Checkpoint-Synchronization
lowing steps. Operations
1. The CPU operation is delayed until all concep- All interruptions and the execution of certain
tually previous accesses by this CPU to instructions cause a checkpoint-synchronization
storage have been completed, both for pur- action to be performed. The operations which
poses of machine-check detection and as cause a checkpoint-synchronization action are
observed by other CPUs and by channel pro- called checkpoint-synchronization operations and
grams. include:

2. All previous checkpoints, if any, are canceled. CPU reset


All interruptions: external, I/O, machine
3. Optionally, a new checkpoint is established. check, program, restart, and supervisor call
The CPU operation is delayed until all of these The BRANCH ON CONDITION (BCR) instruc-
actions appear to be completed, as observed by tion with the M and R fields containing all
other CPUs and by channel programs. ones and all zeros, respectively

Chapter 11. Machine-Check Handling 11-3


The instructions LOAD PSW, LOAD PSW For SUPERVISOR CALL, a checkpoint-
EXTENDED, SET STORAGE KEY synchronization action is performed before the
EXTENDED, and SUPERVISOR CALL instruction is executed, including the updating of
All I/O instructions the instruction address in the PSW. The
The instructions MOVE TO PRIMARY, MOVE checkpoint-synchronization action taken after the
TO SECONDARY, PROGRAM CALL, supervisor-call interruption is considered to be part
PROGRAM TRANSFER, SET ADDRESS of the interruption action and not part of the
SPACE CONTROL, and SET SECONDARY instruction execution. For I/O instructions, a
ASN, and PROGRAM RETURN when the checkpoint-synchronization action is always per-
state entry to be unstacked is a program-call formed before the instruction is executed and may
state entry or may not be performed after the instruction is
The four trace functions: branch tracing, ASN executed.
tracing, mode tracing, and explicit tracing
PAGE IN and PAGE OUT The four trace functions branch tracing, ASN
tracing, mode tracing, and explicit tracing cause
Programming Note: The instructions which are
checkpoint-synchronization actions to be per-
defined to cause the checkpoint-synchronization
formed before the trace action and after com-
action invalidate checkpoint information but do not
pletion of the trace action.
necessarily establish a new checkpoint. Addi-
tionally, the CPU may establish a checkpoint
between any two instructions or units of operation, Channel-Subsystem Recovery
or within a single unit of operation. Thus, the
point of interruption for the machine check is not When errors are detected in the channel sub-
necessarily at an instruction defined to cause a system, the channel subsystem attempts to
checkpoint-synchronization action. analyze and recover the internal state associated
with the various channel-subsystem functions and
Checkpoint-Synchronization Action the state of the channel subsystem and various
For all interruptions except I/O interruptions, a subchannels. This process, which is called
checkpoint-synchronization action is performed at channel-subsystem recovery, may result in a com-
the completion of the interruption. For I/O inter- plete recovery or may result in the termination of
ruptions, a checkpoint-synchronization action may one or more I/O operations and the clearing of the
or may not be performed at the completion of the affected subchannels. Special channel-report-
interruption. For all interruptions except program, pending machine-check-interruption conditions
supervisor-call, and exigent machine-check inter- may be generated to indicate to the program the
ruptions, a checkpoint-synchronization action is status of the channel-subsystem recovery.
also performed before the interruption. The fetch
Malfunctions associated with the I/O operations,
access to the new PSW may be performed either
depending on the severity of the malfunction, may
before or after the first checkpoint-synchronization
be reported by means of the I/O-interruption
action. The store accesses and the changing of
mechanism or by means of the channel-report-
the current PSW associated with the interruption
pending and channel-subsystem-damage
are performed after the first checkpoint-
machine-check-interruption conditions.
synchronization action and before the second.

For all checkpoint-synchronization instructions Unit Deletion


except BRANCH ON CONDITION (BCR), I/O
instructions, and SUPERVISOR CALL, checkpoint- In some models, malfunctions in certain units of
synchronization actions are performed before and the system can be circumvented by discontinuing
after the execution of the instruction. For BCR, the use of the unit. Examples of cases where unit
only one checkpoint-synchronization action is nec- deletion may occur include the disabling of all or a
essarily performed, and it may be performed either portion of a cache or of a translation-lookaside
before or after the instruction address is updated. buffer (TLB). Unit deletion may be reported as a
degradation machine-check-interruption condition.

11-4 z/Architecture Principles of Operation


reports a failing-storage location detected during
Handling of Machine Checks an I/O operation, both I/O-error and machine-
A machine check is caused by a machine mal- check conditions may be indicated. The I/O-error
function and not by data or instructions. This is condition is the primary indication to the program.
ensured during the power-on sequence by initial- The machine-check condition is a secondary indi-
izing the machine controls to a valid state and by cation, which is presented as system recovery
placing valid CBC in the CPU registers, in the together with a failing-storage address.
storage keys, and in main storage.
Certain malfunctions detected as part of I/O
Designation of an unavailable component, such as instructions and I/O operations are reported by
a storage location, subchannel, or I/O device, means of special machine-check conditions called
does not cause a machine-check indication. I/O machine-check conditions. Thus, malfunctions
Instead, such a condition is indicated by the detected as part of an operation which is I/O
appropriate program or I/O interruption or related may be reported, depending on the error,
condition-code setting. In particular, an attempt to in any of three ways: I/O-error condition, I/O
access a storage location which is not in the con- machine-check condition, or non-I/O machine-
figuration, or which has power off at the storage check condition. In some cases, the definition
unit, results in an addressing exception when requires the error to be reported by only one of
detected by the CPU and does not generate a these mechanisms; in other cases, any one, or in
machine-check condition, even though the storage some cases, more than one, may be indicated.
location or its associated storage key has invalid Programming Note: Although the definition for
CBC. Similarly, if the channel subsystem attempts machine-check conditions is that they are caused
to access such a location, an I/O-interruption con- by machine malfunctions and not by data and
dition indicating program check is generated rather instructions, there are certain unusual situations in
than a machine-check condition. which machine-check conditions are caused by
events which are not machine malfunctions. Two
A machine check is indicated whenever the result
examples follow:
of an operation could be affected by information
with invalid CBC or when any other malfunction 1. In some cases, the channel-report-pending
makes it impossible to establish reliably that an machine-check-interruption condition indicates
operation can be, or has been, performed cor- a non-error situation. For example, this condi-
rectly. When information with invalid CBC is tion is generated at the completion of the
fetched but not used, the condition may or may function specified by RESET CHANNEL
not be indicated, and the invalid CBC is pre- PATH.
served. 2. Improper use of DIAGNOSE may result in
machine-check conditions.
When a machine malfunction is detected, the
action taken depends on the model, the nature of
the malfunction, and the situation in which the Validation
malfunction occurs. Malfunctions affecting
operator-facility actions may result in machine Machine errors can be generally classified as solid
checks or may be indicated to the operator. Mal- or intermittent, according to the persistence of the
functions affecting certain other operations such malfunction. A persistent machine error is said to
as SIGNAL PROCESSOR may be indicated by be solid, and one that is not persistent is said to
means of a condition code or may result in a be intermittent. In the case of a register or
machine-check-interruption condition. storage location, a third type of error must be con-
sidered, called externally generated. An externally
A malfunction detected as part of an I/O operation generated error is one where no failure exists in
may cause a machine-check-interruption condition, the register or storage location but invalid CBC
an I/O-error condition, or both. I/O-error condi- has been introduced into the location by actions
tions are indicated by an I/O interruption or by the external to the location. For example, the value
appropriate condition-code setting during the exe- could be affected by a power transient, or an
cution of an I/O instruction. When the machine incorrect value may have been introduced when
the information was placed at the location.

Chapter 11. Machine-Check Handling 11-5


Invalid CBC is preserved as invalid when informa- unpredictable. Programmed and manual vali-
tion with invalid CBC is fetched or when an dation of checking blocks causes the contents to
attempt is made to update only a portion of the be changed explicitly.
checking block. When an attempt is made to
Programming Note: The machine-check-
replace the contents of the entire checking block
interruption handler must assume that the regis-
and the block contains invalid CBC, it depends on
ters require validation. Thus, each register should
the operation and the model whether the block
be loaded, using an instruction defined to validate,
remains with invalid CBC or is replaced. An oper-
before the register is used or stored.
ation which replaces the contents of a checking
block with valid CBC, while ignoring the current
contents, is called a validation operation. Vali- Invalid CBC in Storage
dation is used to place a valid CBC in a register or
at a location which has an intermittent or The size of the checking block in storage depends
externally generated error. on the model but is never more than 4K bytes.

Validating a checking block does not ensure that a When invalid CBC is detected in storage, a
valid CBC will be observed the next time the machine-check condition may occur; depending on
checking block is accessed. If the failure is solid, the circumstances, the machine-check condition
validation is effective only if the information placed may be system damage, instruction-processing
in the checking block is such that the failing bits damage, or system recovery. If the invalid CBC is
are set to the value to which they fail. If an detected as part of the execution of a channel
attempt is made to set the bits to the state oppo- program, the error is reported as an I/O-error con-
site to that in which they fail, then the validation dition. When a CCW, indirect-data-address word,
will not be effective. Thus, for a solid failure, vali- or data is prefetched from storage, is found to
dation is only useful to eliminate the error condi- have invalid CBC, but is not used in the channel
tion, even though the underlying failure remains, program, the condition is normally not reported as
thereby reducing the exposure to additional an I/O-error condition. The condition may or may
reports. The locations, however, cannot be used, not be reported as a machine-check-interruption
since invalid CBC will result from attempts to store condition. Invalid CBC detected during accesses
other values at the location. For an intermittent to storage for other than CPU-related accesses
failure, however, validation is useful to restore a may be reported as system recovery with storage
valid CBC such that a subsequent partial store error uncorrected indicated, since the primary
into the checking block will be permitted. (A error indication is reported by some other means.
partial store is a store into a checking block
without replacing the entire checking block.) When the storage checking block consists of mul-
tiple bytes and contains invalid CBC, special
When a checking block consists of multiple bytes storage-validation procedures are generally neces-
in storage, or multiple bits in CPU registers, the sary to restore or place new information in the
invalid CBC can be made valid only when all of checking block. Validation of storage is provided
the bytes or bits are replaced simultaneously. with the manual load-clear and system-reset-clear
operations and is also provided as a program
For each type of field in the system, certain function. Programmed storage validation is done
instructions are defined to validate the field. a block at a time, by executing the privileged
Depending on the model, additional instructions instruction TEST BLOCK. Manual storage vali-
may also perform validation; or, in some models, a dation by clear reset validates all blocks which are
register is automatically validated as part of the available in the configuration.
machine-check-interruption sequence after the ori-
ginal contents of the register are placed in the A checking block with invalid CBC is never vali-
appropriate save area. dated unless the entire contents of the checking
block are replaced. An attempt to store into a
When an error occurs in a checking block, the ori- checking block having invalid CBC, without
ginal information contained in the checking block replacing the entire checking block, leaves the
should be considered lost even after validation. data in the checking block (including the check
Automatic register validation leaves the contents bits) unchanged. Even when an instruction or a

11-6 z/Architecture Principles of Operation


channel-program-input operation specifies that the a location in storage which has an intermittent, or
entire contents of a checking block are to be one-time, failure. However, if a permanent failure
replaced, validation may or may not occur, exists in a portion of the storage, a subsequent
depending on the operation and the model. fetch may find an invalid CBC.
Programming Note: Machine-check conditions
may be reported for prefetched and unused data. Invalid CBC in Storage Keys
Depending on the model, such situations may or
may not be successfully retried. For example, a Depending on the model, each storage key may
BRANCH AND LINK (BALR) instruction which be contained in a single checking block, or the
specifies an R field of zero will never branch, but access-control and fetch-protection bits and the
on some models a prefetch of the location desig- reference and change bits may be in separate
nated by register 0 may occur. Access exceptions checking blocks.
associated with this prefetch will not be reported.
However, if an invalid checking-block code is Figure 11-1 on page 11-8 describes the action
detected, CPU retry may be attempted. taken when the storage key has invalid CBC. The
Depending on the model, the prefetch may recur figure indicates the action taken for the case when
as part of the retry, and thus the retry will not be the access-control and fetch-protection bits are in
successful. Even when the CPU retry is suc- one checking block and the reference and change
cessful, the performance degradation of such a bits are in a separate checking block. In
retry is significant, and system recovery may be machines where both fields are included in a
presented, normally with a failing-storage address. single checking block, the action taken is the com-
To avoid continued degradation, the program bination of the actions for each field in error,
should initiate proceedings to eliminate use of the except that completion is permitted only if an error
location and to validate the location. in all affected fields permits completion. Refer-
ences to main storage to which key-controlled pro-
Programmed Validation of Storage tection does not apply are treated as if an access
Provided that an invalid CBC does not exist in the key of zero is used for the reference. This
storage key associated with a 4K-byte block, the includes such references as channel-program ref-
instruction TEST BLOCK causes the entire erences during initial program loading and implicit
4K-byte block to be set to zeros with a valid CBC, references, such as interruption action and
regardless of the current contents of the storage. DAT-table accesses.
TEST BLOCK thus removes an invalid CBC from

Chapter 11. Machine-Check Handling 11-7



Action Taken on Invalid CBC

For Access-Control and For Reference and
Type of Reference Fetch-Protection Bits Change Bits

SET STORAGE KEY Complete; validate. Complete; validate.


EXTENDED

INSERT STORAGE KEY PD; preserve. PD; preserve.
EXTENDED

RESET REFERENCE BIT PD or complete; PD; preserve.
EXTENDED preserve.

INSERT VIRTUAL STORAGEPD; preserve. CPF; preserve.
KEY or TEST PROTEC-
TION

CPU prefetch (informa-CPF; preserve. CPF; preserve.
tion not used)

Channel-program pre- IPF; preserve. IPF; preserve.
fetch (information
not used)

Fetch, nonzero access MC; preserve. MC or complete;
key preserve.

Store, nonzero accessMC; preserve. MC and preserve; or
key complete and correct.

Fetch, zero access MC or complete; MC or complete;
key preserve. preserve.

Store, zero access MC or complete; MC and preserve; or
key preserve. complete and correct.

Explanation:

CPU virtual- and logical-address store accesses are sub-
ject to page protection. When the page-protection bit
is one, the location will not be changed; however, the
machine may indicate a machine-check condition if the
storage key or the data itself has invalid CBC.

The contents of the main-storage location are not changed.

The contents of the reference and change bits are set
to ones if the "complete" action is taken.

The action shown for an access key of zero is also appli-
cable to references to which key-controlled protection
does not apply.

Figure 11-1 (Part 1 of 2). Invalid CBC in Storage Keys

11-8 z/Architecture Principles of Operation



Explanation (Continued):

Complete The condition does not cause termination of the execution
of the instruction, and, unless an unrelated condition
prohibits it, the execution of the instruction is
completed, ignoring the error condition. No machine-
check-damage conditions are reported, but system recovery
may be reported.

Correct The reference and change bits are set to ones with valid
CBC.

Preserve The contents of the entire checking block having invalid
CBC are left unchanged.

Validate The entire key is set to the new value with valid CBC.

CPF Invalid CBC in the storage key for a CPU prefetch which
is unused, or for instructions which do not examine the
reference and change bits, may result in any of the fol-
lowing situations:
The operation is completed; no machine-check condi-
tion is reported.
The operation is completed; system recovery, with
storage-key error uncorrected, is reported.
Instruction-processing damage, with or without backup
and with storage-key error uncorrected, is reported.

IPF Invalid CBC in the storage key for a channel-program pre-
fetch which is unused may result in any of the following:
The I/O operation is completed; no machine-check con-
dition is reported.
The I/O operation is completed; system recovery, with
storage-key error uncorrected, is reported.

MC Same as PD for CPU references, but a channel-subsystem
reference may result in the following combinations of
I/O-error conditions and machine-check conditions:
An I/O-error condition is reported; no machine-check
condition is reported.
An I/O-error condition is reported; system recovery,
with or without storage-key error uncorrected, is
reported.

PD Instruction-processing damage, with or without backup
and with or without storage-key error uncorrected, is
reported.

Note: When storage-key error uncorrected is reported, a failing-
storage address may or may not also be reported.

Figure 11-1 (Part 2 of 2). Invalid CBC in Storage Keys

Chapter 11. Machine-Check Handling 11-9


Invalid CBC in Registers Invalid CBC associated with the prefix register
cannot safely be reported by the machine-check
When invalid CBC is detected in a CPU register, a interruption, since the interruption itself requires
machine-check condition may be recognized. that the prefix value be applied to convert real
CPU registers include the general, floating-point, addresses to the corresponding absolute
floating-point-control, access, control, and TOD addresses. Invalid CBC in the prefix register
programmable registers, the current PSW, the causes the CPU to enter the check-stop state
prefix register, the TOD clock, the CPU timer, and immediately.
the clock comparator.
On those models which do not validate registers
When a machine-check interruption occurs, during a machine-check interruption, the following
whether or not it is due to invalid CBC in a CPU instructions will cause validation of a register, pro-
register, the following actions affecting the CPU vided the information in the register is not used
registers, other than the prefix register and the before the register is validated. Other instructions,
TOD clock, are taken as part of the interruption. although they replace the entire contents of a reg-
ister, do not necessarily cause validation.
1. The contents of the registers are saved in
assigned storage locations. Any register General registers are validated by BRANCH AND
which is in error is identified by a corre- SAVE and LOAD ADDRESS executed in the
sponding validity bit of zero in the machine- 64-bit addressing mode, by LOAD (LGR), and by
check-interruption code. Malfunctions LOAD (LG) and LOAD MULTIPLE (LMG) if the
detected during register saving do not result in operand is on a doubleword boundary.
additional machine-check-interruption condi-
tions; instead, the correctness of all the infor- Floating-point registers are validated by LOAD
mation stored is indicated by the appropriate (LDR) and, if the operand is on a doubleword
setting of the validity bits. boundary, by LOAD (LD).
2. On some models, registers with invalid CBC
The floating-point-control register is validated by
are then validated, their actual contents being
LOAD FLOATING POINT CONTROL REGISTER.
unpredictable. On other models, programmed
validation is required. Access registers are validated by LOAD ACCESS
The prefix register and the TOD clock are not MULTIPLE. Only the even-odd access-register
stored during a machine-check interruption, have pairs that are included in the set of access regis-
no corresponding validity bit, and are not vali- ters specified for LOAD ACCESS MULTIPLE are
dated. validated. Thus, when a single access register is
specified, or when a pair of access registers
On those models in which registers are not auto- starting with an odd-numbered register is speci-
matically validated as part of the machine-check fied, no register is validated.
interruption, a register with invalid CBC will not
cause a machine-check-interruption condition Control registers may be validated either singly or
unless the contents of the register are actually in groups by using the instruction LOAD
used. In these models, each register may consist CONTROL (LCTLG).
of one or more checking blocks, but multiple regis-
ters are not included in a single checking block. The TOD programmable register, CPU timer, clock
When only a portion of a register is accessed, comparator, and prefix register are validated by
invalid CBC in the unused portion of the same SET CLOCK PROGRAMMABLE REGISTER, SET
register may cause a machine-check-interruption CPU TIMER, SET CLOCK COMPARATOR, and
condition. For example, invalid CBC in the right SET PREFIX, respectively.
half of a floating-point register may cause a
machine-check-interruption condition if a LOAD The TOD clock is validated by a SET CLOCK
(LE) operation attempts to replace the left half, or instruction that sets the clock.
short form, of the register. Programming Note: Depending on the register
and the model, the contents of a register may be
validated by the machine-check interruption, or the

11-10 z/Architecture Principles of Operation


model may require that a program execute a vali- The CPU may be removed from the check-stop
dating instruction after the machine-check inter- state by CPU reset.
ruption has occurred. In the case of the CPU
timer, depending on the model, both the machine- In a multiprocessing configuration, a CPU entering
check interruption and validating instructions may the check-stop state generates a request for a
be required to restore the CPU timer to full malfunction-alert external interruption to all CPUs
working order. in the configuration. Except for the reception of a
malfunction alert, other CPUs and the I/O system
are normally unaffected by the check-stop state in
Check-Stop State a CPU. However, depending on the nature of the
condition causing the check stop, other CPUs may
In certain situations, it is impossible or undesirable
also be delayed or stopped, and channel sub-
to continue operation when a machine error
system and I/O activity may be affected.
occurs. In these cases, the CPU may enter the
check-stop state, which is indicated by the check-
stop indicator.
System Check Stop
In a multiprocessing configuration, some errors,
In general, the CPU may enter the check-stop malfunctions, and damage conditions are of such
state whenever an uncorrectable error or other severity that the condition causes all CPUs in the
malfunction occurs and the machine is unable to configuration to enter the check-stop state. This
recognize a specific machine-check-interruption condition is called a system check stop. The state
condition. of the channel subsystem and I/O activity is
unpredictable.
The CPU always enters the check-stop state if
any of the following conditions exists:
Machine-Check Interruption
PSW bit 13 is zero, and an exigent machine-
check condition is generated. A request for a machine-check interruption, which
is made pending as the result of a machine check,
During the execution of an interruption due to is called a machine-check-interruption condition.
one exigent machine-check condition, another There are two types of machine-check-interruption
exigent machine-check condition is detected. conditions: exigent conditions and repressible
During a machine-check interruption, the conditions.
machine-check-interruption code cannot be
stored successfully, or the new PSW cannot Exigent Conditions
be fetched successfully.
Invalid CBC is detected in the prefix register. Exigent machine-check-interruption conditions are
those in which damage has or would have
A malfunction in the receiving CPU, which is occurred such that execution of the current
detected after accepting the order, prevents instruction or interruption sequence cannot safely
the successful completion of a SIGNAL continue. Exigent conditions include two sub-
PROCESSOR order and the order was a classes: instruction-processing damage and
reset, or the receiving CPU cannot determine system damage. In addition to indicating specific
what the order was. The receiving CPU exigent conditions, system damage is used to
enters the check-stop state. report any malfunction or error which cannot be
There may be many other conditions for particular isolated to a less severe report.
models when an error may cause check stop.
Exigent conditions for instruction sequences can
When the CPU is in the check-stop state, be either nullifying exigent conditions or termi-
instructions and interruptions are not executed. nating exigent conditions, according to whether
The TOD clock is normally not affected by the the instructions affected are nullified or terminated.
check-stop state. The CPU timer may or may not Exigent conditions for interruption sequences are
run in the check-stop state, depending on the terminating exigent conditions. The terms
error and the model. The start key and stop key nullification and termination have the same
are not effective in this state.

Chapter 11. Machine-Check Handling 11-11


meanings as those used in Chapter 5, Program condition, any pending repressible conditions
Execution, except that more than one instruction may also be reported. The meaningfulness of
may be involved. Thus, a nullifying exigent condi- the validity bits depends on what exigent con-
tion indicates that the CPU has returned to the dition is reported.
beginning of a unit of operation prior to the error.
2. Classification of damage as either exigent or
A terminating exigent condition means that the
repressible does not imply the severity of the
results of one or more instructions may have
damage. The distinction is whether action
unpredictable values.
must be taken as soon as the damage is
detected (exigent) or whether the CPU can
Repressible Conditions continue processing (repressible). For a
repressible condition, the current instruction
Repressible machine-check-interruption conditions can be completed before taking the machine-
are those in which the results of the instruction- check interruption if the CPU is enabled for
processing sequence have not been affected. machine checks; if the CPU is disabled for
Repressible conditions can be delayed, until the machine checks, the condition can safely be
completion of the current instruction or even kept pending until the CPU is again enabled
longer, without affecting the integrity of CPU oper- for machine checks.
ation. Repressible conditions are of three groups:
For example, the CPU may be disabled for
recovery, alert, and repressible damage. Each
machine-check interruptions because it is han-
group includes one or more subclasses.
dling an earlier instruction-processing-damage
A malfunction in the CPU, storage, or operator interruption. If, during that time, an I/O opera-
facilities which has been successfully corrected or tion encounters a storage error, that condition
circumvented internally without logical damage is can be kept pending because it is not
called a recovery condition. Depending on the expected to interfere with the current machine-
model and the type of malfunction, some or all check processing. If, however, the CPU also
recovery conditions may be discarded and not makes a reference to the area of storage con-
reported. Recovery conditions that are reported taining the error before re-enabling machine-
are grouped in one subclass, system recovery. check interruptions, another
instruction-processing-damage condition is
A machine-check-interruption condition not directly created, which is treated as an exigent condi-
related to a machine malfunction is called an alert tion and causes the CPU to enter the check-
condition. The alert conditions are grouped in two stop state.
subclasses: degradation and warning. 3. A repressible condition may be a floating con-
dition. A floating repressible condition is eli-
A malfunction resulting in an incorrect state of a gible to cause an interruption on any CPU in
portion of the system not directly affecting sequen- the configuration. At the point when a CPU
tial CPU operation is called a repressible-damage performs an interruption for a floating
condition. Repressible-damage conditions are repressible condition, the condition is no
grouped in five subclasses, according to the func- longer eligible to cause an interruption on the
tion affected: timing-facility damage, external remaining CPUs in the configuration.
damage, channel report pending, channel-
subsystem damage, and service-processor
damage. Interruption Action
Programming Notes: A machine-check interruption causes the following
actions to be taken. An architectural-mode iden-
1. Even though repressible conditions are usually tification with the value 01 hex is stored at real
reported only at normal points of interruption, location 163. The PSW reflecting the point of
they may also be reported with exigent interruption is stored as the machine-check old
machine-check conditions. Thus, if an exigent PSW in the quadword at real location 352. The
machine-check condition causes an instruction contents of other registers are stored in register-
to be abnormally terminated and a machine- save areas at real locations 4608-4863,
check interruption occurs to report the exigent 4892-4895, 4900-4911, 4913-4919, and

11-12 z/Architecture Principles of Operation


4928-5119. After the contents of the registers are eliminated. If the machine check occurs during
stored in register-save areas, depending on the the execution of a machine function, such as a
model, the registers may be validated with the CPU-timer update, the machine-check interruption
contents being unpredictable. A machine-check- takes place after the machine function has been
interruption code (MCIC) of eight bytes is stored at completed.
real locations 232-239. An external-damage code
may be stored at real locations 244-247, and a When the CPU is disabled for a particular
failing-storage address may be stored at real repressible machine-check condition, the condition
locations 248-255. The new PSW is fetched from remains pending. Depending on the model and
real locations 480-495. In addition, a machine- the condition, multiple repressible conditions may
check logout may have occurred. be held pending for a particular subclass, or only
one condition may be held pending for a particular
The machine-generated addresses used to access subclass, regardless of the number of conditions
the old and new PSW, the MCIC, extended inter- that may have been detected for that subclass.
ruption information, and the fixed-logout area are
all real addresses. When a repressible machine-check interruption
occurs because the interruption condition is in a
The fields in assigned storage locations that are subclass for which the CPU is enabled, pending
accessed during the machine-check interruption conditions in other subclasses may also be indi-
are summarized in Figure 11-2. cated by the same interruption code, even though

the CPU is disabled for those subclasses. All indi-


Starting Length cated conditions are then cleared.
Information Stored (Fetched) Location\in Bytes

Architectural-mode identification 163 1 If a machine check which is to be reported as a


Old PSW 352 16 system-recovery condition is detected during the
New PSW (fetched) 48 16
Machine-check-interruption code 232 8 execution of the interruption procedure due to a
Register-save areas previous machine-check condition, the system-
Floating-point registers -15 468 128
General registers -15 4736 128 recovery condition may be combined with the
Floating-point control register 4892 4 other conditions, discarded, or held pending.
TOD programmable register 49 4
CPU timer 494 8
Clock comparator 4913 7 An exigent machine-check condition can cause a
Access registers -15 4928 64 machine-check interruption only when PSW bit 13
Control registers -15 4992 128
Extended interruption information is one. When a nullifying exigent condition causes
External-damage code 244 4 a machine-check interruption, the interruption is
Failing-storage address 248 8
Fixed-logout area 4864 16 taken at a normal point of interruption. When a
terminating exigent condition causes a machine-
Explanation:
check interruption, the interruption terminates the
\ All locations are in real storage. execution of the current instruction and may elimi-

nate the program and supervisor-call interruptions,


Figure 11-2. Machine-Check-Interruption Locations if any, that would have occurred if execution had
continued. Proper execution of the interruption
If the machine-check-interruption code cannot be sequence, including the storing of the old PSW
stored successfully or the new PSW cannot be and other information, depends on the nature of
fetched successfully, the CPU enters the check- the malfunction. When an exigent machine-check
stop state. condition occurs during the execution of a
machine function, such as a CPU-timer update,
A repressible machine-check condition can initiate
the sequence is not necessarily completed.
a machine-check interruption only if both PSW bit
13 is one and the associated subclass mask bit, if If, during the execution of an interruption due to
any, in control register 14 is also one. When it one exigent machine-check condition, another
occurs, the interruption does not terminate the exigent machine check is detected, the CPU
execution of the current instruction; the inter- enters the check-stop state. If an exigent machine
ruption is taken at a normal point of interruption, check is detected during an interruption due to a
and no program or supervisor-call interruptions are

Chapter 11. Machine-Check Handling 11-13


repressible machine-check condition, system Only certain points in the processing may be used
damage is reported. as a point of interruption. For repressible
machine-check interruptions, the point of inter-
When PSW bit 13 is zero, an exigent machine- ruption must be after one unit of operation is com-
check condition causes the CPU to enter the pleted and any associated program or
check-stop state. supervisor-call interruption is taken, and before the
next unit of operation is begun.
Machine-check-interruption conditions are handled
in the same manner regardless of whether the Exigent machine-check conditions for instruction
wait-state bit in the PSW is one or zero: a sequences are those in which damage has or
machine-check condition causes an interruption if would have occurred to the instruction stream.
the CPU is enabled for that condition. Thus, the damage can normally be associated
with a point part way through an instruction, and
Machine checks which occur while the rate control this point is called the point of damage. In some
is set to the instruction-step position are handled cases, there may be one or more instructions sep-
in the same manner as when the control is set to arating the point of damage and the point of inter-
the process position; that is, recovery mechanisms ruption, and the processing associated with one or
are active, and machine-check interruptions occur more instructions may be damaged. When the
when allowed. Machine checks occurring during a point of interruption is a point prior to the point of
manual operation may be indicated to the oper- damage due to a nullifiable exigent machine-check
ator, may generate a system-recovery condition, condition, the point of interruption can be only at
may result in system damage, or may cause a the same points as for repressible machine-check
check stop, depending on the model. conditions.

Every reasonable attempt is made to limit the side In addition to the point of interruption permitted for
effects of any machine check and the associated repressible machine-check conditions, the point of
interruption. Normally, interruptions, as well as interruption for a terminating exigent machine-
the progress of I/O operations, remain unaffected. check condition may also be after the unit of oper-
The malfunction, however, may affect these activ- ation is completed but before any associated
ities, and, if the currently active PSW has bit 13 program or supervisor-call interruption occurs. In
set to one, the machine-check interruption will this case, a valid PSW instruction address is
indicate the total extent of the damage caused, defined as that which would have been stored in
and not just the damage which originated the con- the old PSW for the program or supervisor-call
dition. interruption. Since the operation has been termi-
nated, the values in the result fields, other than
Point of Interruption the instruction address, are unpredictable. Thus,
the validity bits associated with fields which are
The point in the processing which is indicated by due to be changed by the instruction stream are
the interruption and used as a reference point by meaningless when a terminating exigent machine-
the machine to determine and indicate the validity check condition is reported.
of the status stored is referred to as the point of
interruption. When the point of interruption and the point of
damage due to an exigent machine-check condi-
Because of the checkpoint capability in models tion are separated by a checkpoint-
with CPU retry, the interruption resulting from an synchronization function, the damage has not
exigent machine-check-interruption condition may been isolated to a particular program, and system
indicate a point in the CPU processing sequence damage is indicated.
which is logically prior to the error. Additionally,
the model may have some choice as to which When an exigent machine-check-interruption con-
point in the CPU processing sequence the inter- dition occurs, the point of interruption which is
ruption is indicated, and, in some cases, the chosen affects the amount of damage which must
status which can be indicated as valid depends on be indicated. An attempt is made, when possible,
the point chosen. to choose a point of interruption which permits the
minimum indication of damage. In general, the

11-14 z/Architecture Principles of Operation


preference is the interruption point immediately
preceding the error. Machine-Check-Interruption Code
On all machine-check interruptions, a machine-
When all the status information stored as a result check-interruption code (MCIC) is stored in the
of an exigent machine-check-interruption condition doubleword starting at real location 232. The
does not reflect the same point, an attempt is code has the format shown in Figure 11-3.
made, when possible, to choose the point of inter-
ruption so that the instruction address which is Bits in the MCIC which are not assigned or not
stored in the machine-check old PSW is valid. implemented by a particular model are stored as
zeros.

S P S C E D C S C S S K D W M P IF E F G C S
D D RD DGW P P K BE C E S P S M AAC P R RT

4 8 12 16 24 26 31

I A D P F A C C
E R A R C PT C

32 4 42 46 48 56 63

Bits Name

System damage (SD)


1 Instruction-processing damage (PD)
2 System recovery (SR)
4 Timing-facility damage (CD)
5 External damage (ED)
7 Degradation (DG)
8 Warning (W)
9 Channel report pending (CP)
1 Service-processor damage (SP)
11 Channel-subsystem damage (CK)
14 Backed up (B)
16 Storage error uncorrected (SE)
17 Storage error corrected (SC)
18 Storage-key error uncorrected (KE)
19 Storage degradation (DS)
2 PSW-MWP validity (WP)
21 PSW mask and key validity (MS)
22 PSW program-mask and condition-code validity (PM)
23 PSW-instruction-address validity (IA)
24 Failing-storage-address validity (FA)
26 External-damage-code validity (EC)
27 Floating-point-register validity (FP)
28 General-register validity (GR)
29 Control-register validity (CR)
31 Storage logical validity (ST)
32 Indirect storage error (IE)
33 Access-register validity (AR)
34 Delayed-access exception (DA)
42 TOD-programmable-register validity (PR)
43 Floating-point-control-register validity (FC)
44 Ancillary report (AP)
46 CPU-timer validity (CT)
47 Clock-comparator validity (CC)

Note: All other bits of the MCIC are unassigned and stored as zeros.
Figure 11-3. Machine-Check Interruption-Code Format

Chapter 11. Machine-Check Handling 11-15


Subclass Programming Notes:
1. System recovery may be used to report a
Bits 0-2 and 4-11 are the subclass bits which failing-storage address detected by a CPU
identify the type of machine-check condition prefetch or by an I/O operation.
causing the interruption. At least one of the sub-
2. Unless the corresponding validity bits are
class bits is stored as a one. When multiple
ones, the indication of system recovery does
errors have occurred, several subclass bits may
not imply storage logical validity or that the
be set to ones.
fields stored as a result of the machine-check
interruption are valid.
System Damage
Bit 0 (SD), when one, indicates that damage has
occurred which cannot be isolated to one or more
Timing-Facility Damage
Bit 4 (CD), when one, indicates that damage has
of the less severe machine-check subclasses.
occurred to the TOD clock, CPU timer, clock
When system damage is indicated, the ancillary-
comparator, or TOD programmable register, or to
report bit, bit 44, is meaningful, the remaining bits
the CPU-timer or clock-comparator external-
in the machine-check-interruption code are not
interruption conditions. The timing-facility-damage
meaningful, and information stored in the register-
machine-check condition is set whenever any of
save areas and machine-check extended-
the following occurs:
interruption fields is not meaningful.
1. The TOD clock enters the error or not-
System damage is a terminating exigent condition operational state.
and has no subclass-mask bit.
2. The CPU timer is damaged, and the CPU is
enabled for CPU-timer external interruptions.
Instruction-Processing Damage
On some models, this condition may be
Bit 1 (PD), when one, indicates that damage has
recognized even when the CPU is not enabled
occurred to the instruction processing of the CPU.
for CPU-timer interruptions. Depending on the
model, the machine-check condition may be
The exact meaning of bit 1 depends on the setting
generated only as the CPU timer enters an
of the backed-up bit, bit 14. When the backed-up
error state. Or, the machine-check condition
bit is one, the condition is called processing
may be continuously generated whenever the
backup. When the backed-up bit is zero, the con-
CPU is enabled for CPU-timer interruptions,
dition is called processing damage. These two
until the CPU timer is validated.
conditions are described in Synchronous
Machine-Check-Interruption Conditions on 3. The clock comparator is damaged, and the
page 11-18. CPU is enabled for clock-comparator external
interruptions. On some models, this condition
Instruction-processing damage can be a nullifying may be recognized even when the CPU is not
or a terminating exigent condition and has no enabled for clock-comparator interruptions.
subclass-mask bit.
Timing-facility damage may also be set along with
System Recovery instruction-processing damage when an instruction
Bit 2 (SR), when one, indicates that malfunctions which accesses the TOD clock, CPU timer, or
were detected but did not result in damage or clock comparator produces incorrect results.
have been successfully corrected. Some malfunc- Depending on the model, the TOD programmable
tions detected as part of an I/O operation may register, CPU timer, or clock comparator may be
result in a system-recovery condition in addition to validated by the interruption which reports the
an I/O-error condition. The presence and extent TOD clock, CPU timer, or clock comparator as
of the system-recovery capability depend on the invalid.
model.
Timing-facility damage is a repressible condition.
System recovery is a repressible condition. It is It is masked by the external-damage subclass-
masked by the recovery subclass-mask bit, which mask bit, which is in bit position 38 of control reg-
is in bit position 36 of control register 14. ister 14.

11-16 z/Architecture Principles of Operation


Timing-facility-damage conditions for the CPU Warning
timer and the clock comparator are not recognized Bit 8 (W), when one, indicates that damage is
on most models when these facilities are not in imminent in some part of the system (for example,
use. The facilities are considered not in use when that power is about to fail, or that a loss of cooling
the CPU is disabled for the corresponding external is occurring). Whether warning conditions are
interruptions (PSW bit 7, or the subclass-mask recognized depends on the model.
bits, bits 52 and 53 of control register 0, are
zeros), and when the corresponding set and store If the condition responsible for the imminent
instructions are not executed. Timing-facility- damage is removed before the interruption request
damage conditions that are already pending is honored (for example, if power is restored), the
remain pending, however, when the CPU is disa- request does not remain pending, and no inter-
bled for the corresponding external interruption. ruption occurs. Conversely, the request is not
cleared by the interruption, and, if the condition
Timing-facility-damage conditions due to damage persists, more than one interruption may result
to the TOD clock are always recognized. from the same condition.

External Damage Warning is a repressible condition. It is masked


Bit 5 (ED), when one, indicates that damage has by the warning subclass-mask bit, which is in bit
occurred during operations not directly associated position 39 of control register 14.
with processing the current instruction.
Channel Report Pending
When bit 5, external damage, is one and bit 26, Bit 9 (CP), when one, indicates that a channel
external-damage-code validity, is also one, the report, consisting of one or more channel-report
external-damage code has been stored to indi- words, has been made pending, and the contents
cate, in more detail, the cause of the external- of the channel-report words describe, in further
damage machine-check interruption. When the detail, the effect of the malfunction and the results
external damage cannot be isolated to one or of analysis or the action performed. A channel
more of the conditions as defined in the external- report becomes pending when one of the following
damage code, or when the detailed indication for conditions has occurred:
the condition is not implemented by the model,
external damage is indicated with bit 26 set to 1. Channel-subsystem recovery has been com-
zero. The presence and extent of reporting pleted. The channel-subsystem recovery may
external damage depend on the model. have been initiated with no prior notice to the
program or may have been a result of a con-
External damage is a repressible condition. It is dition previously reported to the program.
masked by the external-damage subclass-mask 2. The function specified by RESET CHANNEL
bit, which is in bit position 38 of control register PATH has been completed.
14.
A channel report may also become pending under
Degradation other conditions.
Bit 7 (DG), when one, indicates that continuous
degradation of system performance, more serious The channel-report words which make up the
than that indicated by system recovery, has channel report may be cleared, one at a time, by
occurred. Degradation may be reported when execution of the instruction STORE CHANNEL
system-recovery conditions exceed a machine- REPORT WORD, which is described in
preestablished threshold or when unit deletion has Chapter 14, I/O Instructions.
occurred. The presence and extent of the
degradation-report capability depend on the Bit 9 is meaningless when channel-subsystem
model. damage is reported.

Degradation is a repressible condition. It is Channel report pending is a floating repressible


masked by the degradation subclass-mask bit, condition. It is masked by the channel-report-
which is in bit position 37 of control register 14. pending subclass-mask bit, which is in bit position
35 of control register 14.

Chapter 11. Machine-Check Handling 11-17


Service-Processor Damage presence and extent of reporting delayed access
Bit 10 (SP), when one, indicates that damage has exception depend on the model.
occurred to the service processor. Service- Programming Note: The occurrence of a
processor damage may be made pending at all delayed access exception normally indicates that
CPUs in the configuration, or it may be detected the program is using an improper procedure to
independently by each CPU. The presence and update the DAT tables.
extent of reporting service-processor damage
depend on the model. Ancillary Report
Bit 44 (AP), when one, indicates that a malfunc-
Service-processor damage is a repressible condi-
tion of a system component has occurred which
tion and has no subclass-mask bit.
has been recognized previously or which has
affected the activities of multiple system elements
Channel-Subsystem Damage such as CPUs and subchannels. When the mal-
Bit 11 (CK), when one, indicates that an error or function affects the activities of multiple elements,
malfunction has occurred in the channel sub- an ancillary-report condition is recognized for all of
system, or that the channel subsystem is in the the affected elements except one. This bit, when
check-stop state. The channel subsystem enters zero, indicates that this malfunction of a system
the check-stop state when a malfunction occurs component has not been recognized previously.
which is so severe that the channel subsystem This bit is meaningful for all conditions indicated
cannot continue, or if power is lost in the channel by either the machine-check-interruption code or
subsystem. the external-damage code.
Channel-subsystem damage is a floating Depending on the model, recognition of an
repressible condition and has no subclass-mask ancillary-report condition may not be provided, or
bit. it may not be provided for all system malfunctions.
When ancillary-report recognition is not provided,
Subclass Modifiers bit 44 is set to zero.

Bits 14 (B), 34 (DA), and 44 (AP) of the machine-


Synchronous
check-interruption code act as modifiers to the
subclass bits. Machine-Check-Interruption
Conditions
Backed Up
Bit 14 (B), when one, indicates that the point of The instruction-processing damage and backed-up
interruption is at a checkpoint before the point of bits, bits 1 and 14 of the machine-check-
error. This bit is meaningful only when the interruption code, identify, in combination, two
instruction-processing-damage bit, bit 1, is also set conditions.
to one. The presence and extent of the capability
to indicate a backed-up condition depend on the Bit 1 Bit 14 Name of Condition
model. 1 0 Processing damage
1 1 Processing backup
Delayed Access Exception
Bit 34 (DA), when one, indicates that an access Processing Backup
exception was detected during a storage access The processing-backup condition indicates that the
using DAT when no such exception was detected point of interruption is prior to the point, or points,
by an earlier test for access exceptions. of error. This is a nullifying exigent condition.
When all of the other CPU-related-damage sub-
Bit 34 is a modifier to instruction-processing classes and modifiers of the machine-check-
damage (bit 1) and is meaningful only when bit 1 interruption code are zero, and certain validity bits
of the machine-check-interruption code is one. associated with CPU status are indicated as valid,
When bit 1 is zero, bit 34 has no meaning. The then the machine has successfully returned to a
checkpoint prior to the malfunction, and no
damage has yet occurred to the CPU.

11-18 z/Architecture Principles of Operation


The subclass bits which must be zero for no access-register translation, and dynamic address
damage to have occurred are as follows: translation. Processing damage causes any
supervisor-call-interruption condition and program-
MCIC
interruption condition to be discarded. However,
Bit Name
the contents of the old PSW and interruption-code
0 System damage
locations for these interruptions may be set to
4 Timing-facility damage
unpredictable values.
The delayed-access-exception subclass-modifier
bit, MCIC bit 34, must be zero for no damage to Storage Errors
have occurred.
Bits 16-18 of the machine-check-interruption code
The validity bits in the machine-check-interruption are used to indicate an invalid CBC or a near-valid
code which must be one for no damage to have CBC detected in main storage or an invalid CBC
occurred are as follows: in a storage key. Bit 19, storage degradation,
MCIC may be indicated concurrently with bit 17. The
Bit Name failing-storage-address field, when indicated as
20 PSW MWP bits valid, identifies a location within the storage
21 PSW mask and key checking block containing the error, or, for
22 PSW program mask and condition code storage-key error uncorrected, within the block
23 PSW instruction address associated with the storage key. Bit 32, indirect
27 Floating-point registers storage error, may be set to one to indicate that
28 General registers the location designated by the failing-storage
29 Control registers address is not the original source of the error.
31 Storage logical validity (result fields within
The storage-error-uncorrected and storage-key-
current checkpoint interval)
error-uncorrected bits do not in themselves indi-
33 Access registers
cate the occurrence of damage because the error
42 TOD programmable register
detected may not have affected a result. The
43 Floating-point-control register
portion of the configuration affected by an invalid
46 CPU timer
CBC is indicated in the subclass field of the
47 Clock comparator
machine-check-interruption code.
Programming Note: The processing-backup
condition is reported rather than system recovery Storage errors detected for a channel program,
to indicate that a malfunction or failure stands in when indicated as I/O-error conditions, may also
the way of continued operation of the CPU. The be reported as system recovery. CBC errors that
malfunction has not been circumvented, and occur in storage or in the storage key and that are
damage would have occurred if instruction proc- detected on prefetched or unused data for a CPU
essing had continued. program may or may not be reported, depending
on the model.
Processing Damage
The processing-damage condition indicates that Storage Error Uncorrected
damage has occurred to the instruction processing Bit 16 (SE), when one, indicates that a checking
of the CPU. The point of interruption is a point block in main storage contained invalid CBC and
beyond some or all of the points of damage. that the information could not be corrected. The
Processing damage is a terminating exigent condi- contents of the checking block in main storage
tion; therefore, the contents of result fields may be have not been changed. The location reported
unpredictable and still indicated as valid. may have been accessed or prefetched for this
CPU or another CPU or a channel program, or it
Processing damage may include malfunctions in may have been accessed as the result of a
program-event recording, monitor call, tracing, model-dependent storage access.

Chapter 11. Machine-Check Handling 11-19


Storage Error Corrected Programming Note: Because storage degrada-
Bit 17 (SC), when one, indicates that a checking tion is normally reported with system recovery, the
block in main storage contained near-valid CBC recovery subclass mask, bit 36 of control register
and that the information has been corrected 14, should be set to one in order for storage
before being used. Depending on the model, the degradation to be indicated.
contents of the checking block in main storage
may or may not have been restored to valid CBC. Indirect Storage Error
The location reported may have been accessed or Bit 32 (IE), when one, indicates that the physical
prefetched for this CPU or for another CPU or for main-storage location identified by the failing-
a channel program, or it may have been accessed storage address is not the original source of the
as the result of a model-dependent storage error. Instead, the error originated in another level
access. The presence and extent of the storage- of the storage hierarchy and has been propagated
error-correction capability depend on the model. to the current physical-storage portion of the
This indication may or may not be accompanied storage hierarchy. Bit 32 is meaningful only when
by an indication of storage degradation, bit 19 bit 16 or 18 (storage error uncorrected or
(DS). storage-key error uncorrected) of the machine-
check-interruption code is one. When bits 16 and
Storage-Key Error Uncorrected 18 are both zeros, bit 32 has no meaning.
Bit 18 (KE), when one, indicates that a storage
key contained invalid CBC and that the informa- For errors originating outside the storage hier-
tion could not be corrected. The contents of the archy, the attempt to store is rejected, and the
checking block in the storage key have not been appropriate error indication is presented. When
changed. The storage key may have been an error is detected during implicit movement of
accessed or prefetched for this CPU or for another information inside the storage hierarchy, the action
CPU or for a channel program, or it may have is not rejected and reported in this manner
been accessed as the result of a model- because the movement may be asynchronous and
dependent storage access. may be initiated as the result of an attempt to
access completely unrelated information. Instead,
Storage Degradation errors in the contents of the source during implicit
moving of information from one portion of the
Bit 19 (DS), when one, indicates that degradation storage hierarchy to another may be preserved in
of the recovery characteristics has occurred for the target area by placing a special invalid CBC in
the 4K-byte block reported by the failing-storage the checking block associated with the target
address. location. These propagated errors, when detected
later, are reported as indirect storage errors. The
Storage degradation indicates that although the original source of such an error may have been in
associated storage error has been corrected, there a cache associated with an I/O processor or a
are solid failures associated with the storage block CPU, or the error may have been the result of a
(or with its associated key) that cause the cor- data-path failure in transmitting data from one
rection process to take a substantial amount of portion of the storage hierarchy to another. Addi-
time, and that if an additional error occurs in the tionally, a propagated error may be generated
block, the error may not be correctable or may go during the movement of data from one physical
undetected. Thus, this bit indicates that use of the portion of storage to another as the result of a
indicated block of storage should be avoided, if storage-reconfiguration action.
possible.
The presence and extent of reporting indirect
The indication of storage degradation has storage error depend on the model.
meaning only when failing-storage-address Programming Note: See the programming notes
validity, MCIC bit 24, is also one. The presence under TEST BLOCK in Chapter 10, Control
and extent of reporting storage degradation Instructions for the action which should be taken
depend on the model. after storage errors are reported.

11-20 z/Architecture Principles of Operation


Machine-Check Interruption-Code PSW Program-Mask and
Validity Bits Condition-Code Validity
Bit 22 (PM), when one, indicates that the program
Bits 20-24, 26-29, 31, 33, 42, 43, 46, and 47 of mask and condition code of the machine-check
the machine-check-interruption code are validity old PSW are correct.
bits. Each bit indicates the validity of a particular
field in storage. With the exception of the storage- PSW-Instruction-Address Validity
logical-validity bit (bit 31), each bit is associated Bit 23 (IA), when one, indicates that the
with a field stored during the machine-check inter- addressing-mode and instruction-address bits, bits
ruption. When a validity bit is one, it indicates that 31, 32, and 64-127, of the machine-check old
the saved value placed in the corresponding PSW are correct.
storage field is valid with respect to the indicated
point of interruption and that no error was Failing-Storage-Address Validity
detected when the data was stored. Bit 24 (FA), when one, indicates that a correct
failing-storage address has been stored at real
When a validity bit is zero, one or more of the fol- location 248-255 after a storage-error-uncorrected,
lowing conditions may have occurred: the original storage-key-error-uncorrected, or storage-error-
information was incorrect, the original information corrected condition has occurred. The presence
had invalid CBC, additional malfunctions were and extent of the capability to identify the failing-
detected while storing the information, or none or storage location depend on the model. When no
only part of the information was stored. Even such errors are reported, that is, bits 16-18 of the
though the information is unpredictable, the machine-check-interruption code are zeros, the
machine attempts, when possible, to place valid failing-storage address is meaningless, even
CBC in the storage field and thus reduce the pos- though it may be indicated as valid.
sibility of additional machine checks being caused.
External-Damage-Code Validity
The validity bits for the floating-point registers, Bit 26 (EC), when one, and provided that bit 5,
general registers, control registers, access regis- external damage, is also one, indicates that a
ters, TOD programmable register, floating-point valid external-damage code has been stored in
control register, CPU timer, and clock comparator the word at real location 244. When bit 5 is zero,
indicate the validity of the saved value placed in bit 26 has no meaning.
the corresponding save area. The information in
these registers after the machine-check inter- Floating-Point-Register Validity
ruption is not necessarily correct even when the Bit 27 (FP), when one, indicates that the contents
correct value has been placed in the save area of the floating-point-register save area at real
and the validity bit set to one. The use of the reg- locations 4608-4735 reflect the correct state of the
isters and the operation of the facility associated floating-point registers at the point of interruption.
with the control registers, floating-point control reg-
ister, TOD programmable register, CPU timer, and General-Register Validity
clock comparator are unpredictable until these Bit 28 (GR), when one, indicates that the contents
registers are validated. (See Invalid CBC in of the general-register save area at real locations
Registers on page 11-10.) 4736-4863 reflect the correct state of the general
registers at the point of interruption.
PSW-MWP Validity
Bit 20 (WP), when one, indicates that bits 12-15 of Control-Register Validity
the machine-check old PSW are correct. Bit 29 (CR), when one, indicates that the contents
of the control-register save area at real locations
PSW Mask and Key Validity 4992-5119 reflect the correct state of the control
Bit 21 (MS), when one, indicates that the system registers at the point of interruption.
mask, PSW key, and miscellaneous bits of the
machine-check old PSW are correct. specifically,
this bit covers bits 0-11, 16, 17, 24-30, and 33-63
of the PSW.

Chapter 11. Machine-Check Handling 11-21


Storage Logical Validity Clock-Comparator Validity
Bit 31 (ST), when one, indicates that the storage Bit 47 (CC), when one, indicates that the clock
locations, the contents of which are modified by comparator is not in error, that the contents of the
the instructions being executed, contain the clock-comparator save area at real locations
correct information relative to the point of inter- 4913-4919 reflect the correct state of the clock
ruption. That is, all stores before the point of comparator at the time the interruption occurred,
interruption are completed, and all stores, if any, and that zeros have been stored at real location
after the point of interruption are suppressed. 4912.
When a store before the point of interruption is
Programming Note: The validity bits must be
suppressed because of an invalid CBC, the
used in conjunction with the subclass bits and the
storage-logical-validity bit may be indicated as
backed-up bit in order to determine the extent of
one, provided that the invalid CBC has been pre-
the damage caused by a machine-check condi-
served as invalid.
tion. No damage has occurred to the system
when all of the following are true:
When instruction-processing damage is indicated
but processing backup is not indicated, the The four PSW-validity bits, the six register-
storage-logical-validity bit has no meaning. validity bits, the two timing-facility-validity bits,
and the storage-logical-validity bit are all ones.
Storage logical validity reflects only the instruction-
Subclass bits 0, 4, 5, 10, and 11 are zeros.
processing activity and does not reflect errors in
the state of storage as the result of either I/O The instruction-processing-damage bit is zero
operations or the storing of the old PSW and other or, if one, the backed-up bit is also one.
interruption information.
The delayed-access-exception bit is zero.

Access-Register Validity
Bit 33 (AR), when one, indicates that the contents Machine-Check Extended
of the access-register save area at real locations
4928-4991 reflect the correct state of the access Interruption Information
registers at the point of interruption. As part of the machine-check interruption, in some
cases, extended interruption information is placed
TOD-Programmable-Register Validity in fixed areas assigned in storage. The contents
Bit 42 (PR), when one, indicates that the contents of registers associated with the CPU are placed in
of the TOD-programmable-register save area at register-save areas. For external damage, addi-
real locations 4900-4903 reflect the correct state tional information is provided for some models by
of the TOD programmable register at the point of storing an external-damage code. When storage
interruption. error uncorrected, storage error corrected, or
storage-key error uncorrected is indicated, the
Floating-Point-Control-Register Validity failing-storage address is saved.
Bit 43 (FC), when one, indicates that the contents
of the floating-point-control-register save area at Each of these fields has associated with it a
real locations 4892-4895 reflect the correct state validity bit in the machine-check-interruption code.
of the floating-point-control register at the point of If, for any reason, the machine cannot store the
interruption. proper information in the field, the associated
validity bit is set to zero.
CPU-Timer Validity
Bit 46 (CT), when one, indicates that the CPU Register-Save Areas
timer is not in error and that the contents of the
CPU-timer save area at real locations 4904-4911 As part of the machine-check interruption, the
reflect the correct state of the CPU timer at the current contents of the CPU registers, except for
time the interruption occurred. the prefix register and the TOD clock, are stored
in eight register-save areas assigned in storage.
Each of these areas has associated with it a
validity bit in the machine-check-interruption code.

11-22 z/Architecture Principles of Operation


If, for any reason, the machine cannot store the Failing-Storage Address
proper information in the field, the associated
validity bit is set to zero. When storage error uncorrected, storage error cor-
rected, or storage-key error uncorrected is indi-
The following are the eight sets of registers and
cated in the machine-check-interruption code, the
the real locations in storage where their contents
associated address, called the failing-storage
are saved during a machine-check interruption.
address, is stored at real locations 248-255. The
Locations Registers field is valid only if the failing-storage-address
4608-4735 Floating-point registers 0-15 validity bit, bit 24 of the machine-check-
4736-4863 General registers 0-15 interruption code, is one.
4892-4895 Floating-point-control register
4900-4903 TOD programmable register In the case of storage errors, the failing-storage
4904-4911 CPU timer address may designate any byte within the
4913-4919 Clock comparator checking block. For storage-key error uncor-
4928-4991 Access registers 0-15 rected, the failing-storage address may designate
4992-5119 Control registers 0-15 any address within the block of storage associated
with the storage key that is in error. When an
error is detected in more than one location before
External-Damage Code the interruption, the failing-storage address may
designate any of the failing locations. The
The word at real location 244 is the external-
address stored is an absolute address; that is, the
damage code. This field, when implemented and
value stored is the address that is used to refer-
indicated as valid, describes the cause of external
ence storage after dynamic address translation
damage. The field is valid only when the external-
and prefixing have been applied.
damage bit and the external-damage-code-validity
bit (bits 5 and 26 in the machine-check-
interruption code) are both ones. The presence
and extent of reporting an external-damage code
Handling of Machine-Check
depend on the model. Conditions
The external-damage code has the following Floating Interruption Conditions
format:
// An interruption condition which is made available
S to any CPU in a multiprocessing configuration is
C called a floating interruption condition. The first
//
19 31 CPU that accepts the interruption clears the inter-
ruption condition, and it is no longer available to
ETR Sync Check (SC): Bit 19, when one, indi- any other CPU in the configuration.
cates that bits 32 through the rightmost incre-
mented bit of a running clock are not in Floating interruption conditions include service-
synchronism with the same bits of the ETR. signal external-interruption and I/O-interruption
conditions. Two machine-check-interruption condi-
If the condition happens more than once before tions, channel report pending and channel-
the interruption occurs, the condition is generated subsystem damage, are floating interruption
only once. The condition is generated for all conditions. Depending on the model, some
CPUs in the configuration, and the condition for a machine-check-interruption conditions associated
CPU is cleared by the interruption taken by the with system recovery and warning may also be
CPU. floating interruption conditions.

Reserved: Bits 0-7, 10-16, and 21-31 are A floating interruption is presented to the first CPU
reserved for future expansion and are always set in the configuration which is enabled for the inter-
to zero. ruption condition and can accept the interruption.
A CPU cannot accept the interruption when the
CPU is in the check-stop state, has an invalid

Chapter 11. Machine-Check Handling 11-23


prefix, is performing an unending string of inter- damage and instruction-processing damage) are
ruptions due to a PSW-format error of the type controlled only by the machine-check mask, PSW
that is recognized early, or is in the stopped state. bit 13. When PSW bit 13 is one, an exigent con-
However, a CPU with the rate control set to dition causes a machine-check interruption. When
instruction step can accept the interruption when PSW bit 13 is zero, the occurrence of an exigent
the start key is activated. machine-check condition causes the CPU to enter
the check-stop state.
Programming Note: When a CPU enters the
check-stop state in a multiprocessing configura-
The repressible machine-check conditions, except
tion, the program on another CPU can determine
channel-subsystem damage and service-processor
whether a floating interruption may have been
damage, are controlled both by the machine-check
reported to the failing CPU and then lost. This
mask, PSW bit 13, and by five subclass-mask bits
can be accomplished if the interruption program
in control register 14. If PSW bit 13 is one and
places zeros in the real storage locations con-
one of the subclass-mask bits is one, the associ-
taining old PSWs and interruption codes after the
ated condition initiates a machine-check inter-
interruption has been handled (or has been moved
ruption. If a subclass-mask bit is zero, the
into another area for later processing). After a
associated condition does not initiate an inter-
CPU enters the check-stop state, the program on
ruption but is held pending. However, when a
another CPU can inspect the old-PSW and
machine-check interruption is initiated because of
interruption-code locations of the failing CPU. A
a condition for which the CPU is enabled, those
nonzero value in an old PSW or interruption code
conditions for which the CPU is not enabled may
indicates that the CPU has been interrupted but
be presented along with the condition which initi-
the program did not complete the handling of the
ates the interruption. All conditions presented are
interruption.
then cleared.

Floating Machine-Check-Interruption Control register 14 contains mask bits that specify


Conditions whether certain conditions can cause machine-
Floating machine-check-interruption conditions are check interruptions. It has the following format:
reset only by the manually initiated resets through
/
the operator facilities. When a machine check CRDEW
occurs which prohibits completion of a floating MMMMM
machine-check interruption, the interruption condi- /
tion is no longer considered a floating interruption 32 35 39
condition, and system damage is indicated. Bits 35-39 of control register 14 are the subclass
masks for repressible machine-check conditions.
Floating I/O Interruptions In addition, bit 32 of control register 14 is initial-
The detection of a machine malfunction by the ized to one but is otherwise ignored by the
channel subsystem, while in the process of pre- machine.
senting an I/O-interruption request for a floating
I/O interruption, may be reported as channel Programming Note: The program should avoid,
report pending or as channel-subsystem damage. whenever possible, operating with PSW bit 13, the
Detection of a machine malfunction by a CPU, machine-check mask, set to zero, since any
while in the process of accepting a floating I/O exigent machine-check condition which is recog-
interruption, is reported as system damage. nized during this situation will cause the CPU to
enter the check-stop state. In particular, the
program should avoid executing I/O instructions or
Machine-Check Masking allowing I/O interruptions with PSW bit 13 zero.

All machine-check interruptions are under control Channel-Report-Pending Subclass


of the machine-check mask, PSW bit 13. In addi- Mask
tion, some machine-check conditions are con- Bit 35 (CM) of control register 14 controls channel-
trolled by subclass masks in control register 14. report-pending interruption conditions. This bit is
initialized to zero.
The exigent machine-check conditions (system

11-24 z/Architecture Principles of Operation


Recovery Subclass Mask Warning Subclass Mask
Bit 36 (RM) of control register 14 controls system- Bit 39 (WM) of control register 14 controls warning
recovery interruption conditions. This bit is initial- interruption conditions. This bit is initialized to
ized to zero. zero.

Degradation Subclass Mask


Bit 37 (DM) of control register 14 controls degra- Machine-Check Logout
dation interruption conditions. This bit is initialized
to zero. As part of the machine-check interruption, some
models may place model-dependent information in
External-Damage Subclass Mask the fixed-logout area. This area is 16 bytes in
Bit 38 (EM) of control register 14 controls timing- length and starts at real location 4864.
facility-damage and external-damage interruption
conditions. This bit is initialized to one.
Summary of Machine-Check
Masking
A summary of machine-check masking is given in
Figure 11-4 and Figure 11-5 on page 11-26.

Machine-Check Condition
Sub- Action when CPU
MCIC Class Disabled
Bit Subclass Mask for Subclass

System damage - Check stop


1 Instruction-processing damage - Check stop
2 System recovery RM Y
4 Timing-facility damage EM P
5 External damage EM P
7 Degradation DM P
8 Warning WM P
9 Channel report pending CM P
1 Service-processor damage - P
11 Channel-subsystem damage - P

Explanation:

- The condition does not have a subclass mask.

P Indication is held pending.

Y Indication may be held pending or may be discarded.

CM Channel-report-pending subclass mask (bit 35 of CR14).

DM Degradation subclass mask (bit 37 of CR14).

EM External-damage subclass mask (bit 38 of CR14).

RM Recovery subclass mask (bit 36 of CR14).

WM Warning subclass mask (bit 39 of CR14).

Figure 11-4. Machine-Check-Condition Masking

Chapter 11. Machine-Check Handling 11-25



Control State of Bit
Register 14 on Initial
Bit Description Bit Position CPU Reset

Channel-report-pending subclass mask 35


Recovery subclass mask 36
Degradation subclass mask 37
External-damage subclass mask 38 1
Warning subclass mask 39

Figure 11-5. Machine-Check Control-Register Bits

11-26 z/Architecture Principles of Operation


Chapter 12. Operator Facilities
Manual Operation . . . . . . . . . . . . . . . . 12-1 Manual Indicator . . . . . . . . . . . . . . . 12-3
Basic Operator Facilities . . . . . . . . . . . . 12-1 Power Controls . . . . . . . . . . . . . . . . 12-4
Address-Compare Controls . . . . . . . . . 12-1 Rate Control . . . . . . . . . . . . . . . . . 12-4
Alter-and-Display Controls . . . . . . . . . 12-2 Restart Key . . . . . . . . . . . . . . . . . . 12-4
Architectural-Mode Indicator . . . . . . . . 12-2 Start Key . . . . . . . . . . . . . . . . . . . 12-4
Architectural-Mode-Selection Controls . . . 12-2 Stop Key . . . . . . . . . . . . . . . . . . . 12-4
Check-Stop Indicator . . . . . . . . . . . . 12-3 Store-Status Key . . . . . . . . . . . . . . . 12-5
IML Controls . . . . . . . . . . . . . . . . . 12-3 System-Reset-Clear Key . . . . . . . . . . 12-5
Interrupt Key . . . . . . . . . . . . . . . . . 12-3 System-Reset-Normal Key . . . . . . . . . 12-5
Load Indicator . . . . . . . . . . . . . . . . 12-3 Test Indicator . . . . . . . . . . . . . . . . . 12-5
Load-Clear Key . . . . . . . . . . . . . . . . 12-3 TOD-Clock Control . . . . . . . . . . . . . . 12-5
Load-Normal Key . . . . . . . . . . . . . . . 12-3 Wait Indicator . . . . . . . . . . . . . . . . . 12-6
Load-Unit-Address Controls . . . . . . . . . 12-3 Multiprocessing Configurations . . . . . . . . 12-6

A machine malfunction that prevents a manual


Manual Operation operation from being performed correctly, as
The operator facilities provide functions for the defined for that operation, may cause the CPU to
manual operation and control of the machine. The enter the check-stop state or give some other indi-
functions include operator-to-machine communi- cation to the operator that the operation has failed.
cation, indication of machine status, control over Alternatively, a machine malfunction may cause a
the setting of the TOD clock, initial program machine-check-interruption condition to be recog-
loading, resets, and other manual controls for nized.
operator intervention in normal machine operation.

A model may provide additional operator facilities Basic Operator Facilities


which are not described in this chapter. Examples
are the means to indicate specific error conditions
in the equipment, to change equipment configura-
Address-Compare Controls
tions, and to facilitate maintenance. Furthermore,
The address-compare controls provide a way to
controls covered in this chapter may have addi-
stop the CPU when a preset address matches the
tional settings which are not described here. Such
address used in a specified type of main-storage
additional facilities and settings may be described
reference.
in the appropriate System Library publication.
One of the address-compare controls is used to
Most models provide, in association with the oper-
set up the address to be compared with the
ator facilities, a console device which may be
storage address.
used as an I/O device for operator communication
with the program; this console device may also be
Another control provides at least two positions to
used to implement some or all of the facilities
specify the action, if any, to be taken when the
described in this chapter.
address match occurs:
The operator facilities may be implemented on dif- 1. The normal position disables the address-
ferent models in various technologies and config- compare operation.
urations. On some models, more than one set of
2. The stop position causes the CPU to enter the
physical representations of some keys, controls,
stopped state on an address match. When
and indicators may be provided, such as on mul-
the control is in this setting, the test indicator
tiple local or remote operating stations, which may
is on. Depending on the model and the type
be effective concurrently.
of reference, pending I/O, external, and

Copyright IBM Corp. 1990, 2000 12-1


machine-check interruptions may or may not Alter-and-Display Controls
be taken before entering the stopped state.
A third control may specify the type of storage ref- The operator facilities provide controls and proce-
erence for which the address comparison is to be dures to permit the operator to alter and display
made. A model may provide one or more of the the contents of locations in storage, the storage
following positions, as well as others: keys, the general, floating-point, floating-point-
control, access, and control registers, the prefix,
1. The any position causes the address compar-
and the PSW.
ison to be performed on all storage refer-
ences. Before alter-and-display operations may be per-
2. The data-store position causes address com- formed, the CPU must first be placed in the
parison to be performed when storage is stopped state. During alter-and-display oper-
addressed to store data. ations, the manual indicator may be turned off
temporarily, and the start and restart keys may be
3. The I/O position causes address comparison
inoperative.
to be performed when storage is addressed
by the channel subsystem to transfer data or Addresses used to select storage locations for
to fetch a channel-command or indirect-data- alter-and-display operations are real addresses.
address word. Whether references to the The capability of specifying logical, virtual, or
measurement block, interruption-response absolute addresses may also be provided.
block, channel-path-status word, channel-
report word, subchannel-status word,
subchannel-information block, and operation- Architectural-Mode Indicator
request block cause a match to be indicated
depends on the model. The architectural-mode indicator shows the archi-
tectural mode of operation (the ESA/390 mode,
4. The instruction-address position causes z/Architecture mode, or some other mode)
address comparison to be performed when selected by the last architectural-mode-selection
storage is addressed to fetch an instruction. operation and by the last SIGNAL PROCESSOR
The rightmost bit of the address setting may set-architecture order or the last reset that deter-
or may not be ignored. The match is indi- mined the mode.
cated only when the first byte of the instruc-
tion is fetched from the selected location. It
depends on the model whether a match is
Architectural-Mode-Selection
indicated when fetching the target instruction Controls
of EXECUTE.
The architectural-mode-selection controls provide
Depending on the model and the type of refer- for the selection of either the ESA/390 architec-
ence, address comparison may be performed on tural mode of operation or, possibly, some other
virtual, real, or absolute addresses, and it may be architectural mode of operation. (The
possible to specify the type of address. z/Architecture mode is selected from the ESA/390
mode by the SIGNAL PROCESSOR set-
In a multiprocessing configuration, it depends on architecture order.) Depending on the model, the
the model whether the address setting applies to architectural-mode selection may be provided as
one or all CPUs in the configuration and whether part of the IML operation or may be a separate
an address match causes one or all CPUs in the operation.
configuration to stop.
As part of the architectural-mode-selection
process, all CPUs and the associated channel-
subsystem components in a particular configura-
tion are placed in the same architectural mode.

12-2 z/Architecture Principles of Operation


Check-Stop Indicator loaded successfully. For details, see Initial
Program Loading on page 4-47.)
The check-stop indicator is on when the CPU is in
the check-stop state. Reset operations normally Load-Clear Key
cause the CPU to leave the check-stop state and
thus turn off the indicator. The manual indicator Activating the load-clear key causes a reset oper-
may also be on in the check-stop state. ation to be performed and initial program loading
to be started by using the I/O device designated
IML Controls by the load-unit-address controls. Clear reset is
performed on the configuration. For details, see
The IML controls provided with some models Resets on page 4-41 and Initial Program
perform initial machine loading (IML), which is the Loading on page 4-47.
loading of licensed internal code into the machine.
The load-clear key is effective when the CPU is in
The IML operation, when provided, may be used
the operating, stopped, load, or check-stop state.
to select the ESA/390 mode or, possibly, some
other mode of operation.
Load-Normal Key
When the IML operation is completed, the state of
the affected CPUs, channel subsystem, main Activating the load-normal key causes a reset
storage, and operator facilities is the same as if a operation to be performed and initial program
power-on reset had been performed, except that loading to be started by using the I/O device des-
the value and state of the TOD clock are not ignated by the load-unit-address controls. Initial
changed. The contents of expanded storage may CPU reset is performed on the CPU for which the
have been cleared to zeros with valid checking- load-normal key was activated, CPU reset is prop-
block code or may have remained unchanged, agated to all other CPUs in the configuration, and
depending on the model. a subsystem reset is performed on the remainder
of the configuration. For details, see Resets on
The IML controls are effective while the power is page 4-41 and Initial Program Loading on
on. page 4-47.

Interrupt Key The load-normal key is effective when the CPU is


in the operating, stopped, load, or check-stop
When the interrupt key is activated, an external- state.
interruption condition indicating the interrupt key is
generated. (See Interrupt Key on page 6-12.) Load-Unit-Address Controls
The interrupt key is effective when the CPU is in The load-unit-address controls specify four
the operating or stopped state. It depends on the hexadecimal digits, which provide the device
model whether the interrupt key is effective when number used for initial program loading. For
the CPU is in the load state. details, see Initial Program Loading on
page 4-47.
Load Indicator
Manual Indicator
The load indicator is on during initial program
loading, indicating that the CPU is in the load The manual indicator is on when the CPU is in the
state. The indicator goes on for a particular CPU stopped state. Some functions and several
when the load-clear or load-normal key is acti- manual controls are effective only when the CPU
vated for that CPU and the corresponding opera- is in the stopped state.
tion is started. It goes off after the new PSW is

Chapter 12. Operator Facilities 12-3


Power Controls If the setting of the rate control is changed while
the CPU is in the operating or load state, the
The power controls are used to turn the power on results are unpredictable.
and off.
Restart Key
The CPUs, storage, channel subsystem, operator
facilities, and I/O devices may all have their power Activating the restart key initiates a restart inter-
turned on and off by common controls, or they ruption. (See Restart Interruption on
may have separate power controls. When a par- page 6-46.)
ticular unit has its power turned on, that unit is
reset. The sequence is performed so that no The restart key is effective when the CPU is in the
instructions or I/O operations are performed until operating or stopped state. The key is not effec-
explicitly specified. The controls may also permit tive when the CPU is in the check-stop state. It
power to be turned on in stages, but the machine depends on the model whether the restart key is
does not become operational until power on is effective when any CPU in the configuration is in
complete. the load state.

When the power is completely turned on, an IML The effect is unpredictable when the restart key is
operation is performed on models which have an activated while any CPU in the configuration is in
IML function. A power-on reset is then initiated the load state. In particular, if the CPU performs a
(see Resets on page 4-41). It depends on the restart interruption and enters the operating state
model whether the architectural mode of operation while another CPU is in the load state, operations
can be selected when the power is turned on, or such as I/O instructions, the SIGNAL
whether the mode-selection controls have to be PROCESSOR instruction, and the INVALIDATE
used to change the mode after the power is on. PAGE TABLE ENTRY instruction may not operate
according to the definitions given in this publica-
Rate Control tion.

The setting of the rate control determines the Start Key


effect of the start function and the manner in
which instructions are executed. Activating the start key causes the CPU to
perform the start function. (See Stopped, Oper-
The rate control has at least two positions. The ating, Load, and Check-Stop States on
normal position is the process position. Another page 4-1.)
position is the instruction-step position. When the
rate control is set to the process position and the The start key is effective only when the CPU is in
start function is performed, the CPU starts oper- the stopped state. The effect is unpredictable
ating at normal speed. When the rate control is when the stopped state has been entered by a
set to the instruction-step position and the wait- reset.
state bit is zero, one instruction or, for interruptible
instructions, one unit of operation is executed, and Stop Key
all pending allowed interruptions are taken before
the CPU returns to the stopped state. When the Activating the stop key causes the CPU to perform
rate control is set to the instruction-step position the stop function. (See Stopped, Operating,
and the wait-state bit is one, no instruction is exe- Load, and Check-Stop States on page 4-1.)
cuted, but all pending allowed interruptions are
taken before the CPU returns to the stopped state. The stop key is effective only when the CPU is in
For details, see Stopped, Operating, Load, and the operating state.
Check-Stop States on page 4-1.
Operation Note: Activating the stop key has no
The test indicator is on while the rate control is not effect when:
set to the process position. An unending string of certain program or
external interruptions occurs.

12-4 z/Architecture Principles of Operation


The prefix register contains an invalid Test Indicator
address.
The CPU is in the load or check-stop state. The test indicator is on when a manual control for
operation or maintenance is in an abnormal posi-
Store-Status Key tion that can affect the normal operation of a
program.
Activating the store-status key initiates a store-
status operation. (See Store Status on Setting the address-compare controls to the stop
page 4-48.) position or setting the rate control to the
instruction-step position turns on the test indicator.
The store-status key is effective only when the
CPU is in the stopped state. The test indicator may be on when one or more
diagnostic functions under the control of DIAG-
Operation Note: The store-status operation may
NOSE are activated, or when other abnormal con-
be used in conjunction with a standalone dump
ditions occur.
program for the analysis of major program mal-
functions. For such an operation, the following The abnormal setting of a manual control causes
sequence would be called for: the test indicator of the affected CPU to be turned
1. Activation of the stop or system-reset-normal on; however, in a multiprocessing configuration,
key the operation of other CPUs may be affected even
2. Activation of the store-status key though their test indicators are not turned on.
3. Activation of the load-normal key to enter a Operation Note: If a manual control is left in a
standalone dump program setting intended for maintenance purposes, such
The system-reset-normal key must be activated in an abnormal setting may, among other things,
step 1 when (1) the stop key is not effective result in false machine-check indications or cause
because a continuous string of interruptions is actual machine malfunctions to be ignored. It may
occurring, (2) the prefix register contains an also alter other aspects of machine operation,
invalid address, or (3) the CPU is in the check- including instruction execution, channel-subsystem
stop state. operation, and the functioning of operator controls
and indicators, to the extent that operation of the
machine does not comply with that described in
System-Reset-Clear Key
this publication.
Activating the system-reset-clear key causes a
clear-reset operation to be performed on the con- TOD-Clock Control
figuration. For details, see Resets on
page 4-41. When the TOD-clock control is not activated, that
is, the control is set to the secure position, the
The system-reset-clear key is effective when the state and value of the TOD clock are protected
CPU is in the operating, stopped, load, or check- against unauthorized or inadvertent change by not
stop state. permitting the instructions SET CLOCK or DIAG-
NOSE to change the state or value.
System-Reset-Normal Key
When the TOD-clock control is activated, that is,
Activating the system-reset-normal key causes a the control is set to the enable-set position, alter-
CPU-reset operation and a subsystem-reset oper- ation of the clock state or value by means of SET
ation to be performed. In a multiprocessing con- CLOCK or DIAGNOSE is permitted. This setting
figuration, a CPU reset is propagated to all CPUs is momentary, and the control automatically
in the configuration. For details, see the section returns to the secure position.
Resets in Chapter 4, Control.
If there is more than one physical representation
The system-reset-normal key is effective when the of the TOD-clock control, the TOD clock is secure
CPU is in the operating, stopped, load, or check-
stop state.

Chapter 12. Operator Facilities 12-5


only if all TOD-clock controls in the configuration may be used together with a control to select the
are set to the secure position. desired CPU.

There need not be more than one of each of the


Wait Indicator following keys and controls in a multiprocessing
configuration: address compare, IML, power,
The wait indicator is on when the wait-state bit in
system reset clear, system reset normal, and TOD
the current PSW is one. Instead of a wait indi-
clock.
cator, a model may have a means of indicating a
time-averaged value of the wait-state bit.
One check-stop, manual, test, and wait indicator is
provided for each CPU. A load indicator is pro-
vided only on a CPU capable of performing I/O
Multiprocessing Configurations operations. Alternatively, a single set of indicators
In a multiprocessing configuration, one of each of may be switched to more than one CPU.
the following keys and controls is provided for
each CPU: alter and display, interrupt, rate, There need not be more than one architectural-
restart, start, stop, and store status. The load- mode indicator in a multiprocessing configuration.
clear key, load-normal key, and load-unit-address
controls are provided for each CPU capable of In a system capable of reconfiguration, there must
performing I/O operations. Alternatively, a single be a separate set of keys, controls, and indicators
set of initial-program-loading keys and controls in each configuration.

12-6 z/Architecture Principles of Operation


Chapter 13. I/O Overview
Input/Output (I/O) . . . . . . . . . . . . . . . . 13-1 Subchannel Number . . . . . . . . . . . . . 13-5
The Channel Subsystem . . . . . . . . . . . . 13-1 Device Number . . . . . . . . . . . . . . . . 13-5
Subchannels . . . . . . . . . . . . . . . . . 13-2 Device Identifier . . . . . . . . . . . . . . . 13-5
Attachment of Input/Output Devices . . . . . 13-2 Execution of I/O Operations . . . . . . . . . . 13-6
Channel Paths . . . . . . . . . . . . . . . . 13-2 Start-Function Initiation . . . . . . . . . . . 13-6
Control Units . . . . . . . . . . . . . . . . . 13-4 Path Management . . . . . . . . . . . . . . 13-6
I/O Devices . . . . . . . . . . . . . . . . . . 13-4 Channel-Program Execution . . . . . . . . 13-7
I/O Addressing . . . . . . . . . . . . . . . . . . 13-5 Conclusion of I/O Operations . . . . . . . . 13-7
Channel-Path Identifier . . . . . . . . . . . 13-5 I/O Interruptions . . . . . . . . . . . . . . . 13-9

by which the channel subsystem provides informa-


Input/Output (I/O) tion about associated I/O devices to CPUs, which
obtain this information by executing I/O
The terms input and output are used to
instructions. The actual number of subchannels
describe the transfer of data between I/O devices
provided depends on the model and the configura-
and main storage. An operation involving this kind
tion; the maximum addressability is 65,536.
of transfer is referred to as an I/O operation. The
facilities used to control I/O operations are collec- I/O devices are attached through control units to
tively called the channel subsystem. (I/O devices the channel subsystem by means of channel
and their control units attach to the channel sub- paths. Control units may be attached to the
system.) This chapter provides a brief description channel subsystem by more than one channel
of the basic components and operation of the path, and an I/O device may be attached to more
channel subsystem. than one control unit. In all, an individual I/O
device may be accessible to the channel sub-
system by as many as eight different channel
The Channel Subsystem paths, depending on the model and the configura-
The channel subsystem directs the flow of infor- tion. The total number of channel paths provided
mation between I/O devices and main storage. It by a channel subsystem depends on the model
relieves CPUs of the task of communicating and the configuration; the maximum addressability
directly with I/O devices and permits data proc- is 256.
essing to proceed concurrently with I/O proc-
essing. The channel subsystem uses one or more The performance of a channel subsystem
channel paths as the communication link in man- depends on its use and on the system model in
aging the flow of information to or from I/O which it is implemented. Channel paths are pro-
devices. As part of I/O processing, the channel vided with different data-transfer capabilities, and
subsystem also executes a path-management an I/O device designed to transfer data only at a
operation, tests for channel-path availability, specific rate (a magnetic-tape unit or a disk
chooses an available channel path, and initiates storage, for example) can operate only on a
execution of the I/O operation with the device. channel path that can accommodate at least this
data rate.
Within the channel subsystem are subchannels.
One subchannel is provided for and dedicated to The channel subsystem contains common facilities
each I/O device accessible to the channel sub- for the control of I/O operations. When these
system. Each subchannel provides information facilities are provided in the form of separate,
concerning the associated I/O device and its autonomous equipment designed specifically to
attachment to the channel subsystem. The sub- control I/O devices, I/O operations are completely
channel also provides information concerning I/O overlapped with the activity in CPUs. The only
operations and other functions involving the asso- main-storage cycles required by the channel sub-
ciated I/O device. The subchannel is the means system during I/O operations are those needed to

Copyright IBM Corp. 1990, 2000 13-1


transfer data and control information to or from the channel. Each subchannel is addressed by using
final locations in main storage, along with those a 16-bit binary subchannel number.
cycles that may be required for the channel sub-
system to access the subchannels when they are After I/O processing at the subchannel has been
implemented as part of nonaddressable main requested by executing START SUBCHANNEL,
storage. These cycles do not delay CPU pro- the CPU is released for other work, and the
grams, except when both the CPU and the channel subsystem assembles or disassembles
channel subsystem concurrently attempt to refer- data and synchronizes the transfer of data bytes
ence the same main-storage area. between the I/O device and main storage. To
accomplish this, the channel subsystem maintains
and updates an address and a count that describe
Subchannels the destination or source of data in main storage.
Similarly, when an I/O device provides signals that
A subchannel provides the logical appearance of a
should be brought to the attention of the program,
device to the program and contains the informa-
the channel subsystem transforms the signals into
tion required for sustaining a single I/O operation.
status information and stores the information in
The subchannel consists of internal storage that
the subchannel, where it can be retrieved by the
contains information in the form of a CCW
program.
address, channel-path identifier, device number,
count, status indications, and I/O-interruption sub-
class code, as well as information on path avail-
ability and functions pending or being performed. Attachment of Input/Output
I/O operations are initiated with a device by exe- Devices
cuting I/O instructions that designate the sub-
channel associated with the device. Channel Paths
Each device is accessible by means of one sub- The channel subsystem communicates with I/O
channel per channel subsystem to which it is devices by means of channel paths between the
assigned during installation. The device may be a channel subsystem and control units. A control
physically identifiable unit or may be housed unit may be accessible by the channel subsystem
internal to a control unit. For example, in certain by more than one channel path. Similarly, an I/O
disk-storage devices, each actuator used in device may be accessible by the channel sub-
retrieving data is considered to be a device. In all system through more than one control unit, each
cases, a device, from the point of view of the having one or more channel paths to the channel
channel subsystem, is an entity that is uniquely subsystem.
associated with one subchannel and that responds
to selection by the channel subsystem by using Devices that are attached to the channel sub-
the communication protocols defined for the type system by multiple channel paths may be
of channel path by which it is accessible. accessed by the channel subsystem by using any
of the available channel paths. Similarly, a device
In some models, subchannels are provided in having the dynamic-reconnection feature and
blocks. In these models, more subchannels may operating in multipath mode can be initialized to
be provided than there are attached devices. operate such that the device may choose any
Subchannels that are provided but do not have channel path to which it is attached when logically
devices assigned to them are not used by the reconnecting to the channel subsystem to con-
channel subsystem to perform any function and tinue a chain of I/O operations.
are indicated by storing the associated device-
number-valid bit as zero in the subchannel- The channel subsystem may contain more than
information block of the subchannel. one type of channel path. Examples of channel-
path types used by the channel subsystem are the
The number of subchannels provided by the ESCON-I/O interface, FICON-I/O interface,
channel subsystem is independent of the number FICON-converted-I/O interface, and IBM
of channel paths to the associated devices. For System/360 and System/370 I/O interface. The
example, a device accessible through alternate term serial-I/O interface is used to refer the
channel paths still is represented by a single sub-

13-2 z/Architecture Principles of Operation


ESCON-I/O interface, the FICON-I/O interface, function may be indicated when an absence of
and the FICON-converted-I/O interface. The term data transfer exceeds the prescribed limit.
parallel-I/O interface is used to refer to the IBM
System/360 and System/370 I/O interface. In byte-multiplex mode, the I/O device stays log-
ically connected to the channel path only for a
The ESCON-I/O interface is described in the short interval of time. The facilities of a channel
System Library publication IBM Enterprise path capable of operating in byte-multiplex mode
Systems Architecture/390 ESCON I/O Interface, may be shared by a number of concurrently oper-
SA22-7202. The FICON-I/O interface is described ating I/O devices. In this mode all I/O operations
in the ANSI standards document Fibre Channel - are split into short intervals of time during which
Single-Byte Command Code Sets-2 (FC-SB-2). only a segment of information is transferred over
The IBM System/360 and System/370 I/O inter- the channel path. During such an interval, only
face is described in the System Library publication one device and its associated subchannel are log-
IBM System/360 and System/370 I/O Interface ically connected to the channel path. The inter-
Channel to Control Unit OEMI, GA22-6974. vals associated with the concurrent operation of
multiple I/O devices are sequenced in response to
Depending on the type of channel path, the facili- demands from the devices. The channel-
ties provided by the channel path, and the I/O subsystem facility associated with a subchannel
device, an I/O operation may occur in one of three exercises its controls for any one operation only
modes, frame-multiplex mode, burst mode, or for the time required to transfer a segment of
byte-multiplex mode. information. The segment can consist of a single
byte of data, a few bytes of data, a status report
In frame-multiplex mode, the I/O device may stay from the device, or a control sequence used for
logically connected to the channel path for the the initiation of a new operation.
duration of a channel program. The facilities of a
channel path capable of operating in frame- Ordinarily, devices with high data-transfer-rate
multiplex mode may be shared by a number of requirements operate with the channel path in
concurrently operating I/O devices. In this mode frame-multiplex mode, slower devices run in burst
the information required to complete an I/O opera- mode, and the slowest devices run in byte-
tion is divided into frames which may be inter- multiplex mode. Some control units have a
leaved with frames from I/O operations for other manual switch for setting the desired mode of
I/O devices. During this period, multiple I/O operation.
devices are considered to be logically connected
to the channel path. An I/O operation that occurs on a
parallel-I/O-interface type of channel path may
In burst mode, the I/O device monopolizes a occur in either burst mode or byte-multiplex mode
channel path and stays logically connected to the depending on the facilities provided by the
channel path for the transfer of a burst of informa- channel path and the I/O device. For improved
tion. No other device can communicate over the performance, some channel paths and control
channel path during the time a burst is transferred. units are provided with facilities for high-speed
The burst can consist of a few bytes, a whole transfer and data streaming. See the System
block of data, a sequence of blocks with associ- Library publication IBM System/360 and
ated control and status information (the block System/370 I/O Interface Channel to Control Unit
lengths may be zero), or status information which OEMI, GA22-6974, for a description of those two
monopolizes the channel path. The facilities of facilities.
the channel path capable of operating in burst
mode may be shared by a number of concurrently An I/O operation that occurs on a
operating I/O devices. serial-I/O-interface type of channel path may occur
in either frame-multiplex mode or burst mode. For
Some channel paths can tolerate an absence of improved performance, some control units
data transfer for about a half minute during a attaching to the serial-I/O interface provide the
burst-mode operation, such as occurs when a long capability to provide sense data to the program
gap on magnetic tape is read. An equipment mal- concurrent with presentation of unit-check status,

Chapter 13. I/O Overview 13-3


if permitted to do so by the program. (See Con- other hand, in some electronic I/O devices, such
current Sense on page 17-18.) as the channel-to-channel adapter, the control unit
does not have an identity of its own.
Depending on the control unit or channel sub-
system, access to a device through a subchannel From the programmer's point of view, most func-
may be restricted to a single channel-path type. tions performed by the control unit can be merged
with those performed by the I/O device. There-
The modes and features described above affect fore, this publication normally makes no specific
only the protocol used to transfer information over mention of the control-unit function; the execution
the channel path and the speed of transmission. of I/O operations is described as if the I/O devices
No effects are observable by CPU or channel pro- communicated directly with the channel sub-
grams with respect to the way these programs are system. Reference is made to the control unit
executed. only when emphasizing a function performed by it
or when describing how the sharing of the control
Control Units unit among a number of devices affects the exe-
cution of I/O operations.
A control unit provides the logical capabilities nec-
essary to operate and control an I/O device and I/O Devices
adapts the characteristics of each device so that it
can respond to the standard form of control pro- An input/output (I/O) device provides external
vided by the channel subsystem. storage, a means of communication between data-
processing systems, or a means of communication
Communication between the control unit and the between a system and its environment. I/O
channel subsystem takes place over a channel devices include such equipment as magnetic-tape
path. The control unit accepts control signals from units, direct-access-storage devices (for example,
the channel subsystem, controls the timing of data disks), display units, typewriter-keyboard devices,
transfer over the channel path, and provides indi- printers, teleprocessing devices, and sensor-based
cations concerning the status of the device. equipment. An I/O device may be physically dis-
tinct equipment, or it may share equipment with
The I/O device attached to the control unit may be other I/O devices.
designed to execute only certain limited oper-
ations, or it may execute many different oper- Most types of I/O devices, such as printers, or
ations. A typical operation is moving a recording tape devices, use external media, and these
medium and recording data. To accomplish its devices are physically distinguishable and identifi-
operations, the device needs detailed signal able. Other types are solely electronic and do not
sequences peculiar to its type of device. The directly handle physical recording media. The
control unit decodes the commands received from channel-to-channel adapter, for example, provides
the channel subsystem, interprets them for the for data transfer between two channel paths, and
particular type of device, and provides the signal the data never reaches a physical recording
sequence required for execution of the operation. medium outside main storage. Similarly, commu-
nication controllers may handle the transmission of
A control unit may be housed separately, or it may information between the data-processing system
be physically and logically integrated with the I/O and a remote station, and its input and output are
device, the channel subsystem, or a CPU. In the signals on a transmission line.
case of most electromechanical devices, a well-
defined interface exists between the device and In the simplest case, an I/O device is attached to
the control unit because of the difference in the one control unit and is accessible from one
type of equipment the control unit and the device channel path. Switching equipment is available to
require. These electromechanical devices often make some devices accessible from two or more
are of a type where only one device of a group channel paths by switching devices among control
attached to a control unit is required to transfer units and by switching control units among
data at a time (magnetic-tape units or disk-access channel paths. Such switching equipment pro-
mechanisms, for example), and the control unit is vides multiple paths by which an I/O device may
shared among a number of I/O devices. On the be accessed. Multiple channel paths to an I/O

13-4 z/Architecture Principles of Operation


device are provided to improve performance or I/O numbered subchannel is subchannel 0. The
availability, or both, within the system. The man- highest-numbered subchannel of the channel sub-
agement of multiple channel paths to devices is system has a subchannel number equal to one
under the control of the channel subsystem and less than the number of subchannels provided. A
the device, but the channel paths may indirectly maximum of 65,536 subchannels can be provided.
be controlled by the program. Normally, subchannel numbers are only used in
communication between the CPU program and the
channel subsystem.
I/O Addressing
Four different types of I/O addressing are provided Device Number
by the channel subsystem for the necessary
addressing of the various components: channel- Each subchannel that has an I/O device assigned
path identifiers, subchannel numbers, device to it also contains a system-unique parameter
numbers, and, though not visible to programs, called the device number. The device number is
addresses dependent on the channel-path type. a 16-bit value that is assigned as one of the
parameters of the subchannel at the time the
device is assigned to the subchannel.
Channel-Path Identifier
The device number provides a means to identify a
The channel-path identifier (CHPID) is a system-
device, independent of any limitations imposed by
unique eight-bit value assigned to each installed
the system model, the configuration, or channel-
channel path of the system. A CHPID identifies a
path protocols. The device number is used in
physical channel path. A CHPID is specified by
communications concerning the device that take
the second-operand address of RESET CHANNEL
place between the system and the system oper-
PATH and designates the physical channel path
ator. For example, the device number is entered
that is to be reset. The channel paths by which a
by the system operator to designate the input
device is accessible are identified in the
device to be used for initial program loading.
subchannel-information block (SCHIB), each by its
associated CHPID, when STORE SUBCHANNEL Programming Note: The device number is
is executed. The CHPID can also be used in assigned at device-installation time and may have
operator messages when it is necessary to identify any value. However, the user must observe any
a particular channel path. A system model may restrictions on device-number assignment that
provide as many as 256 channel paths. The may be required by the control program, support
maximum number of channel paths and the programs, or the particular control unit or I/O
assignment of CHPIDs to channel paths depends device.
on the system model.
Device Identifier
Subchannel Number
A device identifier is an address, not apparent to
A subchannel number is a system-unique 16-bit the program, that is used by the channel sub-
value used to address a subchannel. The sub- system to communicate with I/O devices. The
channel is addressed by eight I/O instructions: type of device identifier used depends on the spe-
CANCEL SUBCHANNEL, CLEAR SUBCHANNEL, cific channel-path type and the protocols provided.
HALT SUBCHANNEL, MODIFY SUBCHANNEL, Each subchannel contains one or more device
RESUME SUBCHANNEL, START SUBCHANNEL, identifiers.
STORE SUBCHANNEL, and TEST SUB-
CHANNEL. Each I/O device accessible to the For a channel path of the parallel-I/O-interface
channel subsystem is assigned a dedicated sub- type the device identifier is called a device
channel at installation time. All I/O functions rela- address and consists of an eight-bit value. For
tive to a specific I/O device are specified by the the ESCON-I/O interface, the device identifier con-
program by designating the subchannel assigned sists of a four-bit control-unit address and an
to the I/O device. Subchannels are always eight-bit device address. For the FICON-I/O inter-
assigned subchannel numbers within a single face, the device identifier consists of an eight-bit
range of contiguous numbers. The lowest- control-unit-image ID and an eight-bit device

Chapter 13. I/O Overview 13-5


address. For the FICON-converted-I/O interface, may be transferred to the device as modifier bits
the device identifier consists of a four-bit control- in the command code of a control command, may
unit address and an eight-bit device address. be transferred to the device as data during a
control or write operation, or may be made avail-
The device address identifies the particular I/O able to the device by other means.
device (and, on the parallel-I/O-interface, the
control unit) associated with a subchannel. The
device address may identify, for example, a partic-
Start-Function Initiation
ular magnetic-tape drive, disk-access mechanism,
CPU programs initiate I/O operations with the
or transmission line. Any number in the range
instruction START SUBCHANNEL. This instruc-
0-255 can be assigned as a device address.
tion passes the contents of an operation-request
block (ORB) to the subchannel. The contents of
For further information about the device identifier
the ORB include the subchannel key, the address
used with a particular channel-path type, see the
of the first CCW to be executed, and the format of
appropriate publication for the channel-path type.
the CCWs. The CCW specifies the command to
be executed and the storage area, if any, to be
used.
Execution of I/O Operations
I/O operations are initiated and controlled by infor- When the ORB contents have been passed to the
mation with three types of formats: the instruction subchannel, the execution of START SUB-
START SUBCHANNEL, channel-command words CHANNEL is complete. The results of the exe-
(CCWs), and orders. The START SUBCHANNEL cution of the instruction are indicated by the
instruction is executed by a CPU and is part of the condition code set in the program-status word.
CPU program that supervises the flow of requests
for I/O operations from other programs that When facilities become available, the channel sub-
manage or process the I/O data. system fetches the first CCW and decodes it
according to the format bit specified in the ORB.
When START SUBCHANNEL is executed, param- If the format bit is zero, format-0 CCWs are speci-
eters are passed to the target subchannel fied. If the format bit is one, format-1 CCWs are
requesting that the channel subsystem perform a specified. Format-0 and format-1 CCWs contain
start function with the I/O device associated with the same information, but the fields are arranged
the subchannel. The channel subsystem performs differently in the format-1 CCW so that 31-bit
the start function by using information at the sub- addresses can be specified directly in the CCW.
channel, including the information passed during
the execution of the START SUBCHANNEL Path Management
instruction, to find an accessible channel path to
the device. Once the device has been selected, If the first CCW passes certain validity tests and
execution of an I/O operation is accomplished by does not have the suspend flag specified, the
the decoding and executing of a CCW by the channel subsystem attempts device selection by
channel subsystem and the I/O device. One or choosing a channel path from the group of
more CCWs arranged for sequential execution channel paths that are available for selection. A
form a channel program and are executed as one control unit that recognizes the device identifier
or more I/O operations, respectively. Both connects itself logically to the channel path and
instructions and CCWs are fetched from main responds to its selection. The channel subsystem
storage, and their formats are common for all sends the command-code part of the CCW over
types of I/O devices, although the modifier bits in the channel path, and the device responds with a
the command code of a CCW may specify device- status byte indicating whether the command can
dependent conditions for the execution of an oper- be executed. The control unit may logically dis-
ation at the device. connect from the channel path at this time, or it
may remain connected to initiate data transfer.
Operations peculiar to a device, such as rewinding
tape or positioning the access mechanism on a If the attempted selection does not occur as a
disk drive, are specified by orders which are result of either a busy indication or a path-not-
decoded and executed by I/O devices. Orders

13-6 z/Architecture Principles of Operation


operational condition, the channel subsystem To complement dynamic address translation in
attempts to select the device by an alternate CPUs, CCW indirect data addressing is provided.
channel path if one is available. When selection A flag in the CCW specifies that an indirect-data-
has been attempted on all paths available for address list is to be used to designate the storage
selection and the busy condition persists, the areas for that CCW. Each time the boundary of a
operation remains pending until a path becomes block of storage is reached, the list is referenced
free. If a path-not-operational condition is to determine the next block of storage to be used.
detected on one or more of the channel paths on The ORB specifies whether the size of each block
which device selection was attempted, the of storage is 2K-bytes or 4K-bytes. CCW indirect
program is alerted by a subsequent I/O inter- data addressing permits essentially the same
ruption. The I/O interruption occurs either upon CCW sequences to be used for a program running
execution of the channel program (assuming the with dynamic address translation active in a CPU
device was selected on an alternate channel path) as would be used if the CPU were operating with
or as a result of the execution being abandoned, equivalent contiguous real storage. CCW indirect
path-not-operational conditions being detected on data addressing permits the program to designate
all of the channel paths on which device selection data blocks having absolute storage addresses up
was attempted. to 2-1, independent of whether format-0 or
format-1 CCWs have been specified in the ORB.
Channel-Program Execution In general, execution of an I/O operation or chain
of operations involves as many as three levels of
If the command is initiated at the device and
participation:
command execution does not require any data to
be transferred to or from the device, the device 1. Except for effects due to the integration of
may signal the end of the operation immediately CPU and channel-subsystem equipment, a
on receipt of the command code. In operations CPU is busy for the duration of the execution
that involve the transfer of data, the subchannel is of START SUBCHANNEL, which lasts until
set up so that the channel subsystem will respond the addressed subchannel has been passed
to service requests from the device and assume the ORB contents.
further control of the operation.
2. The subchannel is busy for a new START
SUBCHANNEL from the receipt of the ORB
An I/O operation may involve the transfer of data
contents until the primary interruption condi-
to or from one storage area, designated by a
tion is cleared at the subchannel.
single CCW, or to or from a number of noncontig-
uous storage areas. In the latter case, generally a 3. The I/O device is busy from the initiation of
list of CCWs is used for execution of the I/O oper- the first operation at the device until either the
ation, each CCW designating a contiguous subchannel becomes suspended or the sec-
storage area, and the CCWs are coupled by data ondary interruption condition is placed at the
chaining. Data chaining is specified by a flag in subchannel. In the case of a suspended sub-
the CCW and causes the channel subsystem to channel, the device again becomes busy
fetch another CCW upon the exhaustion or filling when execution of the suspended channel
of the storage area designated by the current program is resumed.
CCW. The storage area designated by a CCW
fetched on data chaining pertains to the I/O opera- Conclusion of I/O Operations
tion already in progress at the I/O device, and the
I/O device is not notified when a new CCW is The conclusion of an I/O operation normally is
fetched. indicated by two status conditions: channel end
and device end. The channel-end condition indi-
Provision is made in the CCW format for the pro-
cates that the I/O device has received or provided
grammer to specify that, when the CCW is
all data associated with the operation and no
decoded, the channel subsystem request an I/O
longer needs channel-subsystem facilities. This
interruption as soon as possible, thereby notifying
condition is called the primary interruption condi-
a CPU program that chaining has progressed at
tion, and the channel end in this case is the
least as far as that CCW in the channel program.
primary status. Generally, the primary interruption

Chapter 13. I/O Overview 13-7


condition is any interruption condition that relates single START SUBCHANNEL instruction. When
to an I/O operation and that signals the conclusion the current CCW specifies command chaining and
at the subchannel of the I/O operation or chain of no unusual conditions have been detected during
I/O operations. the operation, the receipt of the device-end signal
causes the channel subsystem to fetch a new
The device-end signal indicates that the I/O device CCW. If the CCW passes certain validity tests
has concluded execution and is ready to execute and the suspend flag is not specified in the new
another operation. This condition is called the CCW, execution of a new command is initiated at
secondary interruption condition, and the device the device. If the CCW fails to pass the validity
end in this case is the secondary status. Gener- tests, the new command is not initiated, command
ally, the secondary interruption condition is any chaining is suppressed, and the status associated
interruption condition that relates to an I/O opera- with the new CCW causes an interruption condi-
tion and that signals the conclusion at the device tion to be generated. If the suspend flag is speci-
of the I/O operation or chain of operations. The fied, execution of the new command is not
secondary interruption condition can occur concur- initiated, and command chaining is concluded.
rently with, or later than, the primary interruption
condition. Execution of the new command is initiated by the
channel subsystem in the same way as the pre-
Concurrent with the primary or secondary inter- vious operation. The ending signals occurring at
ruption conditions, both the channel subsystem the conclusion of an operation caused by a CCW
and the I/O device can provide indications of specifying command chaining are not made avail-
unusual situations. able to the program. When another I/O operation
is initiated by command chaining, the channel sub-
The conditions signaling the conclusion of an I/O system continues execution of the channel
operation can be brought to the attention of the program. If, however, an unusual condition has
program by I/O interruptions or, when the CPUs been detected, command chaining is suppressed,
are disabled for I/O interruptions, by programmed the channel program is terminated, an interruption
interrogation of the channel subsystem. In the condition is generated, and the ending signals
former case, these conditions cause storing of the causing the termination are made available to the
I/O-interruption code, which contains information program.
concerning the interrupting source. In the latter
case, the interruption code is stored as a result of The suspend-and-resume function provides the
the execution of TEST PENDING INTERRUPTION program with control over the execution of a
. channel program. The initiation of the suspend
function is controlled by the setting of the
When the primary interruption condition is recog- suspend-control bit in the ORB. The suspend
nized, the channel subsystem attempts to notify function is signaled to the channel subsystem
the program, by means of an interruption request, during channel-program execution by specifying
that a subchannel contains information describing the suspend (S) flag in the first CCW or in a CCW
the conclusion of an I/O operation at the sub- fetched during command chaining.
channel. The information identifies the last CCW
used and may provide its residual byte count, thus Suspension occurs when the channel subsystem
describing the extent of main storage used. Both fetches a CCW with a valid S flag. The command
the channel subsystem and the I/O device may in this CCW is not sent to the I/O device, and the
provide additional indications of unusual conditions device is signaled that the chain of commands is
as part of either the primary or secondary inter- concluded. A subsequent RESUME SUB-
ruption condition. The information contained at CHANNEL instruction informs the channel sub-
the subchannel may be stored by the execution of system that the CCW that caused suspension may
TEST SUBCHANNEL or the execution of STORE have been modified and that the channel sub-
SUBCHANNEL. This information, when stored, is system must refetch the CCW and examine the
called a subchannel-status word (SCSW). current setting of the suspend flag. If the suspend
flag is found to be not specified in the CCW, the
Facilities are provided for the program to initiate channel subsystem resumes execution of the
execution of a chain of I/O operations with a chain of commands with the I/O device.

13-8 z/Architecture Principles of Operation


Channel-program execution may be terminated I/O-interruption subclass for which the interruption
prematurely by HALT SUBCHANNEL or CLEAR is made pending is under programmed control
SUBCHANNEL. The execution of HALT SUB- through the use of MODIFY SUBCHANNEL. A
CHANNEL causes the channel subsystem to issue pending I/O interruption may be accepted by any
the halt signal to the I/O device and terminate CPU that is enabled for interruptions from its
channel-program execution at the subchannel. I/O-interruption subclass. Each CPU has eight
When channel-program execution is terminated by mask bits in control register 6 which control the
the execution of HALT SUBCHANNEL, the enabling of that CPU for each of the eight
program is notified of the termination by means of I/O-interruption subclasses, with the I/O mask (bit
an I/O-interruption request. The interruption 6) in the PSW the master I/O-interruption mask for
request is generated when the device presents the CPU.
status for the terminated operation. If, however,
the halt signal was issued to the device during When an I/O interruption occurs at a CPU, the
command chaining after the receipt of device end I/O-interruption code is stored in the
but before the next command was transferred to I/O-communication area of that CPU, and the
the device, the interruption request is generated I/O-interruption request is cleared. The
after the device has been signaled. In the latter I/O-interruption code identifies the subchannel for
case, the device-status field of the SCSW will which the interruption was pending. The condi-
contain zeros. The execution of CLEAR SUB- tions causing the generation of the interruption
CHANNEL clears the subchannel of indications of request may then be retrieved from the sub-
the channel program in execution, causes the channel explicitly by TEST SUBCHANNEL or by
channel subsystem to issue the clear signal to the STORE SUBCHANNEL.
I/O device, and causes the channel subsystem to
generate an I/O-interruption request to notify the A pending I/O-interruption request may also be
program of the completion of the clear function. cleared by TEST PENDING INTERRUPTION
when the corresponding I/O-interruption subclass
is enabled but the PSW has I/O interruptions disa-
I/O Interruptions bled or TEST SUBCHANNEL when the CPU is
disabled for I/O interruptions from the corre-
Conditions causing I/O-interruption requests are
sponding I/O-interruption subclass. A pending
asynchronous to activity in CPUs, and more than
I/O-interruption request may also be cleared by
one condition can occur at the same time. The
CLEAR SUBCHANNEL. Both CLEAR SUB-
conditions are preserved at the subchannels until
CHANNEL and TEST SUBCHANNEL clear the
cleared by TEST SUBCHANNEL or CLEAR SUB-
preserved interruption condition at the subchannel
CHANNEL, or reset by an I/O-system reset.
as well.
When an I/O-interruption condition has been
Normally, unless the interruption request is
recognized by the channel subsystem and indi-
cleared by CLEAR SUBCHANNEL, the program
cated at the subchannel, an I/O-interruption
executes TEST SUBCHANNEL to obtain informa-
request is made pending for the I/O-interruption
tion concerning the execution of the operation.
subclass specified at the subchannel. The

Chapter 13. I/O Overview 13-9


13-10 z/Architecture Principles of Operation
Chapter 14. I/O Instructions
I/O-Instruction Formats . . . . . . . . . . . . . 14-1 RESET CHANNEL PATH . . . . . . . . . . 14-8
I/O-Instruction Execution . . . . . . . . . . . . 14-1 RESUME SUBCHANNEL . . . . . . . . . . 14-9
Serialization . . . . . . . . . . . . . . . . . . 14-1 SET ADDRESS LIMIT . . . . . . . . . . . 14-11
Operand Access . . . . . . . . . . . . . . . 14-1 SET CHANNEL MONITOR . . . . . . . . 14-12
Condition Code . . . . . . . . . . . . . . . . 14-2 START SUBCHANNEL . . . . . . . . . . 14-14
Program Exceptions . . . . . . . . . . . . . 14-2 STORE CHANNEL PATH STATUS . . . 14-15
Instructions . . . . . . . . . . . . . . . . . . . . 14-2 STORE CHANNEL REPORT WORD . . 14-16
CANCEL SUBCHANNEL . . . . . . . . . . 14-4 STORE SUBCHANNEL . . . . . . . . . . 14-17
CLEAR SUBCHANNEL . . . . . . . . . . . 14-4 TEST PENDING INTERRUPTION . . . . 14-17
HALT SUBCHANNEL . . . . . . . . . . . . 14-5 TEST SUBCHANNEL . . . . . . . . . . . 14-19
MODIFY SUBCHANNEL . . . . . . . . . . 14-7

The I/O instructions include all instructions that are subsystem-identification word. The format of the
provided for the control of channel-subsystem subsystem-identification word is as follows:
operations. The I/O instructions are listed in
Figure 14-1 on page 14-3. All of the I/O /
Subchannel
instructions are privileged instructions. ///1 Number
/
Several I/O instructions result in the channel sub- 32 48 63
system being signaled to perform functions asyn-
chronous to the execution of the instructions. The Bits 48-63 of general register 1 form the binary
description of each instruction of this type contains number of the subchannel to be used for the func-
a section called Associated Functions, which tion specified by the instruction. Bits 0-31 of
summarizes the asynchronous functions. general register 1 are ignored and bits 32-47
specify the binary number one.

I/O-Instruction Formats
Most I/O instructions use the S format: I/O-Instruction Execution

Op Code B D Serialization

16 2 31 The execution of any I/O instruction causes serial-


ization and checkpoint synchronization to occur.
The use of the second-operand address and For a definition of the serialization of CPU oper-
general registers 1 and 2 (as implied operands) ations, see CPU Serialization on page 5-89.
depends on the I/O instruction. Figure 14-1 on
page 14-3 defines which operands are used to Operand Access
execute each I/O instruction. In addition, detailed
information regarding operand usage appears in During execution of an I/O instruction, the order in
the description of each I/O instruction. which fields of the operand and fields of the sub-
channel (if applicable) are accessed is unpredict-
All I/O instructions that reference a subchannel able. It is also unpredictable as to whether fetch
use the contents of general register 1 as an accesses are made to fields of an operand or the
implied operand. For these I/O instructions, bit subchannel (as applicable) when those fields are
positions 32-63 of general register 1 contain the not needed to complete execution of the I/O
instruction. (See Relation between Operand
Accesses on page 5-88.)

Copyright IBM Corp. 1990, 2000 14-1


Condition Code In situations where conditions exist that could
cause more than one nonzero condition code to
During the execution of some I/O instructions, the be set, priority of the condition codes is as follows:
results of certain tests are used to set one of four
Condition code 3 has precedence over condition
condition codes in the PSW. The I/O instructions
codes 1 and 2.
for which execution can result in the setting of the
condition code are listed in Figure 14-1 on
Condition code 1 has precedence over condition
page 14-3. The condition code indicates the
code 2.
result of the execution of the I/O instruction. The
general meaning of the condition code for I/O
instructions is given below; the meaning of the Program Exceptions
condition code for a specific instruction appears in
the description of that instruction. The program exceptions that the I/O instructions
can encounter are access, operand, privileged-
Condition Code 0: Instruction execution operation, and specification exceptions.
produced the expected or most probable result. Figure 14-1 on page 14-3 shows the exceptions
(See Deferred Condition Code (CC) on page that are applicable to each of the I/O instructions.
16-8 for a description of conditions that can be The execution of the instruction is suppressed for
encountered subsequent to the presentation of privileged-operation, operand, and specification
condition code 0 that result in a nonzero deferred exceptions. Except as indicated otherwise in the
condition code.) section Special Conditions for each instruction,
the instruction ending for access exceptions is as
Condition Code 1: Instruction execution described in Recognition of Access Exceptions
produced the alternate or second-most-probable on page 6-35.
result, or status conditions were present that may
or may not have prevented the expected result.
Instructions
Condition Code 2: Instruction execution was
The mnemonics, format, and operation codes of
ineffective because the designated subchannel or
the I/O instructions are given in Figure 14-1 on
channel-subsystem facility was busy with a previ-
page 14-3. The figure also indicates the condi-
ously initiated function.
tions that can cause a program interruption and
Condition Code 3: Instruction execution was whether the condition code is set.
ineffective because the designated element was
In the detailed descriptions of the individual
not operational or because some condition pre-
instructions, the mnemonic and the symbolic
cluded initiation of the normal function.
operand designation for the assembler language
are shown with each instruction. In the case of
START SUBCHANNEL, for example, SSCH is the
mnemonic and D(B) the operand designation.

14-2 z/Architecture Principles of Operation



Mne- Op
Name monic Characteristics Code

CANCEL SUBCHANNEL XSCH S C P OP GS B276


CLEAR SUBCHANNEL CSCH S C P OP GS B23
HALT SUBCHANNEL HSCH S C P OP GS B231
MODIFY SUBCHANNEL MSCH S C P A SPOP GS BB232
RESET CHANNEL PATH RCHP S C P OP G1 B23B

RESUME SUBCHANNEL RSCH S C P OP GS B238


SET ADDRESS LIMIT SAL S P OP G1 B237
SET CHANNEL MONITOR SCHM S P OP GM B23C
START SUBCHANNEL SSCH S C P A SPOP GS BB233
STORE CHANNEL PATH STATUS STCPSS P A SP ST BB23A

STORE CHANNEL REPORT WORD STCRWS C P A SP ST BB239


STORE SUBCHANNEL STSCHS C P A SPOP GS ST BB234
TEST PENDING INTERRUPTION TPI S C P A SP ST BB236
TEST SUBCHANNEL TSCH S C P A SPOP GS ST BB235

Explanation:

Causes serialization and checkpoint synchronization.
A Access exceptions for logical addresses.
A When the effective address is zero, it is not used to access storage, and no access
exceptions can occur, except that access exceptions may occur during access-register
translation.
B B field designates an access register in the access-register mode.
C Condition code is set.
G1 Instruction execution includes the implied use of general register 1
as a parameter.
GM Instruction execution includes the implied use of multiple general
registers. General register 1 is used as a parameter, and general
register 2 may be used as a parameter depending on the contents of
general register 1.
GS Instruction execution includes the implied use of general register 1
as the subsystem-identification word.
OP Operand exception.
P Privileged-operation exception.
S S instruction format.
SP Specification exception.
ST PER storage-alteration event.

Figure 14-1. Summary of I/O Instructions

Chapter 14. I/O Instructions 14-3


CANCEL SUBCHANNEL Condition code 3 is set and no other action is
taken when the subchannel is not operational for
XSCH [S] CANCEL SUBCHANNEL. A subchannel is not
operational for CANCEL SUBCHANNEL when the
'B276' ////////////////
subchannel is not provided in the channel sub-
16 31 system, has no valid device number assigned to it,
or is not enabled.
The current start function, if any, is terminated at
CANCEL SUBCHANNEL can encounter the
the designated subchannel if CANCEL SUB-
program exceptions listed below. Bit positions
CHANNEL is applicable.
32-47 of general register 1 must contain the value
0001 hex; otherwise, an operand exception is
General register 1 contains the subsystem-
recognized.
identification word, which designates the sub-
channel for which the current START FUNCTION,
Resulting Condition Code:
if any, is to be terminated.
0 Start function canceled
If the subchannel (1) is not subchannel active, 1 Status-pending
(2) is start-pending or resume-pending or sus- 2 CANCEL SUBCHANNEL not applicable
pended, and (3) contains only the start function, 3 Not operational
then the start function at the subchannel is termi-
nated and the subchannel is made no longer start- Program Exceptions:
pending, resume-pending, or suspended, as Operand
appropriate. In addition, internal indications of Privileged operation
busy are reset for the subchannel.
Programming Notes:
Condition code 0 is set to indicate that the actions
described above have been taken. 1. The actions taken by CANCEL SUBCHANNEL
are completed during execution of the instruc-
If an invalid ORB field or a no-path-available con- tion. If condition code 0 is presented, there is
dition is present for a previously initiated start no subsequent I/O interruption resulting from
function and the condition was not reported during the terminated I/O operation. However, the
the execution of START SUBCHANNEL, condition device may have signaled a busy condition
code 0 may be indicated for CANCEL SUB- while the canceled operation was start-
CHANNEL provided that the subchannel is not yet pending. In this case, the device owes a no-
status-pending to report the error condition; if con- longer-busy signal to the channel subsystem.
dition code 0 is presented, no subsequent status This may result in unsolicited device-end
is generated to indicate the error condition. status before the next operation is initiated at
the device.
Special Conditions
2. Upon completion of CANCEL SUBCHANNEL
with condition code 0, the subchannel is ready
Condition code 1 is set and no other action is
to accept a new start function initiated by
taken when the subchannel is status-pending with
START SUBCHANNEL.
any status.

Condition code 2 is set and no other action is CLEAR SUBCHANNEL


taken when CANCEL SUBCHANNEL is not appli-
cable and the subchannel is not status-pending. CSCH [S]

CANCEL SUBCHANNEL is not applicable when 'B23' ////////////////
the subchannel (1) has no function specified,
(2) has a function other than the start function 16 31
alone specified, (3) is not resume-pending and is
not start-pending and is not suspended, or (4) is The designated subchannel is cleared, the current
subchannel-active. start or halt function, if any, is terminated at the
designated subchannel, and the channel sub-

14-4 z/Architecture Principles of Operation


system is signaled to asynchronously perform the and other indications are provided that describe in
clear function at the designated subchannel and at greater detail the condition that was encountered.
the associated device. (See Interruption-Response Block on
page 16-6.)
General register 1 contains the subsystem-
identification word, which designates the sub- Measurement data is not accumulated and the
channel that is to be cleared. device-connect time is not stored in the extended-
status word for the subchannel for a start function
If a start or halt function is in progress, it is termi- that is terminated by CLEAR SUBCHANNEL.
nated at the subchannel.
Special Conditions
The subchannel is made no longer status-pending.
All activity, as indicated in the activity-control field Condition code 3 is set and no other action is
of the SCSW, is cleared at the subchannel, except taken when the subchannel is not operational for
that the subchannel is made clear-pending. Any CLEAR SUBCHANNEL. A subchannel is not
functions in progress, as indicated in the function- operational for CLEAR SUBCHANNEL when the
control field of the SCSW, are cleared at the sub- subchannel is not provided in the channel sub-
channel, except for the clear function which is to system, has no valid device number assigned to it,
be performed because of the execution of this or is not enabled.
instruction.
CLEAR SUBCHANNEL can encounter the
The channel subsystem is signaled to asynchro- program exceptions that are listed below. Bit
nously perform the clear function. The clear func- positions 32-47 of general register 1 must contain
tion is summarized below in the section the value 0001 hex; otherwise, an operand excep-
Associated Functions and is described in detail tion is recognized.
in Clear Function on page 15-13.
Resulting Condition Code:
Condition code 0 is set to indicate that the actions
0 Function initiated
described above have been taken.
1 --
2 --
Associated Functions
3 Not operational
Subsequent to the execution of CLEAR SUB-
Program Exceptions:
CHANNEL, the channel subsystem asynchro-
nously performs the clear function. If conditions Operand
allow, the channel subsystem chooses a channel Privileged operation
path and attempts to issue the clear signal to the
device to terminate the I/O operation, if any. The HALT SUBCHANNEL
subchannel then becomes status-pending. Condi-
tions encountered by the channel subsystem that HSCH [S]
preclude issuing the clear signal to the device do
'B231' ////////////////
not prevent the subchannel from becoming status-
pending (see Clear Function on page 15-13). 16 31

When the subchannel becomes status-pending as


The current start function, if any, is terminated at
a result of performing the clear function, data
the designated subchannel, and the channel sub-
transfer, if any, with the associated device has
system is signaled to asynchronously perform the
been terminated. The SCSW stored when the
halt function at the designated subchannel and at
resulting status is cleared by TEST SUB-
the associated device.
CHANNEL has the clear-function bit stored as
one. If the channel subsystem can determine that
General register 1 contains the subsystem-
the clear signal was issued to the device, the
identification word, which designates the sub-
clear-pending bit is stored as zero in the SCSW.
channel that is to be halted.
Otherwise, the clear-pending bit is stored as one,

Chapter 14. I/O Instructions 14-5


If a start function is in progress, it is terminated at status-pending. When the status-pending condi-
the subchannel. tion is subsequently cleared by TEST SUB-
CHANNEL, the halt-pending bit is stored as one in
The subchannel is made halt-pending and the halt the SCSW.
function is indicated at the subchannel.
If a status-pending condition is eliminated during
When HALT SUBCHANNEL is executed and the execution of HALT SUBCHANNEL, then this con-
designated subchannel is subchannel-and-device- dition is reestablished along with the other status
active and status-pending with intermediate status, conditions when completion of the halt function is
the status-pending indication is eliminated (see the indicated to the program.
discussion of bits 24, 25, and 28 in Activity
Control (AC) on page 16-13). The status- The halt-pending condition may not be recognized
pending condition is reestablished as part of the by the channel subsystem if a status-pending con-
halt function (see the section Associated dition has been generated. This situation could
Functions below). occur, for example, when alert status is presented
or generated while the subchannel is already start-
The channel subsystem is signaled to asynchro- pending or resume-pending, or when primary
nously perform the halt function. The halt function status is presented during the attempt to initiate
is summarized below in the section Associated the I/O operation for the first command as speci-
Functions and is described in detail in Halt fied by the start function or implied by the resume
Function on page 15-14. function. If recognition of the status-pending con-
dition by the channel subsystem has occurred log-
Condition code 0 is set to indicate that the actions ically prior to recognition of the halt-pending
described above have been taken. condition, the SCSW, when cleared by TEST
SUBCHANNEL, has the halt-pending bit stored as
Associated Functions one.

Subsequent to the execution of HALT SUB- If measurement data is being accumulated when a
CHANNEL, the channel subsystem asynchro- start function is terminated by HALT SUB-
nously performs the halt function. If conditions CHANNEL, the measurement data continues to be
allow, the channel subsystem chooses a channel accumulated for the subchannel and reflects the
path and attempts to issue the halt signal to the extent of subchannel and device usage required, if
device to terminate the I/O operation, if any. The any, while performing the currently terminated
subchannel then becomes status-pending. start function. The measurement data, if any, is
accumulated in the measurement block for the
When the subchannel becomes status-pending as
subchannel or placed in the extended-status word,
a result of performing the halt function, data
as appropriate, when the subchannel becomes
transfer, if any, with the associated device has
status-pending with primary or secondary status.
been terminated. The SCSW stored when the
(See Channel-Subsystem Monitoring on
resulting status is cleared by TEST SUB-
page 17-1.)
CHANNEL has the halt-function bit stored as one.
If the halt signal was issued to the device, the Special Conditions
halt-pending bit is stored as zero. Otherwise, the
halt-pending bit is stored as one, and other indi- Condition code 1 is set and no other action is
cations are provided that describe in greater detail taken when the subchannel is status-pending
the condition that was encountered. (See alone or is status-pending with any combination of
Interruption-Response Block on page 16-6 and alert, primary, or secondary status.
Halt Function on page 15-14.)
Condition code 2 is set and no other action is
In some models, path availability is tested as part taken when the subchannel is busy for HALT
of the halt function (rather than as part of the exe- SUBCHANNEL. The subchannel is busy for
cution of the instruction). In these models, when HALT SUBCHANNEL when a halt function or
no channel path is available for selection, the halt clear function is already in progress at the sub-
signal is not issued, and the subchannel is made channel.

14-6 z/Architecture Principles of Operation


Condition code 3 is set and no other action is General register 1 contains the subsystem-
taken when the subchannel is not operational for identification word, which designates the sub-
HALT SUBCHANNEL. A subchannel is not opera- channel that is to be modified as specified by
tional for HALT SUBCHANNEL when the sub- certain fields of the SCHIB. The second-operand
channel is not provided in the channel subsystem, address is the logical address of the SCHIB and is
has no valid device number assigned to it, or is designated on a word boundary.
not enabled. In some models, a subchannel is
also not operational for HALT SUBCHANNEL The channel-subsystem operations that may be
when no channel paths are available for selection influenced due to placement of SCHIB information
by the device. (See Channel-Path Availability on in the subchannel are:
page 15-12 for a description of channel paths I/O processing (E field)
that are available for selection.) interruption processing (interruption parameter
and ISC field)
HALT SUBCHANNEL can encounter the program
path management (D, LPM, and POM fields)
exceptions listed below. Bit positions 32-47 of
monitoring and address-limit-checking
general register 1 must contain the value 0001
(measurement-block index, LM, and MM
hex; otherwise, an operand exception is recog-
fields)
nized.
concurrent-sense facility (S field)
Resulting Condition Code: Bits 0-1 and 6-7 of word 1, and bits 0-30 of word
6 of the SCHIB operand must be specified as
0 Function initiated
zeros, and bits 9-10 of word 1 must not both be
1 Status-pending with other than intermediate
ones. The remaining fields of the SCHIB are
status
ignored and do not affect the processing of
2 Busy
MODIFY SUBCHANNEL. (For further details, see
3 Not operational
Subchannel-Information Block on page 15-1.)
Program Exceptions:
Condition code 0 is set to indicate that the infor-
Operand mation from the SCHIB has been placed in the
Privileged operation program-modifiable fields of the subchannel,
Programming Note: After execution of HALT except that when the device-number-valid (V) bit
SUBCHANNEL, the status-pending condition indi- at the designated subchannel is zero.
cating the completion of the halt function may be
Special Conditions
delayed for an extended period of time, for
example, when the device is a magnetic-tape unit
Condition code 1 is set and no other action is
executing a rewind command.
taken when the subchannel is status-pending.
(See Status Control (SC) on page 16-16.)
MODIFY SUBCHANNEL
Condition code 2 is set and no other action is
MSCH D(B) [S] taken when a clear, halt, or start function is in

'B232' B D progress at the subchannel. (See Function


Control (FC) on page 16-12.)
16 2 31
Condition code 3 is set and no other action is
The information contained in the subchannel- taken when the subchannel is not operational for
information block (SCHIB) is placed in the MODIFY SUBCHANNEL. A subchannel is not
program-modifiable fields of the subchannel. As a operational for MODIFY SUBCHANNEL when the
result, the program influences, for that sub- subchannel is not provided in the channel sub-
channel, certain aspects of I/O processing relative system.
to the clear, halt, resume, and start functions and
certain I/O support functions. MODIFY SUBCHANNEL can encounter the
program exceptions listed below. In word 1 of the
SCHIB, bits 0-1 and 6-7 must be zeros, and bits 9

Chapter 14. I/O Instructions 14-7


and 10 must not both be ones; in word 6 of the 3. It is recommended that the program inspect
SCHIB, bits 0-30 must be zeros; otherwise an the contents of the subchannel by subse-
operand exception is recognized. quently executing STORE SUBCHANNEL
when MODIFY SUBCHANNEL sets the condi-
Bit positions 32-47 of general register 1 must tion code to 0. Use of STORE SUB-
contain the value 0001 hex; otherwise, an operand CHANNEL provides a method for determining
exception is recognized. if the designated subchannel was changed or
not. Failure to inspect the subchannel fol-
The execution of MODIFY SUBCHANNEL is sup- lowing the setting of condition code 0 by
pressed on all addressing and protection MODIFY SUBCHANNEL may result in condi-
exceptions. tions that the program does not expect to
occur. This is especially true when the
The second operand must be designated on a dynamic-I/O facility is installed and MODIFY
word boundary; otherwise, a specification excep- SUBCHANNEL is executed in a logical parti-
tion is recognized. tion.

Resulting Condition Code:


RESET CHANNEL PATH
0 Function completed
1 Status-pending RCHP [S]
2 Busy
'B23B' ////////////////
3 Not operational
16 31
Program Exceptions:
Access (fetch, operand 2) The channel-path-reset facility is signaled to
Operand perform the channel-path-reset function at the
Privileged operation channel path designated by general register 1.
Specification
General register 1 has the following format:
Programming Notes:
/
1. If a device signals I/O-error alert while the /// CHPID
associated subchannel is disabled, the /
32 56 63
channel subsystem issues the clear signal to
the device and discards the I/O-error-alert
indication without generating an Channel-Path Identifier (CHPID): Bit positions
I/O-interruption condition. 56-63 of general register 1 form the binary number
which designates the channel-path identifier of the
2. If a device presents unsolicited status while
channel path on which the channel-path-reset
the associated subchannel is disabled, that
function is to be performed.
status is discarded by the channel subsystem
without generating an I/O-interruption condi- Bits 32-55 of general register 1 are reserved and
tion. However, if the status presented con- must contain zeros; otherwise, an operand excep-
tains unit check, the channel subsystem tion is recognized. Bits 0-31 of general register 1
issues the clear signal for the associated sub- are ignored.
channel and does not generate an
I/O-interruption condition. This should be If conditions allow, the channel-path-reset facility
taken into account when the program uses is signaled to asynchronously perform the
MODIFY SUBCHANNEL to enable a sub- channel-path-reset function on the designated
channel. For example, the medium on the channel path. The channel-path-reset function is
associated device that was present when the summarized below in the section Associated
subchannel became disabled may have been Functions and is described in detail in Channel-
replaced, and, therefore, the program should Path Reset on page 17-10.
verify the integrity of that medium.

14-8 z/Architecture Principles of Operation


Condition code 0 is set to indicate that the 3 Not operational
channel-path-reset facility has been signaled.
Program Exceptions:
Associated Functions
Operand
Privileged operation
Subsequent to the execution of RESET CHANNEL
PATH, the channel-path-reset facility asynchro-
Programming Notes:
nously performs the channel-path-reset function.
Certain indications are reset at all subchannels 1. To eliminate the possibility of a data-integrity
that have access to the designated channel path, exposure for devices that have the capability
and the reset signal is issued on that channel of generating unsolicited device-end status,
path. Any I/O functions in progress at the devices I/O operations in progress with such devices
are reset, but only for the channel path on which on the channel path for which RESET
the reset signal is received. An I/O operation or CHANNEL PATH is to be executed must be
chain of I/O operations taking place in multipath terminated by execution of either HALT SUB-
mode may be able to continue to execute on other CHANNEL or CLEAR SUBCHANNEL. Other-
channel paths in the multipath group, if any. (See wise, subsequent to receiving the reset signal,
Channel-Path-Reset Function on page 15-44.) the device may present an unsolicited device
end that may be interpreted by the channel
The result of performing the channel-path-reset subsystem as a solicited device end and
function on the designated channel path is com- cause command chaining to occur.
municated to the program by means of a channel
2. If the status-verification facility is being used
report (see Channel Report on page 17-19).
and RESET CHANNEL PATH is executed
without first stopping all ongoing operations
Special Conditions
associated with the channel path being reset,
Condition code 2 is set and no other action is erroneous device-status-check conditions may
taken when, on some models, the channel-path- be detected.
reset facility is busy performing the channel-path-
reset function for a previous execution of the RESUME SUBCHANNEL
RESET CHANNEL PATH instruction.
RSCH [S]

Condition code 3 is set and no other action is 'B238' ////////////////
taken when, on some models, the designated
channel path is not operational for the execution 16 31
of RESET CHANNEL PATH. On these models,
the channel path is not operational for the exe- The channel subsystem is signaled to perform the
cution of RESET CHANNEL PATH when the des- resume function at the designated subchannel.
ignated channel path is not physically available.
General register 1 contains the subsystem-
If the channel-path-reset facility is busy and the identification word, which designates the sub-
designated channel path is not physically avail- channel at which the resume function is to be
able, it depends on the model whether condition performed.
code 2 or 3 is set.
The subchannel is made resume-pending.
RESET CHANNEL PATH can encounter the
program exceptions listed below. Bit positions Logically prior to the setting of condition code 0
32-55 of general register 1 must contain zeros; and only if the subchannel is currently in the sus-
otherwise, an operand exception is recognized. pended state, path-not-operational conditions at
the subchannel, if any, are cleared.
Resulting Condition Code:
0 Function initiated The channel subsystem is signaled to asynchro-
1 -- nously perform the resume function. The resume
2 Busy function is summarized below in the section

Chapter 14. I/O Instructions 14-9


Associated Functions and is described in detail valid device number assigned to it, or is not
in Start Function and Resume Function on enabled.
page 15-17.
RESUME SUBCHANNEL can encounter the
Condition code 0 is set to indicate that the actions program exceptions listed below. Bit positions
described above have been taken. 32-47 of general register 1 must contain the value
0001 hex; otherwise, an operand exception is
Associated Functions recognized.

Subsequent to the execution of RESUME SUB- Resulting Condition Code:


CHANNEL, the channel subsystem asynchro-
0 Function initiated
nously performs the resume function. Except
1 Status-pending
when the subchannel is subchannel-active, if the
2 Function not applicable
execution of RESUME SUBCHANNEL results in
3 Not operational
the setting of condition code 0, performance of the
resume function causes execution of a currently
Program Exceptions:
suspended channel program to be resumed with
the associated device, provided that the suspend Operand
flag for the current CCW has been set to zero by Privileged operation
the program. If the suspend flag remains set to
one, execution of the channel program remains Programming Notes:
suspended. But, if the subchannel is subchannel- 1. When channel-program execution is resumed
active at the time the execution of RESUME SUB- from the suspended state, the device views
CHANNEL results in the setting of condition code the resumption as the beginning of a new
0, then it is unpredictable whether execution of the chain of commands. When the suspension of
current program is resumed or whether it is found channel-program execution occurs and the
by the resume function that the subchannel has device requires that certain commands be first
become suspended in the interim. The sub- or appear only once in a chain of commands
channel is found to be suspended by the resume (for example, direct-access-storage devices),
function only if the subchannel is status-pending the program must ensure that the appropriate
with intermediate status when the resume-pending commands in the proper sequence are
condition is recognized by the channel subsystem. fetched by the channel subsystem after
(See Start Function and Resume Function on channel-program execution is resumed. One
page 15-17.) way the program can ensure proper
sequencing of commands at the device is by
Special Conditions allowing the I/O interruption to occur for an
intermediate interruption condition due to sus-
Condition code 1 is set and no other action is
pension.
taken when the subchannel is status-pending.
It is not reliable to notify the program that the
Condition code 2 is set and no other action is subchannel is suspended by using the PCI
taken when the resume function is not applicable. flag in the CCW that contains the S flag
The resume function is not applicable when the because the PCI I/O interruption may occur
subchannel (1) has any function other than the before the subchannel is suspended. The
start function alone specified, (2) has no function SCSW would indicate that an I/O operation is
specified, (3) is resume-pending, or (4) does not in progress at the subchannel and device in
have suspend control specified for the start func- this case.
tion in progress.
The suspend flag of the target CCW should
be set to zero before RESUME SUB-
Condition code 3 is set and no other action is
CHANNEL is executed; otherwise, it is pos-
taken when the subchannel is not operational for
sible that the resume-pending condition may
the resume function. A subchannel is not opera-
be recognized and the CCW refetched while
tional for the resume function if the subchannel is
the suspend flag is still one, in which case the
not provided in the channel subsystem, has no
resume-pending condition would be reset, and

14-10 z/Architecture Principles of Operation


the execution of the channel program would value, and the specified address is passed to the
be suspended. If the suspend flag of the facility.
target CCW is set to zero before the execution
of RESUME SUBCHANNEL, the channel General register 1 contains the absolute address
program is not suspended, provided that the to be used as the address-limit value. The speci-
subchannel is not subchannel-active at the fied address must be on a 64K-byte boundary and
time the execution of RESUME SUB- may designate a maximum absolute storage
CHANNEL results in the setting of condition address of 2,147,418,112 (7FFF0000 hex) regard-
code 0. If condition code 0 is set while the less of whether the central processor is operating
subchannel is still subchannel-active, it is in the 24-bit, 31-bit, or 64-bit addressing mode.
unpredictable whether the resume-pending Bits 0-31 of general register 1 are ignored and bit
condition is recognized by the channel sub- 32 must be zero.
system or whether it is found by the resume
function that the subchannel has become sus- General register 1 has the following format:
pended in the interim. The subchannel is
/
found to be suspended by the resume function /// Address-Limit Value
only if the subchannel is status-pending with /
intermediate status at the time the resume- 32 63
pending condition is recognized. When the
subchannel is suspended, the execution of Associated Functions
TEST SUBCHANNEL, which clears the inter-
mediate interruption condition, also clears the The value that is used by the address-limit-
indication of resume-pending. checking facility when determining whether to
permit or prohibit a data access is called the
2. Some models recognize a resume-pending
address-limit value. The initialized address-limit
condition only after a CCW having a valid S
value is zero. The initial address-limit value is
flag set to one is fetched. Therefore, if a sub-
used by the address-limit-checking facility until the
channel is resume-pending and, during exe-
facility recognizes a signal (caused by the exe-
cution of the channel program, no CCW is
cution of SET ADDRESS LIMIT) to use a specified
fetched having a valid S flag set to one, the
address. The recognition of this specified address
subchannel remains resume-pending until the
as the new address-limit value occurs asynchro-
primary interruption condition is cleared by
nously with respect to the execution of SET
TEST SUBCHANNEL.
ADDRESS LIMIT.
3. Path availability is not tested during the exe-
cution of RESUME SUBCHANNEL. Instead, If address-limit checking is specified for a sub-
path availability is tested when the channel channel, then whether the specified address is
subsystem begins performance of the resume used by the address-limit-checking facility (when
function. determining whether to permit or prohibit a data
access) depends on whether SET ADDRESS
4. The contents of the CCW fetched during per-
LIMIT was executed before, during, or after the
formance of the resume function may be dif-
execution of START SUBCHANNEL for that sub-
ferent from the contents of the same CCW
channel. If SET ADDRESS LIMIT is executed
when it was previously fetched and contained
before START SUBCHANNEL, then the specified
a valid S flag.
address is used by the address-limit-checking
facility. If SET ADDRESS LIMIT is executed
SET ADDRESS LIMIT during or after the execution of START SUB-
CHANNEL, then it is unpredictable whether the
SAL [S]
specified address is used by the address-limit-
'B237' //////////////// checking facility for that particular start function.
For a description of the manner in which address-
16 31
limit checking is performed, see Address-Limit
Checking on page 17-17.
The address-limit-checking facility is signaled to
use the specified address as the address-limit

Chapter 14. I/O Instructions 14-11


Special Conditions Measurement-Block-Update Control (M): Bit 62
of general register 1 is the measurement-mode-
SET ADDRESS LIMIT can encounter the program control bit that controls the measurement-block-
exceptions listed below. General register 1 must update mode. When bit 62 of general register 1 is
be designated on a 64K byte boundary, and bit 32 one and conditions allow, the measurement-block-
of general register 1 must be zero; otherwise, an update facility is signaled to asynchronously make
operand exception condition is recognized. the measurement-block-update mode active. In
addition, the measurement-block origin (MBO)
Condition Code: The code remains unchanged. address (in general register 2) and the
measurement-block key (MBK) (in general register
Program Exceptions: 1) are passed to the measurement-block-update
Operand facility. The asynchronous functions that are per-
Privileged operation formed by the measurement-block-update facility
are summarized below in the section Associated
Functions and are described in detail in Channel-
SET CHANNEL MONITOR Subsystem Monitoring on page 17-1.
SCHM [S]
When bit 62 of general register 1 is zero and con-
'B23C' //////////////// ditions allow, the measurement-block-update

16 31 mode is made inactive if it is active or remains


inactive if it is inactive. The contents of bit posi-
tions 32-35 (MBK) of general register 1 and the
The monitoring modes of the channel subsystem contents of general register 2 are ignored.
are made either active or inactive, depending on
the setting of the measurement-mode-control bits Device-Connect-Time-Measurement Control
in general register 1. Depending on the setting of (D): Bit 63 of general register 1 is the
the measurement-mode-control bit for measurement-mode-control bit that controls the
measurement-block update, the channel sub- device-connect-time-measurement mode. When
system is signaled to make the mode active, or bit 63 is one and conditions allow, the device-
the mode is made inactive. If the measurement- connect-time-measurement mode is made active if
mode-control bit for measurement-block update is it is inactive or remains active if it is active. When
one, the measurement-block origin and the bit 63 is zero and conditions allow, the device-
measurement-block key are passed to the channel connect-time-measurement mode is made inactive
subsystem. Depending on the setting of the if it is active or remains inactive if it is inactive.
measurement-mode-control bit for device-connect
time, the mode is made active or inactive. Bit positions 36-61 of general register 1 are
reserved and must contain zeros; otherwise, an
General register 1 has the following format: operand exception is recognized.
/
///MBK MD General register 2 has the following format:
/
32 36 62 63
Measurement Block Origin

63
Ignored: Bit positions 0-31 of general register 1
are ignored. Measurement-Block Origin (MBO): Bit positions
0-63 of general register 2 contain the absolute
Measurement-Block Key (MBK): Bit positions
address of the measurement-block origin (MBO).
32-35 of general register 1 contain the
When bit 62 of general register 1 is one, the MBO
measurement-block key. When bit 62 is one,
address designates the beginning of the
MBK specifies the access key that is to be used
measurement-block area. The origin of the
by the channel subsystem when it accesses the
measurement-block area must be designated on a
measurement-block area. Otherwise, MBK is
32-byte boundary. The MBO address is used by
ignored.

14-12 z/Architecture Principles of Operation


the channel subsystem to locate measurement is enabled for measurement by this facility already
blocks. When bit 62 of general register 1 is zero, has a start function in progress when the signal is
the contents of general register 2 are ignored. generated, it is unpredictable when measurement
data for that subchannel is stored by using the
If the channel-subsystem timer that is used by the MBK and MBO associated with that signal.
channel-subsystem-monitoring facilities is in the
error state, the state is reset. This happens inde- While the measurement-block-update mode is
pendent of the setting of the two measurement- active, performance measurements are accumu-
mode-control bits. (See Channel-Subsystem lated for subchannels that are enabled for
Timing on page 17-1 for a description of the measurement-block update. Measurements for a
timing facilities.) subchannel are accumulated in a single 32-byte
measurement block within the measurement-block
Associated Functions area. A subchannel is enabled for the
measurement-block-update mode by setting the
When the measurement-block-update facility is measurement-block-update-enable bit to one in
signaled (by means of SET CHANNEL MONITOR) the SCHIB and then executing MODIFY SUB-
to make the measurement-block-update mode CHANNEL for that subchannel. The measure-
active, the functions that are performed by the ment block that is used to accumulate
facility depend on whether or not the mode is measurements for a subchannel is determined by
already active when the signal is generated. the measurement-block index that is contained in
the subchannel.
If the measurement-block-update mode is inactive
when the signal is generated, the mode remains When the device-connect-time-measurement
inactive until the measurement-block-update mode is active, measurements of the length of
facility recognizes the signal. When the time that the device is actively communicating with
measurement-block-update facility recognizes the the channel subsystem during the execution of a
signal, the measurement-block-update mode is channel program are accumulated for subchannels
made active, and the MBK and MBO associated that are enabled for device-connect-time measure-
with that signal (that is, the MBK and MBO that ment. Measurements for a subchannel are pro-
were passed when the signal was generated) are vided in the ESW of the IRB. A subchannel is
used to control the storing of measurement data. enabled for device-connect-time-measurement
mode by setting the device-connect-time-
If the measurement-block-update mode is active measurement-enable bit to one in the SCHIB and
when the signal is generated, the mode remains then executing MODIFY SUBCHANNEL for that
active, and the MBK and MBO associated with the subchannel.
execution of a previous SET CHANNEL
MONITOR instruction continue to be used to For a more detailed description of the
control the storing of measurement data until the measurement-block-update mode, the format and
measurement-block-update facility recognizes the contents of the measurement block, and the
signal. When the measurement-block-update device-connect-time-measurement mode, see
facility recognizes the signal, the MBK and MBO Channel-Subsystem Monitoring on page 17-1.
associated with that signal are used instead of the
MBK and MBO associated with the execution of a Special Conditions
previous SET CHANNEL MONITOR instruction.
SET CHANNEL MONITOR can encounter the
In either of the above cases, the measurement- program exceptions listed below. Bits 36-61 of
block-update facility recognizes the signal during, general register 1 must be zeros, and the MBO
or subsequent to, the execution of the SET address specified in general register 2 must be
CHANNEL MONITOR instruction that caused the designated on a 32-byte boundary when bit 62 (M)
signal to be generated and logically prior to the of general register 1 is one; otherwise, an operand
performance of any start function that is initiated exception is recognized.
by the subsequent execution of START SUB-
CHANNEL for a subchannel that is enabled for Condition Code: The code remains unchanged.
measurement by this facility. If a subchannel that

Chapter 14. I/O Instructions 14-13


Program Exceptions: Associated Functions
Operand
Subsequent to the execution of START SUB-
Privileged operation
CHANNEL, the channel subsystem asynchro-
Programming Note: When the channel sub- nously performs the start function.
system is initialized, the measurement-block-
update and device-connect-time-measurement The contents of the ORB, other than the fields that
modes are made inactive. must contain all zeros, are checked for validity. In
some models, the fields of the ORB that must
contain zeros are also checked asynchronously
START SUBCHANNEL (rather than during the execution of the instruc-
SSCH D(B) [S] tion). When invalid fields are detected asynchro-
nously, the subchannel becomes status-pending
'B233' B D with primary, secondary, and alert status and with

16 2 31 deferred condition code 1 and program check indi-


cated. (See Program Check on page 16-24.) In
this situation, the I/O operation or chain of I/O
The channel subsystem is signaled to asynchro-
operations is not initiated at the device, and the
nously perform the start function for the associ-
condition is indicated by the start-pending bit
ated device, and the execution parameters that
being stored as one when the SCSW is cleared by
are contained in the designated ORB are placed
the execution of TEST SUBCHANNEL. (See
at the designated subchannel. (See Operation-
Subchannel-Status Word on page 16-6).
Request Block on page 15-21.)
In some models, path availability is tested asyn-
General register 1 contains the subsystem-
chronously (rather than as part of the execution of
identification word, which designates the sub-
the instruction). When no channel path is avail-
channel that is to be started. The second-operand
able for selection, the subchannel becomes
address is the logical address of the ORB and is
status-pending with primary and secondary status
designated on a word boundary.
and with deferred condition code 3 indicated. The
I/O operation or chain of I/O operations is not initi-
The execution parameters contained in the ORB
ated at the device, and this condition is indicated
are placed at the subchannel.
by the start-pending bit being stored as one when
When START SUBCHANNEL is executed and the the SCSW is cleared by the execution of TEST
subchannel is status-pending with only secondary SUBCHANNEL.
status and the extended-status-word format bit (L
If conditions allow, a channel path is chosen and
bit) is zero, the status-pending condition is dis-
execution of the channel program that is desig-
carded at the subchannel.
nated in the ORB is initiated. (See Start Function
The subchannel is made start-pending, and the and Resume Function on page 15-17.)
start function is indicated at the subchannel.
Special Conditions
Logically prior to the setting of condition code 0,
Condition code 1 is set and no other action is
path-not-operational conditions at the subchannel,
taken if the subchannel is status-pending when
if any, are cleared.
START SUBCHANNEL is executed. In some
The channel subsystem is signaled to asynchro- models, condition code 1 is not set when the sub-
nously perform the start function. The start func- channel is status-pending with only secondary
tion is summarized below in the section status; instead, the status-pending condition is dis-
Associated Functions and is described in detail carded.
in Start Function and Resume Function on
Condition code 2 is set and no other action is
page 15-17.
taken when a start, halt, or clear function is cur-
Condition code 0 is set to indicate that the actions
described above have been taken.

14-14 z/Architecture Principles of Operation


rently in progress at the subchannel (see Func- STORE CHANNEL PATH STATUS
tion Control (FC) on page 16-12).
STCPS D(B) [S]
Condition code 3 is set and no other action is
taken when the subchannel is not operational for 'B23A' B D

START SUBCHANNEL. A subchannel is not 16 2 31
operational for START SUBCHANNEL if the sub-
channel is not provided in the channel subsystem,
A channel-path-status word of up to 256 bits is
has no valid device number associated with it, or
stored at the designated location.
is not enabled.
The second-operand address is the logical
A subchannel is also not operational for START
address of the location where the channel-path-
SUBCHANNEL, in some models, when no
status word is to be stored and is designated on a
channel path is available for selection. In these
32-byte boundary.
models, the lack of an available channel path is
detected as part of START SUBCHANNEL exe-
The channel-path-status word indicates which
cution. In other models, channel path availability
channel paths are actively communicating with a
is only tested as part of the asynchronous start
device at the time STORE CHANNEL PATH
function.
STATUS is executed. Bit positions 0-255 corre-
spond, respectively, to the channel paths having
START SUBCHANNEL can encounter the
the channel-path identifiers 0-255. Each of the
program exceptions listed below. The execution
256 bits at the designated location is set to one,
of START SUBCHANNEL is suppressed on all
set to zero, or left unchanged, as follows:
addressing and protection exceptions. In word 1
of the ORB, bits 13 and 25-30 must be zeros, and For all channel paths in the configuration that
in word 2 of the ORB, bit 0 must be 0; otherwise, are actively communicating with devices at the
in some models, an operand exception is recog- time STORE CHANNEL PATH STATUS is
nized. In other models, an I/O-interruption condi- executed, the corresponding bits are stored as
tion is generated indicating program check as part ones.
of the asynchronous start function.
For all channel paths that are (1) provided in
the system (PIM bit in the PMCW is one) and
Bit positions 32-47 of general register 1 must
(2) in the configuration but not currently being
contain the value 0001 hex; otherwise, an operand
used by the channel subsystem in actively
exception is recognized.
communicating with devices, the corre-
The second operand must be designated on a sponding bits are stored as zeros.
word boundary; otherwise, a specification excep- For all channel paths that are not provided in
tion is recognized, and the execution of START the system (PIM bit in the PMCW is zero), the
SUBCHANNEL is suppressed. corresponding bits either are not stored or are
stored as zeros.
Resulting Condition Code:
For all channel paths in the configuration that
0 Function initiated are in the channel-path-terminal state or are
1 Status-pending not physically available (the corresponding
2 Busy PAM bit in the PMCW is zero), the corre-
3 Not operational sponding bits are stored as zeros.

Program Exceptions: Special Conditions


Access (fetch, operand 2)
Operand STORE CHANNEL PATH STATUS can encounter
Privileged operation the program exceptions listed below. The exe-
Specification cution of STORE CHANNEL PATH STATUS is
suppressed on all addressing and protection
exceptions. The second operand must be desig-

Chapter 14. I/O Instructions 14-15


nated on a 32-byte boundary; otherwise, a specifi- designated location and condition code 0 to be
cation exception is recognized. set. A pending CRW can only be stored by exe-
cuting STORE CHANNEL REPORT WORD and,
Condition Code: The code remains unchanged. once stored, is no longer pending. Thus, each
pending CRW is presented only once to the
Program Exceptions: program.
Access (store, operand 2)
Privileged operation When no channel reports are pending in the
Specification channel subsystem, execution of STORE
CHANNEL REPORT WORD causes zeros to be
Programming Notes: stored at the designated location and condition
code 1 to be set.
1. To ensure a consistent interpretation of
channel-path-status-word bits, the program Special Conditions
should, prior to the initial use of the area,
store zeros at the location where the channel- STORE CHANNEL REPORT WORD can
path-status word is to be stored. encounter the program exceptions listed below.
The execution of STORE CHANNEL REPORT
STORE CHANNEL REPORT WORD is suppressed on all addressing and pro-
tection exceptions. The second operand must be
WORD designated on a word boundary; otherwise, a
STCRW D(B) [S] specification exception is recognized.

'B239' B D Resulting Condition Code:

16 2 31 0 CRW stored
1 Zeros stored
A CRW containing information affecting the 2 --
channel subsystem is stored at the designated 3 --
location.
Program Exceptions:
The second-operand address is the logical Access (store, operand 2)
address of the location where the CRW is to be Privileged operation
stored and is designated on a word boundary. Specification

When a malfunction or other condition affecting Programming Notes:


channel-subsystem operation is recognized, a
channel report (consisting of one or more CRWs) 1. CRW overflow conditions may occur if STORE
describing the condition is made pending for CHANNEL REPORT WORD is not executed
retrieval and analysis by the program. The to clear pending channel reports. If the over-
channel report contains information concerning the flow condition is encountered, one or more
identity and state of a facility of the channel sub- channel-report words have been lost. (See
system following the detection of the malfunction Channel-Subsystem Recovery on
or other condition. For a description of the page 17-19 for details.)
channel report, the CRW, and program-recovery 2. A pending CRW can be cleared by any CPU
actions related to the channel subsystem, see in the configuration executing STORE
Channel-Subsystem Recovery on page 17-19. CHANNEL REPORT WORD, regardless of
whether a machine-check interruption has
When one or more channel reports are pending, occurred in any CPU.
the instruction causes a CRW to be stored at the

14-16 z/Architecture Principles of Operation


STORE SUBCHANNEL Resulting Condition Code:
0 SCHIB stored
STSCH D(B) [S]

1 --
'B234' B D 2 --
3 Not operational
16 2 31
Program Exceptions:
Control and status information for the designated Access (store, operand 2)
subchannel is stored in the designated SCHIB. Operand
Privileged operation
General register 1 contains the subsystem-
Specification
identification word, which designates the sub-
channel for which the information is to be stored. Programming Notes:
The second-operand address is the logical
address of the SCHIB and is designated on a 1. Device status that is stored in the SCSW may
word boundary. include device-busy, control-unit-busy, or
control-unit-end indications.
The information that is stored in the SCHIB con- 2. The information that is stored in the SCHIB is
sists of the path-management-control word, the obtained from the subchannel. The STORE
SCSW, and three words of model-dependent infor- SUBCHANNEL instruction does not cause the
mation. (See Subchannel-Information Block on channel subsystem to interrogate the
page 15-1.) addressed device.
The execution of STORE SUBCHANNEL does not 3. STORE SUBCHANNEL may be executed at
change any information contained in the sub- any time to sample conditions existing at the
channel. subchannel, without causing any pending
status conditions to be cleared.
Condition code 0 is set to indicate that control and
4. Repeated execution of STORE SUB-
status information for the designated subchannel
CHANNEL without an intervening delay (for
has been stored in the SCHIB. Whenever the
example, to determine when a subchannel
execution of STORE SUBCHANNEL results in the
changes state) should be avoided because
setting of condition code 0, the information in the
repeated accesses of the subchannel by the
SCHIB indicates a consistent state of the sub-
CPU may delay or prohibit access of the sub-
channel.
channel by the channel subsystem to update
the subchannel.
Special Conditions

Condition code 3 is set and no other action is TEST PENDING INTERRUPTION


taken when the designated subchannel is not
operational for STORE SUBCHANNEL. A sub- TPI D(B) [S]

channel is not operational for STORE SUB- 'B236' B D
CHANNEL if the subchannel is not provided in the
channel subsystem. 16 2 31

STORE SUBCHANNEL can encounter the The I/O-interruption code for a pending I/O inter-
program exceptions listed below. Bit positions ruption at the subchannel is stored at the location
32-47 of general register 1 must contain the value designated by the second-operand address, and
0001 hex; otherwise, an operand exception is the pending I/O-interruption request is cleared.
recognized.
The second-operand address, when nonzero, is
The second operand must be designated on a the logical address of the location where the two-
word boundary; otherwise, a specification excep- word I/O-interruption code, consisting of words 0
tion is recognized. and 1, is to be stored. The second-operand

Chapter 14. I/O Instructions 14-17


address must be designated on a word boundary; CHANNEL or MODIFY SUBCHANNEL, this field
otherwise, a specification exception is recognized. contains zeros.

If the second-operand address is zero, the three- Interruption-Identification Word: Word 2, when
word I/O-interruption code, consisting of words stored, contains the interruption-identification
0-2, is stored at real locations 184-195. In this word, which further identifies the source of the
case, low-address protection and key-controlled I/O-interruption. Word 2 is stored only when the
protection do not apply. second-operand address is zero. The interruption-
identification word is defined as follows:
In the access-register mode, when the second-
operand address is zero, it is unpredictable
ISC
whether access-register translation occurs for
access register B. If the translation occurs, the 2 5 31
resulting address-space-control element is not
used; that is, the interruption code still is stored at Interruption Subclass (ISC): Bit positions 2-4 of
real locations 184-195. the interruption-identification word contain a value
in the range 0-7 that specifies the I/O-interruption
Pending I/O-interruption requests are accepted
subclass associated with the subchannel for which
only for those I/O-interruption subclasses allowed
the pending I/O-interruption request was cleared.
by the I/O-interruption subclass mask in control
register 6 of the CPU executing the instruction. If Special Conditions
no I/O-interruption requests exist that are allowed
by control register 6, the I/O-interruption code is TEST PENDING INTERRUPTION can encounter
not stored, the second-operand location is not the program exceptions listed below. The exe-
modified, and condition code 0 is set. cution of TEST PENDING INTERRUPTION is sup-
pressed on all addressing and protection
If a pending I/O-interruption request is accepted, exceptions. The second operand must be desig-
the I/O-interruption code is stored, the pending nated on a word boundary; otherwise, a specifica-
I/O-interruption request is cleared, and condition tion exception is recognized.
code 1 is set. The I/O-interruption code that is
stored is the same as would be stored if an I/O Resulting Condition Code:
interruption had occurred. However, PSWs are
not swapped, as when an I/O-interruption occurs. 0 Interruption code not stored
1 Interruption code stored
The I/O-interruption code that is stored during exe- 2 --
cution of the instruction is defined as follows: 3 --

Program Exceptions:
Word Subsystem-Identification Word
Access (store, operand 2, second-operand
1 Interruption Parameter address nonzero only)

2Interruption-Identification Word Privileged operation
Specification
31
Programming Notes:
Subsystem-Identification Word (SID): See 1. TEST PENDING INTERRUPTION should only
I/O-Instruction Formats on page 14-1. be executed with a second-operand address
of zero when I/O interruptions are masked off.
Interruption Parameter: Word 1 contains a four- Otherwise, an I/O-interruption code stored by
byte parameter which is specified by the program the instruction may be lost if an I/O inter-
and which previously was passed to the sub- ruption occurs. The I/O-interruption code that
channel in word 0 of the ORB or the PMCW. identifies the source of an I/O interruption
When a device presents alert status and the inter- taken subsequent to TEST PENDING INTER-
ruption parameter was not passed previously to RUPTION is also stored at real locations
the subchannel by executing START SUB-

14-18 z/Architecture Principles of Operation


184-195, replacing an I/O-interruption code described above) is stored in the IRB, and no con-
that was stored by the instruction. ditions or indications are cleared. Condition code
1 is set to indicate that these actions have been
2. In the access-register mode, when the
taken.
second-operand address is zero, an access
exception is recognized if access-register
Figure 14-2 describes which conditions and indi-
translation occurs and the access register is in
cations are cleared by TEST SUBCHANNEL when
error. This exception can be prevented by
the subchannel is status-pending. All other condi-
making the B field zero or by placing
tions and indications at the subchannel remain
00000000 hex, 00000001 hex, or any other
unchanged.
valid contents in the access register.

Subchannel Condition\
TEST SUBCHANNEL
Alert Int Pri Sec Status
TSCH D(B) [S] StatusStatusStatusStatus Pdg
Field Pdg Pdg Pdg Pdg Alone
'B235' B D
Function C Nc C C C
16 2 31 Control

Activity Cp Nr Cp Cp Cp
Control and status information for the subchannel Control
is stored in the designated IRB.
Status Cs Cs Cs Cs Cs
Control
General register 1 contains the subsystem-
identification word, which designates the sub- N condition C Nr C C C
channel for which the information is to be stored.

The second-operand address is the logical Explanation:
address of the IRB and is designated on a word
boundary. \ Note that the rightmost column applies to
status-pending when it is alone. The other
four status-pending conditions result in the
The information that is stored in the IRB consists clearing actions given. These actions apply
of the SCSW, the extended-status word, and the both when a single status-pending condition
occurs and when a combination of the four
extended-control word. (See Interruption- status-pending conditions occurs. In the
Response Block on page 16-6.) combination case, all the clearing actions
of the individual cases apply.
If the subchannel is status-pending, the status- C Cleared.
Cp The resume-, start-, halt-, clear-pending,
pending bit of the status-control field is stored as and suspended conditions are cleared.
one. Whether or not the subchannel is status- Cs The status-pending condition is cleared.
pending has an effect on the functions that are Nc Not changed unless function control indicates
the halt function and activity control
performed when TEST SUBCHANNEL is exe- indicates suspended. If both the halt
cuted. function and suspended are indicated, condi-
tions are cleared as for status-pending
When the subchannel is status-pending and TEST alone.
Nr Not changed unless activity control indicates
SUBCHANNEL is executed, information (as suspended and function control indicates the
described above) is stored in the IRB, followed by start function with or without the halt func-
the clearing of certain conditions and indications tion. If the halt function is indicated, the
conditions are cleared as for status-pending
that exist at the subchannel (as described in alone. If only the start function is indi-
Figure 14-2). If an I/O-interruption request is cated, the resume-pending condition and the
pending for the subchannel, the request is N condition are cleared.

cleared. Condition code 0 is set to indicate that
these actions have been taken. Figure 14-2. Conditions and Indications Cleared at the
Subchannel by TEST SUBCHANNEL
When the subchannel is not status-pending and
TEST SUBCHANNEL is executed, information (as

Chapter 14. I/O Instructions 14-19


Special Conditions 3. When an I/O interruption occurs, it is the
result of a status-pending condition at the sub-
Condition code 3 is set and no other action is channel, and typically TEST SUBCHANNEL is
taken when the subchannel is not operational for executed to clear the status. TEST SUB-
TEST SUBCHANNEL. A subchannel is not opera- CHANNEL may also be executed at any other
tional for TEST SUBCHANNEL if the subchannel time to sample conditions existing at the sub-
is not provided, has no valid device number asso- channel.
ciated with it, or is not enabled.
4. Repeated execution of TEST SUBCHANNEL
TEST SUBCHANNEL can encounter the program to determine when a start function has been
exceptions listed below. When the execution of completed should be avoided because there
TEST SUBCHANNEL is terminated on addressing are conditions under which the completion of
and protection exceptions, the state of the sub- the start function may or may not be indicated.
channel is not changed. Bit positions 32-47 of For example, if the channel subsystem is
general register 1 must contain the value 0001 holding an interface-control-check (IFCC) con-
hex; otherwise, an operand exception is recog- dition in abeyance (for any subchannel)
nized. because another subchannel is already status-
pending, and if the start function being tested
The second operand must be designated on a by TEST SUBCHANNEL has as the only path
word boundary; otherwise, a specification excep- available for selection the channel path with
tion is recognized. the IFCC condition, then the start function
may not be initiated until the status-pending
Resulting Condition Code: condition in the other subchannel is cleared,
allowing the IFCC condition to be indicated at
0 IRB stored; subchannel status-pending
the subchannel to which it applies.
1 IRB stored; subchannel not status-pending
2 -- 5. Repeated execution of TEST SUBCHANNEL
3 Not operational without an intervening delay, for example, to
determine when a subchannel changes state,
Program Exceptions: should be avoided because repeated
accesses of the subchannel by the CPU may
Access (store, operand 2)
delay or prohibit accessing of the subchannel
Operand
by the channel subsystem. Execution of
Privileged operation
TEST SUBCHANNEL by multiple CPU's for
Specification
the same subchannel at approximately the
same time may have the same effect and also
Programming Notes:
should be avoided.
1. Device status that is stored in the SCSW may
6. The priority of I/O-interruption handling by a
include device-busy, control-unit-busy, or
CPU can be modified by execution of TEST
control-unit-end indications.
SUBCHANNEL. When TEST SUBCHANNEL
2. The information that is stored in the IRB is is executed and the designated subchannel
obtained from the subchannel. The TEST has an I/O-interruption request pending, that
SUBCHANNEL instruction does not cause the I/O-interruption request is cleared and the
channel subsystem to interrogate the SCSW is stored, without regard to any previ-
addressed device. ously established priority. The relative priority
of the remaining I/O-interruption requests is
unchanged.

14-20 z/Architecture Principles of Operation


Chapter 15. Basic I/O Functions
Control of Basic I/O Functions . . . . . . . . . 15-1 Operation-Request Block . . . . . . . . . 15-21
Subchannel-Information Block . . . . . . . 15-1 Channel-Command Word . . . . . . . . . 15-26
Path-Management-Control Word . . . . 15-2 Command Code . . . . . . . . . . . . . . 15-28
Subchannel-Status Word . . . . . . . . . 15-7 Designation of Storage Area . . . . . . . 15-28
Model-Dependent Area . . . . . . . . . . 15-7 Chaining . . . . . . . . . . . . . . . . . . . 15-30
Summary of Modifiable Fields . . . . . . 15-7 Data Chaining . . . . . . . . . . . . . . 15-32
Channel-Path Allegiance . . . . . . . . . . . 15-10 Command Chaining . . . . . . . . . . . 15-33
Working Allegiance . . . . . . . . . . . . . 15-11 Skipping . . . . . . . . . . . . . . . . . . . 15-34
Active Allegiance . . . . . . . . . . . . . . 15-11 Program-Controlled Interruption . . . . . 15-34
Dedicated Allegiance . . . . . . . . . . . 15-11 CCW Indirect Data Addressing . . . . . . 15-35
Channel-Path Availability . . . . . . . . . 15-12 Suspension of Channel-Program
Control-Unit Type . . . . . . . . . . . . . 15-12 Execution . . . . . . . . . . . . . . . . 15-37
Clear Function . . . . . . . . . . . . . . . . . 15-13 Commands and Flags . . . . . . . . . . . 15-39
Clear-Function Path Management . . . . 15-13 Branching in Channel Programs . . . . . 15-40
Clear-Function Subchannel Modification .15-13 Transfer in Channel . . . . . . . . . . . 15-40
Clear-Function Signaling and Command Retry . . . . . . . . . . . . . . 15-41
Completion . . . . . . . . . . . . . . . 15-14 Concluding I/O Operations Prior to Initiation 15-41
Halt Function . . . . . . . . . . . . . . . . . . 15-14 Concluding I/O Operations during Initiation .15-41
Halt-Function Path Management . . . . . 15-15 Immediate Conclusion of I/O Operations . . 15-42
Halt-Function Signaling and Completion .15-15 Concluding I/O Operations During Data
Start Function and Resume Function . . . . 15-17 Transfer . . . . . . . . . . . . . . . . . . 15-42
Start-Function and Resume-Function Channel-Path-Reset Function . . . . . . . . 15-44
Path Management . . . . . . . . . . . 15-18 Channel-Path-Reset-Function Signaling . 15-44
Execution of I/O Operations . . . . . . . . . 15-20 Channel-Path-Reset
Blocking of Data . . . . . . . . . . . . . . 15-21 Function-Completion Signaling . . . . 15-44

Some I/O instructions specify to the channel sub- Subchannel-Information Block


system that a function is to be performed. Collec-
tively, these functions are referred to as the basic The subchannel-information block (SCHIB) is the
I/O functions. The basic I/O functions are the operand of the MODIFY SUBCHANNEL and
clear, halt, start, resume, and channel-path-reset STORE SUBCHANNEL instructions. The two
functions. rightmost bits of the SCHIB address are zeros,
designating the SCHIB on a word boundary. The
SCHIB contains three major fields: the path-
Control of Basic I/O Functions management-control word (PMCW), the
Information that is present at the subchannel con- subchannel-status word (SCSW), and a model-
trols how the clear, halt, resume, and start func- dependent area. (Figure 15-1 on page 15-2
tions are performed. This information is shows the format of the PMCW, and Figure 16-2
communicated to the program in the subchannel- on page 16-7 shows the format of the SCSW.)
information block during execution of STORE
SUBCHANNEL. STORE SUBCHANNEL is used to store the
current PMCW, the SCSW, and model-dependent
data of the designated subchannel. MODIFY
SUBCHANNEL alters certain PMCW fields at the
subchannel. When the program needs to change
the contents of one or more of the PMCW fields,
the normal procedure is (1) to execute STORE
SUBCHANNEL to obtain the current contents,
(2) to perform the required modifications to the

Copyright IBM Corp. 1990, 2000 15-1


PMCW in main storage, and (3) to execute parameter can be set to any value by START
MODIFY SUBCHANNEL to pass the new informa- SUBCHANNEL and MODIFY SUBCHANNEL.
tion to the subchannel. The SCHIB has the fol- The initial value of the interruption parameter is
lowing format: zero.

I/O-Interruption Subclass Code (ISC): Bits 2-4


Word
of word 1 contain a binary value (0-7) which corre-
1 sponds to the bit position of the I/O-interruption
subclass-mask bit in control register 6 of each
2
Path-Management-Control Word CPU in the configuration. The setting of that
3 mask bit in control register 6 of a CPU controls
the recognition of interruption requests relating to
4

this subchannel by that CPU (see Priority of
5 Interruptions on page 16-5). The ISC can be set
to any value by MODIFY SUBCHANNEL. The
6 initial value of the ISC is zero.

7
Reserved: Bits 0-1 and 5-7 of word 1 are
8 Subchannel-Status Word reserved and stored as zeros by STORE SUB-

9 CHANNEL. Bits 0-1 and 6-7 must be zeros when
MODIFY SUBCHANNEL is executed; otherwise,
1 an operand exception is recognized. Bit 5 of word

11 Model-Dependent Area 1 is ignored when MODIFY SUBCHANNEL is exe-
cuted.
12
Enabled (E): Bit 8 of word 1, when one, indi-
cates that the subchannel is enabled for all I/O
Path-Management-Control Word functions. When the E bit is zero, status pre-
Words 0-6 of the SCHIB contain the path- sented by the device is not made available to the
management-control word (PMCW). The PMCW program, and I/O instructions other than MODIFY
has the format shown in Figure 15-1 when the SUBCHANNEL and STORE SUBCHANNEL that
subchannel is valid (see Device Number Valid are executed for the designated subchannel cause
(V) on page 15-4). condition code 3 to be set. The E bit can be
either zero or one when MODIFY SUBCHANNEL
The format of the PMCW is as follows: is executed; initially, all subchannels are not
enabled; IPL causes the IPL I/O device to become

Interruption Parameter enabled.

1ISC ELMMMDTV Device Number
Limit Mode (LM): Bits 9-10 of word 1 define the
2 LPM PNOM LPUM PIM limit mode (LM) of the subchannel. The limit

3 MBI POM PAM mode is used by the channel subsystem when

4 CHPID- CHPID-1 CHPID-2 CHPID-3 address-limit checking is invoked for an I/O opera-

5 CHPID-4 CHPID-5 CHPID-6 CHPID-7
tion. (See Address-Limit Checking on
page 17-17.) Address-limit checking is under the
6 S
control of the address-limit-checking-control bit
8 16 24 31
that is passed to the subchannel in the operation-
Figure 15-1. PMCW Format request block (ORB) during the execution of
START SUBCHANNEL. (See Address-Limit-
Interruption Parameter: Bits 0-31 of word 0 Checking Control (A) on page 15-23.) The defi-
contain the interruption parameter that is stored as nitions of the LM bits, whose values are used
word 1 of the interruption code. The interruption during data transfer, are as follows:

15-2 z/Architecture Principles of Operation


Bit Bit Bit Device-Connect-Time-Measurement
9 10 Function 12 Enable:
0 0 Initialized value. No limit checking is 0 Initialized value. The subchannel is not
performed for this subchannel. enabled for device-connect-time measure-
0 1 Data address must be equal to, or ment. Storing of the device-connect-time
greater than, the current address limit. interval (DCTI) in the extended-status word
1 0 Data address must be less than the (ESW) does not occur.
current address limit. 1 The subchannel is enabled for device-
1 1 Reserved. connect-time measurement. If the device-
connect-time-measurement mode is active
Bits 9 and 10 can contain any of the first three bit and timing facilities are provided for the sub-
combinations shown above when MODIFY SUB- channel, the value of the DCTI is stored in
CHANNEL is executed. Specification of the the ESW when TEST SUBCHANNEL is exe-
reserved bit combination in the operand causes an cuted after channel-program execution is
operand exception to be recognized when completed or suspended at the subchannel,
MODIFY SUBCHANNEL is executed. provided no error conditions described by
subchannel logout have been detected. If
Measurement Mode Enable (MM): Bits 11 and the device-connect-time-measurement mode
12 of word 1 enable the measurement-block- is inactive, no measurement values are
update mode and the device-connect-time- stored in the ESW.
measurement mode, respectively, of the
subchannel. These bits can contain any value The meaning of the measurement-mode (MM)
when MODIFY SUBCHANNEL is executed; ini- enable bits described above applies when the
tially, neither measurement mode is enabled. The timing-facility bit for the subchannel is one. When
definition of each of these bits is as follows: the timing-facility bit is zero, the effect of the MM
bits is changed, as described below under Timing
Bit Facility. (For more discussion on measurement
11 Measurement-Block-Update Enable: modes, see Measurement-Block Update on
0 Initialized value. The subchannel is not page 17-2 and Device-Connect-Time
enabled for measurement-block update. Measurement on page 17-8.)
Storing of measurement-block data does not
occur. Multipath Mode (D): Bit 13 of word 1, when one,
1 The subchannel is enabled for indicates that the subchannel operates in multi-
measurement-block update. If the path mode when executing an I/O operation or
measurement-block-update mode is active, chain of I/O operations. For proper operation in
measurement data is accumulated in the multipath mode when more than one channel path
measurement block at the time channel- is available for selection, the associated device
program execution is completed or sus- must have the dynamic-reconnection feature
pended at the subchannel or completed at installed and must be set up for multipath-mode
the device, as appropriate, provided no error operation. During performance of a start function
conditions described by subchannel logout in multipath mode, a device is allowed to request
have been detected. (See Measurement- service from the channel subsystem over any of
Block Update on page 17-2.) If the the channel paths indicated at the subchannel as
measurement-block-update mode is inactive, being available for selection (see Logical-Path
no measurement-block data is stored. Mask (LPM) on page 15-4 and Path-Available
Mask (PAM) on page 15-7). Bit 13, when zero,
indicates that the subchannel operates in single-
path mode when executing an I/O operation or
chain of I/O operations. In single-path mode, the
entire start function is performed by using the
channel path on which the first command of the
I/O operation or chain of I/O operations was
accepted by the device. The D bit can be either
zero or one when MODIFY SUBCHANNEL is exe-

Chapter 15. Basic I/O Functions 15-3


cuted; initially, the subchannel is in single-path exists for that channel path. When a dedicated
mode. allegiance exists at the subchannel for a channel
path, the logical availability of the channel path is
Timing Facility (T): Bit 14 of word 1, when one, ignored whenever a clear, halt, resume, or start
indicates that the channel-subsystem-timing facility function is performed. (See Channel-Path
is available for the subchannel and is under the Allegiance on page 15-10). If the subchannel is
control of the two measurement-mode-enable bits idle, the logical availability of the channel path is
(MM) and SET CHANNEL MONITOR. Bit 14, ignored whenever the control unit initiates a
when zero, indicates that the channel-subsystem- request to present alert status to the channel sub-
timing facility is not available for the subchannel. system. The logical availability of a channel path
When bit 14 is zero, the START SUBCHANNEL associated with the subchannel can be changed
count is the only measurement data that can be by setting the corresponding LPM bit in the SCHIB
accumulated in the measurement block for the and then executing MODIFY SUBCHANNEL, or
subchannel. Storing of the START SUB- by setting the corresponding LPM bit in the ORB
CHANNEL count is under the control of bit 11 and and then executing START SUBCHANNEL. Ini-
SET CHANNEL MONITOR, as described above tially, each installed channel path is logically avail-
under Measurement Mode Enable. Similarly, if able.
the T bit is zero, no device-connect-time-interval
(DCTI) values can be measured for the sub- Path-Not-Operational Mask (PNOM): Any of
channel. (See Measurement-Block Update on bits 8-15 of word 2, when one, indicates that a
page 17-2 and Device-Connect-Time path-not-operational condition has been recog-
Measurement on page 17-8.) nized on the corresponding channel path. Each
bit of the PNOM corresponds one-for-one, by rela-
Device Number Valid (V): Bit 15 of word 1, tive bit position, with a CHPID located in an asso-
when one, indicates that the device-number field ciated byte of words 4 and 5 of the SCHIB. The
(see below) contains a valid device number and channel subsystem recognizes a path-not-
that a device associated with this subchannel may operational condition when, during an attempted
be physically installed. Bit 15, when zero, indi- device selection in order to perform a clear, halt,
cates that the subchannel is not valid, there is no resume, or start function, the device associated
I/O device currently associated with the sub- with the subchannel appears not operational on a
channel, and the contents of all other defined channel path that is operational for the sub-
fields of the SCHIB are unpredictable. channel. When a path-not-operational condition is
recognized, the state of the channel path changes
Device Number: Bits 16-31 of word 1 contain from operational for the subchannel to not opera-
the binary representation of the four-digit tional for the subchannel. A channel path is oper-
hexadecimal device number of the device that is ational for the subchannel if the associated device
associated with this subchannel. The device appeared operational on that channel path the last
number is a system-unique parameter that is time the channel subsystem attempted device
assigned to the subchannel and the associated selection in order to perform a clear, halt, resume,
device when the device is installed. or start function. A device appears to be opera-
tional on a channel path when the device
Logical-Path Mask (LPM): Bits 0-7 of word 2 responds to an attempted device selection. A
indicate the logical availability of channel paths to channel path is not operational for the subchannel
the associated device. Each bit of the LPM corre- if the associated device appeared not operational
sponds one-for-one, by relative bit position, with a on that channel path the last time the channel
CHPID located in an associated byte of words 4 subsystem attempted device selection in order to
and 5 of the SCHIB. A bit set to one means that perform a clear, halt, resume, or start function.
the corresponding channel path is logically avail- Any of bits 8-15 of word 2, when zero, indicates
able; a zero means the corresponding channel that a path-not-operational condition has not been
path is logically not available. When a channel recognized on the corresponding channel path.
path is logically not available, the channel sub-
system does not use that channel path to initiate Initially, each of the eight possible channel paths
performance of any clear, halt, resume, or start associated with each subchannel is considered to
function, except when a dedicated allegiance be operational, regardless of whether the respec-

15-4 z/Architecture Principles of Operation


tive channel paths are installed or available; there-
POM Value and
fore, unless a path-not-operational condition is Device State Value of Specified Bit
recognized during initial program loading, the before Selection Subsequent to Selection
PMCW, if stored, contains a PNOM of all zeros if Attempt Attempt
stored prior to executing a CLEAR SUB-
Device SCSW
CHANNEL, HALT SUBCHANNEL, RESUME SUB- State POM POM PNOM N Bit
CHANNEL, or START SUBCHANNEL instruction.
OP 1
Programming Note: The PNOM indicates those NOP
channel paths for which a path-not-operational OP 1 1
NOP 1 1 1
condition has been recognized during the perform-
ance of the most recent clear, halt, resume, or Explanation:
start function. That is, the PNOM indicates which
Device state as it appears on the
of the channel paths associated with the sub- corresponding channel path.
channel have made a transition from the opera-
tional to the not-operational state for the Prior to the attempted device selection
during the performance of either a start
subchannel during the execution of the most function or a resume function while the
recent clear, halt, resume, or start function. subchannel is suspended, the channel
However, the transition of a channel path from the subsystem clears all existing
not-operational to the operational state for the path-not-operational conditions, if any,
at the designated subchannel.
subchannel is indicated in the POM. Therefore,
the POM must be examined in order to determine The N bit (bit 15, word of the SCSW) is
whether any of the channel paths that are associ- indicated to the program and the N
condition is cleared at the subchannel when
ated with a designated subchannel are operational TEST SUBCHANNEL is executed the next time
for the subchannel. the subchannel is status-pending for other
than intermediate status alone provided that
it is not also suspended.
Furthermore, while performing either a start or
resume function, the transition of a channel path NOP The device is not operational on the
from the not-operational to the operational state corresponding channel path.

for the subchannel is recognized by the channel
OP The device is operational on the
subsystem only during the initiation sequence for corresponding channel path.
the first command specified by the start function or
implied by the resume function. Therefore, a Figure 15-2. Resulting POM, PNOM, and N-Bit Values
channel path which is currently not operational for Subsequent to Selection Attempt
the subchannel can be used by the device associ-
ated with the subchannel when reconnecting to Last-Path-Used Mask (LPUM): Bits 16-23 of
the channel subsystem in order to continue word 2 indicate the channel path that was last
command chaining; however, the channel sub- used for communicating or transferring information
system does not indicate a transition of that between the channel subsystem and the device.
channel path from the not-operational to the oper- Each bit of the LPUM corresponds one-for-one, by
ational state for the subchannel in the POM. relative bit position, with a CHPID located in an
associated byte of words 4 and 5 of the SCHIB.
Each bit of the LPUM is stored as zero except for
the bit which corresponds to the channel path last
used whenever one of the following occurs:
1. The first command of a start or resume func-
tion is accepted by the device (see Activity
Control (AC) on page 16-13).
2. The device and channel subsystem are
actively communicating when the suspend
function is performed for the channel program
in execution.

Chapter 15. Basic I/O Functions 15-5


3. Status has been accepted from the device Path-Operational Mask (POM): Bits 16-23 of
that is recognized as an interruption condition, word 3 indicate the last known operational state of
or a condition has been recognized that sup- the device on the corresponding channel paths.
presses command chaining (see Interruption Each bit of the POM corresponds one-for-one, by
Conditions on page 16-2). relative bit position, with a CHPID located in an
associated byte of words 4 and 5 of the SCHIB. If
4. An interface-control-check condition has been
the associated device appeared operational on a
recognized (see Interface-Control Check on
channel path the last time the channel subsystem
page 16-28), and no subchannel-logout infor-
attempted device selection in order to perform a
mation is currently present in the subchannel.
clear, halt, resume, or start function, then the
The LPUM field of the PMCW contains the most channel path is operational for the subchannel,
recent setting. The initial value of the LPUM is and the bit corresponding to the channel path in
zero. the POM is one. A device appears to be opera-
tional on a channel path when the device
Path-Installed Mask (PIM): Bits 24-31 of word 2 responds to an attempted device selection. A
indicate which of the channel paths 0-7 to the I/O channel path is also operational for the sub-
device are physically installed. The PIM indicates channel if MODIFY SUBCHANNEL is executed
the validity of the channel-path identifiers (see and the bit corresponding to that channel path in
below) for those channel paths that are physically the POM is specified as one.
installed. Each bit of the PIM corresponds one-
for-one, by relative bit position, with a CHPID If the associated device appeared not operational
located in an associated byte of words 4 and 5 of on a channel path the last time the channel sub-
the SCHIB. A PIM bit stored as one indicates that system attempted device selection in order to
the corresponding channel path is installed. A perform a clear, halt, resume, or start function,
PIM bit stored as zero indicates that the corre- then the channel path is not operational for the
sponding channel path is not installed. The PIM subchannel, and the bit corresponding to the
always reflects the full complement of installed channel path in the POM is zero. A channel path
paths to the device, regardless of how the system is also not operational for the subchannel if
is configured. Therefore, some of the channel MODIFY SUBCHANNEL is executed and the bit
paths indicated in the PIM may not be physically corresponding to that channel path in the POM is
available in that configuration, as indicated by the specified as zero.
bit settings in the path-available mask (see below).
The initial value of the PIM indicates all the phys- If the device associated with the subchannel
ically installed channel paths to the device. appears not operational on a channel path that is
operational for the subchannel during an
Measurement-Block Index (MBI): Bits 0-15 of attempted device selection in order to perform a
word 3 form an index value used by the clear, halt, resume, or start function, then the
measurement-block-update facility when the channel subsystem recognizes a path-not-
measurement-block-update mode is active (see operational condition. If an SCSW is subse-
SET CHANNEL MONITOR on page 14-12) and quently stored, then bit 15 of word 0 is one,
the subchannel is enabled for the mode (see indicating the path-not-operational condition.
Measurement Mode Enable (MM) on When a path-not-operational condition is recog-
page 15-3). When the measurement-block index nized, the state of the channel path changes from
is used, five zero bits are appended on the right, operational for the subchannel to not operational
and the result is added to the measurement-block- for the subchannel.
origin address designated by SET CHANNEL
MONITOR. The calculated address, called the When the channel path is not operational for the
measurement-block address, designates the subchannel, a path-not-operational condition
beginning of a 32-byte storage area where meas- cannot be recognized. Moreover, a channel path
urement data is stored. (See Measurement that is not operational for the subchannel may be
Block on page 17-3.) The MBI can contain any available for selection; if the channel subsystem
value when MODIFY SUBCHANNEL is executed; chooses that channel path while executing a path-
the initial value is zero. management operation, and if during the
attempted device selection, the device appears to

15-6 z/Architecture Principles of Operation


be operational again on that channel path, then fier of a physical channel path to a control unit by
the state of the channel path changes from not which the associated I/O device may be accessed.
operational for the subchannel to operational for A unique CHPID is assigned to each physical
the subchannel. channel path in the system.

The POM can contain any value when MODIFY Different devices that are accessible by the same
SUBCHANNEL is executed. Initially, each of the physical channel path have, in their respective
eight possible channel paths associated with each subchannels, the same CHPID value. The CHPID
subchannel is considered to be operational, value may, however, appear in each subchannel
regardless of whether the respective channel in different locations in the CHPID fields 0-7.
paths are installed or available; therefore, unless a
path-not-operational condition is recognized during Subchannels that share an identical set of channel
initial program loading, the PMCW, if stored, con- paths have the same corresponding PIM bits set
tains a POM of all ones if stored prior to executing to ones. The channel-path identifiers (CHPIDs)
a CLEAR SUBCHANNEL, HALT SUBCHANNEL, for these channel paths are the same and occupy
RESUME SUBCHANNEL, or START SUB- the same respective locations in each SCHIB.
CHANNEL instruction.
Reserved: Bits 0-30 of word 6 are reserved and
Path-Available Mask (PAM): Bits 24-31 of word are stored as zeros by STORE SUBCHANNEL.
3 indicate the physical availability of installed They must be zeros when MODIFY SUB-
channel paths. Each bit of the PAM corresponds CHANNEL is executed; otherwise, an operand
one-for-one, by relative bit position, with a CHPID exception condition is recognized.
located in an associated byte of words 4 and 5 of
the SCHIB. A PAM bit of one indicates that the Concurrent Sense (S): Bit 31 of word 6, when
corresponding channel path is physically available one, indicates that the subchannel is in
for use in accessing the device. A PAM bit of concurrent-sense mode. When the subchannel is
zero indicates the channel path is not physically in concurrent-sense mode, whenever the sub-
available for use in accessing the device. When a channel becomes status-pending with alert status,
channel path is not physically available, it may, and the status byte accepted from the device con-
depending upon the model and the extent of tains the unit-check indication, then the channel
failure, be used during performance of the reset- subsystem may attempt to retrieve sense informa-
channel-path function. A channel path which is tion from the associated device and place that
physically available may become not physically sense information in the extended-control word.
available as a result of reconfiguring the system,
or this may occur as a result of the performance Subchannel-Status Word
of the channel-path-reset function. The initial Words 7-9 of the SCHIB contain a copy of the
value of the PAM reflects the set of channel paths SCSW. The format of the SCSW is described in
by which the I/O device is physically accessible at Subchannel-Status Word on page 16-6. The
the time of initialization. SCSW is stored by executing either STORE SUB-
CHANNEL or TEST SUBCHANNEL (see STORE
Note: The change in the availability of a channel
SUBCHANNEL on page 14-17 and TEST
path affects all subchannels having access to that
SUBCHANNEL on page 14-19).
channel path. Whenever the setting of a PAM bit
is referred to in conjunction with the availability
status of a channel path, for brevity, reference is
Model-Dependent Area
Words 10-12 of the SCHIB contain model-
made in this chapter to a single PAM bit instead of
dependent information.
to the respective PAM bits in all of the affected
subchannels.
Summary of Modifiable Fields
Channel-Path Identifiers (CHPIDs): Words 4 Figure 15-3 on page 15-8 lists the initial settings
and 5 contain eight one-byte channel-path identi- for fields in a subchannel whose device-number-
fiers corresponding to channel paths 0-7 of the valid bit is one and indicates what modifies the
PIM. A CHPID is valid if the corresponding PIM fields.
bit is one. Each valid CHPID contains the identi-
All of the PMCW fields contain meaningful infor-

Chapter 15. Basic I/O Functions 15-7


mation when STORE SUBCHANNEL is executed the device-number-valid bit is one. The validity of
and the designated subchannel is idle. Sub- the subchannel fields that are modifiable by the
channel fields that the channel subsystem does channel subsystem depends on the state of the
not modify contain valid information whenever subchannel at the time STORE SUBCHANNEL is
STORE SUBCHANNEL is executed, provided that executed.

Modified
Program Modifies by Channel
Subchannel Field Initial Value by Executing Subsystem

Interruption parameter Zeros MSCH,SSCH No



I/O-interruption subclass code Zeros MSCH No

Enabled (E) Zero MSCH No

Limit mode (LM) Zeros MSCH No

Measurement mode (MM) Zeros MSCH Yes

Multipath mode (D) Zero MSCH No

Timing facility (T) Installed value None No

Device number valid (V) Installed value None No

Device number Installed value None No

Logical-path mask (LPM) Path-installed-mask MSCH,SSCH No
value

Path-not-operational mask (PNOM) Zeros CSCH,SSCH,RSCH Yes

Last-path-used mask (LPUM) Zeros CSCH Yes

Path-installed mask (PIM) Installed value None No

Measurement-block index (MBI) Zeros MSCH No

Path-operational mask (POM) Ones CSCH,MSCH,RSCH Yes

Path-available mask (PAM) Installed values None Yes

Channel-path ID -7 (CHPID) Installed value None No

Concurrent sense (S) Zero MSCH No

Subchannel-status word (SCSW) Zero TSCH Yes

Model-dependent area \ None \

Figure 15-3 (Part 1 of 2). Modification of Subchannel Fields

15-8 z/Architecture Principles of Operation



Explanation:

\ Model-dependent.

These fields are not meaningful if the subchannel is not valid.
Initializing of a subchannel is performed when I/O-system reset occurs.
(See the section I/O-System Reset in Chapter 17, I/O Support
Functions.) One or more of the installed-value parameters that are
unmodifiable by the program may be set when the subchannel is idle. In
this case, all the program-modifiable fields are set to their initialized
values, and the program is notified of such a change by a channel report.
(See the section Channel-Report Word in Chapter 17, I/O
Support Functions.)

Subchannel fields that are not normally modifiable by the channel subsystem
may be modified as a result of dynamic configuration changes or as a
result of external actions. When this occurs, the program is notified
of the change by a channel report that is made pending at the time of the
change.

When any of the following error conditions associated with the
measurement-block-update mode are detected, the measurement-block-update
mode is disabled by the channel subsystem (bit 11, word 1, of the SCHIB
zero) in the affected subchannel. The device-connect-time-measurement-
enable bit (bit 12, word 1 of the SCHIB) is never modified by the channel
subsystem.

Measurement program check
Measurement protection check
Measurement data check
Measurement key check

This information is entered when the channel-subsystem configuration is
established.

The mask is modified by the resume function only when the subchannel is in
the suspended state at the time RESUME SUBCHANNEL is executed.

The channel subsystem may modify the PAM to reflect changes in the system
configuration caused by partitioning or unpartitioning channel paths
because of reconfiguration or permanent failure of part of the I/O system.

Figure 15-3 (Part 2 of 2). Modification of Subchannel Fields

Chapter 15. Basic I/O Functions 15-9


Programming Notes: sponding POM bits have been set to zeros.
The next START SUBCHANNEL causes the
1. System performance may be degraded if the
channel subsystem to again attempt device
LPM is not used to make channel paths for
selection by choosing a channel path from
which a path-not-operational condition has
among all of the channel paths that are avail-
been indicated in the PNOM logically not
able for selection. If device selection is not
available.
successful and all channel paths available for
2. If, during the performance of a start function, a selection have again been chosen, deferred
channel path becomes not physically available condition code 3 is set, but the N bit in the
because a channel-path failure has been SCSW is zero. The POM contains zeros in at
recognized, continued performance of the start least those bit positions that correspond to the
function may be precluded. That is, the channel paths that are available for selection.
program may or may not be notified, and the (See Channel-Path Availability on
subchannel may remain in the subchannel- page 15-12 for a description of the term
and-device-active state until cleared by the available for selection.) When the N bit in the
performance of the clear function. SCSW is zero, the PNOM is also zero.
3. If the same MBI is placed in more than one 6. If the program is to detect path-not-operational
subchannel by the program, the channel- conditions, the PNOM should be inspected fol-
subsystem-monitoring facility updates the lowing the execution of TEST SUBCHANNEL
same locations with measurement data (which results in the setting of condition code
relating to more than one subchannel. In this zero and the valid storing of the N bit as one)
case, the values stored in the measurement and preceding the performance of another
data are unpredictable. (See Measurement- start, resume, halt, or clear function at the
Block Update on page 17-2.) subchannel.
4. Modification of the I/O configuration (reconfig-
uration) may be accomplished in various ways
depending on the model. If the reconfigura- Channel-Path Allegiance
tion procedure affects the physical availability The channel subsystem establishes allegiance
of a channel path, then any change in avail- conditions between subchannels and channel
ability can be detected by executing STORE paths. The kind of allegiance established at a
SUBCHANNEL for a subchannel that has subchannel for a channel path or set of channel
access to the channel path and by subse- paths depends upon the state of the subchannel,
quently examining the PAM bits of the SCHIB. the device, and the information, if any, transferred
5. The definitions of the PNOM, POM, and N bit between the channel subsystem and device. The
are such that a path-not-operational condition way in which path management is handled during
is reported to the program only the first time the performance of a clear, halt, resume, or start
the condition is detected by the channel sub- function is determined by the kind of allegiance, if
system after the corresponding POM bit is set any, currently recognized between a subchannel
to one. and a channel path.

For example, if the POM bit for every channel Performing the clear function at a subchannel
path available for selection is one and the clears any currently existing allegiance condition in
device appears not operational on all corre- the subchannel for all channel paths.
sponding channel paths while the channel
subsystem is attempting to initiate a start func- Performing the reset-channel-path function clears
tion at the device, the channel subsystem all currently existing allegiances for that channel
makes the subchannel status-pending, with path in all subchannels.
deferred condition code 3 and with the N bit
stored as one. The PNOM in the SCHIB indi- When a channel path becomes not physically
cates the channel path or channel paths that available, all internal indications of prior allegiance
appeared not operational, for which the corre- conditions are cleared in all subchannels having
access to the designated channel path.

15-10 z/Architecture Principles of Operation


Working Allegiance does not actively communicate with that device on
any other channel path. When the channel sub-
A subchannel has a working allegiance for a system accepts a no-longer-busy indication from
channel path when the subchannel becomes the device that does not cause an interruption
device-active on that channel path. Once a condition, this status does not constitute the initi-
working allegiance is established, the channel ation of active communication. An active alle-
subsystem maintains the working allegiance at the giance at a subchannel for a channel path is
subchannel for the channel path until either the terminated when the channel subsystem is no
subchannel is no longer device-active or a dedi- longer actively communicating with the I/O device
cated allegiance is recognized, whichever occurs on that channel path.
earlier. Unless a dedicated allegiance is recog-
A working allegiance can become an active alle-
nized, a working allegiance for a channel path is
giance.
extended to the set of channel paths that are
available for selection if the device is specified to
be operating in multipath mode (that is, the Dedicated Allegiance
multipath-mode bit is stored as one in the SCHIB).
Otherwise, the working allegiance remains only for If a channel path is physically available (that is,
that channel path over which the start function the corresponding PAM bit is one), a dedicated
was initiated. allegiance may be recognized for that channel
path. If a channel path is not physically available,
Once a working allegiance is established for a a dedicated allegiance cannot be recognized for
channel path or set of channel paths, the working the corresponding channel path. The channel
allegiance is not changed until the subchannel is subsystem establishes a dedicated allegiance at
no longer device-active or until a dedicated alle- the subchannel for a channel path when (1) the
giance is established. If the subchannel is oper- subchannel becomes status-pending with alert
ating in single-path mode, a working allegiance is status, and device status containing the unit-check
maintained only for a single path. indication is present but (2) concurrent-sense
information is not present at the subchannel. A
While a working allegiance exists at a subchannel, dedicated allegiance is maintained until the sub-
an active allegiance can occur only for a channel channel is no longer start-pending (unless it
path for which the working allegiance is being becomes suspended) or resume-pending following
maintained, unless the device is specified as oper- performance of the next start function, clear func-
ating in multipath mode. When the device is tion, or channel-path-reset function or the next
specified as operating in multipath mode, an resume function if applicable. If the subchannel
active allegiance may also occur for a channel becomes suspended, the dedicated allegiance
path that is not available for selection if the pres- remains until the resume function is initiated and
entation of status by the device on that channel the subchannel is no longer resume-pending.
path causes an alert interruption condition to be Unless a clear or channel-path-reset function is
recognized. performed, the subchannel establishes a working
allegiance when the dedicated allegiance ends.
A working allegiance is cleared in any subchannel This occurs when the subchannel becomes
having access to a channel path if the channel device-active. While a dedicated allegiance exists
path becomes not physically available. at a subchannel for a channel path, only that
channel path is available for selection until the
Active Allegiance dedicated-allegiance condition is cleared.

A subchannel has an active allegiance established A dedicated allegiance can become an active alle-
for a channel path no later than when active com- giance. While a dedicated allegiance exists, an
munication has been initiated on that channel path active allegiance can only occur for the same
with an I/O device. The subchannel can have an channel path.
active allegiance to only one channel path at a
time. While the subchannel has an active alle- A currently existing dedicated allegiance is cleared
giance for a channel path, the channel subsystem at any subchannel having access to a channel
path when the channel path becomes not phys-

Chapter 15. Basic I/O Functions 15-11


ically available or whenever the device appears
Value of
not operational on the channel path for which the Bit 'n' Channel-
dedicated allegiance exists. Path
PIMPAMLPMCondition Channel-Path State

Channel-Path Availability - X Not installed

1 - X Not physically available
When a channel path is not physically available,
the channel subsystem does not use the channel 1 1 X Not logically available
path to perform any of the basic I/O functions
except, in some cases, the channel-path-reset 1 1 1 Active Available for selection

function and does not respond to any control-unit- 1 1 1 Inactive Available for selection
initiated requests on that same channel path. If a
channel path is not physically available, the condi- Explanation:

tion is indicated by the corresponding path- - Bit value is not meaningful.
available-mask (PAM) bit being zero when STORE
SUBCHANNEL is executed (see Path-Available If the channel path is recognized as being
used in active communication with a device,
Mask (PAM) on page 15-7). Furthermore, if the the channel-path condition is described as
channel path is not physically available for the active. Otherwise, its condition is described
subchannel designated by STORE SUB- as inactive.

CHANNEL, then it is not physically available for A PAM bit cannot have the value one when the
any subchannel that has a device which is acces- corresponding PIM bit has the value zero.
sible by that channel path.
If a dedicated allegiance exists to the
channel path at the subchannel, the state of
Unless a dedicated allegiance exists at a sub- the bit is ignored, and the channel path is
channel for the channel path, a channel path considered to be available for selection.
becomes available for selection if it is logically
The channel path may appear to be active when
available and physically available (as indicated by a channel-path-terminal condition has been
the bits in the LPM and PAM corresponding to the recognized.
channel path being stored as ones when STORE
X Condition is not meaningful.
SUBCHANNEL is executed). If a dedicated alle-
giance exists at a subchannel for the channel
path, only that channel path is available for Figure 15-4. Path Condition and Path-Availability
Status for PIM, PAM, and LPM Values
selection, and the setting of the corresponding
LPM bit is ignored. If the channel path is currently
being used and a dedicated allegiance exists at Control-Unit Type
the subchannel for the channel path, selection of
the device is delayed until the channel path is no In Clear Function on page 15-13, Halt Function
longer being used. on page 15-14, and Start Function and Resume
Function on page 15-17, reference is made to
The availability status of the eight logical paths to type-1, type-2, and type-3 control units. For a
the associated device described in Figure 15-4 is description of these control-unit types, see the
determined by the hierarchical arrangement of the System Library publication IBM System/360 and
corresponding bit values contained in the PIM, System/370 I/O Interface Channel to Control Unit
PAM, and LPM and by existing conditions, if any, OEMI, GA22-6974. For the purposes of this defi-
recognized by the channel subsystem. nition, all control units attaching to a serial-I/O
interface are considered type-2 control units.

15-12 z/Architecture Principles of Operation


6. If the associated subchannel has no alle-
Clear Function giance for any channel path, if no last-used
Subsequent to the execution of CLEAR SUB- channel path is indicated, and if there exist
CHANNEL, the channel subsystem executes the one or more channel paths that are available
clear function. Performance of the clear function for selection, one of those channel paths is
consists in (1) executing a path-management chosen.
operation, (2) modifying fields at the subchannel, If none of the channel-path conditions listed above
(3) issuing the clear signal to the associated apply, no channel path is chosen.
device, and (4) causing the subchannel to be
made status-pending, indicating completion of the For item 4, for item 5 under the specified condi-
clear function. tions, and for item 6, the channel subsystem
chooses a channel path from a set of channel
Clear-Function Path Management paths. In these cases, the channel subsystem
may attempt to choose a channel path, provided
A path-management operation is executed as part that the following conditions do not apply:
of the clear function in order to examine channel- 1. A channel-path-terminal condition exists for
path conditions for the associated subchannel and the channel path.
to attempt to choose an available channel path on
which the clear signal can be issued to the associ- 2. Another subchannel has an active allegiance
ated device. for the channel path.
3. The device to be signaled is attached to a
Channel-path conditions are examined in the fol- type-1 control unit, and the subchannel for
lowing order: another device attached to the same control
1. If the channel subsystem is actively communi- unit has an allegiance to the same channel
cating or attempting to establish active com- path, unless the allegiance is a working alle-
munication with the device to be signaled, the giance and primary status has been accepted
channel path that is in use is chosen. by that subchannel.
2. If the channel subsystem is in the process of 4. The device to be signaled is attached to a
accepting a no-longer-busy indication (which type-3 control unit, and the subchannel for
will not cause an interruption condition to be another device attached to the same control
recognized) from the device to be signaled, unit has a dedicated allegiance to the same
and the associated subchannel has no alle- channel path.
giance to any channel path, the channel path
that is in use is chosen. Clear-Function Subchannel
3. If the associated subchannel has a dedicated Modification
allegiance for a channel path, that channel
path is chosen. Path-management-control indications at the sub-
channel are modified during performance of the
4. If the associated subchannel has a working
clear function. Effectively, this modification occurs
allegiance for one or more channel paths, one
after the attempt to choose a channel path, but
of those channel paths is chosen.
prior to the attempt to select the device to issue
5. If the associated subchannel has no alle- the clear signal. The path-management-control
giance for any channel path, if a last-used indications that are modified are as follows:
channel path is indicated, and if that channel
1. The state of all eight possible channel paths
path is available for selection, that channel
at the subchannel is set to operational for the
path is chosen. If that channel path is not
subchannel.
available for selection, either no channel path
is chosen or a channel path is chosen from 2. The last-path-used indication is reset to indi-
the set of channel paths, if any, that are avail- cate no last-used channel path.
able for selection (as though no last-used
3. Path-not-operational conditions, if any, are
channel path were indicated).
reset.

Chapter 15. Basic I/O Functions 15-13


Clear-Function Signaling and The Attempt to Issue the Clear Signal Is Not
Successful: When the channel subsystem
Completion attempts to issue the clear signal to the device,
the attempt may not be successful because of the
Subsequent to the attempt to choose a channel
following conditions:
path and the modification of the path-
management-control fields, the channel sub- 1. The control unit or device signals a busy con-
system, if conditions allow, attempts to select the dition when the channel subsystem attempts
device to issue the clear signal. (See Clear to select the device to issue the clear signal.
Signal on page 17-9.) Conditions associated 2. A path-not-operational condition is recognized
with the subchannel and the chosen channel path, when the channel subsystem attempts to
if any, affect (1) whether an attempt is made to select the device to issue the clear signal.
issue the clear signal, and (2) whether the attempt
to issue the clear signal is successful. Inde- 3. An error condition is encountered when the
pendent of these conditions, the subchannel is channel subsystem attempts to issue the clear
subsequently set status-pending and the perform- signal.
ance of the clear function is complete. These If any of the conditions above exist and the
conditions and their effect on the clear function channel subsystem either determines that the
are described as follows: attempt to issue the clear signal was not suc-
cessful or cannot determine whether the attempt
No Attempt Is Made to Issue the Clear Signal: was successful, the subchannel remains clear-
The channel subsystem does not attempt to issue pending and is set status-pending, and the per-
the clear signal to the device if any of the fol- formance of the clear function is complete.
lowing conditions exist:
1. No channel path was chosen. (See Clear- The Attempt to Issue the Clear Signal Is Suc-
Function Path Management on page 15-13.) cessful: When the channel subsystem deter-
mines that the attempt to issue the clear signal
2. The chosen channel path is no longer avail- was successful, the subchannel is no longer clear-
able for selection. pending and is set status-pending, and the per-
3. A channel-path-terminal condition exists for formance of the clear function is complete. When
the chosen channel path. the subchannel becomes status-pending, the I/O
operation, if any, with the associated device has
4. The chosen channel path is currently being
been terminated.
used to actively communicate with a different
device. Programming Note: Subsequent to the perform-
ance of the clear function, any nonzero status,
5. The device to be signaled is attached to a
except control-unit end alone, that is presented to
type-1 control unit, and the subchannel for
the channel subsystem by the device is passed to
another device attached to the same control
the program as unsolicited alert status. Unsolic-
unit has an allegiance to the same channel
ited status consisting of control-unit end alone or
path, unless the allegiance is a working alle-
zero status is not presented to the program.
giance and primary status has been accepted
by that subchannel.
6. The device to be signaled is attached to a Halt Function
type-3 control unit, and the subchannel for
Subsequent to the execution of HALT SUB-
another device attached to the same control
CHANNEL, the channel subsystem performs the
unit has a dedicated allegiance to the same
halt function. Performance of the halt function
channel path.
consists of (1) executing a path-management
If any of the conditions above exist, the sub- operation, (2) issuing the halt signal to the associ-
channel remains clear-pending and is set status- ated device, and (3) causing the subchannel to be
pending, and the performance of the clear function made status-pending, indicating completion of the
is complete. halt function.

15-14 z/Architecture Principles of Operation


Halt-Function Path Management may attempt to choose a channel path for which
the following conditions do not apply:
A path-management operation is executed as part 1. A channel-path-terminal condition exists for
of the halt function to examine channel-path condi- the channel path.
tions for the associated subchannel and to attempt
2. Another subchannel has an active allegiance
to choose a channel path on which the halt signal
for the channel path.
can be issued to the associated device.
3. The device to be signaled is attached to a
Channel-path conditions are examined in the fol- type-1 control unit, and the subchannel for
lowing order: another device attached to the same control
1. If the channel subsystem is actively communi- unit has an allegiance to the same channel
cating or attempting to establish active com- path, unless the allegiance is a working alle-
munication with the device to be signaled, the giance and primary status has been accepted
channel path that is in use is chosen. by that subchannel.

2. If the channel subsystem is in the process of 4. The device to be signaled is attached to a


accepting a no-longer-busy indication (which type-3 control unit, and the subchannel for
will not cause an interruption condition to be another device attached to the same control
recognized) from the device to be signaled, unit has a dedicated allegiance to the same
and the associated subchannel has no alle- channel path.
giance to any channel path, the channel path
that is in use is chosen. Halt-Function Signaling and
3. If the associated subchannel has a dedicated Completion
allegiance for a channel path, that channel
path is chosen. Subsequent to the attempt to choose a channel
path, the channel subsystem, if conditions allow,
4. If the associated subchannel has a working attempts to select the device to issue the halt
allegiance for one or more channel paths, one signal. (See Halt Signal on page 17-9.) Condi-
of those channel paths is chosen. tions associated with the subchannel and the
5. If the associated subchannel has no alle- chosen channel path, if any, affect (1) whether an
giance for any channel path, if a last-used attempt is made to issue the halt signal,
channel path is indicated, and if that channel (2) whether the attempt to issue the halt signal is
path is available for selection, that channel successful, and (3) whether the subchannel is
path is chosen. If that channel path is not made status-pending to complete the halt function.
available for selection, either no channel path These conditions and their effect on the halt func-
is chosen or a channel path is chosen from tion are described as follows:
the set of channel paths, if any, that are avail-
able for selection (as though no last-used No Attempt Is Made to Issue the Halt Signal:
channel path were indicated). The channel subsystem does not attempt to issue
the halt signal to the device if any of the following
6. If the associated subchannel has no alle- conditions exist:
giance for any channel path, if no last-used
channel path is indicated, and if there exist 1. No channel path was chosen. (See Halt-
one or more channel paths that are available Function Path Management.)
for selection, one of those channel paths is 2. The chosen channel path is no longer avail-
chosen. able for selection.
If none of the channel-path conditions listed above 3. A channel-path-terminal condition exists for
apply, no channel path is chosen. the chosen channel path.

For item 4, for item 5 under the specified condi- 4. The associated subchannel is status-pending
tions, and for item 6, the channel subsystem with other than intermediate status alone.
chooses a channel path from a set of channel 5. The device to be signaled is attached to a
paths. In these cases, the channel subsystem type-1 control unit, and the subchannel for

Chapter 15. Basic I/O Functions 15-15


another device attached to the same control The Attempt to Issue the Halt Signal Is Suc-
unit has an allegiance to the same channel cessful: When the channel subsystem deter-
path, unless the allegiance is a working alle- mines that the attempt to issue the halt signal was
giance and primary status has been accepted successful and ending status, if appropriate, has
by that subchannel. been received at the subchannel, the subchannel
is no longer halt-pending and is set status-
6. The device to be signaled is attached to a
pending, and the halt function is complete. When
type-3 control unit, and the subchannel for
the subchannel becomes status-pending, the I/O
another device attached to the same control
operation, if any, with the associated device has
unit has a dedicated allegiance to the same
been terminated. The conditions that affect the
channel path.
receipt of ending status at the subchannel, and
If the conditions described in items 3 on the effect of the halt signal at the device are
page 15-15, 5 on page 15-15, or 6 exist, the described in the following discussion.
associated subchannel remains halt-pending until
those conditions no longer exist. When the condi- When the subchannel is subchannel-and-device-
tions no longer exist (for the channel-path-terminal active or only device-active during the perform-
condition, when the condition no longer exists as a ance of the halt function, the state continues until
result of executing RESET CHANNEL PATH), the the subchannel is made status-pending because
channel subsystem attempts to issue the halt (1) the device has provided ending status or
signal to the device. (2) the channel subsystem has determined that
ending status is unavailable. When the sub-
If any of the remaining conditions above exist, the channel is idle, start-pending, start-pending and
subchannel remains halt-pending, is set status- resume-pending, suspended, or suspended and
pending, and the halt function is complete. resume-pending, or when the halt signal is issued
during command chaining after the receipt of
The Attempt to Issue the Halt Signal Is Not device end but before the next command is trans-
Successful: When the channel subsystem ferred to the device, no operation is in progress at
attempts to issue the halt signal to the device, the the device, and therefore no status is generated
attempt may not be successful because of the fol- by the device as a result of receiving the halt
lowing conditions: signal. When the subchannel is neither
1. The control unit or device signals a busy con- subchannel-active nor status-pending with inter-
dition when the channel subsystem attempts mediate status, and no errors are detected during
to select the device to issue the halt signal. the attempt to issue the halt signal to the device,
an interruption condition indicating status-pending
2. A path-not-operational condition is recognized alone is generated after the halt signal is issued.
when the channel subsystem attempts to
select the device to issue the halt signal. The effect of the halt signal at the device depends
3. An error condition is encountered when the partially on the type of device and its state. The
channel subsystem attempts to issue the halt effect of the halt signal on a device that is not
signal. active or that is executing a mechanical operation
in which data is not transferred across the channel
If the control unit or device signals a busy condi- path, such as rewinding tape or positioning a disk-
tion (item 1), the subchannel remains halt-pending access mechanism, depends upon the control-unit
until the internal indication of busy is reset. When or device model. If the device is executing a type
this event occurs, the channel subsystem again of operation that is unpredictable in duration or in
attempts to issue the halt signal to the device. which data is transferred across the channel path,
the control unit interprets the signal as one to ter-
If any of the remaining conditions above exists
minate the operation. Pending status conditions
and the channel subsystem either determines that
at the device are not reset. When the control unit
the attempt to issue the halt signal was not suc-
recognizes the halt signal, it immediately ceases
cessful or cannot determine whether the attempt
all communication with the channel subsystem
was successful, then the subchannel remains halt-
until it has reached the normal ending point. The
pending and is set status-pending, and the halt
function is complete.

15-16 z/Architecture Principles of Operation


control unit then requests selection by the channel the I/O operation is terminated, and the
subsystem to present any generated status. subchannel-status bits may reflect unusual condi-
tions that were detected. If the halt signal was
If the subchannel is involved in the data-transfer issued before all data designated for the operation
portion of an I/O operation, data transfer is termi- had been transferred, incorrect length is indicated,
nated during the performance of the halt function, subject to the control of the SLI flag in the current
and the device is logically disconnected from the CCW. The value in the count field of the associ-
channel path. If the halt function is addressed to ated SCSW is unpredictable.
a subchannel executing a chain of I/O operations
and the device has already provided channel end The second interruption condition occurs if
for the current I/O operation, the channel sub- device-end status was not presented with the
system causes the device to be disconnected and channel-end interruption condition. In this situ-
command chaining or command retry to be sup- ation, the subchannel-key, command-address, and
pressed. If the subchannel is executing a chain of count fields of the associated SCSW are not
I/O operations with the device and the halt signal meaningful.
is issued during command chaining at a point after
the receipt of device end for the previous I/O oper- When HALT SUBCHANNEL terminates an I/O
ation but before the next command is transferred operation, the method of termination differs from
to the device, the subchannel is made status- that used upon exhaustion of count or upon
pending with primary and secondary status imme- detection of programming errors to the extent that
diately after the halt signal is issued. The termination by HALT SUBCHANNEL is not contin-
device-status field of the SCSW contains zeros in gent on the receipt of a service request from the
this case. If the halt function is addressed to a associated device.
subchannel that is start-pending and the halt-
pending condition is recognized before initiation of Programming Notes:
the start function, initiation of the start function is 1. When, after an operation is terminated by
not attempted, and the subchannel becomes HALT SUBCHANNEL, the subchannel is
status-pending after the device has been signaled. status-pending with primary, primary and sec-
ondary, or secondary status, the extent of
When the subchannel is not executing an I/O data transferred as described by the count
operation with the associated device, the device is field is unpredictable.
selected, and an attempt is made to issue the halt
signal as the device responds. If the subchannel 2. When the path that is chosen by the path-
is in the device-active state, the subchannel does management operation has a channel-path-
not become status-pending until it receives the terminal condition associated with it, the halt
device-end status from the halted device. If the function remains pending until the condition no
subchannel is neither subchannel-and-device- longer exists. Until the condition is cleared,
active nor device-active, the subchannel becomes the associated subchannel cannot be used to
status-pending immediately after selecting the execute I/O operations, even if other channel
device and issuing the halt signal. The SCSW for paths become available for selection. CLEAR
the latter case has the status-pending bit set to SUBCHANNEL can be executed to terminate
one (see Status-Pending (Bit 31) on the halt-pending condition and make the sub-
page 16-18). channel usable.

The termination of an I/O operation by performing


the halt function may result in two distinct inter- Start Function and Resume
ruption conditions. Function
The first interruption condition occurs when the Subsequent to execution of START SUB-
device generates the channel-end condition. The CHANNEL and RESUME SUBCHANNEL, the
channel subsystem handles this condition as it channel subsystem performs the start and resume
would any other interruption condition from the functions, respectively, to initiate an I/O operation
device, except that the command address in the with the associated device. Performance of a
associated SCSW designates the point at which start or resume function consists of: (1) executing

Chapter 15. Basic I/O Functions 15-17


a path-management operation, (2) executing an start function remains pending until the
I/O operation or chain of I/O operations with the internal indication of busy is reset for that
associated device, and (3) causing the sub- channel path. When the internal indication of
channel to be made status-pending, indicating busy is reset, the performance of the pending
completion of the start function. (Completion of a start function is initiated on that channel path.
start function is described in Chapter 16, I/O
3. If no channel paths are available for selection
Interruptions on page 16-1.) The start function
and no dedicated allegiance exists in the sub-
initiates the execution of a channel program that is
channel for a channel path, a channel path is
designated in the ORB, which in turn is desig-
not chosen.
nated as the operand of START SUBCHANNEL,
in contrast to the resume function which initiates 4. If all channel paths that are available for
the execution of a suspended channel program, if selection have been tried and one or more of
any, beginning at the CCW that caused suspen- them are being used to actively communicate
sion; otherwise, the resume function is performed with other devices, or, alternatively, if the
as if it were a start function (see Resume- channel subsystem has encountered either a
Pending (Bit 20) on page 16-13). control-unit-busy or device-busy condition on
one or more of those channel paths, or a
combination of those conditions on one or
Start-Function and more of those channel paths, the start function
Resume-Function Path remains pending at the subchannel until a
Management channel path, control unit, or device, as appro-
priate, becomes available.
A path-management operation is executed by the
5. If (1) the start function is to be initiated on a
channel subsystem during the performance of
channel path with a device attached to a
either a start or resume function to choose an
type-1 control unit and (2) no other device is
available channel path that can be used for device
attached to the same control unit whose sub-
selection to initiate an I/O operation with that
channel has either a dedicated allegiance to
device. The actions taken are as follows:
the same channel path or a working alle-
1. If the subchannel is currently start-pending giance to the same channel path where
and device-active, the start function remains primary status has not been received for that
pending at the subchannel until the secondary subchannel, then that channel path is chosen
status for the previous start function has been if it is available for selection; otherwise, that
accepted from the associated device and the channel path is not chosen. If, however,
subchannel is made start-pending alone. another channel path to the device is available
When the status is accepted and it does not for selection and if no allegiances exist as
describe an alert interruption condition, the described above, that channel path is chosen.
subchannel is not made status-pending, and If no other channel paths are available for
the performance of the pending start function selection, the start or resume function, as
is subsequently initiated. If the status appropriate, remains pending until a channel
describes an alert interruption condition, the path becomes available.
subchannel becomes status-pending with sec-
6. If the device is attached to a type-3 control
ondary and alert status, the pending start
unit and if at least one other device is
function is not initiated, deferred condition
attached to the same control unit whose sub-
code 1 is set, and the start-pending bit
channel has a dedicated allegiance to the
remains one. If the subchannel is currently
same channel path, another channel path that
start-pending alone, the performance of the
is available for selection may be chosen, or
start function is initiated as described below.
the start function remains pending until the
2. If a dedicated allegiance exists at the sub- dedicated allegiance for the other device is
channel for a channel path, the channel sub- cleared.
system chooses that path for device selection.
7. If a channel path has been chosen and a busy
If a busy condition is encountered while
indication is received during device selection
attempting to select the device and a dedi-
to initiate execution of the first command of a
cated allegiance exists at the subchannel, the

15-18 z/Architecture Principles of Operation


pending channel program, the channel path tions at the subchannel, if any, are preserved
over which the busy indication is received is until the subchannel next becomes clear-
not used again for that device or control unit pending, start-pending, or resume-pending (if
(depending on the device-busy or control-unit- the subchannel was suspended), at which
busy indication received) until the internal indi- time the path-not-operational conditions are
cation of busy is reset. cleared. If, however, the corresponding
channel path is not operational for the sub-
8. If, during an attempt to select the device in
channel, a path-not-operational condition is
order to initiate execution of the first command
not recognized. When the device appears not
specified for the start or implied for the
operational during the selection attempt to
resume function (as described in action 7 on
transfer the first command on a channel path
page 15-18), the channel subsystem receives
that is available for selection, one of the fol-
a busy indication, it performs one of the fol-
lowing actions occurs:
lowing actions:
a. If a dedicated allegiance exists for that
a. If the device is specified to be operating in
channel path, then it is the only channel
multipath mode and the busy indication
path that is available for selection; there-
received is device busy, then the start or
fore, further attempts to initiate the start or
resume function remains pending until the
resume function are abandoned, and an
internal indication of busy is reset. (See
interruption condition is recognized.
Multipath Mode (D) on page 15-3.)
b. If no dedicated allegiance exists and there
b. If the device is specified to be operating in
are alternate channel paths available for
multipath mode and the busy indication
selection which have not been tried, one
received is control unit busy, or if the
of those channel paths is chosen to
device is specified to be operating in
attempt device selection and transfer the
single-path mode, the channel subsystem
first command.
attempts selection of the device by
choosing an alternate channel path that is c. If no dedicated allegiance exists, no alter-
available for selection and continues the nate channel paths are available for
path-management operation until either selection which have not been tried, and
the start or resume function is initiated or the device has appeared operational on at
selection of the device has been least one of the channel paths that were
attempted on all channel paths that are tried, the start or resume function remains
available for selection. If the start or pending at the subchannel until either a
resume function has not been initiated by channel path, a control unit, or the device,
the channel subsystem after all channel as appropriate, becomes available.
paths available for selection have been
d. If no dedicated allegiance exists, no alter-
chosen, the start or resume function
nate channel paths are available for
remains pending until the internal indi-
selection which have not been tried, and
cation of busy is reset.
the device has appeared not operational
c. If the subchannel has a dedicated alle- on all channel paths that were tried,
giance, then action 2 on page 15-18 further attempts to initiate the start or
applies. resume function are abandoned, and an
interruption condition is recognized.
9. When, during the selection attempt to transfer
the first command, the device appears not 10. When the subchannel is active and an I/O
operational and the corresponding channel operation is to be initiated with a device, all
path is operational for the subchannel, a path- device selections occur according to the
not-operational condition is recognized, and LPUM indication if the multipath mode is not
the state of the channel path changes at the specified at the subchannel. For example, if
subchannel from operational for the sub- command chaining is specified, the channel
channel to not operational for the subchannel subsystem transfers the first and all subse-
(see Path-Not-Operational Mask (PNOM) on quent commands describing a chain of I/O
page 15-4). The path-not-operational condi- operations over the same channel path.

Chapter 15. Basic I/O Functions 15-19


1. Setup
Execution of I/O Operations
a. A set-multipath-mode type of command
After a channel path is chosen, the channel sub- must be successfully executed by the
system, if conditions allow, initiates execution of device on each channel path that is to be
an I/O operation with the associated device. Exe- a member of the multipath group being set
cution of additional I/O operations may follow initi- up; otherwise, the multipath mode of oper-
ation and execution of the first I/O operation. The ation may give unpredictable results at the
channel subsystem can execute seven com- subchannel. If, for any reason, one or
mands: write, read, read backward, control, more physically available channel paths to
sense, sense ID, and transfer in channel. Each the device are not included in the multi-
command, except transfer in channel, initiates a path group, these channel paths must not
corresponding I/O operation. Except for periods be available for selection while the sub-
while channel-program execution is suspended at channel is operating in multipath mode. A
the subchannel (see Suspension of Channel- channel path can be made not available
Program Execution on page 15-37), the sub- for selection by having the corresponding
channel is active from the acceptance of the first LPM bit set to zero either in the SCHIB
command until the primary interruption condition is prior to executing MODIFY SUBCHANNEL
recognized at the subchannel. If the primary inter- or in the ORB prior to executing START
ruption condition is recognized before the accept- SUBCHANNEL.
ance of the first command, the subchannel does
not become active. Normally, the primary inter- b. When a set-multipath-mode type of
ruption condition is caused by the channel-end command is transferred to a device, only
signal or, in the case of command chaining, the a single channel path must be logically
channel-end signal for the last CCW of the chain. available in order to avoid alternate
(See Primary Interruption Condition on channel-path selection for the execution of
page 16-4.) The device is active until the sec- that start function; otherwise, device-busy
ondary interruption condition is recognized at the conditions may be detected by the
subchannel. Normally, the secondary interruption channel subsystem on more than one
condition is caused by the device-end signal or, in channel path, which may cause unpredict-
the case of command chaining, the device-end able results for subsequent multipath-
signal for the last CCW of the chain. (See Sec- mode operations. This type of setup
ondary Interruption Condition on page 16-4.) procedure should be used whenever the
membership of a multipath group is
Programming Notes: changed.
In single-path mode, all transfers of commands, 2. Leaving Multipath Mode
data, and status for the I/O operation or chain of To leave multipath mode and continue proc-
I/O operations occur on the channel path over essing in single-path mode, either of the fol-
which the first command was transferred to the lowing two procedures may be used:
device.
a. A disband-multipath-mode type of
When the device has the dynamic-reconnection command may be executed for any
feature installed, an I/O operation or chain of I/O channel path of the multipath group. This
operations may be executed in multipath mode; to command must be followed either by
operate in multipath mode, MODIFY SUB- (1) the execution of MODIFY SUB-
CHANNEL must have been previously executed CHANNEL with bit 13 of word 1 of the
for the subchannel with bit 13 of word 1 of the SCHIB specified as zero, or by (2) the
SCHIB specified as one. (See Multipath Mode specification of only a single channel path
(D) on page 15-3.) In addition, the device must as logically available in the LPM. A start
be set up for multipath mode by execution of function must not be performed at a sub-
certain model-dependent commands appropriate channel operating in multipath mode with
to that type of device. The general procedures for multiple channel paths available for
handling multipath-mode operations are as selection while the device is operating in
follows: single-path mode; otherwise, unpredict-

15-20 z/Architecture Principles of Operation


able results may occur at the subchannel code 0. If the execution of START SUB-
for that function or subsequent start func- CHANNEL results in the setting of a nonzero con-
tions. dition code, the contents of the ORB have not
been placed at the designated subchannel. The
b. A resign-multipath-mode type of command
two rightmost bits of the ORB address must be
is executed on each channel path of the
zeros, placing the ORB on a word boundary; oth-
multipath group (the reverse of the setup
erwise, a specification exception is recognized.
described in item 1 on page 15-20). This
The format of the ORB is as follows:
command must be followed by either
(1) the execution of MODIFY SUB-
Interruption Parameter
CHANNEL with bit 13 of word 1 of the
SCHIB specified as zero, or (2) the spec- 1 Key SCMYFPIAUHT LPM LX

ification of only a single channel path as 2 Channel-Program Address

logically available in the LPM. No start 3 CSS Priority Reserved CU Priority Reserved
function may be performed at a sub-
4 Reserved
channel operating in multipath mode with
5 Reserved
multiple channel paths available for
selection while the device is operating in 6 Reserved

single-path mode; otherwise, unpredict- 7 Reserved

able results may occur at the subchannel 8 16 24 31
for that or subsequent start functions.
The fields in the ORB are defined as follows:
Blocking of Data
Interruption Parameter: Bits 0-31 of word 0 are
Data recorded by an I/O device is divided into preserved unmodified in the subchannel until
blocks. The length of a block depends on the replaced by a subsequent START SUBCHANNEL
device; for example, a block can be a card, a line or MODIFY SUBCHANNEL instruction. These bits
of printing, or the information recorded between are placed in word 1 of the interruption code when
two consecutive gaps on magnetic tape. an I/O interruption occurs and when an inter-
ruption request is cleared by execution of TEST
The maximum amount of information that can be PENDING INTERRUPTION.
transferred in one I/O operation is one block. An
I/O operation is terminated when the associated Subchannel Key: Bits 0-3 of word 1 form the
main-storage area is exhausted or the end of the subchannel key for all fetching of CCWs, IDAWs,
block is reached, whichever occurs first. For and output data and for the storing of input data
some operations, such as writing on a magnetic- associated with the start function initiated by
tape unit or at an inquiry station, blocks are not START SUBCHANNEL. This key is matched with
defined, and the amount of information transferred a storage key during these storage references.
is controlled only by the program. For details, see the section Key-Controlled
Protection in Chapter 3.
Operation-Request Block
Suspend Control (S): Bit 4 of word 1 controls
The operation-request block (ORB) is the operand the performance of the suspend function for the
of START SUBCHANNEL. The ORB specifies the channel program identified in the ORB. The
parameters to be used in controlling that particular setting of the S bit applies to all CCWs of the
start function. These parameters include the inter- channel program designated by the ORB (see
ruption parameter, the subchannel key, the Commands and Flags on page 15-39). When
address of the first CCW, operation-control bits, bit 4 is one, suspend control is specified, and
and a specification of the logical availability of channel-program suspension occurs when a valid
channel paths. suspend flag is detected in a CCW. When bit 4 is
zero, suspend control is not specified, and the
The contents of the ORB are placed at the desig- presence of the suspend flag in any CCW of the
nated subchannel during the execution of START channel program causes a program-check condi-
SUBCHANNEL, prior to the setting of condition tion to be recognized.

Chapter 15. Basic I/O Functions 15-21


Streaming Mode Control (C): Bit 5 of word 1 ending status is received for the synchronizing
controls streaming mode enablement for subchan- command.
nels configured to FICON-converted-I/O-interface
channel paths during performance of the specified When modification control is not specified,
start function. When bit 5 is zero, streaming mode command synchronization is not required and the
is enabled at the subchannel. When bit 5 is one, channel subsystem may transfer commands to the
streaming mode is disabled at the subchannel. Bit I/O device without waiting for status.
5 is meaningful only for subchannels configured to
FICON-converted-I/O-interface channel paths and The M bit is meaningful only for subchannels con-
is ignored for subchannels configured to other figured to FICON-I/O-interface or
channel-path types. FICON-converted-I/O-interface channel paths and
is ignored for other subchannels configured to
When streaming mode is enabled, the channel other channel-path types.
path considers the first command of the specified
channel program to be in progress at the associ- Programming Notes:
ated device when the channel path receives the 1. For FICON-I/O-interface or
indication that the command has been accepted at FICON-converted-I/O-interface channel paths,
the device. In addition, the channel-paths accept- modification control provides the capability to
ance of status, under certain conditions, is recog- optimize dynamically modified channel pro-
nized by the channel without receiving grams that use the PCI flag in the CCW to ini-
acknowledgement of status acceptance from the tiate channel program modification.
device. Specifically, it allows the program to delay the
channel subsystem fetching and transfer of
When streaming mode is not enabled, the channel commands until after status is received for the
path does not consider the first command of the command following the command with the PCI
specified channel program to be in progress at the bit set. This increases the likelihood that a
associated device until the appropriate channel- program-controlled interruption will be
path response, indicating that the device accepted by a central processor and acted
command response or status has been accepted upon by the program that dynamically modi-
at the channel, is sent to the device. In addition, fies one or more command-chained CCWs
when the device sends status to the channel path, that follow the synchronizing command.
the channel's acceptance of that status is not
recognized at the channel path until the channel's In order to increase the probability that any
confirmation of acceptance is received and dynamically modified CCWs are fetched after
acknowledged by the device. their modification, and not prior to their modifi-
cation, the modifying program should be exe-
Modification Control (M): Bit 6 of word 1 speci- cuted as soon as possible following the
fies whether modification control is required for the processor acceptance of the program-
channel program. When bit 6 is set to zero, mod- controlled interruption. Additionally, the
ification control is specified. When bit 6 is one, program should minimize the periods during
modification control is not specified. which the configured central processors are
disabled for I/O interruptions.
When modification control is specified, the channel
For channel paths other than
subsystem forces command synchronization with
FICON-I/O-interface or
the addressed I/O device each time a command is
FICON-converted-I/O-interface channel paths,
executed and the previously executed command
command synchronization is implicit in the sig-
has the PCI and command-chain flags set to one,
nalling protocol between the channel sub-
and the chain-data and suspend flags set to zero.
system and the I/O device; therefore no
When this condition is recognized, the channel
explicit programming action is required to
subsystem signals a synchronization request to
force command synchronization. Regardless,
the I/O device for the current command. The
the program should still attempt to accept and
channel subsystem temporarily suspends
process program-controlled interruptions for
command chaining and does not fetch (or re-fetch)
these channel-path types in as timely a
the next command-chained CCW until after normal

15-22 z/Architecture Principles of Operation


manner as possible for the same reason as When bit 8 is one, format-1 CCWs are specified.
stated above. (See Channel-Command Word on page 15-26,
for the definition of the CCW formats).
2. In order to allow the channel subsystem to
optimize the execution of channel programs
Prefetch Control (P): Bit 9 of word 1 specifies
for FICON-I/O-interface or
whether or not unlimited prefetching of CCWs,
FICON-converted-I/O-interface channel paths,
IDAWs, and associated data is allowed for the
use of the modification-control facility is dis-
channel program. When bit 9 is one, unlimited
couraged, except for channel programs that
prefetching is allowed for CCW's, IDAW's, and
require dynamic modification.
their associated data. It is model dependent
whether prefetching is actually performed for any
Synchronize Control (Y): Bit 7 of word 1 speci-
or all of the CCWs, IDAWs, and associated data
fies whether synchronization control is required for
bytes that comprise the channel program.
the channel program. When Bit 7 is set to zero
and the prefetch-control bit (bit 9 of word 1) is set
When bit 9 of word 0 is zero, no prefetching is
to one, synchronization control is specified. When
allowed, except in the case of data chaining on
Bit 7 is set to one and bit 9 is set to one, synchro-
output where the prefetching of one CCW
nization control is not specified.
describing a data area is allowed. When bit 9 of
word 0 is zero the synchronization-control bit (bit 7
When synchronization control is specified, the
of word 1) is ignored.
channel subsystem forces command synchroniza-
tion with the addressed I/O device whenever the
Additional controls may limit the scope of pre-
current command in execution describes an input
fetching.
operation and the next CCW to be fetched
describes an output operation. When this condi- Initial-Status-Interruption Control (I): Bit 10 of
tion is recognized, the channel subsystem signals word 1 specifies whether or not the channel sub-
a synchronization request to the I/O device when system must verify to the program that the device
the input command is transferred. The transfer of has accepted the first command associated with a
the output command is held pending at the sub- start or resume function. When the I bit is speci-
channel until normal ending status is received sig- fied as one in the ORB, then when the subchannel
naling completion of execution of the input becomes active, indicating that the first command
operation by the I/O device. Upon receipt of the has been accepted for this start or resume func-
ending status, the channel subsystem fetches (or tion, the Z bit (see Zero Condition Code (Z) on
re-fetches) the data associated with the output page 16-11) is set to one at this subchannel, and
command and transfers it to the I/O device. the subchannel becomes status-pending with
intermediate status.
When synchronization control is not specified, the
channel subsystem may transfer commands of the If the subchannel does not become active -- for
channel program without awaiting status that example, when the device signals channel end
would signal completion of I/O execution for each immediately upon receiving the first command,
command. command chaining is not specified in the CCW,
and command retry is not signaled -- the
The Y bit is meaningful only when the subchannel
command-accepted condition (Z bit set to one) is
is configured to FICON-I/O-interface or
not generated; instead, the subchannel becomes
FICON-converted-I/O-interface channel paths and
status-pending with primary status; intermediate
the prefetch-control bit (bit 9 of word 1) is one.
status may also be indicated in this case when the
The Y bit is ignored for subchannels configured to
command is accepted if the first CCW contained
other channel-path types and when the prefetch-
the PCI flag.
control bit is set to zero.
Address-Limit-Checking Control (A): Bit 11 of
Format Control (F): Bit 8 of word 1 specifies the
word 1 specifies whether or not address-limit
format of the channel-command words (CCWs)
checking is specified for the channel program.
which make up the channel program designated
When this bit is zero, no address-limit checking is
by the channel-program-address field. When bit 8
performed for the execution of the channel
of word 1 is zero, format-0 CCWs are specified.

Chapter 15. Basic I/O Functions 15-23


program, independent of the setting of the limit- format-2 IDAWs designate 4K-byte storage blocks.
mode bits in the subchannel (see Limit Mode Regardless of the value of this bit, all specified
(LM) on page 15-2). When this bit is one, IDAWs for the designated channel program must
address-limit checking is allowed for the channel designate the same size storage block; that is,
program, subject to the setting of the limit-mode they must all designate 2K-byte storage blocks
bits in the subchannel. when this bit is one or all 4K-byte storage blocks
when this bit is zero.
Suppress-Suspended-Interruption Control (U):
Bit 12 of word 1, when one, specifies that the Logical-Path Mask (LPM): Bits 16-23 of word 1
channel subsystem is to suppress the generation are preserved unmodified in the subchannel and
of an intermediate interruption condition due to specify to the channel subsystem which of the
suspension if the subchannel becomes sus- logical paths 0-7 are to be considered logically
pended. When bit 12 is zero, the channel sub- available, as viewed by the program. A bit setting
system generates an intermediate interruption of one means that the corresponding channel path
condition whenever the subchannel becomes sus- is logically available; a zero specifies that the cor-
pended during execution of the channel program. responding channel path is logically not available.
If a channel path is specified by the program as
Format-2 IDAW Control (H): Bit 14 of word 1 being logically not available, the channel sub-
specifies the format of IDAWs for CCWs that system does not use that channel path to perform
specify indirect data addressing. When bit 14 of clear, halt, resume, or start functions when
word 1 is one, format-2 (64-bit data address) requested by the program, except when a
IDAWs are provided for all channel commands dedicated-allegiance condition exists for that
which have the IDAW flag set to one in the desig- channel path. If a dedicated-allegiance condition
nated channel program. exists, the setting of the LPM is ignored, and a
resume, start, halt, or clear function is performed
When bit 14 of word 1 is zero, format-1 (31-bit by using the channel path having the dedicated
data address) IDAWs are provided for all channel allegiance.
commands which have the IDAW flag set to one
in the designated channel program. Incorrect-Length-Suppression Mode (L): When
bit 8 of word 1 is one, then bit 24 of word 1, when
Programming Notes: one, specifies the incorrect-length-suppression
1. 64-bit IDAWs provide the only means by mode. When the subchannel is in this mode
which data can be transferred directly when an immediate operation occurs (that is, a
between an I/O device and storage locations device signals the channel-end condition during
with addresses greater than 2G bytes. initiation of the command) and the current CCW
contains a nonzero value in bits 16-31, indication
2. The format-2 IDAW control bit may be speci- of an incorrect-length condition is suppressed.
fied when the CPU is executing in either the
ESA/390 architectural mode or the When bit 8 of word 1 is one, then bit 24 of word 1,
z/Architecture architectural mode. However, when zero, specifies the incorrect-length-indication
when the processor is executing in the mode. When the subchannel is in this mode
ESA/390 architectural mode, program access when an immediate operation occurs (that is, a
to any data locations greater than device signals the channel-end condition during
2,147,483,647 is not possible until the initiation of the command) and the current CCW
processor is placed in the z/Architecture archi- contains a nonzero value in bits 16-31, indication
tectural mode. of an incorrect-length condition is recognized.
Command chaining is suppressed unless the SLI
2K-IDAW Control (T): Bit 15 of word 1 specifies flag in the CCW is one and the chain-data flag is
the main-storage block size for format-2 IDAW zero.
data areas. Bit 15 is meaningful only when bit 14
(format-2 IDAW control) is one and is ignored When bit 8 of word 1 is zero, the value of bit 24 is
when bit 14 is zero. When bit 15 of word 1 is ignored by the channel subsystem, and the sub-
one, all format-2 IDAWs designate 2K-byte channel is in the incorrect-length-suppression
storage blocks. When bit 15 of word 1 is zero, all mode.

15-24 z/Architecture Principles of Operation


ORB Extension (X): Bit 31 of word 1 specifies priority number may be ignored and an alter-
whether the ORB is extended. When bit 31 of native priority number implicitly assigned to
word 1 is zero, the ORB consists of words 0-2 and the subchannel when it becomes start-
words 3-7 are ignored. When bit 31 of word 1 is pending.
one, the ORB consists of words 0-7. Words 0-1
2. When bit 31 (X) of word 1 of the ORB is zero,
are described above. Words 2-7 are described
an implicit priority number is assigned to the
below.
subchannel.
Channel-Program Address: Bits 0-31 of word 2 See the section Channel Subsystem I/O-Priority
designate the location of the first CCW in absolute Facility in Chapter 17 for details regarding how
main storage. Bit 0 of word 2 must be zero; oth- the priority number is assigned for both of these
erwise, either an operand exception or a program- cases.
check condition is recognized. If format-0 CCWs
have been specified in bit 8 of word 1, then bits Control-Unit Priority (CU Priority): When bit 31
1-7 must also be zeros; otherwise, a program- (X) of word 1 of the ORB is one, then byte 2 of
check condition is recognized. word 3 forms an unsigned binary integer that
specifies the priority level that is applied at the
The three rightmost bits of the channel-program associated control unit for all I/O-operations asso-
address must be zeros, designating the CCW on a ciated with the start function.
double-word boundary; otherwise, a program-
check condition is recognized. The specified control-unit priority number can be
any number in the range of 1 to 255. The number
If the channel-program address designates a 1 designates the lowest priority than can be
location protected against fetching or designates a assigned to the I/O-operations at the control unit
location outside the storage of the particular instal- and the number 255 designates the highest pri-
lation, the start function is not initiated at the ority that can be assigned. The number 0 is
device. In this situation, the subchannel becomes defined to mean that no priority is assigned to the
status-pending with primary, secondary, and alert I/O-operations associated with the start function.
status. The handling of I/O-operations in this case
depends on the control unit model.
Channel Subsystem (CSS) Priority: When bit
31 (X) of word 1 of the ORB is one, then byte 0 of Also depending on the model, less than 255 pri-
word 3 forms an unsigned binary integer that ority levels may be supported by the control unit.
specifies the channel subsystem I/O-priority See the control unit's System Library publication
number that is assigned to the designated sub- for additional information regarding the range of
channel when START SUBCHANNEL signals the priority numbers supported and how this priority
channel subsystem to asynchronously perform the number is used.
start function. The specified channel subsystem
priority number is subsequently used to order the The specified control-unit priority number is
selection of subchannels when either a start func- ignored if any of the following conditions exist:
tion or resume function is to be initiated for one or 1. Bit 31 (X) of word 1 is zero. In this case, a
more subchannels that are start-pending or control-unit priority value of zero is transmitted
resume-pending. in the associated outbound frames.
The specified channel subsystem priority can be 2. The designated subchannel is not associated
any number in the range of 0 to 255. The number with a control unit configured to FICON
0 designates the lowest priority than can be channel path,
assigned to the subchannel and the number 255 3. The associated control unit does not provide
designates the highest priority that can be priority execution of I/O operations. In this
assigned. case, the control-unit priority number in the
associated outbound frames is ignored at the
Depending on the model and the configuration:
control unit.
1. Fewer than 256 priority levels may be pro-
vided. For such models, the ORB specified

Chapter 15. Basic I/O Functions 15-25


4. The channel subsystem model does not CCW is fetched subsequent to the execution of
provide for the transmission of the control-unit the instruction. The format of the CCWs fetched
priority number. by the channel subsystem is specified by bit 8 of
word 1 of the ORB. Each additional CCW in the
Reserved: All fields in the ORB that are defined channel program is obtained when the CCW is
as either 0 or Reserved must contain zeros needed. Fetching of the CCWs by the channel
when START SUBCHANNEL is executed; other- subsystem does not affect those locations in main
wise, either an operand exception or a program- storage.
check condition is recognized.
CCWs have either of two different formats, format
Programming Notes: 0 or format 1. The two formats do not differ in the
1. Bit positions of the ORB which presently are information contained in the CCW but only in the
specified to contain zeros may in the future be arrangement of the fields within the CCW.
assigned for the control of new functions.
The formats are defined as follows:
2. The interruption parameter may contain any
information, but ordinarily the information is of Format

significance to the program handling the I/O Cmd Code Data Address
interruption.
8 31

Channel-Command Word Flags //////// Count

32 39 48 63
The channel-command word (CCW) specifies the
command to be executed and, for commands initi- Format 1
ating certain I/O operations, it designates the
Cmd Code Flags Count
storage area associated with the operation, the
action to be taken whenever transfer to or from 8 15 31
the area is completed, and other options.
Data Address

A channel program consists of one or more CCWs 32 63
that are logically linked such that they are fetched
by the channel subsystem and executed in the
Flags
sequence specified by the CPU program. Contig-
uous CCWs are linked by the use of the chain- CCSSPIS
data or chain-command flags, and non-contiguous DCLKCD
IIIA
CCWs may be linked by a CCW specifying the P
transfer-in-channel command.
6
As each CCW is executed, it is recognized as the
current CCW. A CCW becomes current (1) when Format-0 CCWs can be located anywhere in the
it is the first CCW of a channel program and has first 16,777,216 bytes of absolute main storage
been fetched, (2) when, during command and format-1 CCWs can be located anywhere in
chaining, the new CCW is logically fetched, or the first 2,147,483,648 bytes of absolute main
(3) when, during data chaining, the new CCW storage.
takes over control of the I/O operation (see Data
Chaining on page 15-32). When chaining is not Bit 39 (format 0) or bit 15 (format 1) of every CCW
specified, a CCW is no longer current after TEST other than a format-0 CCW specifying transfer in
SUBCHANNEL clears the start-function bit in the channel must be zero. If indirect data addressing
subchannel. is specified and the format-2 IDAW control bit is
zero at the ORB associated with the CCW, then:
The location of the first CCW of the channel
program is designated in the ORB that is the 1. bits 30-31 (format 0) or bits 62-63 (format 1)
operand of START SUBCHANNEL. The first of the CCW must be zeros, designating a
word boundary,

15-26 z/Architecture Principles of Operation


2. bit 0 of the first entry of the indirect-data- commands. It causes the operation specified by
address list must be zero. the command code in the next CCW to be initiated
on normal completion of the current operation.
If indirect data addressing is specified and the
format-2 IDAW control bit is one in the ORB asso-
Suppress-Length-Indication (SLI) Flag: Bit 34
ciated with the CCW, then bits 29-31 (format 0) or
(format 0) or bit 10 (format 1) controls whether an
bits 61-63 (format 1) of the CCW must be zeros
incorrect-length condition is to be indicated to the
designating a doubleword boundary. When any of
program. When this bit is one and the CD flag is
these requirements are not met, a program-check
zero, the incorrect-length indication is suppressed.
condition may be recognized (see CCW Indirect
When both the CC and SLI flags are ones, and
Data Addressing on page 15-35).
the CD flag is zero, command chaining takes
place, regardless of the presence of an incorrect-
Detection of this condition during data chaining
length condition. This bit should be specified in all
causes the I/O device to be signaled to conclude
CCWs where suppression of the incorrect-length
the operation. When the absence of these zeros
indication is desired.
is detected during command chaining or subse-
quent to the execution of START SUBCHANNEL,
Skip (SKIP) Flag: Bit 35 (format 0) or bit 11
the new operation is not initiated, and an inter-
(format 1), when one, specifies the suppression of
ruption condition is generated.
transfer of information to storage during a read,
read-backward, sense ID, or sense operation.
The contents of bit positions 40-47 of a format-0
CCW are ignored.
Program-Controlled-Interruption (PCI) Flag: Bit
36 (format 0) or bit 12 (format 1), when one,
The fields in the CCWs are defined as follows:
causes the channel subsystem to generate an
Command Code: Bits 0-7 (both formats) specify intermediate interruption condition when the CCW
the operation to be executed. takes control of the I/O operation. When the PCI
flag bit is zero, normal operation takes place.
Data Address: Bits 8-31 (format 0) with 40 zero
bits appended to the left of bit 8 or bits 33-63 Indirect-Data-Address (IDA) Flag: Bit 37
(format 1) with 33 zero bits appended to the left of (format 0) or bit 13 (format 1), when one, specifies
bit 33 designate a location in absolute storage. indirect data addressing.

The data address is the first location referred to in Suspend (S) Flag: Bit 38 (format 0) or bit 14
the area designated by the CCW. When a byte (format 1), when one, specifies suspension of
count of zero is specified, this field is not checked. channel-program execution. When valid, it causes
See the section CCW Indirect Data Addressing channel-program execution to be suspended prior
for information regarding the specification of data to execution of the CCW containing the S flag.
addresses greater than 2G bytes. The S flag is valid when bit 4, word 1 of the asso-
ciated ORB is one.
Chain-Data (CD) Flag: Bit 32 (format 0) or bit 8
(format 1), when one, specifies chaining of data. Count: Bits 48-63 (format 0) or bits 16-31
It causes the storage area designated by the next (format 1) specify the number of bytes in the
CCW to be used with the current I/O operation. storage area designated by the CCW.
When the CD flag is one in a CCW, the chain- Programming Note: Bit 39 of a format-0 CCW
command and suppress-length-indication flags or bit 15 of a format-1 CCW, which presently must
(see below) are ignored. be zero, may in the future be assigned for the
control of new functions. It is recommended,
Chain-Command (CC) Flag: Bit 33 (format 0) or therefore, that this bit position not be set to one
bit 9 (format 1), when one, and when the CD flag for the purpose of obtaining an intentional
and S flag are both zeros, specifies chaining of program-check indication.

Chapter 15. Basic I/O Functions 15-27



Command Code Code Command

The command code, bit positions 0-7 of the CCW, x x x x Invalid
m m m m m m 1 Write
specifies to the channel subsystem and the I/O m m m m m m 1 Read
device the operation to be executed. m m m m 1 1 Read backward
m m m m m m 1 1 Control
The two rightmost bits or, when these bits are m m m m 1 Sense
1 1 1 1 Sense ID
zeros, the four rightmost bits of the command x x x x 1 Transfer in channel
code identify the operation to the channel sub- 1 Transfer in channel
system. The channel subsystem distinguishes m m m m 1 Invalid

among the following four operations: Explanation:

Output forward (write, control) m Modifier bit
Input forward (read, sense, sense ID)
Input backward (read backward) x Ignored

Branching (transfer in channel) Format- CCW
The channel subsystem ignores the leftmost bits
Format-1 CCW
of the command code, except in a format-1 CCW
specifying transfer in channel. In this situation, all Format-1 CCW with any of bits -3 nonzero
bits of the command code are decoded by the
channel subsystem. Figure 15-5. Command-Code Assignment

Commands that initiate I/O operations (write, read, Whenever the channel subsystem detects an
read backward, control, sense, and sense ID) invalid command code during the initiation of
cause all eight bits of the command code to be command execution, the program-check-
transferred to the control unit. In these command interruption condition is generated and channel-
codes, the leftmost bit positions contain modifier program execution is terminated. The command
bits. The modifier bits specify to the device how code is ignored during data chaining, unless it
the command is to be executed. They may, for specifies transfer in channel.
example, cause the device to compare data
received during a write operation with data previ-
ously recorded, and they may specify such condi-
Designation of Storage Area
tions as recording density and parity. For the
Note: For a description of the storage area associ-
control command, the modifier bits may contain
ated with a CCW when indirect data addressing is
the order code specifying the control function to
invoked, see the section CCW Indirect Data
be executed. The meaning of the modifier bits
Addressing later in this chapter.
depends on the type of I/O device and is specified
in the System Library publication for the device. The main-storage area associated with an I/O
operation is defined by one or more CCWs. A
The command-code assignment is listed in
CCW defines an area by specifying the address of
Figure 15-5. The symbol x indicates that the bit
the first byte to be transferred and the number of
position is ignored; m identifies a modifier bit.
consecutive bytes contained in the area. The
address of the first byte appears in the data-
address field of the CCW. The number of bytes
contained in the storage area is specified in the
count field.

The data-address field of the CCW designates the


absolute main-storage location of the first byte to
be transferred.

In write, read, control, and sense operations,


storage locations are used in ascending order of

15-28 z/Architecture Principles of Operation


addresses. As information is transferred to or During an output operation, the channel sub-
from main storage, the address from the address system may fetch data from main storage before
field is incremented, and the count from the count the time the I/O device requests the data. Any
field is decremented. The read-backward opera- number of bytes specified by the current CCW
tion places data in storage in a descending order may be prefetched and buffered. When data
of addresses, and both the count and the address chaining during an output operation, the channel
are decremented. When the count reaches 0, the subsystem may fetch one CCW describing a data
storage area defined by the CCW is exhausted. area at any time during the execution of the
current CCW. If unlimited prefetching is allowed
Any main-storage location available to the start by the setting of the prefetch-control bit in the
function can be used in the transfer of data to or ORB, then any number of CCWs, IDAWs, and the
from an I/O device, provided that the location is associated data may be prefetched by the channel
not protected against that type of reference. subsystem. When the I/O operation uses data
Format-0 CCWs can be located in any available and CCWs from locations near the end of the
part of the first 16M bytes of absolute storage. available storage, such prefetching may cause the
Format-1 CCWs may be located in any available channel subsystem to refer to locations that do not
part of the first 2G-bytes of absolute storage, pro- exist. Invalid addresses resulting from the above
vided in both cases that the location is not pro- senario, or resulting from bit 32 of a format-1
tected against a fetch-type reference. When the CCW being nonzero, detected during prefetching
channel subsystem attempts to refer to a pro- of data or CCWs do not affect the execution of the
tected location, the protection-check condition is operation and do not cause error indications until
generated, and the device is signaled to terminate the I/O operation actually attempts to use the
the operation. information. If the operation is concluded by the
I/O device or by execution of HALT SUB-
A main-storage location is available if it is avail- CHANNEL or CLEAR SUBCHANNEL before the
able in the configuration and access to it is not invalid information is needed, the condition is not
prevented by the address-limit-checking facility. If brought to the attention of the program.
an absolute main-storage location is not available,
it is said to have an invalid address. The count field in the CCW can specify any
number of bytes up to 65,535. In format-0 CCWs,
In the event the channel subsystem refers to a the count field is always nonzero unless the
location that is not available, the program-check command code specifies transfer in channel, in
condition is generated. When the first CCW des- which case the count field is ignored. In format-1
ignated by the channel-program address is at an CCWs, the count field may contain the value zero
unavailable location, the start function is not initi- unless data chaining is specified or the CCW is
ated at the device, the status portion of the SCSW fetched while data chaining. Whenever (1) the
is updated with the program-check indication, and count field in a format-1 CCW is zero, (2) data
the subchannel becomes primary, secondary, and chaining is either not specified or is not in effect,
alert status-pending, with a deferred condition and (3) data transfer is requested by the device,
code 1 indicated. Invalid data addresses, as well the device is signaled to stop, and the I/O opera-
as any invalid CCW addresses detected on tion is terminated. The channel subsystem sets
chaining or subsequent to the execution of START the incorrect-length condition if the SLI flag is not
SUBCHANNEL, cause the channel subsystem to one in the CCW. No data is transferred. If the
signal the device to conclude the operation the device does not request data transfer, the opera-
next time the device requests or offers a byte of tion proceeds to the normal ending point.
data or status. In this situation, the subchannel is
made status-pending with program check indi- If a zero byte count is contained in a format-0
cated in the subchannel status, and device status CCW which does not specify transfer in channel,
as a function of the status received from the or if a zero byte count is contained in a format-1
device. The program-check condition causes CCW that specifies data chaining or was fetched
command chaining and command retry to be sup- while data chaining, a program-check condition is
pressed. recognized, and the subchannel is made status-
pending with combinations of primary, secondary,
and alert status as a function of the state of the

Chapter 15. Basic I/O Functions 15-29


subchannel and the status received from the Chaining
device.
Note: For a description of the storage area asso- When the channel subsystem has completed the
ciated with a CCW when indirect data addressing transfer of information specified by a CCW, it can
is invoked, see CCW Indirect Data Addressing continue performing the start function by fetching
on page 15-35. a new CCW. Such fetching of a new CCW is
called chaining, and the CCWs belonging to such
Programming Notes: a sequence are said to be chained.
1. Since a format-1 CCW with a count of zero is
Chaining takes place between CCWs located in
valid, the program can use the CCW count
successive doubleword locations in storage. It
field to specify that no data be transferred to
proceeds in an ascending order of addresses; that
the I/O device. If the device requests a data
is, the address of the new CCW is obtained by
transfer, the device is signaled to terminate
adding 8 to the address of the current CCW. Two
data transfer. If the SLI and chain-command
chains of CCWs located in non-contiguous storage
flags are also specified, and no unusual condi-
areas can be coupled for chaining purposes by a
tions are encountered subsequent to signaling
transfer-in-channel command. All CCWs in a
the device to terminate data transfer, then the
chain apply to the I/O device that is associated
new operation is initiated upon receipt of
with the subchannel designated by the original
device end from the device.
START SUBCHANNEL instruction.
2. If the subchannel is in the incorrect-length-
suppression mode, if the chain-data flag in the Two types of chaining are provided: chaining of
current CCW is zero, and if the operation is data and chaining of commands. Chaining is con-
executed as an immediate operation, then trolled by the chain-data (CD) and chain-command
incorrect length is not indicated, regardless of (CC) flags in conjunction with the suppress-length-
the setting of the SLI flag. indication (SLI) flag in the CCW. These flags
specify the action to be taken by the channel sub-
If the subchannel is in the incorrect-length-
system upon the exhaustion of the current CCW
indication mode, if the chain-data flag in the
and upon receipt of ending status from the device,
current CCW is zero, and if the operation is
as shown in Figure 15-6 on page 15-31.
executed as an immediate operation, then
incorrect length is indicated if the count field of The specification of chaining is effectively propa-
the current CCW specifies a nonzero value, gated through a transfer-in-channel command.
unless suppressed by the SLI flag of the When, in the process of chaining, a transfer-in-
CCW; incorrect length is not indicated, channel command is fetched, the CCW desig-
however, if the count field of the CCW speci- nated by the transfer-in-channel command is used
fies a value of zero. for the type of chaining specified in the CCW pre-
If a new CCW that has a count field of zero is ceding the transfer-in-channel command.
fetched during data chaining or if a CCW is
fetched with the chain-data flag set to one and The CD and CC flags are ignored in a format-0
a count field of zero, then a program-check CCW specifying the transfer-in-channel command.
condition is recognized by the channel sub- In a format-1 CCW specifying the transfer-in-
system. channel command, the CD and CC flags must be
zeros; otherwise, a program-check condition is
recognized.

15-30 z/Architecture Principles of Operation



Action at the Subchannel upon Exhaustion of Count or Receipt of Channel End

Immediate Operation Non-immediate Operation

Flags in Incorrect-Length- Incorrect-Length-
Current CCW Suppression Mode Indication Mode Count Exhausted Count Not
Exhausted
CCW CCW CCW CCW CE Not CE and CE
CD CC SLI Count/
= Count= Count/ = Count= Received Received Received

End, NIL End, NIL End, IL End, NIL Stop, IL End, NIL End, IL
1 End, NIL End, NIL End, NIL End, NIL Stop,NIL End, NIL End, NIL
1 CC CC End, IL CC Stop, IL CC End, IL
1 1 CC CC CC CC Stop, CC CC CC

1 - - End, NIL PC End, IL PC CD \ End, IL

Explanation:

- The selected bit is ignored and may be either zero or one.

\ These situations cannot validly occur. When data chaining is specified, the new
CCW takes control of the operation after transferring the last byte of data
designated by the current CCW, but before the next request for data or status
transfer from the device. The new CCW (which cannot contain a count of zero
unless a program-check condition is also recognized) is in control of the
operation.

The count field must contain a nonzero value when format- CCWs are specified;
otherwise, the operation is terminated with a program-check condition.

CC Command chaining is performed by the channel subsystem upon receipt of device
end.

CD The chain-data flag causes the channel subsystem to immediately fetch a new CCW
for the same operation. The operation continues unless the CCW thus fetched has
a count field of zero, in which case the operation is terminated with a
program-check condition.

CE Channel end from the device which indicates end of block.

End Operation is terminated.

IL Incorrect length is indicated with the subsequent interruption condition
generated at the subchannel.

NIL Incorrect length is not indicated with the subsequent interruption condition
generated at the subchannel.

PC These situations cannot validly occur. The channel subsystem recognizes a
program-check condition when a CCW is fetched that has the chain-data flag set to
one and a count field of zero.

Stop Device is signaled to terminate data transfer, but subchannel remains
subchannel-active until channel end is received.

Figure 15-6. Subchannel Chaining Action

Chapter 15. Basic I/O Functions 15-31


Programming Note: When bit 9 of word 1 of the protected against fetching, or programming errors
ORB is one, unlimited fetching of chained CCWs are detected in an intervening transfer-in-channel
by the channel subsystem is permitted. When command. A data address referring to a nonex-
prefetching is allowed by the ORB, no modification istent or protected area causes an error indication
of the channel program should be performed after only after the I/O device has attempted to transfer
START SUBCHANNEL is executed and before the data to or from the invalid location.
primary interruption condition for the operation has
been received unless the subchannel is currently Data chaining during an input operation causes
suspended and is not resume-pending. the new CCW to be fetched when all data desig-
nated by the current CCW has been placed in
Data Chaining main storage. On an output operation, the
During data chaining, the new CCW fetched by channel subsystem may fetch the new CCW from
the channel subsystem defines a new storage main storage before data chaining occurs. Any
area for the original I/O operation. If the channel programming errors in the prefetched CCW,
path is the parallel-I/O-interface type, then exe- however, do not affect the execution of the opera-
cution of the operation at the I/O device is not tion until all data designated by the current CCW
affected. If the channel path is the has been transferred to the I/O device. If the
serial-I/O-interface type, then execution of the device concludes the operation before all data
operation at the I/O device either is not affected, designated by the current CCW has been trans-
or, depending on the device model, may be termi- ferred, the conditions associated with the pre-
nated with unit-check status. When the operation fetched CCW are not indicated to the program.
at the I/O device is not affected and all data desig- Unlimited prefetching is allowed under the control
nated by the current CCW has been transferred to of the prefetch bit specified in the ORB. (See
main storage or to the device, data chaining Prefetch Control (P) on page 15-23.) When
causes the operation to continue, using the unlimited prefetching is not allowed and an output
storage area designated by the new CCW. The operation is specified, only one CCW describing a
contents of the command-code field of the new data area may be prefetched. If a prefetched
CCW are ignored, unless they specify transfer in CCW specifies transfer in channel, only one more
channel. CCW may be fetched before the exhaustion of the
current CCW.
Data chaining is considered to occur immediately
after the last byte of data designated by the Programming Notes:
current CCW has been transferred to main 1. If the ORB does not specify unlimited pre-
storage or to the device. When the last byte of fetching, no prefetching of CCWs is per-
the data transfer has been placed in main storage formed, except in the case of data chaining on
or accepted by the device, the new CCW takes an output operation where one CCW
over the control of the operation. If the device describing a data area may be prefetched at a
sends channel end after exhausting the count of time.
the current CCW but before transferring any data
to or from the storage area designated by the new If the ORB for the I/O operation specifies that
CCW, the SCSW associated with the concluded prefetching is allowed, any number of CCWs,
operation pertains to the new CCW. IDAWs, and associated data areas may be
prefetched and buffered in the channel sub-
If programming errors are detected in the new system.
CCW or during its fetching, the error indication is The same actions for signaling errors and ter-
generated, and the device is signaled to conclude minating operations take place when unlimited
the operation when it attempts to transfer data prefetching is allowed by the ORB as when it
designated by the new CCW. If the device signals is not allowed. However, when unlimited pre-
the channel-end condition before transferring any fetching is specified and an error condition is
data designated by the new CCW, program check detected, both the channel subsystem and the
or protection check is indicated in the SCSW program must recognize that the point of ter-
associated with the termination. The contents of mination at the channel subsystem and at the
the SCSW pertain to the new CCW unless the I/O device may be different in terms of the
address of the new CCW is invalid, the location is

15-32 z/Architecture Principles of Operation


channel command in execution at the point of locations in main storage with resultant
error. The channel subsystem indicates the destruction of its contents, subject only to the
point of termination at the channel subsystem control of the protection key and the address-
by storing the appropriate CCW address in limit-checking facility, if used.
word 1 of the subchannel-status word and the
3. When, during data chaining, a device transfers
point of termination at the device by storing
data by using the data-streaming feature, an
the secondary-CCW address in word 4 of the
overrun or chaining-check condition may be
format-0 extended-status word.
recognized when a small byte-count value is
When prefetching has been specified in the specified in the CCW. The minimum accept-
ORB, the result of modifications to CCWs able number of bytes that can be specified
after START SUBCHANNEL has been exe- varies as a function of the system model and
cuted or after self-describing channel pro- system activity.
grams have been used, is unpredictable.
(See note 2 for the definition of self-describing Command Chaining
channel programs.) During command chaining, the new CCW fetched
2. Data chaining may be used to rearrange infor- by the channel subsystem specifies a new I/O
mation as it is transferred between main operation. The channel subsystem fetches the
storage and an I/O device. Data chaining new CCW upon the receipt of the device-end
permits blocks of information to be transferred signal for the current operation. If the new CCW
to or from non-contiguous areas of storage, does not specify an S flag and if no unusual con-
and, when used in conjunction with the skip- ditions are detected, the channel subsystem initi-
ping function, data chaining allows the ates the new operation. The presence of the S
program to place in main storage specified flag or unusual conditions causes command
portions of a block of data. chaining to be suppressed. When command
chaining takes place, the completion of the current
When, during an input operation, the program operation does not cause an I/O interruption, and
specifies data chaining to a location in which the count indicating the amount of data transferred
data has been placed under the control of the during the current operation is not made available
current CCW, the channel subsystem, in to the program. For operations involving data
fetching the next CCW, fetches the new con- transfer, the new command always applies to the
tents of the location. This is true even if the next block of data at the device.
location contains the last byte transferred
under the control of the current CCW. When Command chaining takes place and the new oper-
a channel program data-chains to a CCW ation is initiated only if no unusual conditions have
placed in storage by the CCW specifying data been detected in the current operation. In partic-
chaining, the input block is said to be self- ular, the channel subsystem initiates a new I/O
describing. A self-describing block contains operation by command chaining upon receipt of a
one or more CCWs that designate storage status byte containing only the following bit combi-
locations and counts for subsequent data in nations: (1) device end, (2) device end and
the same input block. status modifier, (3) device end and channel end,
The use of self-describing blocks is equivalent and (4) device end, channel end, and status mod-
to the use of unchecked data. An I/O data- ifier. In the first two cases, channel end is sig-
transfer malfunction that affects validity of a naled before device end, with all other status bits
block of information is signaled only at the zeros. If a condition such as attention, unit check,
completion of data transfer. The error condi- unit exception, incorrect length, program check, or
tion normally does not prematurely terminate protection check has occurred, the sequence of
or otherwise affect the execution of the opera- operations is concluded, and the status associated
tion. Thus, there is no assurance that a CCW with the current operation causes an interruption
read as data is valid until the operation is condition to be generated. The new CCW in this
completed. If the CCW thus read is in error, case is not fetched. The incorrect-length condition
use of the CCW in the current operation may does not suppress command chaining if the
cause subsequent data to be placed at wrong current CCW has the SLI flag set to one.

Chapter 15. Basic I/O Functions 15-33


An exception to sequential chaining of CCWs Skipping affects only the handling of information
occurs when the I/O device presents the status- by the channel subsystem. The operation at the
modifier condition with the device-end signal or I/O device proceeds normally, and information is
channel-end and device-end signals. When transferred. The channel subsystem keeps
command chaining is specified and no unusual updating the count but does not place the informa-
conditions have been detected, or when command tion in main storage. Chaining is not precluded by
retry has been previously signaled and an imme- skipping. In the case of data chaining, normal
diate retry could not be performed, the combina- operation is resumed if the skip flag in the new
tion of status-modifier and device-end bits causes CCW is zero.
the channel subsystem to alter the sequential exe-
cution of CCWs. If command chaining was speci- No checking for invalid or protected data
fied, status modifier and device end cause the addresses takes place during skipping.
channel subsystem to fetch and chain to the CCW Programming Note: Skipping, when combined
whose main-storage address is 16 higher than with data chaining, permits the program to place in
that of the CCW that specified chaining. If main storage specified portions of a block of infor-
command retry was previously signaled and mation from an I/O device.
immediate retry could not be performed, the status
causes the channel subsystem to command chain
to the CCW whose storage address is 8 higher Program-Controlled Interruption
than that of the CCW for which retry was initially
signaled. The program-controlled-interruption (PCI) function
permits the program to cause an I/O interruption
When both command and data chaining are speci- during execution of an I/O operation. The function
fied, the first CCW associated with the operation is controlled by the PCI flag of the CCW. Neither
specifies the operation to be executed, and the the value of the PCI flag nor the associated inter-
last CCW specifies whether another operation ruption request affects the execution of the current
follows. operation.

Programming Note: Command chaining makes The value of the PCI flag can be one either in the
it possible for the program to initiate transfer of first CCW designated for the current start or
multiple blocks of data by executing a single resume function or in a CCW fetched during
START SUBCHANNEL instruction. It also permits chaining. If the PCI flag is one in a CCW that has
a subchannel to be set up for execution of other become current, the subchannel becomes status-
commands, such as positioning the disk-access pending with intermediate status, and an
mechanism, and for data-transfer operations I/O-interruption request is generated. The point at
without interference by the program at the end of which the subchannel becomes status-pending
each operation. Command chaining, in conjunc- depends on the progress of the current start or
tion with the status-modifier condition, permits the resume function as follows:
channel subsystem to modify the normal
sequence of operations in response to signals pro- 1. If the PCI flag is one in the first CCW associ-
vided by the I/O device. ated with a start function or a resume function,
the subchannel becomes status-pending with
intermediate status only after the command
Skipping has been accepted.

Skipping causes the suppression of main-storage 2. If the PCI flag is one in a CCW which has
references during an I/O operation. It is defined become current while data chaining, the sub-
only for read, read-backward, sense-ID, and sense channel becomes status-pending with interme-
operations, and is controlled by the skip flag, diate status after all data designated by the
which can be specified individually for each CCW. preceding CCW has been transferred.
When the skip flag is one, skipping occurs; when 3. If the PCI flag is one in a CCW which has
it is zero, normal operation takes place. The become current while command chaining, the
setting of the skip flag is ignored in all other oper- subchannel becomes status-pending with
ations. intermediate status as that CCW becomes
current.

15-34 z/Architecture Principles of Operation


In all cases, if the subchannel is enabled for I/O status, these conditions may or may not be indi-
interruptions, the point of interruption depends on cated again. If the subchannel-status condition is
the current activity in the system and may be detected while prefetching and the operation or
delayed. No predictable relationship exists chain of operations is concluded before the condi-
between the point at which the interruption request tion affects an operation, the condition is reset and
is generated because of the PCI flag and the is not indicated when the subchannel subse-
extent to which data transfer has been completed quently becomes status-pending with primary
to or from the area designated by the CCW. status. If the subchannel-status condition affects
However, all the fields within the SCSW pertain to an operation, the condition is indicated when the
the same instant. subchannel becomes status-pending with primary
status.
An intermediate interruption condition that is made
pending because of a PCI flag remains pending If the program-controlled-interruption condition
during chaining if not cleared by TEST SUB- remains pending until the operation or chain of
CHANNEL or CLEAR SUBCHANNEL. If another operations is concluded at the subchannel, a
CCW containing a PCI flag that is one becomes single interruption request exists. When TEST
current prior to the clearing of the intermediate SUBCHANNEL is subsequently executed, the
interruption condition, only one interruption condi- status-control field of the SCSW stored indicates
tion is preserved. both the primary interruption condition and the
intermediate interruption condition, and the PCI bit
An intermediate interruption may occur while the of the subchannel-status field is one.
subchannel is subchannel-and-device-active with
the operation specified by the CCW causing the The value of the PCI flag is inspected in every
intermediate interruption condition or with the CCW except for those CCWs that specify the
operation specified by a CCW that has subse- transfer-in-channel command. The PCI flag is
quently become current. If the intermediate inter- ignored during initial program loading.
ruption condition is not cleared prior to the
conclusion of the operation or chain of operations, Programming Notes:
the condition is indicated together with the primary 1. The program-controlled interruption provides a
interruption condition at the conclusion of the means of alerting the program to the progress
operation or chain of operations. The intermediate of chaining during an I/O operation. It permits
interruption condition may be cleared by TEST programmed dynamic main-storage allocation.
SUBCHANNEL while the subchannel is
subchannel-active. 2. A CCW with a PCI flag that has a value of
one may, if retried because of command retry,
If the SCSW stored by TEST SUBCHANNEL indi- cause multiple PCI interruptions to occur.
cates that the subchannel is status-pending with (See Command Retry on page 15-41.)
intermediate status and the operation or chain of
operations has not been concluded (that is, the CCW Indirect Data Addressing
activity-control field indicates subchannel-and-
device-active or suspended), then the CCW indirect data addressing permits a single
CCW-address field contains an address which is 8 channel-command word to control the transfer of
higher than the address of the most recent CCW data that spans non-contiguous pages in real main
to become current and have a PCI flag that is storage. The use of CCW indirect data
one, or the CCW-address field contains an addressing also allows the program to designate
address which is 8 higher than a CCW which has data addresses above 16M bytes (format-0
subsequently become current. Unless the SCSW CCWs) or above 2G-bytes (format-1 CCWs).
also contains the primary-status bit set to one, the
device-status field contains zeros, and the count is CCW indirect data addressing is specified by a
unpredictable. flag in the CCW which, when one, indicates that
the data address is not used to directly address
Subchannel-status conditions other than PCI may data. Instead, the address points to a list of
be indicated when the SCSW is stored. If the words, called indirect-data-address words
subchannel is not also status-pending with primary

Chapter 15. Basic I/O Functions 15-35


(IDAWs), each of which contains an address des- ORB, the count field of the CCW, and by the data
ignating a data area within main storage. address in the initial IDAW. When, for example,
the ORB specifies: (1) format-2 IDAWs with
IDAWs have either of two different formats, format 4K-byte blocks, (2) the CCW count field specifies
1 and format 2. The formats are defined as 8K bytes, and (3) the first IDAW designates a
follows: location in the middle of a 4K-byte block, then
three IDAWs are required.
Format 1

Data Address The IDAW designated by the CCW can designate


any location. Data is then transferred, for read,
31 write, control, sense ID, and sense commands, to
Format 2 or from successively higher storage locations or,
for a read-backward command, to successively
Data Address (bytes -3) lower storage locations, until a 2K-byte block

32 boundary (format-1 or format-2 IDAW) or a


4K-byte block boundary (format-2 IDAW) is
Data Address (bytes 4-7) reached. The control of data transfer is then

33 63 passed to the next IDAW. The second and any


subsequent IDAWs must designate, depending on
the command, the first or last byte (for read back-
Bit 0 (format 1) is reserved for future use and ward) of a 2K-byte block (format-1 or format-2
must be zero; otherwise, a program-check condi- IDAW) or a 4K-byte block (format-2 IDAW). Thus,
tion may be recognized, as described below. for read, write, control, sense ID, and sense com-
mands, such format-1 IDAWs have zeros in bit
Format-1 IDAWs, when specified in the ORB of
positions 21-31 and format-2 IDAWs have zeros in
the associated CCW, designate a data area within
bit positions 53-63 (2K-byte blocks) or 52-63
a 2K-byte block of main storage and are capable
(4K-byte blocks). For a read-backward command,
of addressing storage in the range of 0 to
such format-1 IDAWs have ones in bit positions
2,147,483, 647.
21-31 and format-2 IDAWs have ones in bit posi-
tions 53-63 (2K-byte blocks) or 52-63 (4K-byte
Format-2 IDAWs, when specified in the ORB of
blocks).
the associated CCW, designate a data area within
a 2K-byte or 4K-byte block of main storage and
Except for the unique restrictions on the desig-
are capable of addressing storage in the range of
nation of the data address by the IDAW, all other
0 to 2-1. When the ORB format-2 IDAW control
actions taken for the data address, such as for
bit is one and the 2K-IDAW control bit is zero,
protected storage and invalid addresses, and the
each format-2 IDAW of the designated channel
actions taken for data prefetching are the same as
program designates a 4K-byte block of main
when indirect data addressing is not used.
storage. When the format-2 IDAW control bit is
one and the 2K-IDAW control bit is one, each IDAWs pertaining to the current CCW or a pre-
format-2 IDAW designates a 2K-byte data area fetched CCW may be prefetched. The number of
block. All IDAWs associated with the designated IDAWs that can be prefetched cannot exceed that
channel program must specify the same IDAW required to satisfy the count in the CCW that
format and all format-2 IDAWs must specify the points to the IDAWs. An IDAW takes control of
same size storage block. data transfer when the last byte has been trans-
ferred for the previous IDAW. The same actions
When the indirect-data-addressing bit in the CCW
take place as with data chaining regarding when
is one, the data-address field of the CCW desig-
an IDAW takes control of data transfer during an
nates the location of the first IDAW to be used for
I/O operation. That is, when the count for the
data transfer for the command. Additional IDAWs,
CCW has not reached zero, a new IDAW takes
if needed for completing the data transfer for the
control of the data transfer when the last byte has
CCW, are in successive locations in storage. The
been transferred for the previous IDAW for that
number of IDAWs required for a CCW is deter-
CCW, even in situations where (1) channel end,
mined by the IDAW format as specified in the
(2) channel end and device end, or (3) channel

15-36 z/Architecture Principles of Operation


end, device end, and status modifier are received these conditions is recognized, initiation of the
prior to transfer of any data bytes pertaining to the I/O operation does not occur, and the sub-
new IDAW. channel is made status-pending with primary,
secondary, and alert status.
A prefetched IDAW does not take control of an I/O
2. The operation is initiated at the device prior to
operation if the count in the CCW has reached
checking for these conditions. If the device
zero with the transfer of the last byte of data for
attempts to transfer data, the device is sig-
the previous IDAW for that CCW. Program or
naled to terminate the I/O operation, and the
access errors detected in prefetched IDAWs are
subchannel is made status-pending with
not indicated to the program until the IDAW takes
primary, secondary, and alert status as a func-
control of data transfer. However, when the
tion of the subchannel state and the status
channel subsystem detects an invalid CBC on the
presented by the device.
contents of a prefetched IDAW or its associated
key, the condition may be indicated to the
program, when detected, before the IDAW takes Suspension of Channel-Program
control of data transfer. For a description of the Execution
indications provided when an invalid CBC is
detected on the contents of an IDAW or its associ- The suspend function, when used in conjunction
ated key, see Channel-Control Check on with RESUME SUBCHANNEL, provides the
page 16-27. program with a means to stop and restart the exe-
cution of a channel program. The initiation of the
Bits 1-31 (format 1) or bits 0-63 (format 2) desig- suspend function is controlled by the setting of the
nate the absolute storage location of the first byte suspend-control bit in the ORB (bit 4 of word 1).
to be used in the data transfer. When format-1 The suspend function is signaled when suspend
IDAWs are specified, the channel subsystem control has been specified for the subchannel in
forms a 64-bit absolute main-storage address by the ORB and a CCW containing a valid S flag set
appending 33 zero bits to the left of bit 1 which is to one becomes the current CCW. The flag can
then used to access the first byte. be indicated either in the first CCW of the channel
program or in a CCW fetched while command
When the IDAW flag of the CCW is set to one and chaining. The S flag is not valid and causes a
any of the following conditions occurs: program-check condition to be recognized if
1. Format-1 IDAWs are specified in the ORB and (1) the ORB contains the suspend-control bit set
the address in the CCW does not designate to zero, or (2) the CCW is fetched while data
the first IDAW on an integral word boundary, chaining (see Data Chaining on page 15-32,
concerning the handling of programming errors
2. Format-2 IDAWs are specified in the ORB and detected during data chaining).
the address in the CCW does not designate
the first IDAW on an integral doubleword Upon recognition of the suspend function, suspen-
boundary, sion of channel-program execution occurs when
3. The address in the CCW designated a storage the CCW becomes current (see Channel-
location which is not available, Command Word on page 15-26, for a definition
of when a CCW becomes current). If suspension
4. Access to the storage location specified by the occurs during command chaining, the device is
address in the CCW is prohibited by pro- signaled that command chaining is no longer in
tection. effect.
5. Bit 0 (format 1 only) of the first IDAW is not
zero, RESUME SUBCHANNEL signals that the CCW
which caused channel-program suspension may
then, depending on the model, one of the fol- have been modified, that the CCW must be
lowing two actions is taken independent of the refetched, and that the contents of the CCW must
setting of the skip flag (if condition 5 above is ture, be examined to determine the settings of the
action 2 must be taken). flags. If the S flag is one, execution of that CCW
1. The above conditions are checked before initi- does not occur. If the CCW is valid and the S flag
ating the operation at the device. If any of in the CCW is zero, execution is initiated (see

Chapter 15. Basic I/O Functions 15-37


RESUME SUBCHANNEL on page 14-9 and When a valid CCW that contains a valid S flag
Start Function and Resume Function on becomes the current CCW during command
page 15-17). chaining and the resume-pending condition is
recognized, the resume function is performed
When a valid CCW that contains a valid S flag instead of the suspend function.
becomes the current CCW during command
chaining and the resume-pending condition is not When the first CCW of a channel program con-
recognized, the suspend function is performed and tains a valid S flag and the resume-pending condi-
causes the following actions to occur in the order tion is not recognized, the suspend function is
given: performed and causes the following actions to
occur in the order given:
1. The device is signaled that the chain of oper-
ations has been concluded. 1. Channel-program execution is suspended
prior to selection of the device.
2. Channel-program execution is suspended at
the subchannel; all prefetched IDAWs, CCWs, 2. The subchannel is set up such that the
and data are discarded; and the subchannel is resume function can be performed when the
set up such that the resume function can be subchannel is next recognized to be resume-
performed when the subchannel is next recog- pending.
nized to be resume-pending.
3. If the measurement-block-update mode is
3. If the measurement-block-update mode is active and the subchannel is enabled for the
active and the subchannel is enabled for the mode, the SSCH+RSCH count is incremented
mode, the accrued values of the measurement and the accrued function-pending time (a
data, including the start-subchannel and function of the setting of the timing-facility bit)
sample count, are added to the accumulated is added to the accumulated value in the
values in the measurement block for the sub- measurement block for the subchannel.
channel. The start-subchannel count is the
If a measurement-check condition is detected
only measurement data which is updated in
during the measurement-block update, the
the measurement block if the channel-
channel program is not started at the sub-
subsystem-timing facility is not available for
channel. The subchannel is made status
the subchannel. (See Channel-Subsystem
pending with primary, secondary, and alert
Monitoring on page 17-1 for more informa-
status. Deferred condition code one is set,
tion.)
and the start-pending bit remains set to one.
If a measurement-check condition is detected The device-status and subchannel-status
during the measurement-block update, the fields are set to zero, and one of the
channel program is terminated at the sub- measurement-check conditions is indicated in
channel. The subchannel is made status the extended-status flags of the format-0
pending with primary, secondary, and alert ESW. The subchannel is not placed in the
status, the device-status and subchannel- suspended state. (See Subchannel-Control
status fields are set to zero, and one of the Field on page 16-11.)
measurement-check conditions is indicated in
4. The subchannel is placed in the suspended
the extended-status flags of the format-0
state.
ESW. The subchannel is not placed in the
suspended state. (See Subchannel-Control 5. If the subchannel is not resume-pending at
Field on page 16-11.) this point, the subchannel is made status-
pending with intermediate status due to sus-
4. The subchannel is placed in the suspended
pension if the
state.
suppress-suspended-interruption-control bit of
5. If the subchannel is not resume-pending at the ORB is zero; otherwise, the resume func-
this point, the intermediate interruption condi- tion is performed.
tion due to suspension is recognized if the
When the first CCW of a channel program con-
suppress-suspended-interruption bit of the
tains a valid S flag and the resume-pending condi-
ORB is zero; otherwise, the resume function is
performed.

15-38 z/Architecture Principles of Operation


tion is recognized, the resume function is Commands and Flags
performed instead of the suspend function.
Figure 15-7 lists the command codes for the
Programming Notes:
seven commands and indicates which flags are
1. The execution of MODIFY SUBCHANNEL and defined for each command. Except for a format-1
START SUBCHANNEL completes with condi- CCW specifying transfer in channel, the flags are
tion code 2 set if the designated subchannel is ignored for all commands for which they are not
suspended. The start function is indicated at defined. The flags are reserved in a format-1
the subchannel while the subchannel is in the CCW specifying transfer in channel and must be
suspended state. zeros.
2. In certain situations, normal resumption of the
Name Code Flags
execution of a channel program which has
been suspended may not be desired. Normal Write
Read
M M M M M M 1 CD CC SLI PCI IDA S
M M M M M M 1 CD CC SLI SK PCI IDA S
termination of the suspended channel-program Read backward M M M M 1 1 CD CC SLI SK PCI IDA S
Control M M M M M M 1 1 CD CC SLI PCI IDA S
execution may be accomplished by: Sense M M M M 1 CD CC SLI SK PCI IDA S
Sense ID 1 1 1 1 CD CC SLI SK PCI IDA S
a. Executing HALT SUBCHANNEL desig- Transfer in X X X X 1 (See note below)
channel
nating the subchannel
Explanation:
b. Modifying the CCWs in storage such that
CC Chain command


when channel-program execution is CD Chain data
IDA Indirect data addressing
resumed, the command transferred to the M Modifier bit
device is a control command with all modi- PCI Program-controlled interruption
S Suspend
fier bits specified as zeros (no-operation) SK Skip
SLI Suppress-length indication
and with the chain-command flag specified X Ignored in a format- CCW; must be zero in a
format-1 CCW
as zero; and then executing RESUME
SUBCHANNEL. Note: Flags are ignored in a format- transfer-in-
channel CCW and must be zeros in a format-1
transfer-in-channel CCW.
c. When an IRB indicates measurement
check along with zero device status, zero
Figure 15-7. Command Codes and Flags
subchannel status, and status pending
with primary, secondary, and alert status,
All flags have individual significance, except that
it may indicate that the measurement
the CC and SLI flags are ignored when the CD
check was detected during an attempt to
flag is set to one, and, for output forward oper-
place the subchannel into the suspended
ations the SK flag is ignored. The presence of the
state.
SLI flag is ignored for immediate operations
3. If the suspended interruption is suppressed, involving format-0 CCWs, in which case the
the N condition and DCTI values applicable to incorrect-length indication is suppressed regard-
the preceding subchannel-active period are less of the setting of the flag. The incorrect-length
not made available to the program. The exe- indication may be suppressed for immediate oper-
cution of RESUME SUBCHANNEL when the ations when executing a format-1 CCW,
subchannel is in the suspended state causes depending on the incorrect-length-suppression
path-not-operational conditions and the N con- mode. The PCI flag is ignored during initial
dition to be reset to zeros. Path-not- program loading. All flags, except the PCI flag,
operational conditions and the N condition are are ignored when the S flag is one.
not reset when RESUME SUBCHANNEL is
executed and the designated subchannel is Programming Notes:
not in the suspended state. 1. A malfunction that affects the validity of data
transferred in an I/O operation is signaled at
the end of the operation by means of unit
check or channel-data check, depending on
whether the device (control unit) or the
channel subsystem detected the error. In
order to make use of the checking facilities

Chapter 15. Basic I/O Functions 15-39


provided in the system, data read in an input Transfer in Channel
operation should not be used until the end of
the operation has been reached and the Format

validity of the data has been checked. Simi- ////1 CCW Address
larly, on writing, the copy of data in main
storage should not be destroyed until the 8 31

program has verified that no malfunction
/////////////////////////////////////////////////
affecting the transfer and recording of data
was detected. 32 63

2. An error condition may be recognized and the Format 1


I/O operation terminated when 256 or more
1 Zeros
chained commands are executed with a
device and none of the executed commands 8 31
result in the transfer of any data. When this
CCW Address
condition is recognized, program check is indi-
cated. 32 63
3. All CCWs that require suppression of
incorrect-length indications must use the SLI The next CCW is fetched from the location in
flag. absolute main storage designated by the data-
address field of the CCW specifying transfer in
Branching in Channel Programs channel. The transfer-in-channel command does
not initiate any I/O operation, and the I/O device is
The channel subsystem provides two methods to not signaled of the execution of the command.
modify the normal sequential execution of the The purpose of the transfer-in-channel command
CCWs in a channel program. One is the transfer- is to provide chaining between CCWs not located
in-channel command (described in Transfer in in adjacent doubleword locations in an ascending
Channel), which can be used to loop back to a order of addresses. The command can occur in
previously executed CCW, or to connect discontig- both data and command chaining.
uous segments of the channel program. The
Bits 29-31 (format 0) or bits 61-63 (format 1) of a
other method, which uses the status-modifier
CCW that specifies the transfer-in-channel
device-status bit (described in the publication
command must be zeros, designating a CCW on a
ESA/390 Common I/O-Device Commands,
doubleword boundary. Furthermore, a CCW spec-
SA22-7204), allows conditions at the device to
ifying transfer in channel may not be fetched from
cause the channel to bypass the next CCW in the
a location designated by an immediately preceding
channel program.
transfer in channel. When either of these errors is
detected or when an invalid address is designated
in the transfer-in-channel command, the program-
check condition is generated. When a CCW
which specifies the transfer-in-channel command
designates a CCW at a location protected against
fetching, the protection-check condition is gener-
ated. Detection of these errors during data
chaining causes the operation at the I/O device to
be terminated and an interruption condition to be
generated, whereas during command chaining it
causes only an interruption condition to be gener-
ated.

The contents of the second half of the format-0


CCW, bit positions 32-63, are ignored. Similarly,
the contents of bit positions 0-3 of the format-0
CCW are ignored.

15-40 z/Architecture Principles of Operation


Bit positions 0-3 and 8-32 of the format-1 CCW CANCEL SUBCHANNEL (if the instruction is
must contain zeros; otherwise, a program-check installed), CLEAR SUBCHANNEL, or HALT SUB-
condition is generated. CHANNEL. If the I/O operation is ended by
CANCEL SUBCHANNEL, there is no subsequent
Command Retry interruption condition from the I/O operation, and
the subchannel is available for the initiation of
The channel subsystem has the capability to another start function. However, the device may
perform command retry, a procedure that causes have signaled a busy condition while the canceled
a command to be retried without requiring an I/O operation was start-pending. In this case, the
interruption. This retry is initiated by the control device owes a no-longer-busy signal to the
unit presenting either of two status-bit combina- channel subsystem. This may result in unsolicited
tions by means of a special sequence. When device-end status before the next operation is initi-
immediate retry can be performed, it presents a ated at the device. (See also Clear Function on
channel-end, unit-check, and status-modifier page 15-13 and Halt Function on page 15-14.)
status-bit combination, together with device end.
When immediate retry cannot be performed, the
presentation of device end is delayed until the Concluding I/O Operations during
control unit is prepared. When device end is pre- Initiation
sented alone, the previous command is trans- After the designated subchannel has been deter-
ferred again. If device end is accompanied by mined to be in a state such that START SUB-
status modifier, command retry is not performed, CHANNEL can be executed, certain tests are
and the channel subsystem command-chains to performed on the validity of the information speci-
the CCW following the one for which command fied by the program and on the logical availability
retry was signaled (for information on status modi- of the associated device. This testing occurs
fier, see the publication ESA/390 Common during or subsequent to the execution of START
I/O-Device Commands, SA22-7204). When the SUBCHANNEL and during command chaining and
channel subsystem is not capable of performing command retry.
command retry due to an error condition, or when
any status bit other than device end or device end A data-transfer operation is initiated at the sub-
and status modifier accompanies the requested channel and device only when no programming or
command-retry initiation, the retry is suppressed, equipment errors are detected by the channel sub-
and the subchannel becomes status-pending. The system and when the device responds with zero
SCSW stored by TEST SUBCHANNEL contains status during the initiation sequence. When the
the status provided by the I/O device. channel subsystem detects or the device signals
Programming Note: The following possible any unusual condition during the initiation of an
results of a command retry must be anticipated by I/O operation, the command is said to be not
the program: accepted. In this case, the subchannel becomes
status-pending with primary, secondary, and alert
1. A CCW containing a PCI may, if retried status. Deferred condition code 1 is set, and the
because of command retry, cause multiple start-pending bit remains set to one.
PCI interruptions to occur.
2. If a CCW used in an operation is changed Conditions that preclude the initiation of an I/O
before that operation has been successfully operation are detailed in the SCSW stored by
completed, the results are unpredictable. TEST SUBCHANNEL. In this situation, the device
is not started, no interruption conditions are gener-
ated subsequent to TEST SUBCHANNEL, and the
Concluding I/O Operations Prior subchannel is idle. The device is immediately
available for the initiation of another operation,
to Initiation provided the command was not rejected because
Subsequent to execution of START SUB- of the busy or not-operational condition.
CHANNEL or RESUME SUBCHANNEL, and
before the first command is accepted, the start When an unusual condition causes a command to
function can be ended at the subchannel by be not accepted during the initiation of an I/O

Chapter 15. Basic I/O Functions 15-41


operation by command chaining or command command retry occurs for an immediate operation,
retry, an interruption condition is generated, and an interruption condition is not generated. The
the subchannel becomes status-pending with com- subsequent commands in the chain are handled
binations of primary, secondary, and alert status normally, and, usually, the channel-end condition
as a function of the status signaled by the device. for the last CCW generates a primary interruption
The status describing the condition remains at the condition. If device end is signaled with channel
subchannel until cleared by TEST SUBCHANNEL. end, a secondary interruption condition is also
The conditions are indicated to the program by generated.
means of the corresponding status bits in the
SCSW. A path-not-operational condition recog- Whenever immediate completion of an I/O opera-
nized during command chaining is signaled to the tion is signaled, no data has been transferred to or
program by means of an interface-control-check from the device, and the data address in the CCW
indication. The new I/O operation at the device is is not checked for validity. If the subchannel is in
not started. the incorrect-length-suppression mode, incorrect
length is not indicated to the program, and
START SUBCHANNEL is executed independent command chaining is performed when specified.
of its associated device. Tests on most program- If the subchannel is in the incorrect-length-
specified information, on device availability and indication mode, incorrect length and command
unit status, and on most error conditions are per- chaining are under control of the SLI and chain-
formed subsequent to the execution of START command flags. The conditions which cause the
SUBCHANNEL. When any conditions are incorrect-length indication to be suppressed are
detected that preclude the execution of the start summarized in Figure 15-6 on page 15-31.
function, an interruption condition is generated by
Programming Note: I/O operations for which the
the channel subsystem and placed at the sub-
entire operation is specified in the command code
channel, causing it to become status-pending.
may be executed as immediate operations.
Whether the command is executed as an imme-
diate operation depends on the operation and type
Immediate Conclusion of I/O of device.
Operations
During the initiation of an I/O operation, the device
can accept the command and signal the Concluding I/O Operations
channel-end condition immediately upon receipt of During Data Transfer
the command code. An I/O operation causing the
When the subchannel has been passed the con-
channel-end condition to be signaled during the
tents of an ORB, the subchannel is said to be
initiation sequence is called an immediate opera-
start-pending. When the I/O operation has been
tion. Status generated by the device for the
initiated and the command has been accepted, the
immediate command, when command chaining is
subchannel becomes subchannel-and-device
not specified and command retry is not signaled,
active and remains in that state unless (1) the
causes the subchannel to become status-pending
channel subsystem detects an equipment malfunc-
with combinations of primary, secondary, interme-
tion, (2) the operation is concluded by execution
diate, and alert status as a result of information
of CLEAR SUBCHANNEL or HALT SUB-
specified in the ORB and CCW and status pre-
CHANNEL, or (3) status which causes a primary
sented by the device. If the immediate operation
interruption condition to be recognized (usually
is the first operation of the channel program,
channel end) is accepted from the device. When
deferred condition code 1 is set and accompanies
command chaining and command retry are not
the status indications. If intermediate status is
specified or when chaining is suppressed because
indicated, the indication can occur only as a result
of unusual conditions, the status that is recognized
of the CCW having the PCI flag set to one (see
as primary status causes the operation at the sub-
Program-Controlled Interruption on page 15-34).
channel to be concluded and an interruption con-
dition to be generated. The status bits in the
Whenever command chaining is specified after an
associated SCSW indicate primary status and the
immediate operation and no unusual conditions
unusual conditions, if any. The device can
have been detected during the execution, or when
present status that is recognized as primary status

15-42 z/Architecture Principles of Operation


at any time after the initiation of the I/O operation, main storage. When the initial data address in the
and the presentation of status may occur before CCW is invalid, no data is transferred during the
any data has been transferred. operation, and the device is signaled to conclude
the operation in response to the first service
For operations not involving data transfer, the request. On writing, devices such as magnetic-
device normally controls the timing of the tape units request the first byte of data before any
channel-end condition. The duration of data- mechanical motion is started and, if the initial data
transfer operations may be variable and may be address is invalid, the operation is terminated by
controlled by the device or the channel sub- the channel subsystem before the recording
system. medium has been advanced. However, since the
operation has been initiated at the device, the
Excluding equipment errors, and the execution of device presents channel-end status, causing the
the CLEAR SUBCHANNEL, HALT SUB- channel subsystem to recognize a primary inter-
CHANNEL, and RESET CHANNEL PATH ruption condition. Subsequently, the device also
instructions, the channel subsystem signals the presents device-end status, causing the channel
device to conclude execution of an I/O operation subsystem to recognize a secondary interruption
during data transfer whenever any of the following condition. Whether a block at the device is
conditions occurs: advanced when no data is transferred depends on
The storage areas designated for the opera- the type of device.
tion are exhausted or filled.
When command chaining takes place, the sub-
A program-check condition is detected. channel is in the subchannel-and-device-active
A protection-check condition is detected. state from the time the first I/O operation is initi-
ated at the device until the device presents
A chaining-check condition is detected. channel-end status for the last I/O operation of the
A channel-control-check condition is detected chain. The subchannel remains in the device-
that does not affect the control of the I/O oper- active state until the device presents the
ation. device-end status for the last I/O operation of the
chain.
The first of these conditions occurs when the
channel subsystem has decremented the count to Any unusual conditions cause command chaining
zero in the last CCW associated with the opera- to be suppressed and a primary interruption condi-
tion. A count of zero indicates that the channel tion to be generated. The unusual conditions can
subsystem has transferred all information specified be detected by either the channel subsystem or
by the I/O operation. The other four conditions are the device, and the device can provide the indi-
due to errors and cause premature conclusion of cations with channel end, control-unit end, or
data transfer. In either case, the conclusion is sig- device end. When the channel subsystem is
naled in response to a service request from the aware of the unusual condition by the time the
device and causes data transfer to cease. If the channel-end status for the operation is accepted,
device has no blocks defined for the operation the chain is ended as if the operation during which
(such as writing on magnetic tape), it concludes the condition occurred were the last operation of
the operation and presents channel-end status. the chain. The device-end status is recognized as
a secondary interruption condition whether pre-
The device can control the duration of an opera-
sented together with the channel-end status or
tion and the timing of channel end by blocking of
separately. If the device presents unit check or
data. On certain operations for which blocks are
unit exception together with either control-unit end
defined (such as reading on magnetic tape), the
or device end as status which causes the channel
device does not present channel-end status until
subsystem to recognize the primary interruption
the end of the block is reached, regardless of
condition, then the subchannel-and-device-active
whether the device has been previously signaled
state of the subchannel is terminated, and the
to conclude data transfer.
subchannel is made status-pending with primary,
secondary, and alert status. Intermediate status
Checking for the validity of the data address is
may also be indicated if an intermediate inter-
performed only as data is transferred to or from
ruption condition previously existed at the sub-

Chapter 15. Basic I/O Functions 15-43


channel for the initial-status-interruption condition 4. If an I/O operation is in progress in multipath
or the PCI condition and that condition still mode at the device and the device is not cur-
remains pending at the subchannel. The rently communicating over the channel path in
channel-end status which was presented to the execution of that I/O operation when the reset
channel subsystem previously when command signal is received, then the I/O operation may
chaining was signaled is not made available to the or may not be reset depending on whether
program. another channel path is available for selection
in the same multipath group for the device. If
there is at least one other channel path in the
Channel-Path-Reset Function multipath group for the device that is available
for selection, the I/O operation is not reset.
Subsequent to the execution of RESET CHANNEL
However, the channel path on which the
PATH, the channel-path-reset function is per-
system reset is received is removed from the
formed. Execution of the function consists of:
current set of channel paths that form the
(1) issuing the reset signal on the designated
multipath group. If the channel path on which
channel path and (2) causing a channel report to
the reset signal is received is either the only
be made pending, indicating completion of the
channel path of a multipath group or the
channel-path-reset function.
device is operating in single-path mode, the
I/O operation is reset.
Channel-Path-Reset-Function
5. The channel-path-reset function causes I/O
Signaling operations to be terminated at the device as
described above; however, I/O operations are
The channel subsystem issues the reset signal on
never terminated at the subchannel by the
the designated channel path. As part of this oper-
channel-path-reset function.
ation, the following actions are taken:
If an I/O operation is in progress at the sub-
1. All internal indications associated with control
channel and the channel path designated for the
unit busy, device busy, and allegiance condi-
execution of the channel-path-reset function is
tions for the designated channel path are
being used for that I/O operation, the subchannel
reset. These indications are reset at all sub-
may or may not accurately reflect the progress of
channels that have access to the designated
the I/O operation up to that instant. The sub-
channel path. The reset function has no other
channel remains in the state that exists at the time
effect on subchannels, including those having
the channel-path-reset function is performed until
I/O operations in progress.
the state is changed because of some action
2. If the channel path fails to respond properly to taken by the program or by the device.
the reset signal (see I/O-System Reset on
page 17-10 for a detailed description) or, Channel-Path-Reset
because of a malfunction, the reset signal
could not be issued, the channel path is made Function-Completion Signaling
physically not available at each applicable
After the reset signal has been issued and an
subchannel.
attempt has been made to issue the reset signal,
3. If an I/O operation is in progress at the device or after it has been determined that the reset
and the device is actively communicating on signal cannot be issued, the channel-path-reset
the channel path in the execution of that I/O function is completed. (See Reset Signal on
operation when the reset signal is received on page 17-10.)
that channel path, the I/O operation is reset,
and the control unit and device immediately As a result of the channel-path-reset function
terminate current communication with the being performed, a channel report is made
channel subsystem. (To avoid possible misin- pending (see Channel-Subsystem Recovery on
terpretation of unsolicited device-end status, page 17-19) to report the results. If the channel
programming measures can be taken as path responds properly to the system-reset signal,
described in programming note 2 on the channel report indicates that the channel path
page 15-45.) has been initialized and is physically available for

15-44 z/Architecture Principles of Operation


use. If the reset signal was issued but either the erroneously interpreted by the channel sub-
channel path failed to respond properly or the system to be chaining status and thus cause
channel path was already not physically available the channel subsystem to continue the chain
at each subchannel having access to the channel of commands. If this situation occurs, the
path, the channel report indicates that the channel device-end status is not made available to the
path has been initialized but is not physically avail- program and the device is selected again by
able for use. If, because of a malfunction or the channel subsystem; however, the device
because the designated channel path is not in the may interpret the initiation sequence as the
configuration, the reset signal could not be issued, beginning of a new channel program instead
the channel report indicates that the channel path of command chaining. This possibility can be
has not been initialized and is not physically avail- avoided by executing CLEAR SUBCHANNEL
able for use. or HALT SUBCHANNEL, designating the
affected subchannels, prior to executing
Programming Notes: RESET CHANNEL PATH.
1. If an I/O operation is in progress in multipath 3. Execution of the channel-path-reset function
mode when the channel-path-reset function is may, on some models, cause overruns to
performed on a channel path of the multipath occur on other channel paths.
group, it is possible for the I/O operation to be
4. Even though reset is signaled on the desig-
continued on a remaining channel path of the
nated channel path, allegiances to that
group.
channel path by one or more devices may not
2. When the execution of the channel-path-reset have been reset because of a malfunction at a
function causes the I/O operation at the control unit or a malfunction at the physical
device to be reset, unsolicited device-end channel path to the control unit.
status presented by the device, if any, may be

Chapter 15. Basic I/O Functions 15-45


15-46 z/Architecture Principles of Operation
Chapter 16. I/O Interruptions
Interruption Conditions . . . . . . . . . . . . . 16-2 Status Control (SC) . . . . . . . . . . . 16-16
Intermediate Interruption Condition . . . . 16-4 CCW-Address Field . . . . . . . . . . . . 16-18
Primary Interruption Condition . . . . . . . 16-4 Device-Status Field . . . . . . . . . . . . 16-23
Secondary Interruption Condition . . . . . 16-4 Subchannel-Status Field . . . . . . . . . 16-23
Alert Interruption Condition . . . . . . . . . 16-4 Program-Controlled Interruption . . . . 16-23
Priority of Interruptions . . . . . . . . . . . . . 16-5 Incorrect Length . . . . . . . . . . . . . 16-23
Interruption Action . . . . . . . . . . . . . . . . 16-5 Program Check . . . . . . . . . . . . . 16-24
Interruption-Response Block . . . . . . . . . . 16-6 Protection Check . . . . . . . . . . . . 16-26
Subchannel-Status Word . . . . . . . . . . . . 16-6 Channel-Data Check . . . . . . . . . . 16-26
Subchannel Key . . . . . . . . . . . . . . 16-8 Channel-Control Check . . . . . . . . 16-27
Suspend Control (S) . . . . . . . . . . . 16-8 Interface-Control Check . . . . . . . . 16-28
Extended-Status-Word Format (L) . . . 16-8 Chaining Check . . . . . . . . . . . . . 16-29
Deferred Condition Code (CC) . . . . . 16-8 Count Field . . . . . . . . . . . . . . . . . 16-29
Format (F) . . . . . . . . . . . . . . . . 16-10 Extended-Status Word . . . . . . . . . . . . 16-32
Prefetch (P) . . . . . . . . . . . . . . . 16-10 Extended-Status Format 0 . . . . . . . . 16-32
Initial-Status-Interruption Control (I) . . 16-11 Subchannel Logout . . . . . . . . . . . 16-32
Address-Limit-Checking Control (A) . 16-11 Extended-Report Word . . . . . . . . . 16-36
Suppress-Suspended Interruption (U) .16-11 Failing-Storage Address . . . . . . . . 16-37
Subchannel-Control Field . . . . . . . . . 16-11 Secondary-CCW Address . . . . . . . 16-38
Zero Condition Code (Z) . . . . . . . . 16-11 Extended-Status Format 1 . . . . . . . . 16-38
Extended Control (E) . . . . . . . . . . 16-11 Extended-Status Format 2 . . . . . . . . 16-38
Path Not Operational (N) . . . . . . . . 16-12 Extended-Status Format 3 . . . . . . . . 16-39
Function Control (FC) . . . . . . . . . 16-12 Extended-Control Word . . . . . . . . . . . . 16-40
Activity Control (AC) . . . . . . . . . . 16-13

When an I/O operation or sequence of I/O oper- Normally an I/O operation is in execution until the
ations initiated by the execution of START SUB- device signals primary interruption status. Primary
CHANNEL is ended, the channel subsystem and interruption status can be signaled during initiation
the device generate status conditions. The gener- of an I/O operation, or later. An I/O operation can
ation of these conditions can be brought to the be terminated by the channel subsystem per-
attention of the program by means of an I/O inter- forming a clear or halt function when it detects an
ruption or by means of the execution of the TEST equipment malfunction, a program check, a
PENDING INTERRUPTION instruction. (During chaining check, a protection check, or an
certain abnormal situations, these conditions can incorrect-length condition, or by performing a
be brought to the attention of the program by clear, halt, or channel-path-reset function as a
means of a machine-check interruption. See result of the execution of CLEAR SUBCHANNEL,
Channel-Subsystem Recovery on page 17-19 HALT SUBCHANNEL, or RESET CHANNEL
for details.) The status conditions, as well as an PATH, respectively.
address and a count indicating the extent of the
operation sequence, are presented to the program I/O interruptions provide a means for the CPU to
in the form of a subchannel-status word (SCSW). change its state in response to conditions that
The SCSW is stored in an interruption-response occur at I/O devices or subchannels. These con-
block (IRB) during the execution of TEST SUB- ditions can be caused by the program, by the
CHANNEL. channel subsystem, or by an external event at the
device.

Copyright IBM Corp. 1990, 2000 16-1


When an I/O operation is terminated because of
Interruption Conditions an unusual condition detected by the channel sub-
The conditions causing requests for I/O inter- system during the command initiation sequence,
ruptions to be initiated are called I/O-interruption status describing the interruption condition is
conditions. When an interruption condition is placed at the subchannel, causing it to become
recognized by the channel subsystem, it is indi- status-pending. If the unusual condition is
cated at the appropriate subchannel. The sub- detected by the device, the device-status field of
channel is then said to be status-pending. The the associated SCSW identifies the condition.
subchannel becoming status-pending causes the
channel subsystem to generate an I/O-interruption When command chaining takes place, the gener-
request. An I/O-interruption request can be ation of status by the device does not cause an
brought to the attention of the program only once. interruption, and the status is not made available
to the program.
An I/O-interruption request remains pending until it
is accepted by a CPU in the configuration, is with- When the channel subsystem detects any of the
drawn by the channel subsystem, or is cleared by following interruption conditions, it initiates a
means of the execution of TEST PENDING request for an I/O interruption without necessarily
INTERRUPTION, TEST SUBCHANNEL, or communicating with, or having received the status
CLEAR SUBCHANNEL, or by means of sub- byte from, the device:
system reset. When a CPU accepts an inter- A programming error associated with the con-
ruption request and stores the associated tents of the ORB passed to the subchannel by
interruption code, the interruption request is the previous execution of START SUB-
cleared. Alternatively, an I/O-interruption request CHANNEL
can be cleared by means of the execution of
TEST PENDING INTERRUPTION. In either case, A valid suspend flag in the first CCW fetched
the subchannel remains status-pending until the that initiates channel-program execution for
associated interruption condition is cleared when either START SUBCHANNEL or RESUME
TEST SUBCHANNEL or CLEAR SUBCHANNEL SUBCHANNEL, and suppress suspended
is executed or when the subchannel is reset. interruption not specified in the ORB
A programming error associated with the first
An I/O-interruption condition is normally cleared by CCW or first IDAW
means of the execution of TEST SUBCHANNEL.
If TEST SUBCHANNEL is executed, designating a These interruption conditions from the subchannel,
subchannel that has an I/O-interruption request except for the suspended condition, can be
pending, both the interruption request and the accompanied by other subchannel-status indi-
interruption condition at the subchannel are cations, but the device-status indications are all
cleared. The interruption request and the inter- stored as zeros.
ruption condition can also be cleared by CLEAR
The channel subsystem issues the clear signal to
SUBCHANNEL.
the device when status containing unit check is
A device-end status condition generated by the presented to a subchannel that is disabled or
I/O device and presented following the conclusion when the device is not associated with any sub-
of the last I/O operation of a start function is reset channel. However, if the presented status does
at the subchannel by the channel subsystem not contain unit check, the status is accepted by
without generating an I/O-interruption condition or the channel subsystem and discarded without
I/O-interruption request if the subchannel is cur- causing the subchannel to become status-
rently start-pending and if the status contains pending.
device end either alone or accompanied by
An interruption condition caused by the device
control-unit end. If any other status bits accom-
may be accompanied by multiple device-status
pany the device-end status bit, then the channel
conditions. Further, more than one interruption
subsystem generates an I/O-interruption request
condition associated with the same device can be
with deferred condition code 1 indicated.
accepted by the channel subsystem without an
intervening I/O interruption. As an example, when

16-2 z/Architecture Principles of Operation


the channel-end condition is not cleared at the The subchannel and device status associated with
device by the time device end is generated, both an unsolicited interruption condition is never
conditions may be cleared at the device concur- merged with that of any currently existing inter-
rently and indicated in the SCSW together. Alter- ruption condition. If the subchannel is currently
natively, channel-end status may have been status-pending, the unsolicited interruption condi-
previously accepted at the subchannel, and an I/O tion is held in abeyance in either the channel sub-
interruption may have occurred; however, the system or the device, as appropriate, until the
associated status-pending condition may not have status-pending condition has been cleared.
been cleared by TEST SUBCHANNEL by the time Whenever the subchannel is idle and zero status
device-end status was accepted at the sub- is presented by the device, the status is dis-
channel. In this situation, the device-end status carded.
may be merged with the channel-end status
without causing an additional I/O interruption. Solicited Interruption Condition: A solicited
Whether an interruption condition may be merged interruption condition is any interruption condition
at the subchannel with other existing interruption generated as a direct consequence of performing
conditions depends upon whether the interruption or attempting to perform a clear, halt, resume, or
condition is unsolicited or solicited. start function. Solicited interruption conditions
include any interruption condition generated while
Unsolicited Interruption Condition: An unsolic- the subchannel is either subchannel-and-device-
ited interruption condition is any interruption condi- active or device-active. The subchannel and
tion which is unrelated to the performance of a device status associated with a solicited inter-
clear, halt, resume, or start function. An unsolic- ruption condition may be merged at the sub-
ited interruption condition is identified at the sub- channel with that of another currently existing
channel as alert status. An unsolicited interruption solicited interruption condition. Figure 16-1
condition can be generated only when the sub- describes the interruption condition that results
channel is not device-active. from any combination of bits in the status-control
field of the SCSW.

Status-Control Field Status-Control-Bit Combinations

Alert 1 1 1 1 1 1 1 1
Primary 1 1 1 1 1 1 1 1
Secondary 1 1 1 1 1 1 1 1
Intermediate 1 1 1 1 1 1 1 1
Status-pending 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Resulting interrup- E S S S S S - S S S S S S - S S
tion condition

Explanation:

- Combination does not occur.
E Unsolicited or solicited interruption condition.
S Solicited interruption condition.
Indicates the bit stored as zero.
1 Indicates the bit stored as one.

Figure 16-1. Interruption Condition for Status-Control-Bit Combinations

Chapter 16. I/O Interruptions 16-3


Intermediate Interruption ferring commands or data. When a subchannel is
status-pending with a primary interruption condi-
Condition tion, execution of any of the following instructions
results in the setting of a nonzero condition code:
An intermediate interruption condition is a solicited
HALT SUBCHANNEL, MODIFY SUBCHANNEL,
interruption condition that indicates that an event
RESUME SUBCHANNEL, and START SUB-
has occured for which the program had previously
CHANNEL. Once the primary interruption condi-
requested notification. An intermediate inter-
tion is cleared by executing TEST SUBCHANNEL,
ruption condition is described by solicited sub-
the subchannel accepts the START SUB-
channel status, the Z bit, the
CHANNEL instruction. (See START
subchannel-suspended condition, or any combina-
SUBCHANNEL on page 14-14.)
tion of the three. An intermediate interruption con-
dition can occur only after it has been requested
by the program through the use of flags in the Secondary Interruption Condition
ORB or a CCW. Depending on the state of the
subchannel, execution or suspension of the I/O A secondary interruption condition is a solicited
operation continues, unaffected by the setting of interruption condition that normally indicates the
the intermediate-status bit. completion of an I/O operation at the device. A
secondary interruption condition is also generated
An intermediate interruption condition can be indi- by the channel subsystem if the start function is
cated only together with one of the following indi- terminated because a solicited alert interruption
cations: condition is recognized prior to initiating the first
I/O operation at the device. A secondary inter-
1. Subchannel-active
ruption condition is described by the SCSW stored
2. Status-pending with primary status alone as a result of executing TEST SUBCHANNEL
while the subchannel is status-pending with sec-
3. Status-pending with primary status together
ondary status. Once the channel subsystem has
with alert status or secondary status or both
accepted status from the device that causes a
4. Suspended secondary interruption condition to be recognized,
If only the intermediate-status bit and the status- the start function is completed at the device.
pending bit of the status-control field are ones
during the execution of TEST SUBCHANNEL, the Alert Interruption Condition
device-status field is zero.
An alert interruption condition is either a solicited
interruption condition that indicates the occurrence
Primary Interruption Condition
of an unusual condition in a halt, resume, or start
A primary interruption condition is a solicited inter- function or an unsolicited interruption condition
ruption condition that indicates the performance of that describes a condition unrelated to the per-
the start function is completed at the subchannel. formance of a halt, resume, or start function. An
A primary interruption condition is described by alert interruption condition is described by the
the SCSW stored as a result of executing TEST SCSW stored as a result of executing TEST SUB-
SUBCHANNEL while the subchannel is status- CHANNEL while the subchannel is status-pending
pending with primary status. Once the primary with alert status. An alert interruption condition
interruption condition is indicated at the sub- may be generated by either the channel sub-
channel, the channel subsystem is no longer system or the device. Nonzero alert status is
actively participating in the I/O operation by trans- always brought to the attention of the program.

16-4 z/Architecture Principles of Operation


The priority of interruption handling can be modi-
Priority of Interruptions fied by execution of either TEST SUBCHANNEL
All requests for an I/O interruption are asynchro- or CLEAR SUBCHANNEL. When either of these
nous to any activity in any CPU, and interruption instructions is executed and the designated sub-
requests associated with more than one sub- channel has an interruption request pending, that
channel can exist at the same time. The priority interruption request is cleared, without regard to
of interruptions is controlled by two types of mech- any previous established priority. The relative pri-
anisms -- one establishes within the channel sub- ority of the remaining interruption requests is
system the priority among interruption requests unchanged.
from subchannels associated with the same
I/O-interruption subclass, and another establishes Programming Notes:
within a given CPU the priority among requests 1. The I/O-interruption subclass mask is in
from subchannels of different I/O-interruption sub- control register 6, which has the following
classes. The channel subsystem requests an I/O format:
interruption only after it has established priority
among requests from its subchannels. The condi-
tions responsible for the requests are preserved at ///ISC Mask Reserved
the subchannels until cleared by a CPU executing
32 4 63
TEST SUBCHANNEL or CLEAR SUBCHANNEL
or until I/O-system reset is performed.
2. Control register 6 is set to all zeros during
The assignment of priority among requests for initial CPU reset.
interruption from subchannels of the same
I/O-interruption subclass is in the order that the
need for interruption is recognized by the channel Interruption Action
subsystem. The order of recognition by the An I/O interruption can occur only when the
channel subsystem is a function of the type of I/O-interruption subclass-mask bit associated with
interruption condition and the type of channel the subchannel is one and the CPU is enabled for
path. I/O interruptions.
The assignment of priority among requests for The interruption occurs at the completion of a unit
interruption from subchannels of different of operation (see Point of Interruption on
I/O-interruption subclasses is made by the CPU page 5-20). If the channel subsystem establishes
according to the numerical value of the the priority among requests for interruption from
I/O-interruption subclass codes (with zero having subchannels while the CPU is disabled for I/O
highest priority), in conjunction with the interruptions, the interruption occurs immediately
I/O-interruption subclass mask in control register after completion of the instruction enabling the
6. The numerical value of the I/O-interruption sub- CPU and before the next instruction is executed,
class code directly corresponds to the bit position provided that the I/O-interruption subclass-mask
in the I/O-interruption subclass mask in control bit associated with the subchannel is one. Alter-
register 6 of a CPU. If in any CPU an natively, if the channel subsystem establishes the
I/O-interruption subclass-mask bit is zero, then all priority among requests for interruption from sub-
subchannels having an I/O-interruption subclass channels while the I/O-interruption subclass-mask
code numerically equal to the associated position bit is zero for each subchannel which is status-
in the mask register are said to be masked off in pending, the interruption occurs immediately after
the respective CPU. Therefore, a CPU accepts completion of the instruction which sets at least
the highest-priority I/O-interruption request from a one of the I/O-interruption subclass-mask bits to
subchannel which has the lowest-numbered one, provided that the CPU is also enabled for I/O
I/O-interruption subclass code that is not masked interruptions. This interruption is associated with
off by a corresponding bit in control register 6 of the highest-priority I/O-interruption request, as
that CPU. When the highest-priority interruption established by the CPU.
request is accepted by a CPU, it is cleared so that
the interruption request is not accepted by any
other CPU in the configuration.

Chapter 16. I/O Interruptions 16-5


If the channel subsystem has not established the
priority among requests for interruption from the Interruption-Response Block
subchannels by the time the interruption is The interruption-response block (IRB) is the
allowed, the interruption does not necessarily operand of TEST SUBCHANNEL. The two right-
occur immediately after completion of the instruc- most bits of the IRB address are zeros, desig-
tion enabling the CPU. A delay can occur regard- nating the IRB on a word boundary. The IRB
less of how long the interruption condition has contains three major fields: the subchannel-status
existed at the subchannel. word, the extended-status word, and the
extended-control word. The format of the IRB is
The interruption causes the current PSW to be as follows:
stored at the assigned I/O-old PSW real-storage
locations and causes the I/O-interruption code
associated with the interruption to be stored at the Word
1 Subchannel-Status Word
assigned real storage locations 184-195 of the 2
CPU allowing the interruption. Subsequently, an
I/O-new PSW is loaded from its assigned real- 3
4
storage locations and processing resumes in the 5 Extended-Status Word
CPU state indicated by the new PSW. The sub- 6
channel causing the interruption is identified by 7

the interruption code. 8

The I/O-interruption code has the following format / Extended-Control Word /

when it is stored (See TEST PENDING 15
INTERRUPTION on page 14-17.):

Hex. Dec.
The length of the subchannel-status and
B8 184 Subsystem-Identification Word extended-status words is 12 bytes and 20 bytes,
respectively. The length of the extended-control
BC 188 Interruption Parameter word is 32 bytes. When the extended-control bit

C 192 Interruption-Identification (bit 14, word 0) of the SCSW is zero, words 8-15
Word of the interruption-response block may or may not
be stored.
31

Programming Notes: Subchannel-Status Word


1. The I/O-interruption subclass code for all sub- The subchannel-status word (SCSW) provides to
channels is set to zero by I/O-system reset. It the program indications describing the status of a
may be set to any of the values 0-7 by exe- subchannel and its associated device. If perform-
cuting MODIFY SUBCHANNEL. (The opera- ance of a halt, resume, or start function has
tion of the instruction is described in MODIFY occurred, the SCSW may describe the conditions
SUBCHANNEL on page 14-7.) under which the operation was concluded.

2. When the CPU is operating in ESA/390 mode, The SCSW is stored when TEST SUBCHANNEL
an I/O interruption causes the current PSW to is executed and the designated subchannel is
be stored at real locations 56-63 and the operational. The SCSW is placed in words 0-2 of
I/O-new PSW to be loaded from real locations the IRB that is designated as the TEST SUB-
120-127. When the CPU is operating in CHANNEL operand. When STORE SUB-
z/Architecture mode, an I/O interruption CHANNEL is executed, the SCSW is stored in
causes the current PSW to be stored at real words 7-9 of the subchannel-information block
locations 368-383 and the I/O-new PSW to be (described in Subchannel-Information Block on
loaded from real locations 496-511. page 15-1). Figure 16-2 on page 16-7 shows the
format of the SCSW and summarizes its contents.

16-6 z/Architecture Principles of Operation


Word
Key SL CCFPIAUZEN FC AC SC

1 CCW Address

2 Device Status Sch Status Count

4 8 16 2 27 31

BITS NAME

Word
-3 Subchannel key
4 Suspend control (S)
5 ESW Format (L)
6-7 Deferred condition code (CC)
8 Format (F)
9 Prefetch (P)
1 Initial-status interruption control (I)
11 Address-limit-checking control (A)
12 Suppress-suspended interruption (U)
13 Zero condition code (Z)
14 Extended control (E)
15 Path not operational (N)
16 Reserved
17-19 Function control (FC)
(bit 17, start function; bit 18, halt function;
bit 19, clear function)
2-26 Activity control (AC)
(bit 2, resume-pending; bit 21, start-pending;
bit 22, halt-pending; bit 23, clear-pending;
bit 24, subchannel-active; bit 25, device-active;
bit 26, suspended)
27-31 Status control (SC)
(bit 27, alert status; bit 28, intermediate status;
bit 29, primary status; bit 3, secondary status;
bit 31, status-pending)

Word 1
-31 CCW address

Word 2
-7 Device status
(bit , attention; bit 1, status modifier;
bit 2, control-unit end; bit 3, busy;
bit 4, channel end; bit 5, device end;
bit 6, unit check; bit 7, unit exception)
8-15 Subchannel status (Sch Status)
(bit 8, program-controlled interruption; bit 9, incorrect length;
bit 1, program check; bit 11, protection check;
bit 12, channel-data check; bit 13, channel-control check;
bit 14, interface-control check; bit 15, chaining check)
16-31 Count
Figure 16-2. SCSW Format

Chapter 16. I/O Interruptions 16-7


The contents of the subchannel-status word format-0 ESW is cleared at the subchannel by
(SCSW) depend on the state of the subchannel TEST SUBCHANNEL or CLEAR SUBCHANNEL.
when the SCSW is stored. Depending on the
state of the subchannel and the device, the spe- Deferred Condition Code (CC)
cific fields of the SCSW may contain (1) informa- When the start-function bit (bit 17 of word 0) is
tion pertaining to the last operation, one and the status-pending bit (bit 31 of word 0) is
(2) information unrelated to the execution of an also one, bits 6-7 of word 0 indicate the general
operation, (3) zeros, or (4) a value of no reason that the subchannel was status-pending
meaning. The following descriptions indicate when TEST SUBCHANNEL or STORE SUB-
when an SCSW field contains meaningful informa- CHANNEL was executed. The deferred condition
tion. code is meaningful when the subchannel is status-
pending with any combination of status and only
Subchannel Key when the start-function bit of the function-control
When the start-function bit (bit 17 of word 0) is field in the SCSW is one. The meaning of the
one, bits 0-3 of word 0 contain the access key deferred condition code for each value when the
used during performance of the associated start subchannel is status-pending is given in
function. These bits are identical with the key Figure 16-3 on page 16-10.
specified in the ORB (bits 0-3 of word 1). The
subchannel key is meaningful only when the start- The deferred condition code, if not zero, is used to
function bit (bit 17 of word 0) is one. indicate whether conditions have been encount-
ered that preclude the subchannel becoming
Suspend Control (S) subchannel-and-device-active while the sub-
When the start-function bit (bit 17 of word 0) is channel is either start-pending or suspended.
one, bit 4 of word 0, when one, indicates that the
suspend function can be initiated at the sub- Deferred Condition Code 0: A normal I/O inter-
channel. Bit 4 is meaningful only when bit 17 is ruption has taken place.
one. If bit 17 is one and bit 4 is one, channel-
program execution can be suspended if the Deferred Condition Code 1: Status is present in
channel subsystem recognizes a valid S flag the SCSW that was presented by the associated
which is set to one in a CCW. If bit 4 is zero, device or generated by the channel subsystem
channel-program execution cannot be suspended, subsequent to the setting of condition code 0 for
and if an S flag set to one in a CCW is recog- START SUBCHANNEL or RESUME SUB-
nized, a program-check condition is recognized. CHANNEL. If only the alert-status bit and the
status-pending bit of the status-control field of the
SCSW are ones, the status present is not related
Extended-Status-Word Format (L)
to the execution of a channel program. If the
When the status-pending bit (bit 31 of word 0) is
intermediate-status bit, the primary-status bit, or
one, bit 5 of word 0, when one, indicates that a
both are ones, then the status is related to the
format-0 ESW has been stored. A format-0 ESW
execution of the channel program specified by the
is stored when an interruption condition containing
most recently executed START SUBCHANNEL
one of the following indications is cleared by TEST
instruction or implied by the most recently exe-
SUBCHANNEL:
cuted RESUME SUBCHANNEL instruction. (See
Channel-data check Immediate Conclusion of I/O Operations on
Channel-control check page 15-42.) If the secondary-status bit is one
Interface-control check and the primary-status bit is zero, the status
Measurement-block-program check present is related to the channel program speci-
Measurement-block-data check fied by the START SUBCHANNEL instruction or
Measurement-block-protection check implied by the RESUME SUBCHANNEL instruc-
Path verification required tion that preceded the most recently executed
Authorization check START SUBCHANNEL instruction.
The extended-status-word-format bit is meaningful
Deferred Condition Code 2: This code does not
whenever the subchannel is status-pending. The
occur and is reserved for future use.
extended-status information that is used to form a

16-8 z/Architecture Principles of Operation


Deferred Condition Code 3: An attempted model, either fails to recognize the address of
device selection has occurred, and the device the I/O device or considers the I/O device to
appeared not operational on all of the channel be not ready. In the former case, a path-not-
paths that were available for selection of the operational condition is recognized, subject to
device. the setting of the path-operational mask. (See
Path-Operational Mask (POM) on
A device appears not operational when it does not page 15-6.) In the latter case, the not-ready
respond to a selection attempt by the channel condition is indicated when the control unit
subsystem. This occurs when the control unit is responds to the selection and indicates unit
not provided in the system, when power is off in check whenever the not-ready state precludes
the control unit, or when the control unit has been successful initiation of the operation at the I/O
logically switched off the channel path. The not- device. In this case, unit-check status is indi-
operational state is also indicated when the control cated in the SCSW, the subchannel becomes
unit is provided and is capable of attaching the status-pending with primary, secondary, and
device, but the device has not been installed and alert status, and with deferred condition code
the control unit is not designed to recognize the 1 indicated. (See the publication ESA/390
device being selected as one of its attached Common I/O-Device Commands, SA22-7204,
devices. (See also I/O Addressing on for a description of unit-check status.) Refer
page 13-5.) to the System Library publication for the
control unit to determine how the condition is
A deferred condition code 3 also can be set by the indicated.
channel subsystem if no channel paths to the
device are available for selection. (See 2. The deferred condition code is 1 and the
Figure 16-3 on page 16-10.) status-control field contains the status-pending
and intermediate-status bits or the status-
Programming Notes: pending, intermediate-status, and alert-status
bits as ones when HALT SUBCHANNEL has
1. If, during performance of a start function, the been executed and the designated sub-
I/O device being selected is not installed or channel is suspended and status-pending with
has been logically removed from the control intermediate status. If the alert-status bit is
unit, but the associated control unit is opera- one, then subchannel-logout information was
tional and the control unit recognizes the I/O generated as a result of attempting to issue
device being selected as one of its I/O the halt signal to the device.
devices, the control unit, depending upon the

Chapter 16. I/O Interruptions 16-9



Bit 6Bit 7Status Control Meaning

A I P S X Normal I/O interruption


A I P - X
A - P S X
A - P - X
- I P S X
- I P - X
- I - - X
- - P S X
- - P - X

1 A I P S X Either an immediate operation, with chaining not


A I P - X specified, has ended normally, or the setting of some
A I - - X status condition precluded the initiation or resumpt-
A - P S X ion of a requested I/O operation at the device.
A - P - X
A - - S X
A - - - X
- I P S X
- I P - X
- I - - X
- - P S X
- - P - X
- - - S X
- - - - X

1 Reserved Reserved

1 1 - - P S X The device is not operational on any available path or,


- I P S X if a dedicated-allegiance condition exists, the device
is not operational on the path to which the dedicated
allegiance is owed.

Explanation:

- Bit is zero.
The allowed combinations of status-control-bit settings when the
start-function bit is one in the function-control field.
The condition is encountered after the execution of HALT SUBCHANNEL when the
subchannel is currently suspended.
The condition is encountered after the execution of HALT SUBCHANNEL when the
subchannel is currently start-pending.
A Alert status.
I Intermediate status.
P Primary status.
S Secondary status.
X Status-pending.

Figure 16-3. Deferred-Condition-Code Meaning for Status-Pending Subchannel

Format (F) Prefetch (P)


When the start-function bit (bit 17 of word 0) is When the start-function bit (bit 17 of word 0) is
one, bit 8 of word 0 indicates the format of the one, bit 9 of word 0 indicates whether or not
CCWs associated with an I/O operation. The unlimited prefetching of CCWs, IDAWs, and asso-
format bit is meaningful only when bit 17 is one. If ciated data is allowed. The prefetch bit is mean-
bit 8 of word 0 is zero, format-0 CCWs are indi- ingful only when bit 17 is one. If bit 9 is zero,
cated. If it is one, format-1 CCWs are indicated. prefetching of one CCW describing a data area is
(See Channel-Command Word on page 15-26 allowed during output-data-chaining operations
for the description of the two CCW formats.)

16-10 z/Architecture Principles of Operation


and is not allowed during any other operations. If program. The suppress-suspended-interruption bit
bit 9 is one, unlimited prefetching of CCWs, is meaningful only when bit 17 is one.
IDAWs, and associated data is allowed. It is
model dependent whether prefetching is actually Subchannel-Control Field
performed for any or all of the CCWs, IDAWs, and
associated data that comprise the channel The following subchannel-control-information
program. descriptions apply to the subchannel-control field
(bits 13-31 of word 0) of the SCSW.
Initial-Status-Interruption Control (I)
When the start-function bit (bit 17 of word 0) is Zero Condition Code (Z)
one, bit 10 of word 0, when one, indicates that the Bit 13 of word 0, when one, indicates that the sub-
channel subsystem is to generate an intermediate channel has become subchannel-active and the
interruption condition if the subchannel becomes channel subsystem has recognized an initial-
subchannel-active (see Initial-Status-Interruption status-interruption condition at the subchannel.
Control (I) on page 15-23). Bit 10 of word 0, The Z bit is meaningful only when the
when zero, indicates that the subchannel intermediate-status bit (bit 28 of word 0) and the
becoming subchannel-active is not to cause an start-function bit (bit 17 of word 0) are both ones.
intermediate interruption condition to be gener-
ated. If the initial-status-interruption-control bit (bit 10,
word 1 of the ORB) is one when START SUB-
The program requests the intermediate inter- CHANNEL is executed, then the subchannel
ruption condition by means of the ORB. An I/O becoming subchannel-active causes the sub-
interruption that results from that request may be channel to be made status-pending with interme-
due to the channel subsystem performing either a diate status indicating the initial-status-interruption
start function or a resume function. (See Zero condition. The initial-status-interruption condition
Condition Code (Z) for details of the indication remains at the subchannel until the intermediate
given by the channel subsystem when the inter- interruption condition is cleared by the execution
mediate interruption condition is cleared by TEST of TEST SUBCHANNEL or CLEAR SUB-
SUBCHANNEL.) CHANNEL. If the initial-status-interruption-control
bit of the ORB is zero when START SUB-
Address-Limit-Checking Control (A) CHANNEL is executed, then the subchannel
When the start-function bit (bit 17 of word 0) is becoming subchannel-active does not cause an
one, bit 11 of word 0, when one, indicates that the intermediate interruption condition to be gener-
channel subsystem has been requested by the ated, and the initial-status-interruption condition is
program to perform address-limit checking, subject not recognized.
to the setting of the limit mode at the subchannel
(see Address-Limit-Checking Control (A) on Extended Control (E)
page 15-23). The address-limit-checking-control Bit 14 of word 0, when one, indicates that model-
bit is meaningful only when bit 17 is one. dependent information or concurrent-sense infor-
mation is stored in the extended-control word
Suppress-Suspended Interruption (U) (ECW). When bit 14 is zero, the contents of
When the start-function bit (bit 17 of word 0) is words 0-7 of the ECW, if stored, are unpredict-
one, bit 12 of word 0, when one, indicates that the able. The E bit is meaningful whenever the sub-
channel subsystem has been requested by the channel is status-pending with alert status either
program to suppress the generation of a alone or together with primary status, secondary
subchannel-suspended interruption condition when status, or both.
the subchannel is suspended (see Suppress-
Suspended-Interruption Control (U) on Programming Note: During execution of TEST
page 15-24). When bit 12 is zero, the channel SUBCHANNEL, the storing of words 0-7 of the
subsystem generates an intermediate interruption ECW is a model-dependent function subject to the
condition whenever the subchannel is suspended setting of bit 14 as described above. Therefore,
during execution of the associated channel the program should always provide sufficient
storage to accommodate the storing of a 64-byte
IRB.

Chapter 16. I/O Interruptions 16-11


Path Not Operational (N) primary status or becomes suspended and
Bit 15 of word 0, when one, indicates that the N (b) is indicated by storing the path-not-
condition has been recognized by the channel operational bit as a one during the execution
subsystem. The N condition, in turn, indicates of TEST SUBCHANNEL. When a path-not-
that one or more path-not-operational conditions operational condition has been recognized
have been recognized. The channel subsystem and the channel-program execution subse-
recognizes a path-not-operational condition when, quently becomes suspended, the path-not-
during an attempted device selection in order to operational condition does not remain pending
perform a clear, halt, resume, or start function, the if channel-program execution is subsequently
device associated with the subchannel appears resumed. Instead, the old indication is lost,
not operational on a channel path that is opera- and the path-not-operational indication, if any,
tional for the subchannel. A channel path is oper- pertains to the attempt by the channel sub-
ational for the subchannel if the associated device system to resume channel-program execution.
appeared operational on that channel path the last
time the channel subsystem attempted device Function Control (FC)
selection in order to perform a clear, halt, resume, The function-control field indicates the basic I/O
or start function. A channel path is not operational functions that are indicated at the subchannel.
for the subchannel if the associated device This field may indicate the acceptance of as many
appeared not operational on that channel path the as two functions. The function-control field is con-
last time the channel subsystem attempted device tained in bit positions 17-19 of the first word of the
selection in order to perform a clear, halt, resume, SCSW. The function-control field is meaningful at
or start function. A device appears to be opera- an installed subchannel whenever the subchannel
tional on a channel path when the device is valid (see Device Number Valid (V) on
responds to an attempted device selection. page 15-4). The function-control field contains all
zeros whenever both the activity- and status-
The N bit is meaningful whenever the status- control fields contain all zeros. The meaning of
control field contains one of the indications listed the individual bits is as follows:
below, and at least one basic I/O function is also
indicated at the subchannel: Start Function (Bit 17): When one, bit 17 indi-
cates that a start function has been requested and
Status-pending with any combination of
is either pending or in progress at the subchannel.
primary, secondary, or alert status
A start function is requested by executing START
Status-pending alone SUBCHANNEL. A start function is indicated at
the subchannel when condition code 0 is set
Status-pending with intermediate status when
during the execution of START SUBCHANNEL.
the subchannel is also suspended
The start-function indication is cleared at the sub-
The N condition is reset whenever the execution channel when TEST SUBCHANNEL is executed
of TEST SUBCHANNEL results in the setting of and the subchannel is either status-pending alone,
condition code 0 and the N bit is meaningful as or status-pending with any combination of alert,
described above. primary, or secondary status. The start-function
indication is also cleared at the subchannel during
Notes: the execution of CLEAR SUBCHANNEL.
1. A path-not-operational condition does not
imply a malfunctioning channel path. A mal- Halt Function (Bit 18): When one, bit 18 indi-
functioning channel path causes the gener- cates that a halt function has been requested and
ation of an error indication, such as is either pending or in progress at the subchannel.
interface-control check. A halt function is requested by executing HALT
SUBCHANNEL. A halt function is indicated at the
2. When a path-not-operational condition has subchannel when condition code 0 is set for HALT
been recognized and the subchannel subse- SUBCHANNEL. The halt-function indication is
quently becomes status-pending with only cleared at the subchannel when the next status-
intermediate status, the path-not-operational pending condition which occurs is cleared by exe-
condition (a) continues to be recognized until cution of TEST SUBCHANNEL. The next
the subchannel becomes status-pending with status-pending condition depends on the state of

16-12 z/Architecture Principles of Operation


the subchannel when HALT SUBCHANNEL is 22 Halt-pending
executed. If the subchannel is subchannel-active 23 Clear-pending
when HALT SUBCHANNEL is executed, then the 24 Subchannel-active
next status-pending condition is status-pending 25 Device-active
with at least primary status indicated. If the sub- 26 Suspended
channel is device-active when HALT SUB-
When an SCSW is stored that has the status-
CHANNEL is executed, then the next
pending bit of the status-control field zero and all
status-pending condition is status-pending with at
zeros in the activity-control field, the subchannel is
least secondary status indicated. If the sub-
said to be idle or in the idle state.
channel is suspended and status-pending with
intermediate status when HALT SUBCHANNEL is Note: All conditions that are represented by the
executed, then the next status-pending condition bits in the function-control field and by the
is status-pending with intermediate status. If the resume-pending, start-pending, halt-pending,
subchannel is idle when HALT SUBCHANNEL is clear-pending, subchannel-active, and suspended
executed, then the next status-pending condition bits in the activity-control field are reset at the sub-
is status-pending alone. The halt-function indi- channel when TEST SUBCHANNEL is executed
cation is also cleared at the subchannel during the and the subchannel (1) is status-pending alone,
execution of CLEAR SUBCHANNEL. In normal (2) is status-pending with primary status, (3) is
operations, this function is indicated together with status-pending with alert status, or (4) is status-
bit 17; that is, there is a start function either pending with intermediate status and is also sus-
pending or in progress which is to be halted. pended.

Clear Function (Bit 19): When one, bit 19 indi- Resume-Pending (Bit 20): When one, bit 20
cates that a clear function has been requested indicates that the subchannel is resume-pending.
and is either pending or in progress at the sub- The channel subsystem may or may not be in the
channel. A clear function is requested by exe- process of performing the start function. The sub-
cuting CLEAR SUBCHANNEL. A clear function is channel becomes resume-pending when condition
indicated at the subchannel when condition code 0 code 0 is set for RESUME SUBCHANNEL. The
is set for CLEAR SUBCHANNEL (see CLEAR point at which the subchannel is no longer
SUBCHANNEL on page 14-4). The clear- resume-pending is a function of the subchannel
function indication is cleared at the subchannel state existing when the resume-pending condition
when the resulting status-pending condition is is recognized and the state of the device if
cleared by TEST SUBCHANNEL. channel-program execution is resumed.

Activity Control (AC) If the subchannel is in the suspended state when


The activity-control field is contained in bit posi- the resume-pending condition is recognized, the
tions 20-26 of the first word of the SCSW. This CCW that caused the suspension is refetched, the
field indicates the current progress of a basic I/O setting of the suspend flag is examined, and one
function previously accepted at the subchannel. of the following actions is taken by the channel
By using the contents of this field, the program subsystem:
can determine the degree of completion of the 1. If the CCW suspend flag is one, the device is
basic I/O function. The activity-control field is not selected, the subchannel is no longer
meaningful at an installed subchannel whenever resume-pending, and channel-program exe-
the subchannel is valid (see Device Number Valid cution remains suspended.
(V) on page 15-4). However, if an IFCC or CCC
condition is detected during the performance of a 2. If the CCW suspend flag is zero, the channel
basic I/O function and that function is indicated as subsystem attempts to resume channel-
pending, I/O operations may or may not have program execution by performing a modified
been executed at the device. The activity-control start function. The resumption of channel-
bits are defined as follows: program execution appears to the device as
the initiation of a new channel-program exe-
Bit Designation cution. The resume function causes the
20 Resume-pending channel subsystem to execute the path-
21 Start-pending management operation as if a new start func-

Chapter 16. I/O Interruptions 16-13


tion were being initiated, using the ORB 2. If the suspend flag of the most recently
parameters previously passed to the sub- fetched CCW is one, the subchannel is no
channel by START SUBCHANNEL with the longer resume-pending, and the CCW is
exception that the channel-program address is refetched. The subchannel proceeds with
the address of the CCW that caused suspen- channel-program execution if the suspend flag
sion of channel-program execution. of the refetched CCW is zero. The sub-
channel suspends channel-program execution
The subchannel remains resume-pending
if the suspend flag of the refetched CCW is
when, during the performance of the start
one.
function, the channel subsystem (1) deter-
mines that it is not possible to attempt to ini- Some models recognize a resume-pending condi-
tiate the I/O operation for the first command, tion only after a CCW having a valid S flag set to
(2) determines that an attempt to initiate the one is fetched. Therefore, if a subchannel is
I/O operation for the first command does not resume-pending and, during execution of the
result in the command being accepted, or channel program, no CCW is fetched that has a
(3) detects an IFCC or CCC condition and is valid S flag set to one, the subchannel remains
unable to determine whether the first resume-pending until the primary interruption con-
command has been accepted. (See Start dition is cleared by TEST SUBCHANNEL.
Function and Resume Function on
page 15-17.) Start-Pending (Bit 21): When one, bit 21 indi-
cates that the subchannel is start-pending. The
The subchannel is no longer resume-pending
channel subsystem may or may not be in the
when any of the following events occurs:
process of performing the start function. The sub-
a. While performing the start function, the channel becomes start-pending when condition
subchannel becomes subchannel-and- code 0 is set for START SUBCHANNEL. The
device-active or device-active only, or the subchannel remains start-pending when, during
first command is accepted with the performance of the start function, the channel
channel-end and device-end initial status subsystem (1) determines that it is not possible to
and the CCW does not specify command attempt to initiate the I/O operation for the first
chaining. command, (2) determines that an attempt to ini-
tiate the I/O operation for the first command does
b. CLEAR SUBCHANNEL is executed.
not result in the command being accepted, or
c. TEST SUBCHANNEL clears any combina- (3) detects an IFCC or CCC condition and is
tion of primary, secondary, and alert unable to determine whether the first command
status or clears the status-pending condi- has been accepted. (See Start Function and
tion alone. Resume Function on page 15-17.)
d. TEST SUBCHANNEL clears intermediate
The subchannel becomes no longer start-pending
status while the subchannel is suspended.
when any of the following occurs:
e. CANCEL SUBCHANNEL is executed with
1. While performing the start function, the sub-
a resulting condition code 0.
channel becomes subchannel-and-device-
If the subchannel is not in the suspended state active or device-active only, or the first
when the resume-pending condition is recognized, command is accepted with channel-end and
the CCW suspend flag of the most recently device-end initial status and the CCW does
fetched CCW, if any, is examined and one of the not specify command chaining.
following actions is taken by the channel sub-
2. The subchannel becomes suspended because
system:
of a valid suspend flag in the first CCW.
1. If a CCW has not been fetched or the
3. CLEAR SUBCHANNEL is executed.
suspend flag of the most recently fetched
CCW is zero, the subchannel is no longer 4. TEST SUBCHANNEL clears any combination
resume-pending, and the resume function is of primary, secondary, and alert status or
not performed. clears the status-pending condition alone.

16-14 z/Architecture Principles of Operation


5. CANCEL SUBCHANNEL is executed with a 1. While performing the clear function, the
resulting condition code 0. channel subsystem determines that the clear
signal has been issued to the device.
Halt-Pending (Bit 22): When one, bit 22 indi-
2. TEST SUBCHANNEL clears the status-
cates that the subchannel is halt-pending. The
pending condition alone.
channel subsystem may or may not be in the
process of performing the halt function. The sub-
Subchannel-Active (Bit 24): When one, bit 24
channel becomes halt-pending when condition
indicates that the subchannel is subchannel-
code 0 is set for HALT SUBCHANNEL. The sub-
active. A subchannel is said to be subchannel-
channel remains halt-pending when, during the
active when an I/O operation is currently in
performance of the halt function, the channel sub-
execution at the subchannel. The subchannel
system (1) determines that it is not possible to
becomes subchannel-active when the first
attempt to issue the halt signal to the device,
command is accepted and the start function or
(2) determines that the attempt to issue the halt
resume function is not immediately concluded at
signal to the device is not successful, or
the subchannel. (See Immediate Conclusion of
(3) detects an IFCC or CCC condition and is
I/O Operations on page 15-42.) The subchannel
unable to determine whether the halt signal is
is no longer subchannel-active when any of the
issued to the device. (See Halt Function on
following occurs:
page 15-14.)
1. The subchannel becomes suspended.
The subchannel is no longer halt-pending when
2. The subchannel becomes status-pending with
any of the following occurs:
primary status.
1. While performing the halt function, the channel
3. CLEAR SUBCHANNEL is executed.
subsystem determines that the halt signal has
been issued to the device. 4. The device appears not operational during
performance of a halt function.
2. CLEAR SUBCHANNEL is executed.
The subchannel does not become subchannel-
3. TEST SUBCHANNEL clears any combination
active during performance of the function specified
of primary, secondary, and alert status or
by either a HALT SUBCHANNEL or a CLEAR
clears the status-pending condition alone.
SUBCHANNEL instruction.
4. TEST SUBCHANNEL clears intermediate
status while the subchannel is suspended. Device-Active (Bit 25): When one, bit 25 indi-
cates that the subchannel is device-active. A sub-
Clear-Pending (Bit 23): When one, bit 23 indi- channel is said to be device-active when an I/O
cates that the subchannel is clear-pending. The operation is currently in progress at the associated
channel subsystem may or may not be in the device. The subchannel becomes device-active
process of performing the clear function. The sub- when the first command is accepted. The sub-
channel becomes clear-pending when condition channel is no longer device-active when any of
code 0 is set for CLEAR SUBCHANNEL. The the following occurs:
subchannel remains clear-pending when, during
1. The subchannel becomes suspended.
performance of the clear function, the channel
subsystem (1) determines that it is not possible to 2. The subchannel becomes status-pending with
attempt to issue the clear signal to the device, secondary status.
(2) determines that the attempt to issue the clear 3. CLEAR SUBCHANNEL is executed.
signal to the device is not successful, or
(3) detects an IFCC or CCC condition and is 4. The device appears not operational during
unable to determine whether the clear signal is performance of a halt function.
issued to the device. (See Clear Function on If the subchannel is not start-pending or if the
page 15-13.) status accepted from the device also describes an
alert condition, the subchannel becomes status-
The subchannel is no longer clear-pending when pending with secondary status. After the status
either of the following occurs: has been accepted from the device, the device is
capable of accepting a command for executing a

Chapter 16. I/O Interruptions 16-15


new I/O operation. If the subchannel is start- pending as a result of performing the clear func-
pending and the status is device end or device tion.
end with control-unit end, then the channel sub-
system discards the status and performs the start Status Control (SC)
function for the new channel program. (See Start The status-control field is contained in bit positions
Function and Resume Function on page 15-17) 27-31 of the first word of the SCSW. This field
In this situation, the subchannel does not become provides the program with a summary-level indi-
status-pending with the secondary interruption cation of the interruption condition described by
condition, and the status is not made available to either subchannel or device status, the Z bit, or, in
the program. the case of the subchannel-suspended inter-
ruption, the suspended bit (bit 26). More than one
The subchannel does not become device-active summary indication may be signaled as a result of
during performance of the functions specified by existing conditions at the subchannel. Whenever
either a HALT SUBCHANNEL or a CLEAR SUB- the subchannel is enabled (see Enabled (E) on
CHANNEL instruction. page 15-2) and at least bit 31 is one, the sub-
channel is said to be status-pending. Whenever
Suspended (Bit 26): When one, bit 26 indicates the subchannel is disabled, the subchannel is not
that the subchannel is suspended. A subchannel made status-pending. Bit 31 of SCSW word 0 is
is said to be suspended when channel-program meaningful at an installed subchannel whenever
execution is currently suspended. The sub- the subchannel is valid (see Device Number Valid
channel becomes suspended as part of the (V) on page 15-4); bits 27-30 are meaningful
suspend function. (See Suspension of Channel- when bit 31 is one. The status-control bits are
Program Execution on page 15-37.) defined as follows:

The subchannel is no longer suspended when any Alert Status (Bit 27): When one (and when the
of the following occurs: status-pending bit is also one), bit 27 indicates an
1. As part of the resume function following the alert interruption condition exists. In such a case,
execution of RESUME SUBCHANNEL when the subchannel is said to be status-pending with
the subchannel becomes subchannel-and- alert status. An alert interruption condition is
device-active or device-active only, or the first recognized when alert status is present at the sub-
command is accepted for channel-end and channel. Alert status may be subchannel status
device-end initial status, with or without status or device status. Alert status is status generated
modifier, and the CCW does not specify by either the channel subsystem or the device
command chaining. under any of the following conditions:

2. CLEAR SUBCHANNEL is executed. The subchannel is idle (activity-control bits


20-26 and status-control bit 31 are zeros).
3. TEST SUBCHANNEL clears any combination
of primary, secondary, and alert status or The subchannel is start-pending, and the
clears the status-pending condition alone. status condition precludes initiation of the I/O
operation.
4. TEST SUBCHANNEL clears intermediate
status while the halt function is specified. The subchannel is subchannel-and-device-
active, and the status condition has sup-
5. CANCEL SUBCHANNEL is executed with a pressed command chaining or would have
resulting condition code 0. suppressed command chaining if chaining had
Programming Note: When an SCSW is stored been specified (see Chaining on
by STORE SUBCHANNEL or TEST SUB- page 15-30).
CHANNEL following CLEAR SUBCHANNEL but The subchannel is subchannel-and-device-
prior to the subchannel becoming status-pending, active, command chaining is not specified,
and the subchannel-active bit (bit 24 of word 0) is execution of the channel program has just
stored as zero, this does not mean that data been concluded, and the status presented by
transfer has stopped for the device. The program the device is attempting to alter the sequential
cannot determine whether data transfer has execution of commands (see the publication
stopped until the subchannel becomes status- ESA/390 Common I/O-Device Commands,

16-16 z/Architecture Principles of Operation


SA22-7204, for more information on the use of becomes current that contains the suspend flag
status modifier to alter the sequential exe- set to one. When the suspend flag is specified in
cution of commands). the first CCW of a channel program, channel-
program execution is suspended and the sub-
The subchannel is device-active only, and the
channel becomes status-pending with intermediate
status presented by the device is other than
status (the suspended bit indicated) before the
device end, control-unit end, or device end
command in the first CCW is transferred to the
and control-unit end.
device. When the suspend flag is specified in a
The subchannel is suspended (bit 26 is one). CCW fetched during command chaining, channel-
If the subchannel is start-pending when an alert program execution is suspended and the sub-
interruption condition is recognized, the sub- channel becomes status-pending with intermediate
channel becomes status-pending with alert status, status (the suspended bit indicated) only after exe-
deferred condition code 1 is set, the start-pending cution of the preceding CCW is complete.
bit remains one, and execution of the pending I/O
When the PCI flag is specified in a CCW, the gen-
operation is not initiated.
eration of an intermediate interruption condition
When TEST SUBCHANNEL is executed and due to PCI depends on whether the CCW is the
stores an SCSW with the alert-status bit and the first CCW of the channel program. When the PCI
status-pending bit as ones in the IRB, the alert flag is specified in the first CCW of a channel
interruption condition is cleared at the subchannel. program, the subchannel becomes status-pending
The alert interruption condition is also cleared with intermediate status (the PCI bit indicated)
during execution of CLEAR SUBCHANNEL. only after initial status is received for the first
CCW of the channel program indicating the
Whenever alert status is present at the sub- command has been accepted. When the PCI flag
channel, it is brought to the attention of the is specified in a CCW fetched while chaining, the
program. Examples of alert status include atten- subchannel becomes status-pending with interme-
tion, device end (which signals a transition from diate status (the PCI bit indicated) only after exe-
the not-ready to the ready state), incorrect length, cution of the preceding CCW is complete. If
program check, and unit check. chaining occurs before an interruption condition
containing PCI is cleared by TEST SUB-
Intermediate Status (Bit 28): When one (and CHANNEL, the condition is carried over to the
when the status-pending bit is also one), bit 28 next CCW. This carry-over occurs during both
indicates an intermediate interruption condition data and command chaining, and, in either case,
exists. In such a case, the subchannel is said to the condition is propagated through the transfer-in-
be status-pending with intermediate status. Inter- channel command.
mediate status can be indicated when the Z bit (of
the subchannel-control field), the suspended bit (of If the subchannel is status-pending with interme-
the activity-control field), or the PCI bit (of the diate status when HALT SUBCHANNEL is exe-
subchannel-status field) is one. cuted, the intermediate interruption condition
remains at the subchannel, but the interruption
When the initial-status-interruption-control bit is request, if any, is withdrawn, and the subchannel
one in the ORB, the subchannel becomes status- becomes no longer status-pending. The sub-
pending with intermediate status (the Z bit indi- channel remains no longer status-pending until
cated) only after the subchannel is performance of the halt function has ended. The
subchannel-active. If the subchannel does not subchannel then becomes status-pending with
become subchannel-active, the Z condition is not intermediate status indicated (possibly together
generated. with any combination of primary, secondary, and
alert status).
When suspend control is specified and the gener-
ation of an intermediate interruption condition due When TEST SUBCHANNEL is executed and
to suspension is not suppressed in the ORB, then stores an SCSW with the intermediate-status bit
the subchannel can become status-pending with and the status-pending bit as ones in the IRB, the
intermediate status due to suspension if a CCW intermediate interruption condition is cleared at the
subchannel. The intermediate interruption condi-

Chapter 16. I/O Interruptions 16-17


tion is also cleared at the subchannel during the Status-Pending (Bit 31): When one, bit 31 indi-
execution of CLEAR SUBCHANNEL. cates that the subchannel is status-pending and
that information describing the cause of the inter-
Primary Status (Bit 29): When one (and when ruption condition is available to the program. The
the status-pending bit is also one), bit 29 indicates subchannel becomes status-pending whenever
a primary interruption condition exists. In such a intermediate, primary, secondary, or alert status is
case, the subchannel is said to be status-pending generated. When HALT SUBCHANNEL is exe-
with primary status. A primary interruption condi- cuted, designating a subchannel that is idle, the
tion is a solicited interruption condition that indi- subchannel becomes status-pending subsequent
cates the completion of the start function at the to performance of the halt function to notify the
subchannel. The primary interruption condition is program that the halt function has been com-
described by the SCSW stored. When an I/O pleted. When TEST SUBCHANNEL is executed,
operation is terminated by HALT SUBCHANNEL thus storing an SCSW with the status-pending bit
but the halt signal is not issued to the device as one in the IRB, the status-pending condition is
because the device appeared not operational, the cleared at the subchannel. The status-pending
subchannel is made status-pending with primary condition is also cleared at the subchannel during
status (and secondary status) with both the the execution of CLEAR SUBCHANNEL. When
subchannel-status field and the device-status field CLEAR SUBCHANNEL is executed, and the des-
set to zero. ignated subchannel is operational, the subchannel
becomes status-pending subsequent to perform-
When TEST SUBCHANNEL is executed and ance of the clear function to notify the program
stores an SCSW with the primary-status bit and that the clear function has been completed.
the status-pending bit as ones in the IRB, the
primary interruption condition is cleared at the Note: The status-pending bit, in conjunction with
subchannel. The primary interruption condition is the remaining bits of the status-control field, indi-
also cleared at the subchannel during the exe- cates the type of status condition. For example, if
cution of CLEAR SUBCHANNEL. bits 29 and 31 are ones, the subchannel is status-
pending with primary status. Alternatively, if only
Secondary Status (Bit 30): When one (and bit 31 is one, then the subchannel is said to be
when the status-pending bit is also one), bit 30 status-pending or status-pending alone. If only bit
indicates a secondary interruption condition exists. 31 is one in the status-control field, the settings of
In such a case, the subchannel is said to be all bits in the subchannel- and device-status fields
status-pending with secondary status. A sec- are unpredictable. If bit 31 is not one, then the
ondary interruption condition is a solicited inter- remaining bits of the status-control field are not
ruption condition that normally indicates the meaningful.
completion of the I/O operation at the device. The
secondary interruption condition is described by CCW-Address Field
the SCSW stored.
Bits 1-31 of word 1 form an absolute address.
When an I/O operation is terminated by HALT The address indicated is a function of the sub-
SUBCHANNEL but the halt signal is not issued to channel state when the SCSW is stored, as indi-
the device because the device appeared not oper- cated in Figure 16-4 on page 16-19. When the
ational, the subchannel is made status-pending subchannel-status field indicates channel-control
with secondary status (and primary status if the check, channel-data check, or interface-control
subchannel is also subchannel-active) with zeros check, the CCW-address field is usable for
for subchannel and device status. recovery purposes if the CCW-address field-
validity flag in the ESW is one.
When TEST SUBCHANNEL is executed and
stores an SCSW with the secondary-status bit as Programming Note: When a CCW address,
one in the IRB, the secondary interruption condi- either detected in the channel-program address
tion is cleared at the subchannel. The secondary (see Channel-Program Address on page 15-25)
interruption condition is also cleared at the sub- or generated during chaining, would cause the
channel during execution of CLEAR SUB- channel subsystem to fetch a CCW from a
CHANNEL.

16-18 z/Architecture Principles of Operation


location greater than 16,777,215 while format-0 fetch a CCW from a location greater than
CCWs are specified for the operation, the invalid 2,147,483,647 while format-1 CCWs are specified
address is stored in the CCW-address field of the for the operation, the rightmost 31 bits of the
SCSW without truncation. If the invalid address invalid address are stored in the CCW-address
causes the channel subsystem, while chaining, to field.

Subchannel State CCW Address

Start-pending (UUUU/AIPSX) Unpredictable



Start-pending and device-active (UUUU/AIPSX) Unpredictable

Subchannel-and-device-active (UUUU/AIPSX) Unpredictable

Device-active only (UUUU/AIPSX) Unpredictable

Suspended (YYYYY/AIPSX) See note 1

Status-pending (11/AIPSX) because of Channel-program address + 8
unsolicited alert status from the device while
the subchannel was start-pending

Status-pending (Y111/AIPSX) because the Channel-program address + 8
device appeared not operational on all paths

Status-pending (111/AIPSX) because of Channel-program address + 8
solicited alert status from the device while
the subchannel was startpending and device
active

Status-pending (1111/AIPSX) because of See note 2
solicited alert status generated by the
channel subsystem while the subchannel was
start-pending or start-pending and device
active

Status-pending (11/AIPSX) for the program CCW + 8 of the CCW that contained the
controlledinterruption condition while the last recognized PCI, or 8 higher than
subchannel was subchannel-and-device active a CCW which has subsequently become
current

Status-pending (11/AIPSX) for the initial CCW + 8 of the CCW causing the
statusinterruption condition while the intermediate interruption condition,
subchannel was subchannelanddevice active or a CCW which has subsequently
become current

Status-pending (1Y1Y1/AIPSX); termination
occurred because of program check caused by
one of the following conditions:

Bit 24, word 1 of ORB set to one; Channel-program address + 8
incorrectlengthindicationsuppression
facility not installed

Unused bits in ORB not set to zeros Channel-program address + 8

Invalid CCW-address specification in Address of TIC + 8
transfer in channel (TIC)

Invalid CCW-address specification in the Channel-program address + 8
channel-program address in the ORB

Figure 16-4 (Part 1 of 4). CCW Address as Function of Subchannel State

Chapter 16. I/O Interruptions 16-19



Subchannel State CCW Address

Invalid CCW address in TIC Address of TIC + 8



Invalid CCW address in the channel-program Channel-program address + 8
address in the ORB

Invalid CCW address while chaining Invalid CCW address + 8

Invalid command code Address of invalid CCW + 8

Invalid count Address of invalid CCW + 8

Invalid IDAW-address specification Address of invalid CCW + 8

Invalid IDAW address in a CCW Address of invalid CCW + 8

Invalid IDAW address while sequentially Address of current CCW + 8
fetching IDAWs

Invalid data-address specification, Address of invalid CCW + 8
format 1

Invalid data address in a CCW Address of invalid CCW + 8

Invalid data address while sequentially Address of current CCW + 8
accessing storage

Invalid data address in IDAW Address of current CCW + 8

Invalid IDAW specification Address of current CCW + 8

Invalid CCW, format or 1, for a CCW other Address of invalid CCW + 8
than a TIC

Invalid suspend flag CCW fetched during Address of invalid CCW + 8
data chaining has suspend flag set to one

Invalid suspend flag CCW has suspend Address of invalid CCW + 8
flag set to one, but suspend control was
not specified in the ORB

Invalid CCW, format 1, for a TIC Address of TIC + 8

Invalid sequence two TICs Address of second TIC + 8

Invalid sequence 256 or more CCWs Address of 256th CCW + 8
without data transfer

Status-pending (1Y1Y1/AIPSX); termination
occurred because of protection check detected
as follows:

On a CCW access Address of the protected CCW + 8

On data or an IDAW access Address of current CCW + 8

Figure 16-4 (Part 2 of 4). CCW Address as Function of Subchannel State

16-20 z/Architecture Principles of Operation



Subchannel State CCW Address

Status-pending (1Y1Y1/AIPSX); termination Address of current CCW + 8


occurred because of chaining check

Status-pending (YY1Y1/AIPSX); termination Address of current CCW + 8
occurred under count control

Status-pending (1Y1Y1/AIPSX); operation Address of current CCW + 8
prematurely terminated by the device because
of alert status

Status-pending (YYYY1/AIPSX) after termination
by HALT SUBCHANNEL and the activity-control-
field bits indicated below set to ones:

Status-pending alone Unpredictable

Start-pending Unpredictable

Device-active and start-pending Unpredictable

Device-active Unpredictable

Subchannel-active and device-active CCW + 8 of the last executed CCW

Suspended CCW + 8 of CCW causing suspension

Suspended and resume-pending Unpredictable

Status-pending (1/AIPSX) after termination Unpredictable
by CLEAR SUBCHANNEL

Status-pending (YY1Y1/AIPSX); operation CCW + 8 of the last executed CCW
completed normally at the subchannel

Status-pending (11/AIPSX) Unpredictable

Status-pending (11/AIPSX) Unpredictable

Status-pending (1/AIPSX) Unpredictable

Status-pending (1Y111/AIPSX); command chaining Address of current CCW + 8
suppressed because of alert status other than
channel-control check or interface-control
check

Status-pending (1YYY1/AIPSX) because of alert See note 3
status for channel-control check or
interface-control check

Status-pending (1Y1Y1/AIPSX) because of Address of current CCW + 8
channel-data check

Figure 16-4 (Part 3 of 4). CCW Address as Function of Subchannel State

Chapter 16. I/O Interruptions 16-21



Explanation:

The meaning of the notation used in this column is as follows:
A Alert status
I Intermediate status
P Primary status
S Secondary status
X Status-pending
The possible combination of status-control-bit settings is shown to the left of
the / symbol by the use of these symbols:

Corresponding condition is not indicated.
1 Corresponding condition is indicated.
U Unpredictable. The corresponding condition is not meaningful when the
subchannel is not status-pending.
Y The corresponding condition is not significant and is indicated as a
function of the subchannel state.

A CCW becomes current when (1) it is the first CCW of a channel program and
has been fetched, (2) while command chaining, the previous CCW is no longer
current and the new CCW has been fetched, or (3) in the case of data chaining,
the new CCW takes over control of the I/O operation (see the section Data
Chaining in Chapter 15, Basic I/O Functions). If chaining is not specified
or is suppressed, a CCW is no longer current and becomes the last-executed CCW
when secondary status has been accepted by the channel subsystem. During
command chaining, a CCW is no longer current when device-end status has been
accepted or, in the case of data chaining, when the last byte of data for that
CCW has been accepted.

The subchannel may also be resume-pending.

The stored address is the channel-program address (in the ORB) + 8 even though
it is either invalid or protected.

The stored address is the address of the current CCW + 8 even though it is
either invalid or protected.

Incorrect length is indicated as a function of the setting of the
suppress-length-indication flag in the current CCW (see the section
Channel-Command Word in Chapter 15, Basic I/O Functions).

Notes:

1. Unless the subchannel is also resume-pending, the address stored is the address
of the CCW that caused suspension, plus 8. Otherwise, the address stored is
unpredictable.
2. The address of the CCW is given as a function of the alert status indicated.
For example, if a program-check or protection-check condition is recognized,
the CCW address stored is the same as for the entry for program check or
protection check, respectively, in this table. Alternatively, if alert status
for interface-control check or channel-control check is indicated, the CCW
address stored is either the channel-program address (in the ORB) + 8 or
invalid as specified by the field-validity flags in the subchannel logout.
3. Bit 21 of the subchannel-logout information, when stored as one, indicates that
the address is CCW + 8 of the last-fetched CCW if the command for the CCW has
not been accepted by the device. If the command has been accepted by the
device at the time the error condition is recognized, then the address stored
is the address of the CCW + 8 of the last executed CCW.

Figure 16-4 (Part 4 of 4). CCW Address as Function of Subchannel State

16-22 z/Architecture Principles of Operation


Device-Status Field ever the subchannel is status-pending with any
combination of primary, secondary, intermediate,
Device-status conditions are generated by the I/O or alert status. Individual bits contained in the
device and are presented to the channel sub- subchannel-status field may be unpredictable even
system over the channel path. The timing and when the subchannel-status field is meaningful.
causes of these conditions for each type of device When the subchannel is status-pending with
are specified in the System Library publication for deferred condition code 3 indicated, the contents
the device. The device-status field is meaningful of the subchannel-status field are not meaningful.
whenever the subchannel is status-pending with
any combination of primary, secondary, interme- Program-Controlled Interruption
diate, or alert status. Whenever the subchannel is An intermediate interruption condition is generated
status-pending with intermediate status alone, the after a CCW with the program-controlled-
device-status field is zero. When the subchannel- interruption (PCI) flag set to one becomes the
status field indicates channel-control check, current CCW. The I/O interruption due to the PCI
channel-data check, or interface-control check, the flag may be delayed an unpredictable amount of
device-status field is usable for recovery purposes time because of masking of the interruption
if the device-status field-validity flag in the ESW is request or other activity in the system. (See
one. When the subchannel is status-pending with Program-Controlled Interruption on page 15-34.)
deferred-condition code 3 indicated, the contents When the channel subsystem recognizes an alert
of the device-status field are not meaningful. interruption condition due to either a channel-
control-check condition or an interface-control-
If, within a system, the I/O device is accessible check condition, then any previously existing
from more than one channel path, status related intermediate interruption condition caused by a
to channel-subsystem-initiated operations in PCI flag in a CCW may or may not be recognized
single-path mode (solicited status) is signaled over by the channel subsystem.
the initiating channel path. Devices operating in
multipath mode may signal solicited status over Detection of the PCI condition does not affect the
any channel path that belongs to the same path progress of the I/O operation.
group as the initiating channel path. The handling
of conditions not associated with I/O operations Incorrect Length
(unsolicited alert status), such as attention, unit Incorrect length occurs when the number of bytes
exception, and device end due to transition from contained in the storage areas assigned for the
the not-ready to the ready state, depends on the I/O operation is not equal to the number of bytes
type of device and condition and is specified in the requested or offered by the I/O device. Incorrect
System Library publication for the device. length is indicated for one of the following
reasons:
The channel subsystem does not modify the
status bits received from the I/O device. These Long Block on Input: During a read, read-
bits appear in the SCSW as received over the backward, or sense operation, the device
channel path. For more information on the status attempted to transfer one or more bytes to main
bits received from the I/O device, see the publica- storage after the assigned main-storage areas
tion ESA/390 Common I/O-Device Commands, were filled, or the device indicated that more data
SA22-7204. could have been transferred if the count had been
larger. The extra bytes have not been placed in
main storage. The count in the SCSW is zero.
Subchannel-Status Field
Long Block on Output: During a write or control
Subchannel-status conditions are detected and
operation, the device requested one or more bytes
indicated in the SCSW by the channel sub-
from the channel subsystem after the assigned
system. Except for the conditions caused by
main-storage areas were exhausted, or the device
equipment malfunctioning, they can occur only
indicated that more data could have been trans-
while the channel subsystem is involved with the
ferred if the count had been larger. The count in
performance of a halt, resume, or start function.
the SCSW is zero.
The subchannel-status field is meaningful when-

Chapter 16. I/O Interruptions 16-23


Short Block on Input: The number of bytes 1. The absolute CCW address does not corre-
transferred during a read, read-backward, or spond to a physical location.
sense operation is insufficient to fill the main-
2. Format-0 CCWs are specified in the ORB and
storage areas assigned to the operation. The
the absolute CCW address designates a
count in the SCSW is not zero.
location greater than 16,777,215.
Short Block on Output: The device terminated 3. Format-1 CCWs are specified in the ORB and
a write or control operation before all information the absolute CCW address designates a
contained in the assigned main-storage areas was location greater than 2,147,483,647.
transferred to the device. The count in the SCSW
is not zero. Invalid Command Code: There are zeros in the
four rightmost bit positions of the command code
The incorrect-length indication is suppressed when in the CCW designated by the CPA or in a CCW
the current CCW has the SLI flag set to one and fetched on command chaining. The command
the CD flag set to zero. The indication does not code is not tested for validity during data chaining.
occur for operations rejected during the initiation
sequence. The indication also does not occur for Invalid Count, Format 0: A CCW, which is other
immediate operations when the count field is than a CCW specifying transfer in channel, con-
nonzero and the subchannel is in the incorrect- tains zeros in bit positions 48-63.
length-suppression mode. The incorrect-length
indication is not meaningful when the count field of Invalid Count, Format 1: A CCW that specifies
the SCSW is not meaningful. data chaining or a CCW fetched while data
chaining contains zeros in bit positions 16-31.
Presence of the incorrect-length condition sup-
presses command chaining unless the SLI flag in Invalid IDAW-Address Specification: Indirect
the CCW is one or unless the condition occurs in data addressing is specified, and one of the fol-
an immediate operation when the subchannel is in lowing conditions is detected:
the incorrect-length-suppression mode. 1. The ORB specifies format-1 IDAWs and the
contents of the data-address field in the CCW
Program Check do not designate the first IDAW on an integral
Program check occurs when programming errors word boundary; that is, bits 30-31 (format-0
are detected by the channel subsystem. The con- CCW) or bits 62-63 (format-1 CCW) are not
dition can be due to the following causes: zeros.

Invalid CCW-Address Specification: The 2. The ORB specifies format-2 IDAWs and the
channel-program address (CPA) or the transfer-in- contents of the data-address field in the CCW
channel command does not designate the CCW do not designate the first IDAW on an integral
on a doubleword boundary, or bit 0 of the CPA or doubleword boundary; that is, bits 29-31
bit 32 of a format-1 CCW specifying the transfer- (format-0 CCW) or bits 61-63 (format-1 CCW)
in-channel command is not zero. are not zeros.

Invalid CCW Address: The channel subsystem Invalid IDAW Address: The channel subsystem
has attempted to fetch a CCW from a main- has attempted to fetch an IDAW from a main-
storage location which is not available. An invalid storage location which is not available. An invalid
CCW address can occur because the program IDAW address can occur because the program
has designated an invalid address in the channel- has designated an invalid address in a CCW that
program-address field of the ORB or in the specifies indirect data addressing or because the
transfer-in-channel command or because, on channel subsystem, on sequentially fetching
chaining, the channel subsystem attempts to fetch IDAWs, attempts to fetch from an unavailable
a CCW from an unavailable location. A main- location. A main-storage location is unavailable
storage location is unavailable when any of the when any of the following conditions are detected:
following conditions are detected: 1. The absolute IDAW address does not corre-
spond to a physical location.

16-24 z/Architecture Principles of Operation


2. Format-0 CCWs are specified in the ORB and Note: The maximum storage address is deter-
the absolute IDAW address designates a mined as a function of whether 24-bit, 31-bit, or
location greater than 16,777,215. 64-bit addressing is used. When IDAWs are not
specified, the maximum storage address is a func-
3. Format-1 CCWs are specified in the ORB and
tion of the CCW format specified as follows:
the absolute IDAW address designates a
location greater than 2,147,483,647. 1. When 24-bit (format 0) CCWs are specified,
the maximum storage address recognized by
Invalid Data-Address Specification: Bit 32 of a the channel subsystem is 16,777,215.
format-1 CCW is not zero.
2. When 31-bit (format 1) CCWs are specified,
Invalid Data Address: When any of the fol- the maximum storage address recognized by
lowing conditions are detected, an invalid data the channel subsystem is 2,147,483,647.
address is recognized by the channel subsystem. When IDAWs are specified, the maximum storage
1. Use of the data address has caused the address is a function of the IDAW format specified
channel subsystem to attempt to wrap from as follows:
the maximum storage address to zero. 1. When 31-bit (format 1) IDAWs are specified,
2. Use of the data address has caused the the maximum storage address recognized by
channel subsystem to attempt to wrap from the channel subsystem is 2,147,483,647.
zero to the maximum storage address during 2. When 64-bit (format 2) IDAWs are specified,
a read-backward operation. the maximum storage address recognized by
3. The channel subsystem has attempted to the channel subsystem is
transfer data to a storage location which is 18,446,744,073,709,551,616.
unavailable.
Invalid IDAW Specification: When any of the
An invalid data address can occur because the following conditions are detected, an invalid IDAW
program has designated an unavailable location in specification is recognized by the channel sub-
a CCW or in an IDAW, or because the channel system:
subsystem, on sequentially accessing storage,
1. Bit 0 of a format-1 IDAW is not zero.
attempted to access an unavailable location. A
main-storage location is unavailable when any of 2. A second or subsequent format-1 IDAW does
the following conditions are detected: not designate the location of the beginning
byte of a 2K-byte block or, for read-backward
1. The absolute address does not correspond to
operations, the location of the ending byte of a
a physical location.
2K-byte block.
2. Format-0 CCWs are specified in the ORB,
3. A second or subsequent format-2 IDAW does
indirect data addressing is not specified in the
not designate the location of the beginning
CCW, and the absolute address designates a
byte of a 2K-byte or 4K-byte block or, for
location greater than 16,777,215.
read-backward operations, the location of the
3. Format-1 CCWs are specified in the ORB, ending byte of a 2K-byte or 4K-byte block.
indirect data addressing is not specified in the
CCW, and the absolute address designates a Invalid CCW, Format 0: A CCW other than a
location greater than 2,147,483,647. CCW specifying transfer in channel does not
contain a zero in bit position 39.
4. Format-1 IDAWs are specified in the ORB,
indirect data addressing is specified in the
Invalid CCW, Format 1: A CCW other than a
CCW, and the absolute address designates a
CCW specifying transfer in channel does not
location greater than 2,147,483,647.
contain a zero in bit position 15, or a CCW speci-
5. The absolute address is outside the fying transfer in channel does not contain zeros in
addressing range specified by SET ADDRESS bit positions 0-3 and 8-31.
LIMIT and the limit mode at the subchannel is
active.

Chapter 16. I/O Interruptions 16-25


Invalid Suspend Flag: A format-0 or format-1 be made status-pending with primary, secondary,
CCW fetched during data chaining, other than a and alert status. When protection check is
CCW specifying transfer in channel, does not detected after the I/O operation has been initiated
contain a zero in bit position 38 or 14, respec- at the device, the device is signaled to conclude
tively. A CCW other than a CCW specifying the operation after the available data logically prior
transfer in channel does not contain a zero in bit to the protection check has been transferred.
position 38 for a format-0 CCW or bit position 14 However, if an access violation occurs when the
for a format-1 CCW, and suspend control was not channel subsystem is in the process of fetching
specified in the ORB (bit 4 of word 1). either a new IDAW or a new CCW while data
chaining and if the device signals the channel-end
Invalid ORB Format: One or more reserved bit condition before transferring any data designated
positions in the operation-request block (ORB) is by the new CCW or IDAW, then the status is
not zero. (See Operation-Request Block on accepted, and the subchannel becomes status-
page 15-21 for more information.) If the incorrect- pending with primary and alert status and with
length-indication-suppression facility is not protection check indicated. Other indications may
installed, then bit 24 of word 1 of the ORB must accompany the protection-check indication as a
also be zero. function of the operation specified by the CCW,
the status received from the device, and the
Invalid Sequence: The channel subsystem has current state of the subchannel. The protection-
fetched two successive CCWs both of which check condition causes command chaining and
specify transfer in channel, or, depending on the command retry to be suppressed.
model, a sequence of 256 or more CCWs with
command chaining specified was executed by the Channel-Data Check
channel subsystem and did not result in the Channel-data check indicates that an uncorrected
transfer of any data to or from an I/O device. storage error has been detected in regard to data,
contained in main storage, that is currently used in
Detection of the program-check condition during the execution of an I/O operation. The condition
the initiation of an operation at the device causes may be indicated when detected, even if the data
the operation to be suppressed and the sub- is not used when prefetched. Channel-data check
channel to be made status-pending with primary, is indicated when data or the associated key has
secondary, and alert status. When the condition an invalid checking-block code (CBC) in main
is detected after the I/O operation has been initi- storage when that data is referenced by the
ated at the device, the device is signaled to con- channel subsystem.
clude the operation the next time the device
requests or offers a byte of data or status. In this On an input operation, when the channel sub-
situation, the subchannel is made status-pending system attempts to store less than a complete
as a function of the status received from the checking block, and invalid CBC is detected on
device. The program-check condition causes the checking block in storage, the contents of the
command chaining and command retry to be sup- location remain unchanged, with invalid CBC. On
pressed. an output operation, whenever channel-data check
is indicated, no bytes from the checking block with
Protection Check invalid CBC are transferred to the device.
Protection check occurs when the channel sub-
system attempts a storage access that is prohib- During a storage access, the maximum number of
ited by the protection mechanism. Protection bytes that can be transferred is model-dependent.
applies to the fetching of CCWs, IDAWs, and If a channel-data-check condition is recognized
output data, and to the storing of input data. The during that storage access, the number of bytes
subchannel key provided in the ORB is used as transferred to or from storage may not be detect-
the access key for storage accesses associated able by the channel subsystem. Consequently,
with an I/O operation. the number of bytes transferred to or from storage
may not be correctly reflected by the residual
Detection of the protection-check condition during count. However, the residual count that is stored
the fetching of the first CCW or IDAW causes the in the SCSW, when used in conjunction with the
operation to be suppressed and the subchannel to storage-access code and the CCW address, des-

16-26 z/Architecture Principles of Operation


ignates a byte location within the page in which Detection of the channel-control-check condition
the channel-data-check condition was recognized. causes the current operation, if any, to be termi-
nated immediately. The subchannel is made
A condition indicated as channel-data check status-pending with primary and alert status or
causes the current operation, if any, to be termi- with primary, secondary, and alert status as a
nated. The subchannel becomes status-pending function of the type of termination, the current sub-
with primary and alert status or with primary, sec- channel state, and the device status presented, if
ondary, and alert status as a function of the status any. When the channel subsystem recognizes a
received from the device. The count and address channel-control-check condition, any previously
fields of the SCSW stored by TEST SUB- existing intermediate interruption condition caused
CHANNEL pertain to the operation terminated. by a PCI flag in a CCW may or may not be recog-
The extended-status-word-format bit is one, and nized by the channel subsystem. The count and
subchannel-logout information is stored in the data-address fields of the SCSW stored by TEST
ESW when TEST SUBCHANNEL is executed. SUBCHANNEL pertain to the operation termi-
nated. The extended-status-word-format bit is one
Whenever the channel-data-check condition per- and subchannel-logout information is stored in the
tains to prefetched data, the failing-storage- ESW when TEST SUBCHANNEL is executed.
address-validity flag (bit 6 of the ERW) is one. An
address of a location within the checking block for Whenever the channel-control-check condition
which the channel-data-check condition is gener- pertains to an invalid CBC detected on a pre-
ated is stored in the ESW failing-storage-address fetched CCW, a prefetched IDAW, or the key
field. associated with the prefetched CCW or the pre-
fetched IDAW, an extended-report word containing
Uncorrectable storage or key errors detected on bit 6 set to one and the failing-storage address is
prefetched data while the subchannel is start- stored in the ESW when TEST SUBCHANNEL is
pending cause the operation to be canceled executed.
before initiation at the device. In this case, the
subchannel is made status-pending with primary, Channel-control-check conditions encountered
secondary, and alert status, with channel-data while prefetching when the subchannel is start-
check indicated, and with the ESW failing-storage pending cause the operation to be canceled
address. before initiation at the device. In this case, the
subchannel is made status-pending with primary,
Whenever channel-data check is indicated, no secondary, and alert status, with channel-control
measurement data for the subchannel is stored. check indicated, and with the failing-storage
address stored in the extended-status word.
Channel-Control Check
Channel-control check is caused by any machine If a subchannel is halt-pending and the channel
malfunction affecting channel-subsystem controls. subsystem encounters a channel-control-check
The condition includes invalid CBC on a CCW, an condition while performing the halt function for that
IDAW, or the respective associated key. The con- subchannel, the subchannel remains halt-pending
dition may be indicated when an invalid CBC is unless the channel subsystem can determine that
detected on a prefetched CCW, IDAW, or the the halt signal was issued. The subchannel
respective associated key, even if that CCW or remains halt-pending even if the channel sub-
IDAW is not used. system was attempting to issue the halt signal and
is unable to determine if the halt signal was
Channel-control check may also indicate that an issued.
error has been detected in the information trans-
ferred to or from main storage during an I/O oper- If a subchannel is start-pending or resume-
ation. However, when this condition is detected, pending and the channel subsystem encounters a
the error has occurred inboard of the channel channel-control-check condition while performing
path: in the channel subsystem or in the path the start function for that subchannel, the sub-
between the channel subsystem and main channel remains start-pending or resume-pending
storage. unless the channel subsystem can determine that
the first command was accepted. The subchannel

Chapter 16. I/O Interruptions 16-27


remains start-pending or resume-pending even if 6. The channel subsystem recognized the
the channel subsystem was attempting to initiate I/O-error-alert condition (see I/O-Error Alert
the I/O operation for the first command and is (A) on page 16-35).
unable to determine if the command was
7. ESW bit 26, device-status check, is set to
accepted. If the channel subsystem is unable to
one.
determine whether the first command was
accepted, the subchannel is made status-pending Detection of the interface-control-check condition
with at least alert and primary status. causes the current operation, if any, to be termi-
nated immediately, and the subchannel is made
In some situations in which a channel-subsystem status-pending with alert status, primary and alert
malfunction exists, the channel-control-check con- status, secondary and alert status, or primary,
dition may be reported as a machine-check condi- secondary, and alert status as a function of the
tion. type of termination, the current subchannel state,
and the device status presented, if any. When the
Whenever channel-control check is indicated, no channel subsystem recognizes an interface-
measurement data for the subchannel is stored. control-check condition, any previously existing
Programming Note: If the status-control field of intermediate interruption condition caused by a
the SCSW indicates that the subchannel is status- PCI flag in a CCW may or may not be recognized
pending with alert status but the field-validity flags by the channel subsystem. The extended-status-
of the SCSW indicate that the device-status field word-format bit is one and subchannel-logout
is not usable for error-recovery purposes, the information is stored in the ESW when TEST
program should assume that the channel-control- SUBCHANNEL is executed.
check condition occurred while the channel sub-
If a subchannel is halt-pending and the channel
system was accepting alert status from the device
subsystem encounters an interface-control-check
and take the appropriate action for alert status,
condition while performing the halt function for that
even though the status itself has been lost.
subchannel, the subchannel remains halt-pending
unless the channel subsystem can determine that
Interface-Control Check the halt signal was issued. The subchannel
Interface-control check indicates that an invalid
remains halt-pending even if the channel sub-
signal has occurred on the channel path. The
system was attempting to issue the halt signal and
condition is detected by the channel subsystem
is unable to determine if the halt signal was
and usually indicates malfunctioning of an I/O
issued.
device. Interface-control check can occur for the
following reasons: If a subchannel is start-pending or resume-
1. A data or status byte received from a device pending and the channel subsystem encounters
while the subchannel is subchannel-and- an interface-control-check condition while per-
device-active or device-active has an invalid forming the start function for that subchannel, the
checking-block code. subchannel remains start-pending or resume-
pending unless the channel subsystem can deter-
2. The status byte received from a device while
mine that the first command was accepted. The
the subchannel is idle, start-pending, sus-
subchannel remains start-pending or resume-
pended, or halt-pending has an invalid
pending even if the channel subsystem was
checking-block code.
attempting to initiate the I/O operation for the first
3. A device responded with an address other command and is unable to determine if the
than the address designated by the channel command was accepted. If the channel sub-
subsystem during initiation of an operation. system is unable to determine whether the first
command was accepted, the subchannel is made
4. During command chaining, the device
status-pending with at least alert and primary
appeared not operational.
status.
5. A signal from an I/O device either did not
occur or occurred at an invalid time or had an If, while initiating a signaling sequence with the
invalid duration. channel subsystem for the purpose of presenting
status or transferring data, the device presents an

16-28 z/Architecture Principles of Operation


address with invalid parity, the error condition is Detection of the chaining-check condition causes
not made available to the program since the iden- the I/O device to be signaled to conclude the
tity of the device and associated subchannel are operation. It causes command chaining to be
unknown. suppressed.

Whenever interface-control check is indicated, no


measurement data for the subchannel is stored.
Count Field
Programming Note: If the status-control field of Bits 16-31 of word 2 contain the residual count.
the SCSW indicates that the subchannel is status- The count is to be used in conjunction with the ori-
pending with alert status but the field-validity flags ginal count specified in the last CCW and,
of the SCSW indicate that the device-status field depending upon existing conditions (see
is not usable for error-recovery purposes, the Figure 16-4 on page 16-19), indicates the number
program should assume that the interface-control- of bytes transferred to or from the area designated
check condition occurred while the channel sub- by the CCW. The count field is meaningful when-
system was accepting alert status from the device ever the subchannel is status-pending with
and take the appropriate action for alert status, primary status which consists of either (1) device
even though the status itself has been lost. status only or (2) device status together with sub-
channel status of incorrect length only, PCI only,
Chaining Check or both.
Chaining check is caused by channel-subsystem
overrun during data chaining on input operations. In Figure 16-5 on page 16-30, the contents of the
The condition occurs when the I/O-data rate is too count field are listed for all cases where the sub-
high for the particular resolution of data channel is either start-pending, subchannel-and-
addresses. Chaining check cannot occur on device-active, device-active, suspended, or
output operations. status-pending.

Chapter 16. I/O Interruptions 16-29



Subchannel State Count

Start-pending (UUUU/AIPSX) Not meaningful



Start-pending and status-pending Not meaningful
(1YY1/AIPSX)

Start-pending and status-pending (111/AIPSX) Not meaningful
because the device appeared not operational on
all paths

Start-pending and device active (UUUU/AIPSX) Not meaningful

Suspended (YYYYY/AIPSX) Not meaningful

Subchannel-and-device-active (UUUU/AIPSX) Not meaningful

Device-active (UUUU/AIPSX) Not meaningful

Status-pending (11/AIPSX) because of Not meaningful
program-controlled-interruption condition or
initial-status interruption

Status-pending (1Y1Y1/AIPSX); termination
occurred because of:

Program check Not meaningful
Protection check Not meaningful
Chaining check Not meaningful
Channel-control check See note 1
Interface control check Not meaningful
Channel-data check See note 2

Status-pending (YY1Y1/AIPSX); termination Correct
occurred under count control

Status-pending (Y11/AIPSX) Not meaningful

Status-pending (1Y1Y1/AIPSX) Correct; residual count of last used
CCW

Status-pending (1Y111/AIPSX); command chaining Correct; residual count of last used
suppressed because of alert status CCW

Status-pending (YYYY1/AIPSX); after terminationUnpredictable
by HALT SUBCHANNEL

Status-pending (1/AIPSX); after terminationNot meaningful
by CLEAR SUBCHANNEL

Status-pending (YY1Y1/AIPSX); operation Correct; indicates the residual count
completed normally at the subchannel

Figure 16-5 (Part 1 of 2). Contents of Count Field in the SCSW

16-30 z/Architecture Principles of Operation



Subchannel State Count

Status-pending (1Y111/AIPSX); command chaining Correct; original count of CCW


terminated because of alert status specifying the new I/O operation

Status-pending (11/AIPSX) because of alert Not meaningful
status

Explanation:

In situations where more than a single condition exists because of, for example,
alert status that is described by program check and unit check, the entry
appearing first in the table takes precedence.

The meaning of the notation in this column is as follows:

A Alert status
I Intermediate status
P Primary status
S Secondary status
X Status-pending

The allowed combination of status-control-bit settings is shown to the left of
the / symbol.

Bit settings are specified as follows:

Corresponding condition is not indicated.
1 Corresponding condition is indicated.
U Unpredictable. The corresponding condition is not meaningful when the
subchannel is not status-pending.
Y Corresponding condition is not significant and is indicated as a function
of the subchannel state.

The subchannel may also be resume-pending.

The contents of the count field are not meaningful because the count field is
not valid when the SCSW is stored and the subchannel is in the given state.

Notes:

1. The count is unpredictable unless IDAW check is indicated, in which case the
count may not correctly reflect the number of bytes transferred to or from main
storage but will (when used in conjunction with the CCW address) designate a
byte location within the page in which the channel-control-check condition was
recognized.

2. During a storage access, the maximum number of bytes that can be stored by a
channel subsystem is model-dependent. If a channel-data-check condition is
recognized during that access, the number of bytes transferred to or from
storage may not be detectable by the channel subsystem. Consequently, the
number of bytes transferred to or from storage may not be correctly reflected by
the residual count. However, the residual count that is stored when used in
conjunction with the storage-access code and the CCW address designates a byte
location within the page in which the channel-data-check condition was
recognized.

Figure 16-5 (Part 2 of 2). Contents of Count Field in the SCSW

Chapter 16. I/O Interruptions 16-31


Extended-Status Word Extended-Status Format 0
The extended-status word (ESW) provides addi- The ESW stored by TEST SUBCHANNEL is a
tional information to the program about the sub- format-0 ESW when the extended-status-word-
channel and its associated device. The ESW is format bit (bit 5, word 0 of the SCSW) is one and
placed in words 3-7 of the IRB designated by the the subchannel is status-pending with any combi-
second operand of TEST SUBCHANNEL when nation of status as defined in Figure 16-6 on
TEST SUBCHANNEL is executed and the sub- page 16-36. In this case, subchannel-logout infor-
channel designated is operational. If the sub- mation and an ERW are stored in the extended-
channel is status-pending or status-pending with status word. Subchannel logout provides detailed
any combination of primary, secondary, interme- model-independent information, relating to a sub-
diate, or alert status (except as noted in the next channel and describing equipment errors detected
paragraph) when TEST SUBCHANNEL is exe- by the channel subsystem. The information is
cuted, the ESW may have one of the following provided to aid the recovery of an I/O operation, a
types of extended-status formats: device, or both. Whenever subchannel logout is
Format 0 Subchannel logout in word 0, an ERW in provided, the error conditions relate only to the
word 1, a failing-storage address or subchannel reporting the error. If I/O operations
zeros in words 2 and 3, and a involving other subchannels have been affected by
secondary-CCW address or zeros in the error condition, those subchannels also
word 4. provide similar subchannel-logout information. An
extended-report word provides additional informa-
Format 1 Zeros in bytes 0 and 2-3 of word 0, the tion relating to the cause of the malfunction.
LPUM in byte 1 of word 0, an ERW in
word 1, and zeros in words 2-4. A format-0 ESW has this format:
Format 2 Zeros in byte 0, the LPUM in byte 1, and
the device-connect time in bytes 2-3 of Subchannel Logout
word 0; an ERW in word 1; zeros in
words 2-4. 1 Extended-Report Word

Format 3 Zeros in byte 0, the LPUM in byte 1, and 2
Failing-Storage Address
unpredictable values in bytes 2 and 3 of 3
word 0; an ERW in word 1; zeros in
words 2-4. 4 Secondary-CCW Address

Words 0-4 of the ESW contain unpredictable
values if any of the following conditions is met:
Subchannel Logout
1. The subchannel is not status-pending. The subchannel logout has this format:
2. The subchannel is status-pending alone, and

the extended-status-word-format bit is zero. ESF LPUM R FVF SATCDEA SC

3. The subchannel is status-pending with inter- 1 8 16 22 24 26 31
mediate status alone for other than the inter-
mediate interruption condition due to
suspension.
Extended-Status Flags (ESF): Any of the bits
1-7, when one, specifies that an error-check con-
The type of extended-status format stored dition has been detected by the channel sub-
depends upon conditions existing at the sub- system. The following indications are provided in
channel at the time TEST SUBCHANNEL is exe- the ESF field:
cuted. The conditions under which each of the
types of formats is stored are described in the
Key Check. Bit 1, when one, indicates that
the channel subsystem, when accessing data,
remainder of this section.
when attempting to update the measurement
block, or when attempting to fetch either a
CCW or an IDAW, has detected an invalid
checking-block code (CBC) on the associated

16-32 z/Architecture Principles of Operation


storage key. The channel-data-check bit (bit disabling the storing of measurement data for
12 of word 2 of the SCSW), the the subchannel (see Measurement Mode
measurement-block data-check bit (bit 3 of Enable (MM) on page 15-3).
word 0 of the ESW), the CCW-check bit (bit 5
CCW Check. Bit 5, when one, indicates that
of word 0 of the ESW), or the IDAW-check bit
an invalid CBC on the contents of the CCW or
(bit 6 of word 0 of the ESW) identifies the
its associated key has been detected. When
source of the key error.
either of these conditions is detected, the I/O
Note: This condition may be indicated to the operation is terminated, the subchannel
program when an invalid checking-block code becomes status-pending with primary and
on a key is detected but the data, CCW, or alert status, the extended-status-word-format
IDAW is not used when prefetching. In this bit in the SCSW is stored as one, and
case, the failing-storage-address-validity bit channel-control check is indicated in the
(bit 6 of the ERW) is one, indicating that an subchannel-status field. The subchannel also
address of a location within the invalid CBC is becomes status-pending with secondary
stored in words 2 and 3 of the ESW. status as a function of the type of termination
or status received from the device. When
Measurement-Block Program Check. Bit 2,
invalid CBC on the associated key is detected,
when one, indicates that the channel sub-
the key-check bit, bit 1 of the ESF field, is
system, in attempting to update the measure-
also stored as one.
ment block, has detected an invalid absolute
address when combining the measurement- Note: This condition may be indicated to the
block origin with the measurement-block index program when an invalid checking-block code
for this subchannel. on the contents of a prefetched CCW is
detected but the CCW is not used. In this
Measurement-Block Data Check. Bit 3, when
case, the failing-storage-address-validity bit
one, indicates that a malfunction has been
(bit 6 of the ERW) is one, indicating that an
detected involving the data of the measure-
address of a location within the invalid CBC is
ment block in main storage. (See Measure-
stored in words 2 and 3 of the ESW.
ment Block on page 17-3.)
Measurement-block data check is indicated IDAW Check. Bit 6, when one, indicates that
when the measurement block is updated and an invalid CBC on the contents of an IDAW or
an invalid checking-block code (CBC) is its associated key has been detected. When
detected on the storage used to contain the either of these conditions is detected, the I/O
measurement data or on the associated key. operation is terminated with the device, the
When invalid CBC on the associated key is subchannel becomes status-pending with
detected, the key-check bit, bit 1 of the ESF primary and alert status, the extended-status-
field, is also stored as one. word-format bit in the SCSW is one, and
channel-control check is indicated in the
Measurement-Block Protection Check. Bit 4,
subchannel-status field. The subchannel also
when one, indicates that the channel sub-
becomes status-pending with secondary
system, when attempting to update the meas-
status as a function of the type of termination
urement block, has been prohibited from
or status received from the device. When
accessing the measurement block because
invalid CBC on the associated key is detected,
the storage key does not match the
the key-check bit, bit 1 of the ESF field, is
measurement-block key (see Measurement
also one.
Block on page 17-3.) The key provided by
SET CHANNEL MONITOR is used for the Note: This condition may be indicated to the
access of storage associated with program when an invalid checking-block code
measurement-block-update operations (see on the contents of a prefetched IDAW is
SET CHANNEL MONITOR on page 14-12). detected but the IDAW is not used. In this
case, the failing-storage-address-validity bit
Note: Whenever any of the measurement-
(bit 6 of the ERW) is one, indicating that an
check conditions, bits 2-4, is indicated, the
address of a location within the invalid CBC is
channel subsystem sets the subchannel
stored in words 2 and 3 of the ESW.
measurement-block-update-enable bit to zero,
Detection of a channel-data-check condition

Chapter 16. I/O Interruptions 16-33


does not cause the CCW-check and check is indicated in bits 12-14 of word 2 of the
IDAW-check bits to be stored as ones. SCSW.
Reserved. Bit 7 is stored as zero.
Depending on the model, recognition of an
ancillary-report condition may not be provided or it
Last-Path-Used Mask (LPUM): Bits 8-15 indi-
may not be provided for all system malfunctions
cate the channel path that was last used for com-
that effect subchannel activity. When ancillary-
municating or transferring information between the
report recognition is not provided, bit 16 is set to
channel subsystem and the device. The bit corre-
zero.
sponding to the channel path in use is set when-
ever one of the following occurs:
Field-Validity Flags (FVF): Bits 17-21 indicate
1. The first command of a start-subchannel func- the validity of the information stored in the corre-
tion is accepted by the device (see Activity sponding fields of either the SCSW or the
Control (AC) on page 16-13). extended-status word. When the validity bit is
one, the corresponding field has been stored and
2. The device and channel subsystem are
is usable for recovery purposes. When the validity
actively communicating when the channel sub-
bit is zero, the corresponding field is not usable.
system performs the suspend function for the
channel program in execution.
This bit-significant field has meaning when
3. The channel subsystem accepts status from channel-data check, channel-control check, or
the device that is recognized as an inter- interface-control check is indicated in the SCSW.
ruption condition, or a condition has been When these checks are not indicated, this field, as
recognized that suppresses command well as the termination-code and sequence-code
chaining (see Interruption Conditions on fields, has no meaning. Further, when these
page 16-2). checks are not indicated, the last-path-used-mask,
device-status, and CCW-address fields are all
4. The channel subsystem recognizes an
valid. The fields are defined as follows:
interface-control-check condition (see
Interface-Control Check on page 16-28), and 17 Last-path-used mask
no subchannel-logout information is currently 18 Termination code
present at the subchannel. 19 Sequence code
20 Device status
The LPUM field contains the most recent setting
21 CCW address
and is valid whenever the ESW contains informa-
tion in one of the formats 0-3 (see Extended-
Storage-Access Code (SA): Bits 22-23 indicate
Status Word on page 16-32) and the SCSW is
the type of storage access that was being per-
stored. When subchannel-logout information is
formed by the channel subsystem at the time of
present in the ESW, a zero LPUM-field-validity
error. The SA field pertains only to the access of
flag indicates that the LPUM setting is not con-
storage for the purpose of fetching or storing data
sistent with the other subchannel-logout indi-
during execution of an I/O operation. This
cations.
encoded field has meaning only when channel-
data check, channel-control check, or interface-
Ancillary Report (R): Bit 16, when one, indi-
control check is indicated in the subchannel
cates that a malfunction of a system component
status. The access-code assignments are as
has occurred which has been recognized previ-
follows:
ously or which has affected the activities of mul-
tiple subchannels. When the malfunction affects 00 Access type unknown
the activities of multiple subchannels, an ancillary- 01 Read
report condition is recognized for all of the 10 Write
affected subchannels except one. This bit, when 11 Read backward
zero, indicates that this malfunction of a system
component has not been recognized previously. Termination Code (TC): Bits 24-25 indicate the
This bit is meaningful only when a channel-control type of termination that has occurred. This
check, channel-data check, or an interface-control encoded field has meaning only when channel-
data check, channel-control check, or interface-

16-34 z/Architecture Principles of Operation


control check is indicated in the SCSW. The the channel subsystem. The channel subsystem,
types of termination are as follows: in response, issues a clear signal and, except as
described in the next paragraph, causes interface-
00 Halt signal issued
control check to be set and
01 Stop, stack, or normal termination
extended-status-format-0 (logout) information to be
10 Clear signal issued
stored in the ESW.
11 Reserved
When at least one channel check is indicated in When I/O-error alert is signaled and the sub-
the SCSW but the termination-code-field-validity channel has previously been set disabled or no
flag is zero, it is unpredictable which, if any, termi- subchannel is associated with the device, the
nation has been signaled to the device. If more clear signal is issued to the device, and the
than one channel-check condition is indicated in I/O-error-alert indication is ignored by the channel
the SCSW, the device may have been signaled subsystem.
one or more termination codes that are the same
or different. In this situation, if the termination- Sequence Code (SC): Bits 29-31 identify the I/O
code-field-validity flag is one, the termination code sequence in progress at the time of error. The
indicates the most severe of the terminations sig- sequence code pertains only to I/O operations ini-
naled to the device. The termination codes, in tiated by execution of START SUBCHANNEL or
order of increasing severity, are: stop, stack, or RESUME SUBCHANNEL. This encoded field has
normal termination (01); halt signal issued (00); meaning only when channel-data check, channel-
and clear signal issued (10). control check, or interface-control check is indi-
cated in the SCSW.
Device-Status Check (D): When the status-
verification facility is installed, bit 26, when one, The sequence-code assignments are:
indicates that the subchannel logout in the ESW 000 Reserved.
resulted from the channel subsystem detecting
device status that had valid CBC but that con- 001 A nonzero command byte has been sent by
tained a combination of bits that was inappropriate the channel subsystem, but a response has
when the status byte was presented to the not yet been analyzed by the channel sub-
channel subsystem. When the device-status- system. This code is set during the initiation
check bit is one, the interface-control-check status sequence.
bit is set to one. If, additionally, bit 20 of the 010 The command has been accepted by the
subchannel-logout field has been stored as one, device, but no data has been transferred.
then the status byte in error has been stored in
the device-status field of the SCSW. If the status- 011 At least one byte of data has been trans-
verification facility is not installed, bit 26 is stored ferred between the channel subsystem and
as zero. the device. This code may be used when
the channel path is in an idle or polling state.
Secondary Error (E): Bit 27, when one, indi- 100 The command in the current CCW (1) has
cates that a malfunction of a system component not yet been sent to the device, (2) was sent
which may or may not have been directly related but not accepted by the device, or (3) was
to any activity involving subchannels or I/O sent and accepted but command-retry status
devices has occurred. Subsequent to this occur- was presented. This code is set when one
rence, the activity related to this subchannel and of the following conditions occurs:
the associated I/O device was affected and
caused the subchannel to be set status-pending 1. When the command address is updated
with either channel-control check or interface- during command chaining or during the
control check. initiation of a start function or resume
function at the device.
I/O-Error Alert (A): Bit 28, when one, indicates 2. When, during the initiation sequence, the
that subchannel logout in the ESW resulted from status includes attention, control-unit
the signaling of I/O-error alert. The I/O-error-alert end, unit check, unit exception, busy,
signal indicates that the control unit or device has status modifier (without channel end and
detected a malfunction that must be reported to

Chapter 16. I/O Interruptions 16-35



device end), or device end (without Logout Condition
channel end). for SCSW
Indication of

3. When command retry is signaled. Subchannel-Logout Condition Indicated CDC CCC IFCC

4. When the channel subsystem interro- Key check V V -
Measurement-block-program check - - -
gates the device in the process of Measurement-block-data check - - -
Measurement-block-protection check - - -
clearing an interruption condition. CCW check - V -
IDAW check - V -
5. When the channel subsystem signals the Last-path-used mask V V V
Field-validity flags V V V
conclusion of the chain of operations to Termination code V V V
the device during command chaining Device-status check
Secondary error
- - V
- V V


while performing the suspend function. I/O-error alert - - V
Sequence code V V V

101 The command in the current CCW has been Explanation:
accepted, but data transfer is unpredictable.
- No relationship.
This code applies from the time a device is
When more than one SCSW indication is signaled,
logically connected to a channel path until the subchannel-logout conditions that are valid
the time it is determined that a new are the logical OR for each of the respective SCSW
indications.
sequence code applies. This code may also
Only one measurement-block check may be indicated
be used when the channel subsystem places in a specific subchannel logout.
a channel path in the polling or idle state and
This field has a field-validity flag.
it is impossible to determine that code 010 or
CCC Channel-control check.
011 applies. It may also be used at other
times when a channel path cannot distin- CDC Channel-data check.



guish between code 010 or 011. IFCC Interface-control check.

V Bit setting valid.
110 Reserved.

111 Reserved. Figure 16-6. Relationship between Subchannel-Logout


Data and SCSW Bits
Figure 16-6 defines the relationship between indi-
cations provided as subchannel-logout data and
the appropriate SCSW bits. Extended-Report Word
The extended-report word (ERW) provides infor-
mation to the program describing specific condi-
tions that may exist at the device, subchannel, or
channel subsystem. The ERW is stored whenever
the extended-status word is stored. When the
extended-status-word-format bit (bit 5, word 0 of
the SCSW) and the extended-control bit (bit 14,
word 0 of the SCSW) are both zeros, the ERW
contains all zeros. When the extended-status-
word-format bit or the extended-control bit or both
are ones, the ERW has this format:


APTFSCRSCNT

3 8 1 16 21 31

Authorization Check (A): Bit 3, when one, indi-


cates that the start or resume function was termi-
nated because the channel subsystem has been
placed in the isolated state in which pending I/O
operations are not initiated and currently executing
I/O operations are either in the process of being
terminated or have been terminated.

16-36 z/Architecture Principles of Operation


Path-Verification-Required Flag (P): Bit 4, when interface-control check are recognized by the
one, indicates that the program must verify the channel subsystem, situations may exist where
identity of the device. The LPUM, when valid, the termination point of execution of the channel
indicates the channel path for which device verifi- program differs between the channel subsystem
cation is to be performed. When a valid LPUM is and the I/O device. To properly identify the termi-
not available, the identity of the device must be nation points, bit 8 is set to one, and a second
verified for each available channel path. CCW address (Secondary-CCW Address) is pro-
vided in the ESW which designates the last CCW
Channel-Path Timeout (T): Bit 5, when one, executed at the device. When the validity bit is
indicates that, during a signaling sequence, an zero for the previously mentioned errors, the
appropriate signal from the device did not occur channel subsystem was unable to determine the
within a predetermined time interval. Bit 5 is termination point of control unit execution and the
meaningful when the extended-status-word-format secondary-CCW-address field contains zeros.
bit (bit 5, word 0 of the SCSW) and the interface-
control check bit (bit 14, word 2 of the SCSW) are Bit 8 is not set to one unless the program has per-
both ones. mitted prefetching by the setting of the prefetch
control bit (bit 9, word 1 of the ORB) to one for the
Failing-Storage-Address-Validity Flag (F): Bit channel program in execution.
6, when one, and when the extended-status-
word-format bit (bit 5, word 0 of the SCSW) is also Failing-Storage-Address Format (R): Bit 9 indi-
one, indicates that the channel subsystem has cates the format of the failing-storage address
detected an invalid CBC on a CCW, a data when the failing-storage-address validity bit (bit 6
address, an IDAW, or the respective associated of the ERW) is one. When bit 6 is zero, bit 9 is
key and has stored, in words 2 and 3 of the ESW, not meaningful and is stored as zero. When bit 6
an absolute address of a location within the invalid is one and bit 9 is zero, a format-1 failing-storage
CBC. When an ERW is stored with bit 6 set to address is stored in words 2 and 3 of the ESW.
zero, zeros are stored in words 2 and 3 of the When bit 6 is one and bit 9 is one, a format-2
ESW. failing-storage address is stored in words 2 and 3.
See Failing-Storage Address below for a
Concurrent-Sense (S): Bit 7, when one, indi- description of format-1 and format-2 addresses.
cates that the concurrent-sense facility has placed
sense information accepted from the device in the The remaining bits of the ERW are currently
extended-control word and has stored a value in reserved and are stored as zeros when the ERW
bits 10-15 of the ERW which specifies the number is stored.
of sense bytes that have been stored in the
extended-control word. When bit 7 is one, bit 14 Failing-Storage Address
of word 0 of the SCSW is also one. Words 2 and 3 of the extended-status word form a
24, 31, or 64-bit main-storage address. When the
Concurrent-Sense Count (SCNT): When bit 7 is failing-storage-address-validity flag (bit 6 of the
one, bits 10-15 contain a value in the range 1-32 ERW) is one, words 2 and 3 contain either a
which specifies the number of sense bytes stored format-1 failing-storage address or a format-2
into the extended-control word by the concurrent- failing-storage address. When bit 6 is zero, words
sense facility. When bit 7 is zero, bits 10-15 2 and 3 are stored as zeros. When bit 6 is one
contain zeros. the failing-storage-address field designates a byte
location within the invalid checking block associ-
Secondary CCW Address Validity (C): Bit 8, ated with an invalid CBC for a CCW, data
when one, and when the extended-status-word- address, IDAW, or their respective associated key.
format bit (bit 5, word 0 of the SCSW) is also one,
indicates that the channel subsystem has detected The form of the address stored in words 2 and 3
an error condition that precludes continued exe- depends on the addressing mode in use by the
cution of an I/O operation. When prefetching channel subsystem when the error condition is
applies (bit 9, word 1 of the ORB is set to one) detected. When the channel system is operating
and when certain error conditions, identified by in either 24-bit or 31-bit addressing mode, a
channel-control check, channel-data check, or format-1 address is stored and the failing-storage-

Chapter 16. I/O Interruptions 16-37


address-format bit (bit 9 of the ERW) is stored as a. The device-connect-time-measurement
zero. When the channel subsystem is operating mode is inactive.
in 64-bit addressing mode, a format-2 address is
b. The channel-subsystem-timing facility is
stored and bit 6 is stored as one.
not available for the subchannel.
When a format-1 address is stored, bits 1-31 of c. The subchannel is not enabled for the
word 2 form the address associated with the device-connect-time-measurement mode.
reported error condition and word 3 is stored as
Zeros are stored in bytes 0 and 2-3 of word 0, and
zeros. Additionally, bits 0-7 (24-bit addressing
the LPUM is stored in byte 1 of word 0; an ERW
mode) are stored as zeros or bit 0 (31-bit
is stored in word 1; zeros are stored in words 2-4.
addressing mode) is stored as zero. When a
format-2 address is stored, bits 0-31 of word 2 The device-connect-time-measurement mode is
concatenated with bits 0-31 of word 3 form the made inactive when SET CHANNEL MONITOR is
64-bit address associated with the reported error executed and bit 31 of general register 1 is zero.
condition.
A format-1 ESW has this format:
Secondary-CCW Address
When the subchannel-status field indicates
Zeros LPUM Zeros
channel-control check, channel-data check, or
interface-control check and the 1 Extended-Report Word
secondary-CCW-address-validity flag (bit 8 of
2
word 1) is one, bits 1-31 of word 4 form an abso- 3 Zeros
lute address of the last CCW executed by the I/O 4
device at the point the reported check condition
caused channel program termination. When pro- 8 16 31
vided, the secondary-CCW address may be used
for recovery purposes. When the Last-Path-Used Mask (LPUM): For a definition
secondary-CCW-address-validity flag is zero, this of the LPUM, see Last-Path-Used Mask (LPUM)
field contains zeros. on page 16-34.

Extended-Report Word (ERW): For a definition


Extended-Status Format 1
of the ERW, see Extended-Report Word on
The ESW stored by TEST SUBCHANNEL is a page 16-36.
format-1 ESW when all of the following conditions
are met: Extended-Status Format 2
1. The extended-status-word-format bit (bit 5,
The ESW stored by TEST SUBCHANNEL is a
word 0 of the SCSW) is zero.
format-2 ESW when all of the following conditions
2. The subchannel status-control field has the are met:
status-pending bit (bit 31, word 0 of the
1. The extended-status-word-format bit (bit 5,
SCSW) set to one, together with:
word 0 of the SCSW) is zero.
a. The primary-status bit (bit 29, word 0 of
2. The channel-subsystem-timing facility is avail-
the SCSW) alone, or
able for the subchannel.
b. The primary-status bit and other status-
3. The subchannel is enabled for the device-
control bits, or
connect-time-measurement mode.
c. The intermediate-status bit (bit 28, word 0
4. The device-connect-time-measurement mode
of the SCSW) and the suspended bit (bit
is active.
26, word 0 of the SCSW).
5. The subchannel status-control field has the
3. At least one of the following conditions is indi-
status-pending bit (bit 31, word 0 of the
cated:
SCSW) set to one, together with:

16-38 z/Architecture Principles of Operation


a. The primary-status bit (bit 29, word 0 of subchannel is enabled for the device-connect-
the SCSW) alone, or time-measurement mode but no DCTI value is
stored in the ESW (because of the presence of
b. The primary-status bit and other status-
subchannel-logout information), or if the DCTI is
control bits, or
zero, then nothing is added to the corresponding
c. The intermediate-status bit (bit 28, word 0 measurement-block data.
of the SCSW) and the suspended bit (bit
26, word 0 of the SCSW). Extended-Report Word (ERW): For a definition
of the ERW, see Extended-Report Word on
Zeros are stored in byte 0 of word 0, the LPUM is
page 16-36.
stored in byte 1 of word 0, and the device-connect
time is stored in bytes 2-3 of word 0; an ERW is
stored in word 1; zeros are stored in words 2-4. Extended-Status Format 3
A format-2 ESW has this format: The ESW stored by TEST SUBCHANNEL is a
format-3 ESW when the extended-status-word-
format bit (bit 5, word 0 of the SCSW) is zero and
Zeros LPUM DCTI
the subchannel is status-pending with (1) sec-
1 Extended-Report Word ondary status, alert status, or both when primary
status is not also present, or (2) intermediate
2
3 Zeros status when the subchannel is not suspended.
4 Zeros are stored in byte 0 of word 0, and the
LPUM is stored in byte 1 of word 0. Bytes 2-3 of
8 16 31
word 0 contain unpredictable values; an ERW is
stored in word 1; zeros are stored in words 2-4.
Last-Path-Used Mask (LPUM): For a definition
of the LPUM, see Last-Path-Used Mask (LPUM) A format-3 ESW has this format:
on page 16-34.

Zeros LPUM XXXXXXXX XXXXXXXX
Device-Connect-Time Interval (DCTI): Bits
16-31 contain the binary count of time increments 1 Extended-Report Word
accumulated by the channel subsystem during the
2
time that the channel subsystem and the device 3 Zeros
were actively communicating and the subchannel 4
was subchannel-active. The time increment of the
8 16 31
DCTI is 128 microseconds.

If the above conditions for the storing of the DCTI Last-Path-Used Mask (LPUM): For a definition
value in the ESW are met but the device-connect- of the LPUM, see Last-Path-Used Mask (LPUM)
time-measurement mode was made active by SET on page 16-34.
CHANNEL MONITOR subsequent to execution of
START SUBCHANNEL for this subchannel, the An X in the format indicates the bit may be zero
DCTI value stored is greater than or equal to zero or one.
and less than or equal to the correct DCTI value.
Extended-Report Word (ERW): For a definition
Note: The DCTI value stored in the ESW is the
of the ERW, see Extended-Report Word on
same as that used to update the corresponding
page 16-36.
measurement-block data for the subchannel if the
measurement-block-update mode is in use for the Figure 16-7 on page 16-40 summarizes the con-
subchannel. If the measurement-block-update ditions at the subchannel under which each type
mode for the channel subsystem is active and the of information is stored in the ESW.

Chapter 16. I/O Interruptions 16-39



Subchannel Conditions When IRB Is Stored


Extended-Control Word
Subchannel- Path-Management- Extended-
Status Word Control Word Status The extended-control word provides additional
Word (ESW),
Device- Word information to the program describing conditions
Connect-
Status- Device- Time-
that may exist at the channel subsystem, sub-
Control Sus-Connect- Msrmnt- Contents channel, or device. The extended-control (E) bit
Field pen-Time- Timing- Mode-
L ded Msrmnt FacilityEnable For- Bytes (bit 14, word 0 of the SCSW), when one, indicates
AIPSX BitBit Mode Bit Bit mat ,1,2,3
that model-dependent information or concurrent-
---- /////////////////////////////////// sense information has been stored in the
///////////////////////////////
1 /////////////////////////////// U \\\\ extended-control word.
//////////////////////////
//////////////////////////
The information provided in the extended-control
Inactive/////////////////
//////// word is as follows:
11 //////// 1 ZMZZ
1
Active
1 SCSW ERW ERW
1 2 ZMDD Bits Bit Bits ECW

////Inactive/////////////////
5 14 7 1-15 Words -7
////////////
//// //////// 1 ZMZZ Zeros Unpredictable
\\1\1 //// 1 () ()
//// Active
//// 1 1 1 () Concurrent-sense information
//// 1 2 ZMDD 1 Zeros Unpredictable
1 1 Zeros Model-dependent information
\\11 ///////////////////////////////
/////////////////////////////// 3 ZM\\
1 1 1 () Concurrent-sense information
1\1 ///////////////////////////////
If stored, the value of these words is
\\\\1 1 /////////////////////////////// RRRR unpredictable.

Explanation:
Unused bits in the model-dependent information
- Defined to be not meaningful when X is zero. are stored as zeros.
\ Bits may be zeros or ones.
/ Information not relevant in this situation.

A Alert status. Bits 1-15 contain a value equal to the number
D Accumulated device-connect-time-interval (DCTI) of sense bytes returned.
value stored in bytes 2 and 3.
I Intermediate status.
L Extended-status-word format. Unused bytes in the concurrent-sense information
M Last-path-used mask (LPUM) stored in byte 1. are stored as zeros.
P Primary status.
R Subchannel-logout information stored in word .
S Secondary status.
The combination of SCSW bit 5 as , SCSW bit 14
U No format defined. as one, and ERW bit 7 as zero does not occur.
X Status-pending.
Z Bits are stored as zeros.

Figure 16-7. Information Stored in ESW

16-40 z/Architecture Principles of Operation


Chapter 17. I/O Support Functions
Channel-Subsystem Monitoring . . . . . . . . 17-1 Halt Signal . . . . . . . . . . . . . . . . . 17-9
Channel-Subsystem Timing . . . . . . . . . 17-1 Clear Signal . . . . . . . . . . . . . . . . 17-9
Channel-Subsystem Timer . . . . . . . . 17-2 Reset Signal . . . . . . . . . . . . . . . 17-10
Measurement-Block Update . . . . . . . . 17-2 Resets . . . . . . . . . . . . . . . . . . . . 17-10
Measurement Block . . . . . . . . . . . . 17-3 Channel-Path Reset . . . . . . . . . . 17-10
Measurement-Block Origin . . . . . . . . 17-5 I/O-System Reset . . . . . . . . . . . . 17-10
Measurement-Block Key . . . . . . . . . 17-6 Externally Initiated Functions . . . . . . . . 17-14
Measurement-Block Index . . . . . . . . 17-6 Initial Program Loading . . . . . . . . . . 17-15
Measurement-Block-Update Mode . . . 17-6 Reconfiguration of the I/O System . . . . 17-17
Measurement-Block-Update Enable . . 17-6 Status Verification . . . . . . . . . . . . . . . 17-17
Control-Unit-Queuing Measurement . . 17-7 Address-Limit Checking . . . . . . . . . . . 17-17
Control-Unit-Defer Time . . . . . . . . . 17-7 Configuration Alert . . . . . . . . . . . . . . 17-18
Device-Active-Only Measurement . . . . 17-7 Incorrect-Length-Indication Suppression . . 17-18
Time-Interval-Measurement Accuracy . 17-7 Concurrent Sense . . . . . . . . . . . . . . . 17-18
Device-Connect-Time Measurement . . . . 17-8 Channel-Subsystem Recovery . . . . . . . . 17-19
Device-Connect-Time-Measurement Channel Report . . . . . . . . . . . . . . . 17-19
Mode . . . . . . . . . . . . . . . . . . 17-8 Channel-Report Word . . . . . . . . . . . 17-21
Device-Connect-Time-Measurement Channel Subsystem I/O-Priority Facility . . 17-22
Enable . . . . . . . . . . . . . . . . . 17-8 Number of Channel Subsystem
Signals and Resets . . . . . . . . . . . . . . . 17-9 Priority Levels . . . . . . . . . . . . 17-23
Signals . . . . . . . . . . . . . . . . . . . . . 17-9

The I/O support functions are those functions of enabled to use the facilities by means of the exe-
the channel subsystem that are not directly related cution of the MODIFY SUBCHANNEL instruction.
to the initiation or control of I/O operations. The
following I/O support functions are described in The channel-subsystem-monitoring facilities
this chapter: include the channel-subsystem-timing facility,
measurement-block-update facility, control-unit-
channel-subsystem monitoring
queuing-measurement facility, control-unit-defer-
signals and resets
time facility, and
externally initiated functions
device-connect-time-measurement facility. The
status verification
measurement-block-update facility and the device-
address-limit checking
connect-time-measurement facility are logically
configuration alert
distinct and operate independent of one another.
incorrect-length-indication suppression
Each of the facilities that constitute the channel-
concurrent sense
subsystem-monitoring facilities is described in this
channel-subsystem recovery
chapter.
I/O-priority facility

Channel-Subsystem Timing
Channel-Subsystem Monitoring
The channel-subsystem-timing facility provides the
Monitoring facilities are provided in the channel channel subsystem with the capability of meas-
subsystem so that the program can retrieve meas- uring the elapsed time required for performing
ured values on performance for a designated sub- several different phases in processing a start func-
channel. The use of these facilities is under tion initiated by START SUBCHANNEL. These
program control by means of the execution of the elapsed-time measurements are used by both the
SET CHANNEL MONITOR instruction. Addi- measurement-block-update facility and the device-
tionally, each subchannel can be selectively connect-time-measurement facility to provide sub-
channel performance information to the program.

Copyright IBM Corp. 1990, 2000 17-1


While every channel subsystem has a channel- of the subchannels, depending on the particular
subsystem-timing facility, it may or may not be channel-subsystem timer and the way the associ-
provided for use with all subchannels. Subchan- ated devices are physically attached to the
nels for which the facility is provided have the system. The values are unpredictable for those
timing-facility bit (bit 14 of word 1) stored as one devices attached to the system by separately
in the associated subchannel-information block. configurable channel paths whose associated
(See Timing Facility (T) on page 15-4.) If the CPU TOD clocks are not synchronized.
channel-subsystem-timing facility is not provided
for the subchannel, its timing-facility bit is stored Synchronization: If either the measurement-
as zero. block-update mode or device-connect-time-
measurement mode is active and any of the
Subchannels that do not have the channel- channel-subsystem timers are found to be out of
subsystem-timing facility provided are those for synchronization, a channel-subsystem-timer-sync
which the characteristics of the associated device, check is recognized, and a channel report is gen-
the manner in which it is attached to the channel erated to alert the program (see Channel-
subsystem, or the channel-subsystem resources Subsystem Recovery on page 17-19). If neither
required to support the device are such that use of of these modes is active, the lack of synchroniza-
the channel-subsystem-timing facility is precluded. tion is not recognized.

The channel-subsystem-timing facility consists of


at least one channel-subsystem timer and the
Measurement-Block Update
associated logic and storage required for com-
The measurement-block-update facility provides
puting and recording the elapsed-time intervals for
the program with the capability of accumulating
use by the two measurement facilities. The
performance information for subchannels that are
aspects of the channel-subsystem-timing facility
enabled for the measurement-block-update mode
that are of importance to the program are
when the measurement-block-update mode is
described below.
active. A subchannel is enabled for
measurement-block-update mode by setting bit 11
Channel-Subsystem Timer of word 1 of the SCHIB operand to one and then
Each channel-subsystem timer is a binary counter executing MODIFY SUBCHANNEL. The
that is not accessible to the program. The measurement-block-update mode is made active
channel-subsystem timer is incremented by adding by executing SET CHANNEL MONITOR when bit 62
a one to the rightmost bit position every 128 of general register 1 is one.
microseconds. When incrementing the channel-
subsystem timer causes a carry out of the leftmost When the measurement-block-update mode is
bit position, the carry is ignored, and counting con- active and the subchannel is enabled for the
tinues from zero. No indications are generated as measurement-block-update mode, information is
a result of the overflow. accumulated in a measurement block associated
with the subchannel. A measurement block is a
Just as every CPU has access to a TOD clock, 32-byte area in main storage that is associated
every channel subsystem has access to at least with a subchannel for the purpose of accumulating
one channel-subsystem timer. When multiple measurement data. The program specifies a con-
channel-subsystem timers are provided, synchro- tiguous area of absolute storage, referred to as
nization among these timers is also provided, cre- the measurement-block area, and subdivides this
ating the effect that all the timing facilities of the area into 32-byte blocks, one block for each sub-
channel subsystem share a single timer. Synchro- channel for which measurement data is to be
nization among these timers may be supplied accumulated. The measurement-block-update
either through some TOD clock or independently facility uses the measurement-block index con-
by the channel subsystem. tained at the subchannel in conjunction with the
measurement-block origin established by the exe-
If the TOD clocks are not synchronized, the
cution of SET CHANNEL MONITOR to compute the
elapsed times measured by the channel-
absolute address of the measurement block asso-
subsystem-timing facility may, depending upon the
ciated with a subchannel.
model, have unpredictable values for some or all

17-2 z/Architecture Principles of Operation


Measurement data is stored in the measurement accumulate measurement data at the suspension
block associated with the subchannel each time or completion of an I/O function, appear block-
an I/O operation or chain of I/O operations initiated concurrent to CPUs. CPU accesses to the block,
by START SUBCHANNEL is suspended or com- either fetches or stores, are inhibited during the
pleted. The completion of an I/O operation or time the measurement-block update is being per-
chain of I/O operations is normally signaled by the formed by the measurement-block-update facility.
primary interruption condition. Seven fields are
defined in the measurement block in which meas- The measurement block has the following format:
urement data is accumulated by the

measurement-block-update facility: SSCH+RSCH Word SSCH+RSCH Count Sample Count
count, sample count, device-connect time,
function-pending time, device-disconnect time, 1 Device-Connect Time

control-unit-queuing, and device-active-only time. 2 Function-Pending Time

Measurement Block 3 Device-Disconnect Time

The measurement block is a 32-byte area at the 4 Control-Unit-Queuing Time
location designated by the program, using the
measurement-block origin in conjunction with the 5 Device-Active-Only Time

measurement-block index. The measurement 6
block contains the accumulated values of the Reserved
measurement data described below. When the 7

measurement-block-update mode is active and the 16 31
subchannel is enabled for measurement-block
update, the measurement-block-update facility
accumulates the values for the measurement data SSCH+RSCH Count: Bits 0-15 of word 0 are
that accrue during the execution of an I/O opera- used as a binary counter. During the performance
tion or chain of I/O operations initiated by START of a start function for which measurement-block
SUBCHANNEL. update is active, when (1) the primary or sec-
ondary interruption condition, as appropriate, is
When the I/O operation or chain of I/O operations recognized or (2) the suspend function is per-
is suspended or completed and no error condition formed, the counter is incremented by adding one
is encountered, the accrued values are added to in bit position 15, and the measurement data is
the accumulated values in the measurement block stored. The counter wraps around from the
for that subchannel. If an error condition is maximum value of 65,535 to 0. The program is
detected and subchannel-logout information is not alerted when counter overflow occurs.
stored in the extended-status word (ESW), the
accrued values are not added to the accumulated If the measurement-block-update mode is active
values in the measurement block for the sub- and the subchannel is enabled for measuring, the
channel, and the two count fields are not incre- SSCH+RSCH count is incremented even when
mented. the lack of measured values for an individual start
function precludes the updating of the remaining
If any of the accrued time values is detected to fields of the measurement block or when the
exceed the internal storage provided for accruing timing-facility bit for the subchannel is zero. The
these values, or the control unit cannot provide an SSCH+RSCH count is not incremented if the
accurate queuing time or defer time for the current measurement-block-update mode is inactive, if the
operation, or the channel subsystem successfully subchannel is not enabled for the measurement-
recovers from certain error conditions, none of the block update, or if subchannel-logout information
accrued values are added to the measurement has been generated for the start function.
block for the subchannel, the sample count is not
incremented, but the SSCH+RSCH count is incre- Sample Count: Bits 16-31 of word 0 are used as
mented. a binary counter. When the time-accumulation
fields following word 0 of the measurement block
Accesses to the measurement block by the are updated, the counter is incremented by adding
measurement-block-update facility, in order to one in bit position 31. On some models, certain

Chapter 17. I/O Support Functions 17-3


conditions may preclude the measurement-block- Accumulation of device-connect-time intervals for
update facility obtaining the accrued values of the a subchannel and storing this data in the ESW are
measurement data for an individual start function, not affected by whether the measurement-block-
even when the measurement-block-update mode update mode is active. (See Device-Connect-
is active and the subchannel is enabled for that Time Measurement on page 17-8.)
mode. The control unit may also signal that it was
not able to accumulate an accurate queuing time. Function-Pending Time: Bits 0-31 of word 2
In these situations, the sample-count field is not contain the accumulated SSCH- and
incremented. RSCH-function-pending time. Function-pending
time is the time interval between acceptance of
The counter wraps around from the maximum the start function (or resume function if the sub-
value of 65,535 to 0. The program is not alerted channel is in the suspended state) at the sub-
when counter overflow occurs. This field is not channel and acceptance of the first command
updated if the channel-subsystem-timing facility is associated with the initiation or resumption of
not provided for the subchannel. channel-program execution at the device.

The System Library publication for the system When channel-program execution is suspended
model specifies the conditions, if any, that pre- because of a suspend flag in the first CCW of a
clude the updating of the sample count and time- channel program, the suspension occurs prior to
accumulation fields of the measurement block. transferring the first command to the device. In
this case, the function-pending time accumulated
Device-Connect Time: Bits 0-31 of word 1 up to that point is added to the value in the
contain the accumulation of measured device- function-pending-time field of the measurement
connect-time intervals. The device-connect-time block. Function-pending time is not accrued while
interval (DCTI) is the sum of the time intervals the subchannel is suspended. Function-pending
measured whenever the device is logically con- time begins to be accrued again, in this case,
nected to a channel path while the subchannel is when RESUME SUBCHANNEL is subsequently
subchannel active and the device is actively com- executed while the designated subchannel is in
municating with the channel path. The device- the suspended state.
connect time does not include the intervals when
a device is logically connected to a channel path The function-pending-time interval is measured
but is not actively communicating with the using a resolution of 128 microseconds. The
channel. The device reports the accumulation of accumulated value is modulo approximately
time intervals when the device is logically con- 152.71 hours, and the program is not alerted
nected but not actively communicating with the when an overflow occurs. This field is not
channel path as control-unit-defer time. The updated if the channel-subsystem-timing facility is
control-unit-defer time is not included in the not provided for the subchannel.
device-connect-time measurement but, rather, is
added to the accrued device-disconnect-time Device-Disconnect Time: Bits 0-31 of word 3
measurement for the operation. contain the accumulated device-disconnect time.
Device-disconnect time is the sum of the time
The time intervals are measured using a resol- intervals measured whenever the device is log-
ution of 128 microseconds. The accumulated ically disconnected from the channel subsystem
value is modulo approximately 152.71 hours, and while the subchannel is subchannel-active. The
the program is not alerted when an overflow device-disconnect time also includes the sum of
occurs. This field is not updated if (1) the control-unit-defer-time intervals reported by the
channel-subsystem-timing facility is not provided device during the I/O operation.
for the subchannel, (2) the measurement-block-
update mode is inactive, or (3) any of the time Device-disconnect time is not accrued while the
values accrued for the current start function has subchannel is in the suspended state. Device-
been detected to exceed the internal storage in disconnect time begins to be accrued again, in
which it was accrued. this case, on the first device disconnection after
channel-program execution has been resumed at

17-4 z/Architecture Principles of Operation


the device (the subchannel is again subchannel- Device-active-only time is not accumulated when
active). the subchannel is device-active during periods that
the subchannel is active; such time is accumu-
The device-disconnect-time interval is measured lated as device-connect time or device-disconnect
by using a resolution of 128 microseconds. The time as appropriate.
accumulated value is modulo approximately
152.71 hours; the program is not alerted when an The device-active-only-time field is updated such
overflow occurs. This field is not updated if the that bit 31 represents 128 microseconds. The
channel-subsystem-timing facility is not provided accumulated value is modulo approximately
for the subchannel. 152.71 hours; the program is not alerted when an
overflow occurs. This field is not updated if the
The device-disconnect time does not include the channel-subsystem-timing facility is not provided
interval between the primary status condition and for the subchannel.
the secondary status condition at the end of an
I/O operation when the subchannel is no longer Control-Unit-Defer Time: Control-unit-defer time
subchannel-active, but the I/O device is active. If is the sum of the time intervals measured by the
the channel subsystem provides the device-active- control unit whenever the device is logically con-
only measurement facility, this time is accumu- nected to the channel subsystem during an I/O
lated into the device-active-only time field of the operation but is not actively communicating with
measurement block. the channel because of device-dependent delays
in channel program execution. The control-unit-
Control-Unit-Queuing Time: Bits 0-31 of word 4 defer time is not stored in the measurement block
contain the accumulated control-unit-queuing time. as a separate measurement field but is used in
Control-unit-queuing time is the sum of the time the calculation of device-connect-time measure-
intervals measured by the control unit whenever ment and device-disconnect-time measurement for
the device is logically disconnected from the an operation.
channel subsystem during an I/O operation while
the device is busy with an operation initiated from Control-unit-defer time, if supported by a control
a different system. unit, is accrued while the device is logically con-
nected to the channel. The time is reported to the
Control-unit-queuing time is not accrued while the channel when channel-end status is presented
subchannel is in the suspended state. Control- that causes a device disconnection or terminates
unit-queuing time may be accrued for the channel the I/O operation. Control-unit-defer time is sub-
program after the subchannel becomes tracted from the device-connect-time measure-
subchannel-active following a successful ment and is added to the device-disconnect-time
resumption. measurement reported for the operation.

The control-unit-queuing-time field is updated such Reserved: The remaining words of the measure-
that bit 31 represents 128 microseconds. The ment block, along with any words associated with
accumulated value is modulo approximately facilities that are not provided by the channel sub-
152.71 hours; the program is not alerted when an system or the subchannel, are reserved for future
overflow occurs. This field is not updated if the use. They are not updated by the measurement-
channel-subsystem-timing facility is not provided block-update facility.
for the subchannel, or if the control unit does not
provide a queuing time. Measurement-Block Origin
The measurement-block origin specifies the abso-
Device-active-only time: Bits 0-31 of word 5 lute address of the beginning of the measurement-
contain the accumulated device-active-only time. block area on a 32-byte boundary in main storage.
Device-active-only time is the sum of the time The measurement-block origin is passed from
intervals when the subchannel is device-active but general register 2 to the measurement-block-
not subchannel-active at the end of an I/O opera- update facility when SET CHANNEL MONITOR is
tion or chain of I/O operations initiated by a start executed with bit 62 of general register 1 set to
function or resume function. one.

Chapter 17. I/O Support Functions 17-5


Measurement-Block Key the contents of general register 2 are passed to
Bits 32-35 of general register 1 form the four-bit the measurement-block-update facility as the
access key to be used for subsequent absolute address of the measurement-block origin.
measurement-block updates when SET CHANNEL The MBK is also passed to the measurement-
MONITOR causes the measurement-block-update block-update facility as the access key to be used
mode to be made active. The measurement-block when updating the measurement block for each
key is passed to the measurement-block-update subchannel. When the measurement-block-
facility whenever the measurement-block origin is update mode is active, the measurement-block-
passed. update facility accumulates measurements in
individual measurement blocks within the
Measurement-Block Index measurement-block area for subchannels whose
The measurement-block index is set in the sub- measurement-block-update-enable bit is one.
channel through the execution of MODIFY SUB- (See the section "Measurement Block" earlier in
CHANNEL. The measurement-block index this chapter for a description of the measured
specifies which 32-byte measurement block, rela- parameters.)
tive to the measurement-block origin, is to be used
for accumulating the measurement-block parame- If the measurement-block-update mode is already
ters for that subchannel. The location of the active when SET CHANNEL MONITOR is exe-
measurement block of a subchannel is computed cuted, the values for the measurement-block origin
by the measurement-block-update facility by and measurement-block key that are used for a
appending five rightmost zeros to the subchannel enabled for measuring by the
measurement-block index of the subchannel and measurement-block-update facility are dependent
adding the result to the measurement-block origin. upon whether SET CHANNEL MONITOR is exe-
The result is the absolute address of the 32-byte cuted prior to, during, or subsequent to execution
measurement block for that subchannel. When of START SUBCHANNEL for that subchannel. If
the computed measurement-block address SET CHANNEL MONITOR is executed prior to
exceeds 2-1, a measurement-block program- START SUBCHANNEL, the current measurement-
check condition is recognized, and measurement- block origin and measurement-block key are in
block updating does not occur for the preceding control. If SET CHANNEL MONITOR is executed
subchannel-active period. during or subsequent to execution of START SUB-
CHANNEL, it is unpredictable whether the
Programming Note: The initial value of the measurement-block origin and measurement-block
measurement-block index is zero. The program is key that are in control are old or current.
responsible for setting the measurement-block
index to the proper value prior to enabling the Measurement-Block-Update Enable
subchannel for the measurement-block-update Bit 11, word 1, of the SCHIB is the measurement-
mode and making the mode active. To preclude block-update-enable bit. This bit provides the
the possibility of unpredictable results for the capability of controlling the accumulation of
measured parameters in the measurement block, measurement-block parameters on a subchannel
each subchannel for which measured parameters basis. The initial value of the enable bit is zero.
are to be accumulated must have a different value When MODIFY SUBCHANNEL is executed with
for its measurement-block index. the enable bit set to one in the SCHIB, the sub-
channel is enabled for the measurement-block-
Measurement-Block-Update Mode update mode. If the measurement-block-update
The measurement-block-update mode is made mode is active, the measurement-block-update
active by executing SET CHANNEL MONITOR facility accumulates measurement-block parame-
with bit 62 of general register 1 set to one. If bit ters for the subchannel, starting with the next
62 of general register 1 is zero when SET START SUBCHANNEL issued to that subchannel.
CHANNEL MONITOR is executed, the mode is Similarly, if MODIFY SUBCHANNEL is executed
made inactive. When the measurement-block- with bit 11 of word 1 of the SCHIB operand set to
update mode is inactive, no measurement values zero by the program, the subchannel is disabled
are accumulated in main storage. When the for the measurement-block-update mode, and no
measurement-block-update mode is made active, additional measurement-block parameters are
accumulated for that subchannel.

17-6 z/Architecture Principles of Operation


Control-Unit-Queuing Measurement active-only-measurement facility is installed, the
measurement block updates are performed at the
The control-unit-queuing-measurement facility time that secondary status is accepted from the
allows the channel subsystem to accept queuing I/O device, in order that the device-active time
times from control units and, in conjunction with between primary status and secondary status can
the measurement-block-update facility, to accumu- be reported.
late those times in the measurement block.
If the subchannel is start pending when secondary
The System Library publication for the control-unit status is accepted from the I/O device and the
model specifies its ability to supply queuing time. measurement block update is to be performed, the
If a control-unit model is capable of supplying measurement block update is performed prior to
queuing time, the publication specifies the condi- performing the start function. If measurement-
tions that prevent the control unit from accumu- block errors occur, they are reported to the
lating an accurate control-unit-queuing time. program along with the secondary status instead
of performing the start function.
Control-Unit-Defer Time
Time-Interval-Measurement Accuracy
The control-unit-defer-time facility allows the On some models, when time intervals are to be
channel subsystem to accept defer times from measured and condition code 0 is set for START
control units and, in conjunction with the SUBCHANNEL (or RESUME SUBCHANNEL in
measurement-block-update facility, to modify the the case of a suspended subchannel), a period of
device-connect and device-disconnect times latency may occur prior to the initiation of the
reported in the measurement block to reflect the function-pending time measurement. The System
defer time. The control-unit-defer time is sub- Library publication for the system model specifies
tracted from the device-connect-time measure- the mean latency value and variance for each of
ment and is added to the device-disconnect-time the measured time intervals.
measurement reported for an I/O operation.
Programming Notes:
The System Library publication for the control-unit
1. Excessive delays may be encountered by the
model specifies its ability to supply defer time. If a
channel subsystem when attempting to update
control-unit model is capable of supplying defer
measurement data if the program is concur-
time, the publication specifies the conditions that
rently accessing the same measurement-block
prevent the control unit from accumulating an
area. A programming convention should
accurate control-unit-defer time.
ensure that the storage block designated by
SET CHANNEL MONITOR is made read-only
Device-Active-Only Measurement while the measurement-block-update mode is
The device-active-only-measurement facility active.
permits the channel subsystem to report the times
that the device is disconnected between primary 2. To ensure that programs written to support
status and secondary status at the end of an I/O measurement functions are executed properly,
operation or chain of I/O operations. The device- the program should initialize all the measure-
actively-only time is accumulated into word 5 of ment blocks to zeros prior to making the
the 32-byte measurement block. This time is not measurement-block-update mode active. Only
otherwise represented by the measurement data. zeros should appear in the reserved and
unused words of the measurement blocks.
When the device-active-only-measurement facility 3. When the incrementing of an accumulated
is not installed, measurement block updates are value causes a carry to be propagated out of
performed when the subchannel becomes status bit position 0, the carry is ignored, and accu-
pending for primary status. When the device- mulating continues from zero on.

Chapter 17. I/O Support Functions 17-7


Device-Connect-Time program. When timing facilities are provided for
the subchannel, the device-connect-time-
Measurement measurement mode is active, and the subchannel
is enabled for the mode, the DCTI value is passed
The device-connect-time-measurement facility pro-
to the program in the ESW stored when TEST
vides the program with the capability of retrieving
SUBCHANNEL (1) clears the primary-interruption
the length of time that a device is actively commu-
condition with no logout information indicated in
nicating with the channel subsystem while exe-
the SCSW (extended-status-word-format bit is
cuting a channel program. The measured length
zero) or (2) clears the intermediate-status condi-
of time that the device spends actively communi-
tion alone while the subchannel is suspended.
cating on a channel path during the execution of a
channel program is called the device-connect-time If a start function is currently being executed with
interval (DCTI). Control-unit-defer time is not a subchannel enabled for the device-connect-time-
included in the DCTI. measurement mode when SET CHANNEL
MONITOR makes this mode active for the channel
If timing facilities are provided for the subchannel,
subsystem, the value of the DCTI stored under the
the DCTI value is passed to the program in the
appropriate conditions may be zero, a partial
extended-status word (ESW) at the completion of
result, or the full and correct value, depending on
the operation when the primary-status condition is
the model and the progress of the start function at
cleared by TEST SUBCHANNEL and when TEST
the time the mode was activated.
SUBCHANNEL clears an intermediate-status con-
dition alone while the subchannel is suspended. Provision of the DCTI value in the measurement-
The DCTI value passed in the ESW pertains to block area is not affected by whether the device-
the previous subchannel-active period. The connect-time-measurement mode is active.
passing of the DCTI in the ESW is under program
control by the SET CHANNEL MONITOR device-
Device-Connect-Time-Measurement
connect-time-measurement mode-control bit and
Enable
the corresponding enable bit in the subchannel.
Bit 12, word 1, of the SCHIB is the device-
However, the DCTI value is not stored in the ESW
connect-time measurement-mode enable bit. This
if the I/O function initiated by START SUB-
bit provides the program with the capability of
CHANNEL is terminated because of an error con-
selectively controlling the storing of DCTI values
dition that is described by subchannel logout (see
for a subchannel when the device-connect-time-
the section "Extended-Status Format 0" in Chapter
measurement mode is active. The initial value of
16, "I/O Interruptions"). In this case, the
the enable bit is zero. When this enable bit is one
extended-status bit (L) of the SCSW is stored as
in the SCHIB and MODIFY SUBCHANNEL is exe-
one, indicating that the ESW contains logout infor-
cuted, the subchannel is enabled for the device-
mation describing the error condition. See the
connect-time-measurement mode. If the
section "Extended-Status Word" in Chapter 16,
device-connect-time-measurement mode is active,
"I/O Interruptions," for the description of the logout
the device-connect-time-measurement facility
information. If the accrued DCTI value exceeded
begins providing DCTI values for the subchannel,
8.388608 seconds during the previous
starting with the next START SUBCHANNEL
subchannel-active period, then the maximum
issued to the subchannel. In this situation, the
value (FFFF hex) is passed in the ESW.
DCTI values are provided in the ESW (see the
section "Extended-Status Format 2" in Chapter 16,
Device-Connect-Time-Measurement "I/O Interruptions"). Similarly, if MODIFY SUB-
Mode CHANNEL is executed with bit 12, word 1, of the
The device-connect-time-measurement mode is SCHIB operand set to zero by the program, the
made active by executing SET CHANNEL subchannel is disabled for the device-connect-
MONITOR when bit 63 of general register 1 is time-measurement mode, and no further DCTI
one. If bit 63 of general register 1 is zero when values are passed to the program for that sub-
SET CHANNEL MONITOR is executed, the mode channel.
is made inactive, and DCTIs are not passed to the

17-8 z/Architecture Principles of Operation


Architecture/390 ESCON I/O Interface,
Signals and Resets SA22-7202.
During system operation, it may become neces-
sary to terminate an I/O operation or to reset For the FICON-I/O-interface or the
either the I/O system or a portion of the I/O FICON-converted-I/O-interface type of channel
system. (The I/O system consists of the channel path, the halt signal results in the channel sub-
subsystem plus all of the attached control units system using the cancel function defined in the
and devices.) Various signals and resets are pro- ANSI standards document Fibre Channel - Single-
vided for this purpose. Three signals are provided Byte Command Code Sets-2 (FC-SB-2).
for the channel subsystem to notify an I/O device
to terminate an operation or perform a reset func- Clear Signal
tion or both. Two resets are provided to cause The clear signal is provided so the channel sub-
the channel subsystem to reinitialize certain infor- system can terminate an I/O operation and reset
mation contained either at the I/O device or at the status and control information contained at the
channel subsystem. device. The clear signal is issued as part of the
clear function performed subsequent to the exe-
cution of CLEAR SUBCHANNEL. The clear signal
Signals is also issued by the channel subsystem when
certain error conditions or equipment malfunctions
The request that the channel subsystem initiate a
are detected by the I/O device or the channel sub-
signaling sequence is made by one of the fol-
system.
lowing:
1. The program executing the CLEAR SUB- For the parallel-I/O-interface type of channel path,
CHANNEL, HALT SUBCHANNEL, or RESET the clear signal results in the channel subsystem
CHANNEL PATH instruction using the selective-reset sequence control defined
in the System Library publication IBM System/360
2. The I/O device signaling I/O-error alert
and System/370 I/O Interface Channel to Control
3. The channel subsystem itself upon detecting Unit OEMI, GA22-6974.
certain error conditions or equipment malfunc-
tions For the ESCON-I/O-interface type of channel path,
the clear signal results in the channel subsystem
The three signals are the halt signal, the clear
using the selective-reset function defined in the
signal, and the reset signal.
System Library publication IBM Enterprise
Systems Architecture/390 ESCON I/O Interface,
Halt Signal SA22-7202.
The halt signal is provided so the channel sub-
system can terminate an I/O operation. The halt For the FICON-I/O-interface or
signal is issued by the channel subsystem as part FICON-converted-I/O-interface type of channel
of the halt function performed subsequent to the path, the clear signal results in the channel sub-
execution of HALT SUBCHANNEL. The halt system using the selective-reset function defined
signal is also issued by the channel subsystem in the ANSI standards document Fibre Channel -
when certain error conditions are encountered. Single-Byte Command Code Sets-2 (FC-SB-2).
For the parallel-I/O-interface type of channel path, If an I/O operation is in progress at the device and
the halt signal results in the channel subsystem the device is actively communicating over a
using the interface-disconnect sequence control channel path in the execution of that I/O operation
defined in the System Library publication IBM when a clear signal is received on that channel
System/360 and System/370 I/O Interface path, the device disconnects from that channel
Channel to Control Unit OEMI, GA22-6974. path upon receiving the clear signal. Data transfer
and any operation using the facilities of the control
For the ESCON-I/O-interface type of channel path,
unit are immediately concluded, and the I/O
the halt signal results in the channel subsystem
device is not necessarily positioned at the begin-
using the cancel function defined in the System
ning of a block. Mechanical motion not involving
Library publication IBM Enterprise Systems
the use of the control unit, such as rewinding

Chapter 17. I/O Support Functions 17-9


magnetic tape or positioning a disk-access mech- 2. The operator activating a system-reset-clear
anism, proceeds to the normal stopping point, if or system-reset-normal key or a load-clear or
possible. The device may appear busy until termi- load-normal key
nation of the mechanical motion or the inherent
3. The channel subsystem itself upon detecting
cycle of operation, if any, whereupon it becomes
certain error conditions or equipment malfunc-
available. Status information in the device and
tions
control unit is reset, but an interruption condition
may be generated upon the completion of any The resets are channel-path reset and I/O-system
mechanical operation. reset.

Reset Signal Channel-Path Reset


The reset signal is provided so the channel sub- The channel-path-reset facility provides a mech-
system can reset all I/O devices on a channel anism to reset certain indications that pertain to a
path. The reset signal is issued by the channel designated channel path at all associated sub-
subsystem as part of the channel-path-reset func- channels. Channel-path reset occurs when the
tion performed subsequent to the execution of channel subsystem performs the channel-path-
RESET CHANNEL PATH. The reset signal is reset function initiated by RESET CHANNEL
also issued by the channel subsystem as part of PATH. (See RESET CHANNEL PATH on
the I/O-system-reset function. page 14-8.) All internal indications of dedicated
allegiance, control unit busy, and device busy that
For the parallel-I/O-interface type of channel path, pertain to the designated channel path are cleared
the reset signal results in the channel subsystem in all subchannels, and reset is signaled on that
using the system-reset sequence control defined channel path. The receipt of the reset signal by
in the System Library publication IBM System/360 control units attached to that channel path causes
and System/370 I/O Interface Channel to Control all operations in progress and all status, mode set-
Unit OEMI, GA22-6974. tings, and allegiance pertaining to that channel
path of the control unit and its attached devices to
For the ESCON-I/O-interface type of channel path, be reset. (See also the description of the system-
the reset signal results in the channel subsystem reset-signal actions in I/O-System Reset.)
using the system-reset function defined in the
System Library publication IBM Enterprise The results of the channel-path-reset function on
Systems Architecture/390 ESCON I/O Interface, the designated channel path are communicated to
SA22-7202. the program by means of a subsequent machine-
check-interruption condition generated by the
For the FICON-I/O-interface or the channel subsystem (see Channel-Subsystem
FICON-converted-I/O-interface type of channel Recovery on page 17-19).
path, the reset signal results in the channel sub-
system using the system-reset function defined in I/O-System Reset
the ANSI standards document Fibre Channel -
Single-Byte Command Code Sets-2 (FC-SB-2). The I/O-system-reset function is performed when
the channel subsystem is powered on, when initial
Resets program loading is initiated manually (see Initial
Program Loading on page 17-15), and when the
Two resets are provided so the channel sub- system-reset-clear or system-reset-normal key is
system can reinitialize certain information con- activated. The I/O-system-reset function cannot
tained at either the I/O device or the channel be initiated under program control; it must be initi-
subsystem. The request that the channel sub- ated manually. I/O-system reset may fail to com-
system initiate one of the reset functions is made plete due to malfunctions detected at the channel
by one of the following: subsystem or at a channel path. I/O-system reset
is performed as part of subsystem reset, which
1. The program executing the RESET CHANNEL also resets all floating interruption requests,
PATH instruction including pending I/O interruptions. (See Sub-
system Reset on page 4-46.) Detailed
descriptions of the effects of I/O-system reset on

17-10 z/Architecture Principles of Operation


the various components of the I/O system appear dynamic-reconnection feature and are operating in
later in this chapter. multipath mode, however, have the capability to
establish an allegiance to a group of channel
I/O-system reset provides a means for placing the paths during an I/O operation, where all the
channel subsystem and its attached I/O devices in channel paths of the path group are configured to
the initialized state. I/O-system reset affects only the same channel subsystem. If an operation is in
the channel-subsystem configuration in which it is progress for a device that is operating in multipath
performed, including all channel-subsystem com- mode and the reset signal is received on one of
ponents configured to that channel subsystem. the channel paths of that path group, then the
I/O-system reset has no effect on any system operation in progress is reset for the resetting
components that are not part of the channel- channel path only. Although the operation in
subsystem configuration that is being reset. The progress cannot continue on the resetting channel
effects of I/O-system reset on the configured com- path, it can continue on the other channel paths of
ponents of the channel subsystem are described the path group, subject to the following
in the following sections. restrictions:

Channel-Subsystem State: I/O-system reset 1. If the device is actively communicating with


causes the channel subsystem to be placed in the the channel subsystem on a channel path
initialized state, with all the channel-subsystem when it receives the reset signal on that
components in the states described in the fol- channel path, then the operation is reset
lowing sections. All operations in progress are unconditionally, regardless of path groups.
terminated and reset, and all indications of prior 2. If the operation is in progress in multipath
conditions are reset. These indications include mode but the path group consists only of the
status information, interruption conditions (but not resetting path, then the operation is reset.
pending interruptions), dedicated-allegiance condi-
3. Except as noted in item 2, if the operation in
tions, pending channel reports, and all internal
progress is currently in a disconnected state
information regarding prior conditions and oper-
(device not actively communicating with the
ations. In the initialized state, the channel sub-
channel subsystem) or is active on another
system has no activity in progress and is ready to
channel path of a path group, system reset
perform the initial-program-loading (IPL) function
has no effect upon continued execution of the
or respond to I/O instructions, as described in
operation.
Chapter 14, I/O Instructions.
A control unit is completely reset after the reset
Control Units and Devices: I/O-system reset signal has been received on all its channel paths,
causes a reset signal to be sent on all configured provided no new activity is initiated at the control
channel paths, including those which are not phys- unit between the receipt of the first and last reset
ically available (as indicated by the PAM bit being signal. Completely reset means that the current
zero) because of a permanent error condition operation, if any, at the control unit is terminated
detected earlier. When the reset signal is and that control-unit allegiance, control-unit status,
received by a control unit, control-unit functions in and the control-unit mode, if any, are reset.
progress, control-unit status, control-unit alle-
giance, and control-unit modes for the resetting An I/O device is completely reset after the reset
channel path are reset. Device operations in signal has been received on all channel paths of
progress, device status, device allegiance, and the all control units by which the device is accessible,
device mode for the resetting channel path are provided no new activity is initiated at the device
also reset. Control-unit and device mode, alle- between the receipt of the first and last reset
giance, status, and I/O functions in progress for signal. Completely reset means that the current
other channel paths are not affected. operation, if any, at the device is terminated and
that device allegiance, device status, and the
For devices that are operating in single-path device mode are reset.
mode, an operation can be in progress for, at
most, one channel path. Therefore, if the reset In summary, system reset always causes an oper-
signal is received on that channel path, the opera- ation in progress to be reset for the channel path
tion in progress is reset. Devices that have the on which the reset signal is received. If the reset-

Chapter 17. I/O Support Functions 17-11


ting channel path is the only channel path for Multipath mode
which the operation is in progress, then the opera- Path-not-operational mask
tion is completely reset. If a device is actively Last-path-used mask
communicating on a channel path over which the Measurement-block index
reset signal is received, then the operation in Concurrent Sense
progress is unconditionally and completely reset.
The initial values of the following subchannel
The reset signal is not received by control units parameters are assigned as part of the installation
and devices on channel paths from which the procedure for the device associated with each
control unit has been partitioned. A control unit is valid subchannel:
partitioned from a channel path by means of an
Timing facility
enable/disable switch on the control unit for each
Device number
channel path by which it is accessible. Multi-
Logical-path mask (same value as path-
tagged, unsolicited status, if any, remains pending
installed mask)
at the control unit for such a channel path in this
Path-installed mask
case. However, from the point of view of the
Path-available mask
program, the control unit and device appear to be
Channel-path ID 0-7
completely reset if the reset signal is received by
the control unit on all the channel paths by which The values assigned may depend upon the partic-
it is currently accessible. ular system model and the configuration; depend-
encies, if any, are described in the System Library
The resultant reset state of individual control units publication for the system model. Programming
and devices is described in the System Library considerations may further constrain the values
publication for the control unit. assigned.

Channel Paths: I/O-system reset causes a reset The initial value of the path-operational mask is all
signal to be sent on all configured channel paths ones.
and causes the channel subsystem to be placed
in the reset and initialized state, as described in The device-number-valid bit is one for all subchan-
the previous sections. As a result of these nels having an assigned I/O device.
actions, all communication between the channel
subsystem and its attached control units and The initial value of the model-dependent area of
devices is terminated and the components reset, the subchannel-information block is described in
and all configured channel paths are made the System Library publication for the system
quiescent or are deconfigured. model.

Subchannels: I/O-system reset causes all oper- The initial value of the subchannel-status word
ations on all subchannels to be concluded. Status and extended-status word is all zeros.
information, all interruption conditions (but not
pending interruptions), dedicated-allegiance condi- The initialized state of the subchannel is the state
tions, and internal indications regarding prior con- specified by the initial values for the subchannel
ditions and operations in all subchannels are parameters described above. The description of
reset, and all valid subchannels are placed in the the subchannel parameters can be found in
initialized state. Subchannel-Information Block on page 15-1;
Subchannel-Status Word on page 16-6; and in
In the initialized state, the subchannel parameters Extended-Status Word on page 16-32.
of all valid subchannels are set to their initial
values. The initial values of the following sub- Channel-Path-Reset Facility: I/O-system reset
channel parameters are zeros: causes the channel-path-reset facility to be reset.
A channel-path-reset function initiated by RESET
Interruption parameter CHANNEL PATH, either pending or in progress, is
I/O-interruption subclass code (ISC) overridden by I/O-system reset. The machine-
Enabled check-interruption condition, which normally
Limit mode signals the completion of a channel-path-reset
Measurement mode

17-12 z/Architecture Principles of Operation


function, is not generated for a channel-path-reset Pending Channel Reports: I/O-system reset
function that is pending or in progress at the time causes pending channel reports to be reset.
I/O-system reset occurs.
Channel-Subsystem Timer: I/O-system reset
Address-Limit-Checking Facility: I/O-system does not necessarily affect the contents of the
reset causes the address-limit-checking facility to channel-subsystem timer. In models that provide
be reset. The address-limit value is initialized to channel-subsystem-timer checking, I/O-system
all zeros and validated. reset may cause the channel-subsystem timer to
be validated.
Channel-Subsystem-Monitoring Facilities:
I/O-system reset causes the channel-subsystem- Pending I/O Interruptions: I/O-system reset
monitoring facilities to be reset. The does not affect pending I/O interruptions.
measurement-block-update mode and the device- However, during subsystem reset, I/O interruptions
connect-time-measurement mode, if active, are are cleared concurrently with the performance of
made inactive. The measurement-block origin and I/O-system reset. (See Subsystem Reset on
the measurement-block key are both initialized to page 4-46.)
zeros and validated.

Chapter 17. I/O Support Functions 17-13



Area Affected Effect of I/OSystem Reset

Channel-subsystem state Reset and initialized


Control units and devices Reset
Channel paths Quiescent
Subchannels Reset and initialized
Interruption parameter Zeros
I/O-interruptionsubclass code (ISC) Zeros
Enabled bit Zero
Address-limit-mode bits Zeros
Timing-facility bit Installed value
Multipath-mode bit Zero
Measurement-mode bits Zeros
Device-number-valid bit Installed value
Device number Installed value
Logical-path mask Equal to path-installed
mask value
Path-not-operational mask Zeros
Last-path-used mask Zeros
Path-installed mask Installed value
Measurement-block index Zeros
Path-operational mask Ones
Path-available mask Installed value
Channel-path ID -7 Installed value
Concurrent-sense bit Zero
Subchannel-status word Zeros
Extended-status word Zeros
Model-dependent area Model dependent
Channel-path-reset facility Reset
Address-limit-checking facility Reset and initialized
Address-limit value Zeros
Channel-subsystem-monitoring Reset and initialized
facility
Measurement-block-update mode Inactive
Device-connect-time- Inactive
measurement mode
Measurement-block origin Zeros
Measurement-block key Zeros
Pending channel-report words Cleared
Channel-subsystem timer Unchanged/validated

Explanation:

For a detailed description of the effect of I/O-system reset
on each area, see the text.

Initialized value.

Also subject to model-dependent configuration controls, if any.

Figure 17-1. Summary of I/O-System-Reset Actions

Externally Initiated Functions


I/O-system reset, which is an externally initiated
function, is described in I/O-System Reset on
page 17-10.

17-14 z/Architecture Principles of Operation


Initial Program Loading CCW prefetch:
zero (prefetching not allowed)
Initial program loading (IPL) provides a manual Initial-status-interruption control:
means for causing a program to be read from a zero (no request)
designated device and for initiating execution of Address-limit-checking control:
that program. zero (no checking)
Suppress suspended interruption:
Some models may provide additional controls and zero (suppression not allowed)
indications relating to IPL; this additional informa- Logical-path mask:
tion is specified in the System Library publication ones (all channel paths logically available)
for the model. Incorrect-length-suppression mode:
zero (ignored because format-0 CCWs are
IPL is initiated manually by setting the load-unit- specified)
address controls to a four-digit number to desig- Channel-program address:
nate an input device and by subsequently absolute address 0
activating the load-clear or load-normal key. The first CCW to be executed may be either an
actual CCW stored at absolute location 0, or the
Activating the load-clear key causes a clear reset
first CCW to be executed may be implied. In
to be performed on the configuration.
either case, the effect is as if a format-0 CCW
were executed that had this format:
Activating the load-normal key causes an initial
CPU reset to be performed on this CPU, CPU Loc.
reset to be propagated to all other CPUs in the
configuration, and a subsystem reset to be per- 1

formed on the remainder of the configuration. 4 11////////11

In the loading part of the operation, after the 8 16 31
resets have been performed, this CPU enters the
load state. This CPU does not necessarily enter In the illustration above, the CCW specifies a read
the stopped state during performance of the reset. command with the modifier bits zeros, a data
The load indicator is on while the CPU is in the address of 0, a byte count of 24, the chain-
load state. command flag one, the suppress-incorrect-length-
indication flag one, the chain-data flag zero, the
Subsequently, if conditions allow, a read operation skip flag zero, the program-controlled-interruption
is initiated from the designated input device and (PCI) flag zero, the indirect-data-address (IDA)
associated subchannel. The read operation is flag zero, and the suspend flag zero. The CCW
executed as if a START SUBCHANNEL instruc- fetched, as a result of command chaining, from
tion were executed that designated (1) the sub- location 8 or 16, as well as any subsequent CCW
channel corresponding to the device number in the IPL sequence, is interpreted the same as a
specified by the load-unit-address controls and CCW in any I/O operation, except that any PCI
(2) an ORB containing all zeros, except for a byte flags that are specified in the IPL channel program
of all ones in the logical-path mask field. The are ignored.
ORB parameters are interpreted by the channel
subsystem as follows: At the time the subchannel is made start-pending
Interruption parameter: for the IPL read, it is also enabled, which ensures
all zeros proper handling of subsequent status from the
Subchannel key: device by the channel subsystem and facilitates
all zeros subsequent I/O operations using the IPL device.
Suspend control: (Except for the subchannel used by the IPL I/O
zero (suspension not allowed) operation, each subchannel must first be made
CCW format: enabled by MODIFY SUBCHANNEL before it can
zero accept a start function or any status from the
device.)

Chapter 17. I/O Support Functions 17-15


When the IPL subchannel becomes status- The IPL device presented a status byte con-
pending for the last operation of the IPL channel taining indications other than channel end,
program, no I/O-interruption condition is gener- device end, status modifier, control-unit end,
ated. Instead, the subsystem ID is stored in abso- control unit busy, device busy, or retry status
lute locations 184-187, zeros are stored in during the IPL I/O operation. Whenever
absolute locations 188-191, and the subchannel is control-unit end, control unit busy, or device
cleared of the pending status as if TEST SUB- busy is presented in the status byte, normal
CHANNEL had been executed, but without storing path-management actions are taken.
information usually stored in an IRB. If the
A subchannel-status indication other than PCI
subchannel-status field is all zeros and the device-
was generated during the IPL I/O operation.
status field contains only the channel-end indi-
cation, with or without the device-end indication, The PSW loaded from absolute locations 0-7
the IPL I/O operation is considered to be com- has a PSW-format error of the type that is
pleted successfully. If the device-end status for recognized early.
the IPL I/O operation is provided separately after Except in the cases of no corresponding sub-
channel-end status, it causes an I/O-interruption channel for the device number entered or a
condition to be generated. When the IPL I/O machine malfunction, the subsystem ID of the IPL
operation is completed successfully, a new PSW device is stored in absolute locations 184-187;
is loaded from absolute locations 0-7. If the PSW otherwise, the contents of these locations are
loading is successful and if no malfunctions are unpredictable. In all cases of unsuccessful IPL,
recognized which preclude the completion of IPL, the contents of absolute locations 0-7 are unpre-
then the CPU leaves the load state, and the load dictable.
indicator is turned off. If the rate control is set to
the process position, the CPU enters the operating Subsequent to a successful IPL, the subchannel
state, and CPU operation proceeds under control parameters contain the normal values as if an
of the new PSW. If the rate control is set to the actual START SUBCHANNEL had been executed,
instruction-step position, the CPU enters the designating the ORB as described above.
stopped state, with the manual indicator on, after
the new PSW has been loaded. Programming Notes:

If the IPL I/O operation or the PSW loading is not 1. The information read and placed at absolute
completed successfully, the CPU remains in the locations 8-15 and 16-23 may be used as
load state, and the load indicator remains on. CCWs for reading additional information
during the IPL I/O operation: the CCW at
IPL does not complete when any of the following location 8 may specify reading additional
occurs: CCWs elsewhere in storage, and the CCW at
absolute location 16 may specify the transfer-
No subchannel contains a valid device in-channel command, causing transfer to
number equal to the IPL device number speci- these CCWs.
fied by the load-unit-address controls.
2. The status-modifier bit has its normal effect
A malfunction is detected in the CPU, main during the IPL I/O operation, causing the
storage, or channel subsystem which pre- channel subsystem to fetch and chain to the
cludes the completion of IPL. CCW whose address is 16 higher than that of
Unsolicited alert status is presented by the the current CCW. This applies also to the
device subsequent to the subchannel initial chaining that occurs after completion of
becoming start-pending for the IPL read and the read operation specified by the implicit
before the IPL subchannel becomes CCW.
subchannel-active. The IPL read operation is 3. The PSW that is loaded at the completion of
not initiated in this case. the IPL operation may be provided by the first
The IPL device appeared not operational on eight bytes of the IPL I/O operation or may be
all available channel paths to the device, or placed at absolute locations 0-7 by a subse-
there were no available channel paths. quent CCW.

17-16 z/Architecture Principles of Operation


4. Activating the load-normal key implicitly speci- control-check condition is also recognized. For a
fies the use of the first 24 bytes of main summary of the status combinations considered to
storage and the eight bytes at absolute be appropriate or inappropriate, see the System
locations 184-191. Since the remainder of the Library publications IBM Enterprise Systems
IPL program may be placed in any part of Architecture/390 ESCON I/O Interface,
storage, it is possible to preserve such areas SA22-7202, and IBM System/360 and System/370
of storage as may be helpful in debugging or I/O Interface Channel to Control Unit OEMI,
recovery. The IPL program should not be GA22-6974, and the ANSI standards document
placed in the low 512 bytes of storage since Fibre Channel - Single-Byte Command Code
that area is reserved as described in a pro- Sets-2 (FC-SB-2).
gramming note under Compatibility between
z/Architecture and ESA/390 on page 1-14.
When the load-clear key is activated, the IPL Address-Limit Checking
program starts with a cleared machine in a
The address-limit-checking facility provides a
known state, except that information on
storage-protection mechanism for I/O data
external storage remains unchanged.
accesses to storage that augments key-controlled
5. When the PSW at absolute location 0 has bit protection. When address-limit checking is used,
14 set to one, the CPU is placed in the wait absolute storage is divided into two parts by a
state after the IPL operation is completed; at program-controlled address-limit value. I/O data
that point, the load and manual indicators are accesses can then be optionally restricted to only
off, and the wait indicator is on. one of the two parts of absolute storage by the
limit mode at each subchannel. The address-limit
Reconfiguration of the I/O constraint operates at a higher priority than key-
controlled protection so that I/O data accesses to
System the protected part of main storage are prevented
even when the subchannel key is zero or matches
Reconfiguration of the I/O system is handled in a
the key in storage.
model-dependent manner. For example, changes
may be made under program control, by using the The address-limit-checking facility consists of the
model-dependent DIAGNOSE instruction; or man- following elements:
ually, by using system-operator configuration con-
trols; or by using a combination of DIAGNOSE The I/O instruction SET ADDRESS LIMIT.
and manual controls. The method used depends The limit mode at each subchannel.
on the system model. The System Library publi-
cation for the system model specifies how the The address-limit-checking-control bit in the
changes are made. The partitioning of channel ORB.
paths because of reconfiguration is indicated by
the setting of the PAM bits in the SCHIB stored Execution of SET ADDRESS LIMIT passes the
when STORE SUBCHANNEL is executed (see contents of general register 1 to the address-limit-
Path-Available Mask (PAM) on page 15-7). checking facility to be used as the address-limit
value. Bits 32 and 48-63 of general register 1
must contain zeros to designate a valid absolute
address on a 64K-byte boundary; otherwise, an
Status Verification
operand exception is recognized, and execution of
The status-verification facility provides the channel the instruction is suppressed.
subsystem with a means of indicating that a
device has presented a device-status byte that The limit mode at each subchannel indicates the
has valid CBC but that contained a combination of manner in which address-limit checking is to be
bits that was inappropriate when the status byte performed. The limit mode is set by placing the
was presented to the channel subsystem. The desired value in bits 9-10 of word 1 in the SCHIB
indication provided to the program in the ESW by and executing MODIFY SUBCHANNEL. The set-
the channel subsystem is called device-status tings of these bits in the SCHIB have the following
check. When the channel subsystem recognizes meanings:
a device-status-check condition, an interface-

Chapter 17. I/O Support Functions 17-17


00 No limit checking (initialized value). subchannel number which identifies the particular
device causing the I/O-interruption condition.
01 Data address must be equal to or greater
When a device that is not associated with a sub-
than the current address limit.
channel attempts to communicate with the channel
10 Data address must be less than the current subsystem, the configuration-alert facility gener-
address limit. ates a channel report in which the unassociated
11 Reserved. This combination of limit-mode device is identified. For a description of the
bits causes an operand exception to be means by which the program is notified of a
recognized when MODIFY SUBCHANNEL is pending channel report and how the information in
executed. the channel report is retrieved, see Channel
Report on page 17-19.
The address-limit-checking-control bit in the ORB
(bit 11 of word 1) specifies whether address-limit
checking is to be used for the start function that is Incorrect-Length-Indication
accepted when execution of START SUB- Suppression
CHANNEL causes the contents of the ORB to be
The incorrect-length-indication-suppression facility
passed to the subchannel. If the address-limit-
allows the indication of incorrect length for imme-
checking-control bit is zero when the contents of
diate operations to be suppressed in the same
the ORB are passed, address-limit checking is not
manner when using format-1 CCWs as when
specified for that start function. If the bit is one,
using format-0 CCWs. When the incorrect-length-
address-limit checking is specified and is under
indication-suppression facility is installed, bit 24,
the control of the current address limit and the
word 1 of the ORB specifies whether the channel
current setting of the limit mode at the sub-
subsystem is to suppress the indication of incor-
channel.
rect length for an immediate operation when
format-1 CCWs are used or whether this indication
During the performance of the start function, an
will remain under the control of the SLI flag of the
attempt to access an absolute storage location for
current CCW (as is the case for CCWs not exe-
data that is protected by an address limit (either
cuted as immediate operations). This bit provides
high or low) is recognized as an address-limit vio-
the capability for a channel program to operate in
lation, and the access is not allowed. A program-
the same manner regarding the indication of incor-
check condition is recognized, and
rect length regardless of whether format-0 or
channel-program execution is terminated, just as
format-1 CCWs are used.
when an attempt is made to access an invalid
address.
Concurrent Sense
Configuration Alert The concurrent-sense facility provides a mech-
anism whereby sense information that is provided
The configuration-alert facility provides a detection
by the device can be presented by the channel
mechanism for devices that are not associated
subsystem to the program in the same IRB that
with a subchannel in the configuration. The
contains the unit-check indication when the sub-
configuration-alert facility notifies the program by
channel is in concurrent-sense mode. Concurrent-
means of a channel report that a device which is
sense mode is made active at a subchannel for
not associated with a subchannel has attempted
which the concurrent-sense facility is applicable
to communicate with the program.
when MODIFY SUBCHANNEL is executed and bit
Each device must be assigned to a subchannel 31 of word 6 of the SCHIB operand is set to one.
during an installation procedure; otherwise, the The concurrent-sense facility is applicable to sub-
channel subsystem is unable to generate an channels that are associated with channel paths
I/O-interruption condition for the device. This is by which the channel subsystem can attempt to
because the I/O-interruption code contains the retrieve sense information from the device without
requiring program intervention.

17-18 z/Architecture Principles of Operation


Channel-Subsystem Damage on
Channel-Subsystem Recovery page 11-18.)
The channel subsystem provides a recovery 5. Information is provided in the MCIC describing
mechanism for extensive detection of malfunctions a malfunction affecting the continued opera-
and other conditions to ensure the integrity of tional integrity of a process or of the system.
channel-subsystem operation and to achieve auto- (See Instruction-Processing Damage on
matic recovery of some malfunctions. Various page 11-16 and System Damage on
reporting methods are used by the channel- page 11-16.)
subsystem recovery mechanism to assist in
program recovery, maintenance, and repair. Channel reports are used to report malfunctions or
other conditions only when the use of the
The method used to report a particular malfunction I/O-interruption facility is not appropriate and in
or other condition is dependent upon the severity preference to reporting channel-subsystem
of the malfunction or other condition and the damage, instruction-processing damage, or
degree to which the malfunction or other condition system damage.
can be isolated. A malfunction or other condition
in the channel subsystem may be indicated to the Channel Report
program by information being stored by one of the
following methods: When a malfunction or other condition affecting
1. Information is provided in the IRB describing a elements of the channel subsystem has been
condition that has been recognized by either recognized, a channel report is generated. Exe-
the channel subsystem or device that must be cution of recovery actions by the program or by
brought to the attention of the program. Gen- external means may be required to gain recovery
erally, this information is made available to the from the error condition. The channel report indi-
program by the execution of TEST SUB- cates the source of the channel report and the
CHANNEL, which is usually executed in recovery state to the extent necessary for deter-
response to the occurrence of an I/O inter- mining the proper recovery action. A channel
ruption. (See Interruption Action on report consists of one or more channel-report
page 16-5, for a definition of the information words (CRWs) that have been generated from an
stored, as well as Chapter 6, Interruptions analysis of the malfunction or other condition. The
on page 6-1.) inclusion of two or more CRWs within a channel
report is indicated by the chaining flag being
2. Information is provided in a channel report stored as one in all of the CRWs of the channel
describing a machine malfunction affecting the report except the last one in the chain.
identified facility within the channel subsystem.
This information is made available to the When a channel report is made pending by the
program by the execution of STORE channel subsystem for retrieval and analysis by
CHANNEL REPORT WORD, which is usually the program (by means of the execution of
executed in response to the occurrence of a STORE CHANNEL REPORT WORD), a malfunc-
machine-check interruption. (See Chapter 11, tion or other condition that affects the normal
Machine-Check Handling on page 11-1 for operation of one or more of the channel-
a description of the machine-check- subsystem facilities has been recognized. If the
interruption mechanism and the contents of channel report that is made pending is an initial
the machine-check-interruption code.) channel report, a machine-check-interruption con-
3. Information is provided in a channel report dition is generated that indicates one or more
describing a malfunction or other condition CRWs are pending at the channel subsystem. A
affecting a collection of channel-subsystem channel report is initial either if it is the first
facilities. This information is made available channel report to be generated after the most
to the program as indicated in item 2. recent I/O-system reset or if no previously gener-
ated reports are pending and the last STORE
4. Information is provided in the machine-check- CHANNEL REPORT WORD instruction that was
interruption code (MCIC) describing a mal- executed resulted in the setting of condition code
function affecting the continued operational 1, indicating that no channel report was pending.
integrity of the channel subsystem. (See

Chapter 17. I/O Support Functions 17-19


When the machine-check interruption occurs and is the second CRW of the same chain, and not a
bit 9 of the machine-check-interruption code CRW that is part of another channel report.
(channel report pending) is one, a channel report
is pending. If the program clears the first CRW of Channel reports are not presented to the program
a channel report before the associated machine- in any special order, except for channel reports
check interruption has occurred, some models whose first or only CRW indicates the same
may reset the machine-check-interruption condi- reporting-source code and the same reporting-
tion, and the associated machine-check inter- source ID. These channel reports are presented
ruption does not occur. A machine-check to the program in the same order that they are
interruption indicating that a channel report is generated by the channel subsystem, but they are
pending occurs only if the machine-check mask not necessarily presented consecutively. For
(PSW bit 13) and the channel-report-pending sub- example, suppose the channel subsystem gener-
class mask (bit 3 of control register 14) are both ates channel reports A, B, and C, in that order.
ones. The first CRW of channel reports B and C indi-
cates the same reporting-source code and the
If the channel report that is made pending is not same reporting-source ID. Channel report B is
an initial channel report, a machine-check- presented to the program before channel report C
interruption condition is not generated. The CRW is presented, but channel report A may be pre-
that is presented to the program in response to sented after channel report B and before channel
the first STORE CHANNEL REPORT WORD report C.
instruction that is executed after a machine-check
interruption may or may not be part of the initial Programming Notes:
channel report that caused the machine-check 1. The information that is provided in a single
condition to be generated. A pending channel- CRW may be made obsolete by another CRW
report word is cleared by any CPU executing that is subsequently generated for the same
STORE CHANNEL REPORT WORD, regardless channel-subsystem facility. Therefore, the
of whether a machine-check interruption has information that is provided in one channel
occurred in any CPU. If a CRW is not pending report should be interpreted in light of the
and STORE CHANNEL REPORT WORD is exe- information provided by all of the channel
cuted, condition code 1 is set, and zeros are reports that are pending at a given instant.
stored at the location designated by the second-
operand address. During execution of STORE 2. A machine-check-interruption condition is not
CHANNEL REPORT WORD as a result of always generated when a channel report is
receiving a machine-check interruption, condition made pending. The conditions that result in a
code 1 may be set, and zeros may be stored machine-check-interruption condition being
because (1) the related channel report has been generated are described earlier in this section.
cleared by another CPU or (2) a malfunction 3. After a machine-check interruption has
occurred during the generation of a channel occurred with bit 9 of the machine-check-
report. In the latter case, if, during a subsequent interruption code set to one, STORE
attempt, a valid channel report can be made CHANNEL REPORT WORD should be exe-
pending, an additional machine-check-interruption cuted repeatedly until all of the pending
condition is generated. channel reports have been cleared and condi-
tion code 1 has been set.
When a channel report consists of multiple
chained CRWs, they are presented to the program 4. A CRW-overflow condition can occur if the
in the same order that they are placed in the chain program does not execute successive STORE
by the channel subsystem as the result of consec- CHANNEL REPORT WORD instructions in a
utive executions of STORE CHANNEL REPORT timely manner after the machine-check inter-
WORD. If, for example, the first CRW of a chain ruption occurs.
is presented to the program as a result of exe- 5. The number of CRWs that can be pending at
cuting STORE CHANNEL REPORT WORD, then the same time is model-dependent. During
the CRW that is presented as a result of the next the existence of an overflow condition, CRWs
execution of STORE CHANNEL REPORT WORD that would have otherwise been made

17-20 z/Architecture Principles of Operation


pending are lost and are never presented to Reporting-Source Code (RSC): Bits 4-7 specify
the program. the channel-subsystem facility that is associated
with the channel report. Some facilities are further
Channel-Report Word identified in the reporting-source-identification field
(see below). The following combinations of bits
The channel-report word (CRW) provides informa- identify the facilities:
tion to the program that can be used to facilitate
the recovery of an I/O operation, a device, or
Bits
some element of the channel subsystem, such as
4 5 6 7 Designation
0 0 1 0 Monitoring Facility
a channel path or subchannel. The format of the
0 0 1 1 Subchannel
CRW is as follows. Bit 0 is reserved and is
0 1 0 0 Channel Path
always stored as zero. Bit 9 is reserved.
1 0 0 1 Configuration-alert facility
1 0 1 1 Channel Subsystem
SRCRSC A ERC Reporting-source ID
All other bit combinations in the reporting-source-
1 2 3 4 8 9 1 16 31
code field are reserved.

Ancillary Report (A): Bit 8, when one, indicates


Solicited CRW (S): Bit 1, when one, indicates a that a malfunction of a system component has
solicited CRW. A CRW is considered by the occurred which has been recognized previously,
channel subsystem to be solicited if it is made or which has affected the activity of multiple
pending as the direct result of some action that is channel-subsystem facilities. When the malfunc-
taken by the program. When bit 1 is zero, the tion affects the activity of multiple channel-
CRW is unsolicited and has been made pending subsystem facilities, an ancillary-report condition is
as the result of an action taken by the channel recognized for all of the effected facilities except
subsystem that is independent of the program. one. This bit, when zero, indicates that this mal-
function of a system component has not been pre-
Overflow (R): Bit 2, when one, indicates that a viously recognized. This bit is meaningful for all
CRW-overflow condition has been recognized channel reports.
since this CRW became pending and that one or
more CRWs have been lost. This bit is one in the Depending on the model, recognition of an
CRW that has most recently been set pending ancillary-report condition may not be provided, or
when the overflow condition is recognized. When it may not be provided for all system malfunctions
bit 2 is zero, a CRW-overflow condition has not that effect channel-subsystem facilities. When
been recognized. ancillary-report recognition is not provided, bit 8 is
set to zero.
A CRW that is part of a channel report is not
made pending, even though the overflow condition Error-Recovery Code (ERC): Bits 10-15, when
does not exist, if an overflow condition prevented zero, indicate that the channel subsystem has
a previous CRW of that report from being made error information regarding the channel-subsystem
pending. facility identified in the reporting-source code, and
that the program can now request that information.
Chaining (C): Bit 3, when one, and when the Otherwise, bits 10-15 contain the error-recovery
overflow flag is zero, indicates chaining of associ- code which defines the recovery state of the
ated CRWs. Chaining of CRWs is indicated channel-subsystem facility identified in the
whenever a malfunction or other condition is reporting-source code. This field, when used in
described by more than a single CRW. The conjunction with the reporting-source code, can be
chaining flag is zero if the channel report is used by the program to determine whether the
described by a single CRW or if the CRW is the identified facility has already been recovered and
last CRW of a channel report. is available for use or whether recovery actions
are still required. The following is a description of
The chaining flag is not meaningful if the overflow the error-recovery codes:
bit, bit 2, is one.

Chapter 17. I/O Support Functions 17-21


Bits Terminal: The identified facility is in a state such
10 11 12 13 14 15 State that an operation which was in progress can
0 0 0 0 0 0 Event-information pending neither be completed nor terminated in the normal
0 0 0 0 0 1 Available manner.
0 0 0 0 1 0 Initialized
0 0 0 0 1 1 Temporary error Permanent Error with Facility Not Initialized: The
0 0 0 1 0 0 Installed parameters initial- identified facility is in a state of malfunction, and
ized the channel subsystem has not caused a reset
0 0 0 1 0 1 Terminal function to be performed for that facility.
0 0 0 1 1 0 Permanent error with facility
not initialized Permanent Error with Facility Initialized: The
0 0 0 1 1 1 Permanent error with facility identified facility is in a state of malfunction, and
initialized the channel subsystem has caused or may have
0 0 1 0 0 0 Installed parameters modi- caused a reset function to be performed for that
fied facility.

All other bit combinations in the error-recovery- Installed Parameters Modified: One or more
code field are reserved. parameters of the specified facility have been
changed.
The specific meaning of each error-recovery code
depends on the particular reporting-source code Reporting-Source ID (RSID): Bit 16-31 contain
that accompanies it in a CRW. The error-recovery the reporting-source ID which may, depending
codes are defined as follows: upon the condition that caused the channel report
and the reporting-source code, either further iden-
Event-Information Pending: Event information for tify the affected channel-subsystem facility or
the identified facility is available for retrieval by the provide additional information describing the con-
program. This CRW does not indicate the state of dition that caused the channel report. The RSID
the identified facility. field has the following format as a function of the
bit settings of the reporting-source code.
Available: The identified facility is in the same
state that the program would expect if the CRW Reporting-Source
had not been generated. Code Reporting-Source ID
4 5 6 7 Bits 16-31
Initialized: The identified facility is in the same 0 0 1 0 0000 0000 0000 0000
state that existed immediately following the 0 0 1 1 xxxx xxxx xxxx xxxx
I/O-system reset that was part of the most recent 0 1 0 0 0000 0000 yyyy yyyy
system IPL. 1 0 0 1 0000 0000 yyyy yyyy
1 0 1 1 0000 0000 0000 0000
Temporary: The identified facility is not operating Note:
in a normal manner or has recognized the occur-
xxxx xxxx xxxx xxxx Subchannel number
rence of an abnormal event. It is expected that
yyyy yyyy Channel-path ID
subsequent actions either will restore the facility to
(CHPID)
normal operation or will record the appropriate
information describing the abnormal event.

Installed Parameters Initialized: This state is the


Channel Subsystem I/O-Priority
same as the initialized state, except that one or Facility
more parameters that are associated with the The channel subsystem I/O-priority facility pro-
facility and that are not modifiable by the program vides a means by which the program can estab-
may have been changed. lish a priority relationship, at the channel
subsystem, among the subchannels that are
placed into the start-pending state when START
SUBCHANNEL is executed and condition code 0
is indicated.

17-22 z/Architecture Principles of Operation


The program assigns the desired channel- channel subsystem priority selection and fairness
subsystem priority by specifying the desired pri- selection algorithms are always applied to I/O sub-
ority number in the ORB extension when START channels that are either start-pending or resume-
SUBCHANNEL is executed. pending; however, some models may also apply
both algorithms to subchannels that are either
The channel-subsystem priority number specified clear-pending or halt-pending as well. See the
in the ORB is used by the channel subsystem to model's appropriate System-Library publication for
determine the order by which start-pending and a description of the priority and fairness selection
resume-pending subchannels are selected when it algorithms that it provides and whether these algo-
attempts to initiate a start-function or a resume- rithms are also applied to clear-pending or halt-
function. See the section "Start and Resume pending subchannels.
Function" in Chapter 15 for details regarding these
functions. In general, I/O subchannels that are in Number of Channel Subsystem Priority
the start-pending state or resume-pending state Levels
and which have a higher priority number are Depending on the model, fewer than 256 priority
selected for start-function or resume-function initi- levels may be provided by the channel subsystem.
ation by the channel subsystem before start- Each priority level that the model provides is des-
pending or resume-pending subchannels which ignated with an 8-bit unsigned binary integer. The
have a lower priority number. The specific priority lowest provided channel subsystem priority level is
selection algorithm used by the channel sub- designated by the integer 0 and each succeeding
system for this purpose depends on the model. higher priority level is designated by the next
Additionally, the channel subsystem also applies a higher sequential integer. For example, if the
fairness algorithm in conjunction with the priority model provides 16 priority levels, than they are
selection algorithm when selecting I/O subchan- numbered 0-15 respectively from the lowest pri-
nels. The specific fairness selection algorithm ority level to the highest priority level provided.
also depends on the model. For all models, the

Chapter 17. I/O Support Functions 17-23


17-24 z/Architecture Principles of Operation
Chapter 18. Hexadecimal-Floating-Point Instructions
HFP Arithmetic . . . . . . . . . . . . . . . . . . 18-1 LOAD AND TEST . . . . . . . . . . . . . 18-14
HFP Number Representation . . . . . . . . 18-1 LOAD COMPLEMENT . . . . . . . . . . . 18-14
Normalization . . . . . . . . . . . . . . . . . 18-3 LOAD FP INTEGER . . . . . . . . . . . . 18-15
HFP Data Format . . . . . . . . . . . . . . 18-3 LOAD LENGTHENED . . . . . . . . . . . 18-15
Instructions . . . . . . . . . . . . . . . . . . . . 18-4 LOAD NEGATIVE . . . . . . . . . . . . . 18-16
ADD NORMALIZED . . . . . . . . . . . . . 18-8 LOAD POSITIVE . . . . . . . . . . . . . . 18-16
ADD UNNORMALIZED . . . . . . . . . . . 18-9 LOAD ROUNDED . . . . . . . . . . . . . 18-17
COMPARE . . . . . . . . . . . . . . . . . 18-10 MULTIPLY . . . . . . . . . . . . . . . . . 18-18
CONVERT FROM FIXED . . . . . . . . . 18-11 SQUARE ROOT . . . . . . . . . . . . . . 18-19
CONVERT TO FIXED . . . . . . . . . . . 18-11 SUBTRACT NORMALIZED . . . . . . . . 18-21
DIVIDE . . . . . . . . . . . . . . . . . . . 18-12 SUBTRACT UNNORMALIZED . . . . . . 18-21
HALVE . . . . . . . . . . . . . . . . . . . . 18-13

too large by 128, except that a zero characteristic


HFP Arithmetic is produced when a true zero is forced.

HFP Number Representation A true zero is an HFP number with a zero charac-
teristic and zero fraction. A true zero may arise
A hexadecimal-floating-point (HFP) number con- as the normal result of an arithmetic operation
sists of a sign bit, a hexadecimal fraction, and an because of the particular magnitude of the oper-
unsigned seven-bit binary integer called the char- ands. For HFP operations, the result is forced to
acteristic. The characteristic represents a signed be a positive true zero when:
exponent and is obtained by adding 64 to the 1. An HFP exponent underflow occurs and the
exponent value (excess-64 notation). The range HFP-exponent-underflow mask bit in the PSW
of the characteristic is 0 to 127, which corre- is zero.
sponds to an exponent range of 64 to +63. The
magnitude of an HFP number is the product of its 2. The result fraction of an addition or sub-
fraction and the number 16 raised to the power of traction operation is zero and the
the exponent that is represented by its character- HFP-significance mask bit in the PSW is zero.
istic. The number is positive or negative 3. The operand of the CONVERT FROM FIXED
depending on whether the sign bit is zero or one, instruction is zero.
respectively.
4. The dividend in the DIVIDE instruction has a
The fraction of an HFP number is treated as a zero fraction.
hexadecimal number because it is considered to 5. The operand of the HALVE, LOAD FP
be multiplied by a number which is a power of 16. INTEGER, or SQUARE ROOT instruction has
The name, fraction, indicates that the radix point is a zero fraction.
assumed to be immediately to the left of the left-
most fraction digit. 6. One or both operands of a multiplication oper-
ation has a zero fraction.
When an HFP operation would cause the result Item 2, above, applies to normalized and unnor-
exponent to exceed 63, the characteristic wraps malized instructions.
around from 127 to 0, and an
HFP-exponent-overflow condition exists. The When a program interruption for HFP exponent
result characteristic is then too small by 128. underflow occurs, a true zero is not forced;
When an operation would cause the exponent to instead, the fraction and sign remain correct, and
be less than 64, the characteristic wraps around the characteristic is too large by 128. When a
from 0 to 127, and an HFP-exponent-underflow program interruption for HFP significance occurs,
condition exists. The result characteristic is then

Copyright IBM Corp. 1990, 2000 18-1


Zero Result Zero Result
Forced to True Zero Made Positive
Nonzero
Result Short and Short and
Instruction Normalized Long Extended Long Extended
ADD NORMALIZED Yes Y/N Y/N Yes Yes
ADD UNNORMALIZED No Y/N - Yes -
CONVERT BFP TO Yes Yes - No -
HFP
CONVERT FROM Yes Yes Yes Yes Yes
FIXED
DIVIDE Yes Yes Yes Yes Yes
HALVE Yes Yes - Yes -
LOAD No No No No No
LOAD AND TEST No No Yes No No
LOAD COMPLEMENT No No Yes No No
LOAD FP INTEGER Yes Yes Yes Yes Yes
LOAD LENGTHENED No No Yes No No
LOAD NEGATIVE No No Yes No No
LOAD POSITIVE No No Yes Yes Yes
LOAD ROUNDED No No - No -
LOAD ZERO - Yes Yes Yes Yes
MULTIPLY Yes Yes Yes Yes Yes
SQUARE ROOT Yes Yes Yes Yes Yes
STORE No No - No -
SUBTRACT NORMAL- Yes Y/N Y/N Yes Yes
IZED
SUBTRACT UNNOR- No Y/N - Yes -
MALIZED
Explanation:
- Not applicable.
Floating-point-support instruction.
Y/N When the HFP-significance mask bit (PSW bit 23) is zero, a true zero is forced.
When the HFP-significance mask bit is one, the characteristic remains unchanged,
and a program interruption for HFP significance occurs.

Figure 18-1. Normalization and Zero Handling for Instructions with HFP Results

the fraction remains zero, the sign is positive, and FIXED, or the result of LOAD FP INTEGER with a
the characteristic remains correct. zero fraction is positive. The sign for a zero frac-
tion resulting from other HFP operations is estab-
The sign of a sum, difference, product, quotient,
square root, the result of CONVERT FROM

18-2 z/Architecture Principles of Operation


lished from the operand sign, the same as for one. This adjustment is made for both normalized
nonzero fractions. and unnormalized operations.

Figure 18-1 on page 18-2 summarizes, for all


Normalization instructions producing HFP results, the handling of
zero results and whether normalization occurs for
A quantity can be represented with the greatest
nonzero results.
precision by an HFP number of a given fraction
length when that number is normalized. A normal- Programming Note: Up to three leftmost bits of
ized HFP number has a nonzero leftmost the fraction of a normalized number may be zeros,
hexadecimal fraction digit. If one or more leftmost since the nonzero test applies to the entire left-
fraction digits are zeros, the number is said to be most hexadecimal digit.
unnormalized.

Unnormalized numbers are normalized by shifting


HFP Data Format
the fraction left, one digit at a time, until the left-
HFP numbers have a 32-bit (short) format, a
most hexadecimal digit is nonzero and reducing
64-bit (long) format, or a 128-bit (extended)
the characteristic by the number of hexadecimal
format. Numbers in the short and long formats
digits shifted. A number with a zero fraction
may be designated as operands both in storage
cannot be normalized; either its characteristic
and in the floating-point registers, whereas oper-
remains unchanged or its characteristic is made
ands having the extended format can be desig-
zero when the result is forced to be a true zero.
nated only in the floating-point registers.
Addition and subtraction with extended operands,
In all formats, the first bit (bit 0) is the sign bit (S).
as well as the MULTIPLY, DIVIDE, CONVERT
The next seven bits are the characteristic. In the
FROM FIXED, HALVE, LOAD FP INTEGER, and
short and long formats, the remaining bits consti-
SQUARE ROOT operations, are performed only
tute the fraction, which consists of six or 14
with normalization. Addition and subtraction with
hexadecimal digits, respectively.
short or long operands may be specified as either
normalized or unnormalized. For all other oper- Short HFP Number
ations, the result is produced without normaliza- /
tion. SCharacteristic 6-Digit Fraction
/
With unnormalized operations, leftmost zeros in 1 8 31
the result fraction are not eliminated. The result
may or may not be in normalized form, depending Long HFP Number
upon the original operands. /
SCharacteristic 14-Digit Fraction
In both normalized and unnormalized operations, /
the initial operands need not be in normalized 1 8 63
form. The operands for multiply, divide, and
square-root operations are normalized before the Extended HFP Number
arithmetic process. For other normalized oper- High-Order Part
ations, normalization takes place when the inter- /
High-Order Leftmost 14 Digits
mediate arithmetic result is changed to the final SCharacteristicof 28-Digit Fraction
result. /
1 8 63
When the intermediate result of addition, sub-
traction, or rounding causes the fraction to over- Low-Order Part
flow, the fraction is shifted right by one /
Low-Order Rightmost 14 Digits
hexadecimal-digit position, and the value one is
SCharacteristicof 28-Digit Fraction
supplied to the vacated leftmost digit position. /
The fraction is then truncated to the final result 64 72 127
length, while the characteristic is increased by

Chapter 18. Hexadecimal-Floating-Point Instructions 18-3


An extended HFP number has a 28-digit fraction traction, and comparison operations and in the left
and consists of two long HFP numbers that are shift that occurs during normalization.
called the high-order and low-order parts. The
high-order part may be any long HFP number. The entire set of HFP operations with normalized
The fraction of the high-order part contains the results is available for short, long, and extended
leftmost 14 hexadecimal digits of the 28-digit frac- operands in register-register versions; and for
tion. The characteristic and sign of the high-order short and long operands in register-storage ver-
part are the characteristic and sign of the sions. Most instructions generate a result that has
extended HFP number. If the high-order part is the same format as the source operands, except
normalized, the extended number is considered that there are multiplication operations which can
normalized. The fraction of the low-order part generate a long product from short operands or an
contains the rightmost 14 digits of the 28-digit extended product from long operands. Other
fraction. The sign and characteristic of the low- exceptions are instructions which convert oper-
order part of an extended operand are ignored. ands from one floating-point format to another or
between floating-point and fixed-point (binary-
When a result is generated in the extended format integer) formats.
and placed in a register pair, the sign of the low-
order part is made the same as that of the high- Programming Notes:
order part, and, unless the result is a true zero, 1. In the absence of an HFP exponent overflow
the low-order characteristic is made 14 less than or HFP exponent underflow, the long HFP
the high-order characteristic. When the sub- number constituting the low-order part of an
traction of 14 would cause the low-order charac- extended result correctly expresses the value
teristic to become less than zero, the of the low-order part of the extended result
characteristic is made 128 greater than its correct when the characteristic of the high-order part
value. (Thus, the subtraction is performed modulo is 14 or higher. This applies also when the
128.) HFP exponent underflow is indicated only result is a true zero. When the high-order
when the high-order characteristic underflows. characteristic is less than 14 but the number
is not a true zero, the low-order part, when
When an extended result is made a true zero,
considered as a long HFP number, does not
both the high-order and low-order parts are made
express the correct characteristic value.
a true zero.
2. The entire fraction of an extended result par-
The range covered by the magnitude (M) of a nor- ticipates in normalization. The low-order part
malized HFP number depends on the format. alone may or may not appear to be a normal-
ized long HFP number, depending on whether
In the short format: the 15th digit of the normalized 28-digit frac-
16-65 M (1 - 16-6) x 1663 tion is nonzero or zero.

In the long format:


16-65 M (1 - 16-14) x 1663 Instructions
In the extended format: The HFP instructions and their mnemonics and
operation codes are listed in Figure 18-2 on
16-65 M (1 - 16-28) x 1663
page 18-6. The figure indicates, in the column
In all formats, approximately: labeled Characteristics, the instruction format,
5.4 x 1-79 M 7.2 x 175 when the condition code is set, the instruction
fields that designate access registers, and the
Although the final result of an HFP operation has exceptional conditions in operand designations,
six hexadecimal fraction digits in the short format, data, or results that cause a program interruption.
14 fraction digits in the long format, and 28 frac-
tion digits in the extended format, intermediate All HFP instructions are subject to the
results have one additional hexadecimal digit on AFP-register-control bit, bit 45 of control register 0.
the right. This digit is called the guard digit. The The AFP-register-control bit must be one when an
guard digit may increase the precision of the final AFP register is specified as an operand location;
result because it participates in addition, sub-

18-4 z/Architecture Principles of Operation


otherwise, an AFP-register data exception, DXC 1, E Short normalized
is recognized. U Short unnormalized
W Long unnormalized
Mnemonics for the HFP instructions have an R as X Extended normalized
the last letter when the instruction is in the RR,
Note: In the detailed descriptions of the indi-
RRE, or RRF format. Certain letters are used for
vidual instructions, the mnemonic and the sym-
HFP instructions to represent operand-format
bolic operand designation for the assembler
length and normalization, as follows:
language are shown with each instruction. For a
F Thirty-two-bit fixed point register-to-register operation using COMPARE
G Sixty-four-bit fixed point (short), for example, CER is the mnemonic and
D Long normalized R,R the operand designation.

Chapter 18. Hexadecimal-Floating-Point Instructions 18-5



Mne- Op
Name monic Characteristics Code

ADD NORMALIZED (extended HFP) AXR RR C SPDa EU EO LS 36


ADD NORMALIZED (long HFP) ADR RR C Da EU EO LS 2A
ADD NORMALIZED (long HFP) AD RX C A Da EU EO LS B6A
ADD NORMALIZED (short HFP) AER RR C Da EU EO LS 3A
ADD NORMALIZED (short HFP) AE RX C A Da EU EO LS B7A

ADD UNNORMALIZED (long HFP) AWR RR C Da EO LS 2E


ADD UNNORMALIZED (long HFP) AW RX C A Da EO LS B6E
ADD UNNORMALIZED (short HFP) AUR RR C Da EO LS 3E
ADD UNNORMALIZED (short HFP) AU RX C A Da EO LS B7E
COMPARE (extended HFP) CXR RRE C SPDa B369

COMPARE (long HFP) CDR RR C Da 29


COMPARE (long HFP) CD RX C A Da B69
COMPARE (short HFP) CER RR C Da 39
COMPARE (short HFP) CE RX C A Da B79
CONVERT FROM FIXED (32 to ext. HFP) CXFR RRE SPDa B3B6

CONVERT FROM FIXED (32 to long HFP) CDFR RRE Da B3B5


CONVERT FROM FIXED (32 to short HFP)CEFR RRE Da B3B4
CONVERT FROM FIXED (64 to ext. HFP) CXGR RRE N SPDa B3C6
CONVERT FROM FIXED (64 to long HFP) CDGR RRE N Da B3C5
CONVERT FROM FIXED (64 to short HFP)CEGR RRE N Da B3C4

CONVERT TO FIXED (ext. HFP to 32) CFXR RRF C SPDa B3BA


CONVERT TO FIXED (long HFP to 32) CFDR RRF C SPDa B3B9
CONVERT TO FIXED (short HFP to 32) CFER RRF C SPDa B3B8
CONVERT TO FIXED (ext. HFP to 64) CGXR RRF C N SPDa B3CA
CONVERT TO FIXED (long HFP to 64) CGDR RRF C N SPDa B3C9

CONVERT TO FIXED (short HFP to 64) CGER RRF C N SPDa B3C8


DIVIDE (extended HFP) DXR RRE SPDa EU EO FK B22D
DIVIDE (long HFP) DDR RR Da EU EO FK 2D
DIVIDE (long HFP) DD RX A Da EU EO FK B6D
DIVIDE (short HFP) DER RR Da EU EO FK 3D

DIVIDE (short HFP) DE RX A Da EU EO FK B7D


HALVE (long HFP) HDR RR Da EU 24
HALVE (short HFP) HER RR Da EU 34
LOAD AND TEST (extended HFP) LTXR RRE C SPDa B362
LOAD AND TEST (long HFP) LTDR RR C Da 22

LOAD AND TEST (short HFP) LTER RR C Da 32


LOAD COMPLEMENT (extended HFP) LCXR RRE C SPDa B363
LOAD COMPLEMENT (long HFP) LCDR RR C Da 23
LOAD COMPLEMENT (short HFP) LCER RR C Da 33
LOAD FP INTEGER (extended HFP) FIXR RRE SPDa B367

Figure 18-2 (Part 1 of 3). Summary of HFP Instructions

18-6 z/Architecture Principles of Operation



Mne- Op
Name monic Characteristics Code

LOAD FP INTEGER (long HFP) FIDR RRE Da B37F


LOAD FP INTEGER (short HFP) FIER RRE Da B377
LOAD LENGTHENED (long to ext. HFP) LXDR RRE SPDa B325
LOAD LENGTHENED (long to ext. HFP) LXD RXE A SPDa BED25
LOAD LENGTHENED (short to ext. HFP) LXER RRE SPDa B326

LOAD LENGTHENED (short to ext. HFP) LXE RXE A SPDa BED26


LOAD LENGTHENED (short to long HFP) LDER RRE Da B324
LOAD LENGTHENED (short to long HFP) LDE RXE A Da BED24
LOAD NEGATIVE (extended HFP) LNXR RRE C SPDa B361
LOAD NEGATIVE (long HFP) LNDR RR C Da 21

LOAD NEGATIVE (short HFP) LNER RR C Da 31


LOAD POSITIVE (extended HFP) LPXR RRE C SPDa B36
LOAD POSITIVE (long HFP) LPDR RR C Da 2
LOAD POSITIVE (short HFP) LPER RR C Da 3
LOAD ROUNDED (extended to long HFP) LDXR RR SPDa EO 25

LOAD ROUNDED (extended to long HFP) LRDR RR Da EO 25


LOAD ROUNDED (extended to short HFP)LEXR RRE SPDa EO B366
LOAD ROUNDED (long to short HFP) LEDR RR Da EO 35
LOAD ROUNDED (long to short HFP) LRER RR Da EO 35
MULTIPLY (extended HFP) MXR RR SPDa EU EO 26

MULTIPLY (long HFP) MDR RR Da EU EO 2C


MULTIPLY (long HFP) MD RX A Da EU EO B6C
MULTIPLY (long to extended HFP) MXDR RR SPDa EU EO 27
MULTIPLY (long to extended HFP) MXD RX A SPDa EU EO B67
MULTIPLY (short HFP) MEER RRE Da EU EO B337

MULTIPLY (short HFP) MEE RXE A Da EU EO BED37


MULTIPLY (short to long HFP) MDER RR Da EU EO 3C
MULTIPLY (short to long HFP) MER RR Da EU EO 3C
MULTIPLY (short to long HFP) MDE RX A Da EU EO B7C
MULTIPLY (short to long HFP) ME RX A Da EU EO B7C

SQUARE ROOT (extended HFP) SQXR RRE SPDa SQ B336


SQUARE ROOT (long HFP) SQDR RRE Da SQ B244
SQUARE ROOT (long HFP) SQD RXE A Da SQ BED35
SQUARE ROOT (short HFP) SQER RRE Da SQ B245
SQUARE ROOT (short HFP) SQE RXE A Da SQ BED34

SUBTRACT NORMALIZED (extended HFP) SXR RR C SPDa EU EO LS 37


SUBTRACT NORMALIZED (long HFP) SDR RR C Da EU EO LS 2B
SUBTRACT NORMALIZED (long HFP) SD RX C A Da EU EO LS B6B
SUBTRACT NORMALIZED (short HFP) SER RR C Da EU EO LS 3B
SUBTRACT NORMALIZED (short HFP) SE RX C A Da EU EO LS B7B

SUBTRACT UNNORMALIZED (long HFP) SWR RR C Da EO LS 2F


SUBTRACT UNNORMALIZED (long HFP) SW RX C A Da EO LS B6F
SUBTRACT UNNORMALIZED (short HFP) SUR RR C Da EO LS 3F
SUBTRACT UNNORMALIZED (short HFP) SU RX C A Da EO LS B7F

Figure 18-2 (Part 2 of 3). Summary of HFP Instructions

Chapter 18. Hexadecimal-Floating-Point Instructions 18-7



Explanation:

A Access exceptions for logical addresses.
B B field designates an access register in the access-register mode.
C Condition code is set.
Da AFP-register data exception.
EO HFP-exponent-overflow exception.
EU HFP-exponent-underflow exception.
FK HFP-divide exception.
HX HFP-extensions facility.
LS HFP-significance exception.
N Instruction is new in z/Architecture as compared to ESA/39.
QR Square-root facility.
RR RR instruction format.
RRE RRE instruction format.
RRF RRF instruction format.
RX RX instruction format.
RXE RXE instruction format.
SP Specification exception.
SQ HFP-square-root exception.

Figure 18-2 (Part 3 of 3). Summary of HFP Instructions

ADD NORMALIZED teristic increased by one for each hexadecimal


digit of shift until the two characteristics agree.
Mnemonic1 R,R [RR]
When a fraction is shifted right during alignment,
the leftmost hexadecimal digit shifted out is
Op Code R R retained as a guard digit. The fraction that is not

8 12 15 shifted is considered to be extended with a zero in


the guard-digit position. When no alignment shift
Mnemonic1 Op Code Operands occurs, both operands are considered to be
AER '3A' Short HFP extended with zeros in the guard-digit position.
ADR '2A' Long HFP The fractions with signs are then added algebra-
AXR '36' Extended HFP
ically to form a signed intermediate sum.
Mnemonic2 R,D(X,B) [RX]
The intermediate-sum fraction consists of seven
(short format), 15 (long format), or 29 (extended
Op Code R X B D format) hexadecimal digits, including the guard
digit, and a possible carry. If a carry is present,
8 12 16 2 31 the sum is shifted right one digit position so that
Mnemonic2 Op Code Operands the carry becomes the leftmost digit of the frac-
AE '7A' Short HFP tion, and the characteristic is increased by one.
AD '6A' Long HFP
If the addition produces no carry, the
The second operand is added to the first operand, intermediate-sum fraction is shifted left as neces-
and the normalized sum is placed at the first- sary to eliminate any leading hexadecimal zero
operand location. digits resulting from the addition, provided the
fraction is not zero. Zeros are supplied to the
Addition of two HFP numbers consists in charac- vacated rightmost digits, and the characteristic is
teristic comparison, fraction alignment, and signed reduced by the number of hexadecimal digits of
fraction addition. The characteristics of the two shift. The fraction thus normalized is then trun-
operands are compared, and the fraction accom- cated on the right to six (short format), 14 (long
panying the smaller characteristic is aligned with format), or 28 (extended format) hexadecimal
the other fraction by a right shift, with its charac- digits. In the extended format, a characteristic is

18-8 z/Architecture Principles of Operation


generated for the low-order part, which is 14 less Resulting Condition Code:
than the high-order characteristic.
0 Result is zero
1 Result is less than zero
The sign of the sum is determined by the rules of
2 Result is greater than zero
algebra, unless all digits of the intermediate-sum
3 --
fraction are zero, in which case the result is made
a positive true zero.
Program Exceptions:
An HFP-exponent-overflow exception exists when Access (fetch, operand 2 of AE and AD only)
a carry from the leftmost position of the Data with DXC 1, AFP register
intermediate-sum fraction would cause the charac- HFP exponent overflow
teristic of the normalized sum to exceed 127. The HFP exponent underflow
operation is completed by making the result char- HFP significance
acteristic 128 less than the correct value, and a Specification (AXR only)
program interruption for HFP exponent overflow
occurs. The result is normalized, and the sign Programming Notes:
and fraction remain correct. For extended results, 1. An example of the use of the ADD NORMAL-
the characteristic of the low-order part remains IZED instruction (AE) is given in Appendix A.
correct.
2. Interchanging the two operands in an HFP
An HFP-exponent-underflow exception exists addition does not affect the value of the sum.
when the characteristic of the normalized sum 3. The ADD NORMALIZED instruction normal-
would be less than zero and the fraction is not izes the sum but not the operands. Thus, if
zero. If the HFP-exponent-underflow mask bit in one or both operands are unnormalized, preci-
the PSW is one, the operation is completed by sion may be lost during fraction alignment.
making the result characteristic 128 greater than
the correct value, and a program interruption for
HFP exponent underflow occurs. The result is ADD UNNORMALIZED
normalized, and the sign and fraction remain
Mnemonic1 R,R [RR]
correct. If the HFP-exponent-underflow mask bit
in the PSW is zero, a program interruption does
not occur; instead, the operation is completed by Op Code R R
making the result a positive true zero. For
extended results, HFP exponent underflow is not 8 12 15
recognized when the low-order characteristic is
Mnemonic1 Op Code Operands
less than zero but the high-order characteristic is AUR '3E' Short HFP
equal to or greater than zero. AWR '2E' Long HFP

The result fraction is zero when the Mnemonic2 R,D(X,B) [RX]


intermediate-sum fraction, including the guard
digit, is zero. With a zero result fraction, the
Op Code R X B D
action depends on the setting of the
HFP-significance mask bit in the PSW. If the 8 12 16 2 31
HFP-significance mask bit in the PSW is one, no
normalization occurs, the intermediate and final Mnemonic2 Op Code Operands
result characteristics are the same, and a program AU '7E' Short HFP
AW '6E' Long HFP
interruption for HFP significance occurs. If the
HFP-significance mask bit in the PSW is zero, the
The second operand is added to the first operand,
program interruption does not occur; instead, the
and the unnormalized sum is placed at the first-
result is made a positive true zero.
operand location.
For AXR, the R fields must designate valid
The execution of ADD UNNORMALIZED is iden-
floating-point-register pairs; otherwise, a specifica-
tical to that of ADD NORMALIZED, except that:
tion exception is recognized.

Chapter 18. Hexadecimal-Floating-Point Instructions 18-9


1. When no carry is present after the addition, Mnemonic2 R,R [RRE]
the intermediate-sum fraction is truncated to
the proper result-fraction length without a left
Op Code //////// R R
shift to eliminate leading hexadecimal zeros
and without the corresponding reduction of the 16 24 28 31
characteristic.
Mnemonic2 Op Code Operands
2. HFP exponent underflow cannot occur. CXR 'B369' Extended HFP
3. The guard digit does not participate in the
Mnemonic3 R,D(X,B) [RX]
recognition of a zero result fraction. A zero
result fraction is recognized when the fraction
(that is, the intermediate-sum fraction, Op Code R X B D
excluding the guard digit) is zero.
8 12 16 2 31
Resulting Condition Code:
Mnemonic3 Op Code Operands
0 Result fraction zero CE '79' Short HFP
1 Result less than zero CD '69' Long HFP
2 Result greater than zero
3 -- The first operand is compared with the second
operand, and the condition code is set to indicate
Program Exceptions: the result.

Access (fetch, operand 2 of AU and AW only) The comparison is algebraic and follows the pro-
Data with DXC 1, AFP register cedure for normalized subtraction, except that the
HFP exponent overflow difference is discarded after setting the condition
HFP significance code and both operands remain unchanged.
When the difference, including the guard digit, is
Programming Notes: zero, the operands are equal. When a nonzero
1. An example of the use of the ADD UNNOR- difference is positive or negative, the first operand
MALIZED instruction (AU) is given in is high or low, respectively.
Appendix A.
An HFP-exponent-overflow, HFP-exponent-under-
2. Except when the result is made a true zero, flow, or HFP-significance exception cannot occur.
the characteristic of the result of ADD
UNNORMALIZED is equal to the greater of For CXR, the R fields must designate valid
the two operand characteristics, increased by floating-point-register pairs; otherwise, a specifica-
one if the fraction addition produced a carry, tion exception is recognized.
or set to zero if HFP exponent overflow
occurred. Resulting Condition Code:
0 Operands equal
COMPARE 1 First operand low
2 First operand high
Mnemonic1 R,R [RR]
3 --

Op Code R R Program Exceptions:

Access (fetch, operand 2 of CE and CD only)


8 12 15
Data with DXC 1, AFP register
Mnemonic1 Op Code Operands Specification (CXR only)
CER '39' Short HFP
CDR '29' Long HFP

18-10 z/Architecture Principles of Operation


Programming Notes: Condition Code: The code remains unchanged.
1. Examples of the use of the COMPARE
Program Exceptions:
instruction (CDR) are given in Appendix A.
Data with DXC 1, AFP register
2. An exponent inequality alone is not sufficient
Specification (CXFR and CXGR)
to determine the inequality of two operands
with the same sign, because the fractions may
have different numbers of leading CONVERT TO FIXED
hexadecimal zeros.
Mnemonic R,M,R [RRF]
3. Numbers with zero fractions compare equal
even when they differ in sign or characteristic.
Op Code M //// R R

CONVERT FROM FIXED 16 2 24 28 31

Mnemonic R,R [RRE] Mnemonic Op Code Operands


CFER 'B3B8' Short HFP operand, 32-bit
binary-integer result
Op Code //////// R R CFDR 'B3B9' Long HFP operand, 32-bit
binary-integer result
16 24 28 31 CFXR 'B3BA' Extended HFP operand, 32-
bit binary-integer result
Mnemonic Op Code Operands CGER 'B3C8' Short HFP operand, 64-bit
CEFR 'B3B4' 32-bit binary-integer binary-integer result
operand, short HFP result CGDR 'B3C9' Long HFP operand, 64-bit
CDFR 'B3B5' 32-bit binary-integer binary-integer result
operand, long HFP result CGXR 'B3CA' Extended HFP operand, 64-
CXFR 'B3B6' 32-bit binary-integer bit binary-integer result
operand, extended HFP
result The HFP second operand is rounded to an integer
CEGR 'B3C4' 64-bit binary-integer value and then converted to the fixed-point format.
operand, short HFP result
The result is placed at the first-operand location.
CDGR 'B3C5' 64-bit binary-integer
operand, long HFP result
CXGR 'B3C6' 64-bit binary-integer The result is a signed binary integer that is placed
operand, extended HFP in the general register designated by R. A 32-bit
result result replaces bits 32-63 of the register, and bits
0-31 of the register remain unchanged.
The fixed-point second operand is converted to
the HFP format, and the normalized result is The second operand is rounded to an integer
placed at the first-operand location. value by rounding as specified by the modifier in
the M field:
A nonzero result is normalized. A zero result is
made a positive true zero. M Rounding Method
0 Round toward 0
The second operand is a signed binary integer 1 Biased round to nearest
that is located in the general register designated 4 Round to nearest
by R. A 32-bit operand is in bit positions 32-63 5 Round toward 0
of the register. 6 Round toward +
7 Round toward
The result is normalized and rounded toward zero
(truncated) before it is placed at the first-operand A modifier other than 0, 1, or 4-7 is invalid.
location.
The sign of the result is the sign of the second
For CXFR and CXGR, the R field must designate operand, except that a zero result has a plus sign.
a valid floating-point-register pair; otherwise, a
specification exception is recognized. If the rounded result would have a value
exceeding the range that can be represented in

Chapter 18. Hexadecimal-Floating-Point Instructions 18-11


the result format, the largest (in magnitude) repre- Mnemonic3 R,D(X,B) [RX]
sentable number of the same sign as the source
is placed at the target location, and condition code
Op Code R X B D
3 is set.
8 12 16 2 31
HFP exponent underflow is not recognized
because small values are rounded to one (with the Mnemonic3 Op Code Operands
appropriate sign) or to zero, depending on the DE '7D' Short HFP
rounding mode. DD '6D' Long HFP

The M field must designate a valid modifier; oth- The first operand (the dividend) is divided by the
erwise, a specification exception is recognized. second operand (the divisor), and the normalized
For CFXR and CGXR, the R field must designate quotient is placed at the first-operand location. No
a valid floating-point-register pair; otherwise, a remainder is preserved.
specification exception is recognized.
HFP division consists in characteristic subtraction
Resulting Condition Code: and fraction division. The operands are first nor-
malized to eliminate leading hexadecimal zeros.
0 Source was zero The difference between the dividend and divisor
1 Source was less than zero characteristics of the normalized operands, plus
2 Source was greater than zero 64, is used as the characteristic of an intermediate
3 Special case quotient.

Program Exceptions: All dividend and divisor fraction digits participate in


Data with DXC 1, AFP register forming the fraction of the intermediate quotient.
Specification The intermediate-quotient fraction can have no
leading hexadecimal zeros, but a right shift of one
digit position may be necessary, with this causing
DIVIDE an increase of the characteristic by one. The frac-
tion is then truncated to the proper result-fraction
Mnemonic1 R,R [RR]
length.

Op Code R R An HFP-exponent-overflow exception exists when


the characteristic of the final quotient would
8 12 15 exceed 127 and the fraction is not zero. The
operation is completed by making the result char-
Mnemonic1 Op Code Operands
DER '3D' Short HFP acteristic 128 less than the correct value, and a
DDR '2D' Long HFP program interruption for HFP exponent overflow
occurs. The result is normalized, and the sign
Mnemonic2 R,R [RRE] and fraction remain correct. If, for extended
results, the low-order characteristic would also

exceed 127, it too is decreased by 128.


'B22D' //////// R R

16 24 28 31 An HFP-exponent-underflow exception exists


when the characteristic of the final quotient would
Mnemonic2 Op Code Operands be less than zero and the fraction is not zero. If
DXR 'B22D' Extended HFP the HFP-exponent-underflow mask bit in the PSW
is one, the operation is completed by making the
result characteristic 128 greater than the correct
value, and a program interruption for HFP expo-
nent underflow occurs. The result is normalized,
and the sign and fraction remain correct. If the
HFP-exponent-underflow mask bit in the PSW is
zero, a program interruption does not occur;
instead, the operation is completed by making the

18-12 z/Architecture Principles of Operation


result a positive true zero. For extended results, HALVE
HFP exponent underflow is not recognized when
the low-order characteristic is less than zero but Mnemonic R,R [RR]
the high-order characteristic is equal to or greater
than zero.
Op Code R R
HFP exponent underflow does not occur when the
8 12 15
characteristic of an operand becomes less than
zero during normalization of the operands or when Mnemonic Op Code Operands
the intermediate-quotient characteristic is less than HER '34' Short HFP
zero, as long as the final quotient can be repres- HDR '24' Long HFP
ented with the correct characteristic.
The second operand is divided by 2, and the nor-
When the divisor fraction is zero, an HFP-divide malized quotient is placed at the first-operand
exception is recognized. This includes the case of location.
division of zero by zero.
The fraction of the second operand is shifted right
When the dividend fraction is zero but the divisor one bit position, placing the contents of the right-
fraction is nonzero, the quotient is made a positive most bit position in the leftmost bit position of the
true zero. No HFP exponent overflow or HFP guard digit, and a zero is supplied to the leftmost
exponent underflow occurs. bit position of the fraction. The intermediate
result, including the guard digit, is then normal-
The sign of the quotient is the EXCLUSIVE OR of ized, and the final result is truncated to the proper
the operand signs, except that the sign is always length.
plus when the quotient is made a positive true
zero. An HFP-exponent-underflow exception exists
when the characteristic of the final result would be
For DXR, the R fields must designate valid less than zero and the fraction is not zero. If the
floating-point-register pairs; otherwise, a specifica- HFP-exponent-underflow mask bit in the PSW is
tion exception is recognized. one, the operation is completed by making the
result characteristic 128 greater than the correct
Condition Code: The code remains unchanged. value, and a program interruption for HFP expo-
nent underflow occurs. The result is normalized,
Program Exceptions: and the sign and fraction remain correct. If the
Access (fetch, operand 2 of DE and DD only) HFP-exponent-underflow mask bit in the PSW is
Data with DXC 1, AFP register zero, a program interruption does not occur;
HFP divide instead, the operation is completed by making the
HFP exponent overflow result a positive true zero.
HFP exponent underflow
Specification (DXR only) When the fraction of the second operand is zero,
the result is made a positive true zero, and no
Programming Note: Examples of the use of the HFP exponent underflow occurs.
DIVIDE instruction (DER) are given in Appendix A.
The sign of the result is the same as that of the
second operand, except that the sign is always
plus when the quotient is made a positive true
zero.

Condition Code: The code remains unchanged.

Chapter 18. Hexadecimal-Floating-Point Instructions 18-13


Program Exceptions: characteristic, modulo 128. If the extended-
operand fraction is zero, the result is made a true
Data with DXC 1, AFP register
zero with the same sign as the source (the high-
HFP exponent underflow
order and low-order sign bits of the result are the
Programming Notes: same as the high-order sign bit of the source).

1. An example of the use of the HALVE instruc- For LTXR, the R fields must designate valid
tion (HDR) is given in Appendix A. floating-point-register pairs; otherwise, a specifica-
2. With short and long operands, the halve oper- tion exception is recognized.
ation is identical to a divide operation with the
Resulting Condition Code:
number 2 as divisor. Similarly, the result of
HDR is identical to that of MD or MDR with 0 Result is zero
one-half as a multiplier, and the result of HER 1 Result is less than zero
is identical to that of MEE or MEER with one- 2 Result is greater than zero
half as a multiplier. 3 --

Program Exceptions:
LOAD AND TEST
Data with DXC 1, AFP register
Mnemonic1 R,R [RR] Specification (LTXR only)
Programming Note: When, for LTER and LTDR,
Op Code R R the same register is designated as the first-
operand and second-operand location, the opera-
8 12 15
tion is equivalent to a test without data movement.
Mnemonic1 Op Code Operands
LTER '32' Short HFP LOAD COMPLEMENT
LTDR '22' Long HFP
Mnemonic1 R,R [RR]
Mnemonic2 R,R [RRE]

Op Code R R
Op Code //////// R R
8 12 15
16 24 28 31
Mnemonic1 Op Code Operands
Mnemonic2 Op Code Operands LCER '33' Short HFP
LTXR 'B362' Extended HFP LCDR '23' Long HFP

The second operand is placed at the first-operand Mnemonic2 R,R [RRE]


location, and its sign and magnitude are tested to
determine the setting of the condition code. The
condition code is set the same as for a compar- Op Code //////// R R

ison of the second operand with zero. 16 24 28 31
For short and long operands, the second operand Mnemonic2 Op Code Operands
is placed unchanged in the first-operand location. LCXR 'B363' Extended HFP

For extended operands, the high-order sign and The second operand is placed at the first-operand
the entire fraction of the source are placed location with the sign bit inverted.
unchanged in the result, and the low-order sign is
set equal to the high-order sign. If the extended- The sign bit is inverted even if the operand is
operand fraction is nonzero, the high-order char- zero. For all operand lengths, the source fraction
acteristic is placed unchanged in the result is placed unchanged in the result.
high-order characteristic, and the low-order char-
acteristic is set to 14 less than the high-order For short and long operands, the source charac-
teristic is placed unchanged in the result.

18-14 z/Architecture Principles of Operation


For extended operands, the low-order sign is set Program Exceptions:
equal to the high-order sign. If the extended-
Data with DXC 1, AFP register
operand fraction is nonzero, the high-order char-
Specification (FIXR only)
acteristic is placed unchanged in the result
high-order characteristic, and the low-order char- Programming Notes:
acteristic is set to 14 less than the high-order
characteristic, modulo 128. If the extended- 1. LOAD FP INTEGER truncates (rounds toward
operand fraction is zero, the result is made a true zero) an HFP number to an integer value.
zero with the sign inverted from the source (the These integers, which remain in the HFP
high-order and low-order sign bits of the result are format, should not be confused with binary
inverted from the high-order sign bit of the integers, which use a fixed-point format.
source). 2. If the HFP operand is numeric with a large
enough exponent so that it is already an
For LCXR, the R fields must designate valid integer, the result value remains the same,
floating-point-register pairs; otherwise, a specifica- except that an unnormalized operand is nor-
tion exception is recognized. malized, and an operand with a zero fraction
is changed to a positive true zero.
Resulting Condition Code:
0 Result is zero LOAD LENGTHENED
1 Result is less than zero
2 Result is greater than zero Mnemonic1 R,R [RRE]
3 --

Program Exceptions: Op Code //////// R R

Data with DXC 1, AFP register 16 24 28 31
Specification (LCXR only)
Mnemonic1 Op Code Operands
LDER 'B324' Short HFP operand 2,
LOAD FP INTEGER long HFP operand 1
LXDR 'B325' Long HFP operand 2,
Mnemonic R,R [RRE] extended HFP operand 1
LXER 'B326' Short HFP operand 2,
extended HFP operand 1
Op Code //////// R R
Mnemonic2 R,D(X,B) [RXE]
16 24 28 31
/
Mnemonic Op Code Operands Op Code R X B D ////////Op Code
FIER 'B377' Short HFP /
FIDR 'B37F' Long HFP 8 12 16 2 32 4 47
FIXR 'B367' Extended HFP
Mnemonic2 Op Code Operands
The second operand is truncated (rounded toward LDE 'ED24' Short HFP operand 2,
zero) to an integer value in the same floating-point long HFP operand 1
LXD 'ED25' Long HFP operand 2,
format, and the normalized result is placed at the extended HFP operand 1
first-operand location. LXE 'ED26' Short HFP operand 2,
extended HFP operand 1
A nonzero result is normalized. A zero result is
made a positive true zero. The second operand is extended to a longer
format, and the result is placed at the first-operand
For FIXR, the R fields must designate valid location.
floating-point-register pairs; otherwise, a specifica-
tion exception is recognized. For all operand lengths, the source fraction is
extended with zeros and placed in the result. The
Condition Code: The code remains unchanged. sign bit of the result is set the same as the sign of

Chapter 18. Hexadecimal-Floating-Point Instructions 18-15


the source even when the result is made a true The sign bit is made one even if the operand is
zero. zero. For all operand lengths, the source fraction
is placed unchanged in the result.
For long results, the source characteristic is
placed unchanged in the result. For short and long operands, the source charac-
teristic is placed unchanged in the result.
For extended results, the low-order sign is set
equal to the high-order sign. If the fraction is For extended operands, the low-order sign is set
nonzero, the source characteristic is placed equal to the high-order sign. If the extended-
unchanged in the result high-order characteristic, operand fraction is nonzero, the high-order char-
and the low-order characteristic is set to 14 less acteristic is placed unchanged in the result
than the high-order characteristic, modulo 128. If high-order characteristic, and the low-order char-
the fraction is zero, the result is made a true zero acteristic is set to 14 less than the high-order
with the same sign as the source (the high-order characteristic, modulo 128. If the extended-
and low-order sign bits of the result are the same operand fraction is zero, the result is made a neg-
as the sign bit of the source). ative true zero (the high-order and low-order sign
bits of the result are set to one).
For LXD, LXDR, LXE, and LXER, the R field
must designate a valid floating-point-register pair; For LNXR, the R fields must designate valid
otherwise, a specification exception is recognized. floating-point-register pairs; otherwise, a specifica-
tion exception is recognized.
Condition Code: The code remains unchanged.
Resulting Condition Code:
Program Exceptions:
0 Result is zero
Access (fetch, operand 2 of LDE, LXE, and 1 Result is less than zero
LXD only) 2 --
Data with DXC 1, AFP register 3 --
Specification (LXE, LXER, LXD, LXDR)
Program Exceptions:
LOAD NEGATIVE Data with DXC 1, AFP register
Specification (LNXR only)
Mnemonic1 R,R [RR]

LOAD POSITIVE
Op Code R R
Mnemonic1 R,R [RR]
8 12 15

Mnemonic1 Op Code Operands Op Code R R
LNER '31' Short HFP
LNDR '21' Long HFP 8 12 15

Mnemonic2 R,R [RRE] Mnemonic1 Op Code Operands


LPER '3' Short HFP
LPDR '2' Long HFP
Op Code //////// R R
Mnemonic2 R,R [RRE]
16 24 28 31

Mnemonic2 Op Code Operands Op Code //////// R R
LNXR 'B361' Extended HFP
16 24 28 31
The second operand is placed at the first-operand
location with the sign bit made one. Mnemonic2 Op Code Operands
LPXR 'B36' Extended HFP

18-16 z/Architecture Principles of Operation


The second operand is placed at the first-operand LRER '35' Long HFP operand 2,
location with the sign bit made zero. short HFP operand 1
LRDR '25' Extended HFP operand 2,
long HFP operand 1
For all operand lengths, the sign bit is made zero,
and the source fraction is placed unchanged in the Mnemonic2 R,R [RRE]
result.

For short and long operands, the source charac- Op Code //////// R R
teristic is placed unchanged in the result.
16 24 28 31
For extended operands, the low-order sign is set
Mnemonic2 Op Code Operands
equal to the high-order sign. If the extended- LEXR 'B366' Extended HFP operand 2
operand fraction is nonzero, the high-order char- short HFP operand 1
acteristic is placed unchanged in the result
high-order characteristic, and the low-order char- The second operand is rounded to a shorter
acteristic is set to 14 less than the high-order format, and the result is placed at the first-operand
characteristic, modulo 128. If the extended- location.
operand fraction is zero, the result is made a posi-
tive true zero (the high-order and low-order sign Rounding consists in adding a one to the leftmost
bits of the result are set to zero). bit position of the second operand that is to be
dropped and propagating any carry through the
For LPXR, the R fields must designate valid fraction. The sign of the second operand is
floating-point-register pairs; otherwise, a specifica- ignored, and addition is performed as if the frac-
tion exception is recognized. tion were positive.

Resulting Condition Code: If rounding causes a carry out of the leftmost


hexadecimal digit position of the fraction, the frac-
0 Result is zero
tion is shifted right one digit position so that the
1 --
carry becomes the leftmost digit of the fraction,
2 Result is greater than zero
and the characteristic is increased by one.
3 --
The intermediate fraction is then truncated to the
Program Exceptions:
proper result-fraction length.
Data with DXC 1, AFP register
Specification (LPXR only) The sign of the result is the same as the sign of
the second operand. There is no normalization to
LOAD ROUNDED eliminate leading zeros.

Mnemonic1 R,R [RR] An HFP-exponent-overflow exception exists when


shifting the fraction right would cause the charac-
teristic to exceed 127. The operation is completed
Op Code R R by making the result characteristic 128 less than
the correct value, and a program interruption for
8 12 15
HFP exponent overflow occurs. The result is nor-
Mnemonic1 Op Code Operands malized, and the sign and fraction remain correct.
LEDR '35' Long HFP operand 2,
short HFP operand 1 HFP-exponent-underflow and HFP-significance
LDXR '25' Extended HFP operand 2, exceptions cannot occur.
long HFP operand 1
The above mnemonics are alternatives to the fol- For LDXR (or LRDR) and LEXR, the R field must
lowing older mnemonics that are less descriptive designate a valid floating-point-register pair; other-
of operand lengths: wise, a specification exception is recognized.

Condition Code: The code remains unchanged.

Chapter 18. Hexadecimal-Floating-Point Instructions 18-17


Program Exceptions: Mnemonic4 R,D(X,B) [RX]
Data with DXC 1, AFP register
HFP exponent overflow Op Code R X B D
Specification (LDXR, LEXR, LRDR)
8 12 16 2 31
Programming Note: The sign of the rounded
result is the same as the sign of the operand, Mnemonic4 Op Code Operands
even when the result is zero. MD '6C' Long HFP
MDE '7C' Short HFP multiplier and
multiplicand, long HFP
MULTIPLY product
MXD '67' Long HFP multiplier and
Mnemonic1 R,R [RRE] multiplicand, extended
HFP product
The above mnemonic MDE is an alternative to
Op Code //////// R R the following older mnemonic that is less
descriptive of operand lengths:
16 24 28 31
ME '7C' Short HFP multiplier and
Mnemonic1 Op Code Operands multiplicand, long HFP
MEER 'B337' Short HFP product
Mnemonic2 R,R [RR]
The normalized product of the second operand
(the multiplier) and the first operand (the multipli-
Op Code R R cand) is placed at the first-operand location.

8 12 15 Multiplication of two HFP numbers consists in


exponent addition and fraction multiplication. The
Mnemonic2 Op Code Operands
MDR '2C' Long HFP operands are first normalized to eliminate leading
MXR '26' Extended HFP hexadecimal zeros. The sum of the character-
MDER '3C' Short HFP multiplier and istics of the normalized operands, less 64, is used
multiplicand, long HFP as the characteristic of the intermediate product.
product
MXDR '27' Long HFP multiplier and The fraction of the intermediate product is the
multiplicand, extended
exact product of the normalized operand fractions.
HFP product
If the intermediate-product fraction has one
The above mnemonic MDER is an alternative to leading hexadecimal zero digit, the fraction is
the following older mnemonic that is less descrip- shifted left one digit position, bringing the contents
tive of operand lengths: of the guard-digit position into the rightmost posi-
MER '3C' Short HFP multiplier and tion of the result fraction, and the intermediate-
multiplicand, long HFP product characteristic is reduced by one. The
product fraction is then truncated to the proper result-
fraction length.
Mnemonic3 R,D(X,B) [RXE]

/ For MDE and MDER, the multiplier and multipli-


Op Code R X B D ////////Op Code cand fractions have six hexadecimal digits; the
/ product fraction has the full 14 digits of the long
8 12 16 2 32 4 47 format, with the two rightmost fraction digits
always zeros. For MEE and MEER, the multiplier
Mnemonic3 Op Code Operands and multiplicand fractions have six digits, and the
MEE 'ED37' Short HFP
final product fraction is truncated to six digits. The
result, as for all short-format results, replaces the
leftmost 32 bits of the target register, and the
rightmost 32 bit positions of the target register
remain unchanged.

18-18 z/Architecture Principles of Operation


For MD and MDR, the multiplier and multiplicand If either or both operand fractions are zero, the
fractions have 14 digits, and the final product frac- result is made a positive true zero, and no HFP
tion is truncated to 14 digits. For MXD and exponent overflow or HFP exponent underflow
MXDR, the multiplier and multiplicand fractions occurs.
have 14 digits, with the multiplicand occupying the
high-order part of the first operand; the final The sign of the product is the EXCLUSIVE OR of
product fraction contains 28 digits and is an exact the operand signs, except that the sign is always
product of the operand fractions. For MXR, the plus when the result is made a true zero.
multiplier and multiplicand fractions have 28 digits,
and the final product fraction is truncated to 28 The R field for MXD, MXDR, and MXR, and the
digits. R field for MXR must designate valid floating-
point-register pairs. Otherwise, a specification
An HFP-exponent-overflow exception exists when exception is recognized.
the characteristic of the final product would
exceed 127 and the fraction is not zero. The Condition Code: The code remains unchanged.
operation is completed by making the result char-
acteristic 128 less than the correct value, and a Program Exceptions:
program interruption for HFP exponent overflow Access (fetch, operand 2 of MDE, MEE, MD,
occurs. The result is normalized, and the sign and MXD only)
and fraction remain correct. If, for extended Data with DXC 1, AFP register
results, the low-order characteristic would also HFP exponent overflow
exceed 127, it too is decreased by 128. HFP exponent underflow
Specification (MXD, MXDR, MXR)
HFP exponent overflow is not recognized when
the intermediate-product characteristic is initially Programming Notes:
128 but is brought back within range by normaliza-
1. An example of the use of the MULTIPLY
tion.
instruction (MDR) is given in Appendix A.
An HFP-exponent-underflow exception exists 2. Interchanging the two operands in an HFP
when the characteristic of the final product would multiplication does not affect the value of the
be less than zero and the fraction is not zero. If product.
the HFP-exponent-underflow mask bit in the PSW
is one, the operation is completed by making the
result characteristic 128 greater than the correct
SQUARE ROOT
value, and a program interruption for HFP expo- Mnemonic1 R,R [RRE]
nent underflow occurs. The result is normalized,
and the sign and fraction remain correct. If the
HFP-exponent-underflow mask bit in the PSW is Op Code //////// R R
zero, a program interruption does not occur;
16 24 28 31
instead, the operation is completed by making the
result a positive true zero. For extended results, Mnemonic1 Op Code Operands
HFP exponent underflow is not recognized when SQER 'B245' Short HFP
the low-order characteristic is less than zero but SQDR 'B244' Long HFP
the high-order characteristic is equal to or greater SQXR 'B336' Extended HFP
than zero.
Mnemonic2 R,D(X,B) [RXE]
HFP exponent underflow does not occur when the /
characteristic of an operand becomes less than Op Code R X B D ////////Op Code
zero during normalization of the operands, as long /
as the final product can be represented with the 8 12 16 2 32 4 47
correct characteristic.
Mnemonic2 Op Code Operands
SQE 'ED34' Short HFP
SQD 'ED35' Long HFP

Chapter 18. Hexadecimal-Floating-Point Instructions 18-19


The normalized and rounded square root of the Program Exceptions:
second operand is placed at the first-operand
Access (fetch, operand 2 of SQE and SQD
location.
only)
Data with DXC 1, AFP register
When the fraction of the second operand is zero,
HFP square root
the sign and characteristic of the second operand
Specification (SQXR only)
are ignored, and the operation is completed by
placing a positive true zero in the first-operand
Programming Notes:
location.
1. The use of the SQUARE ROOT instruction
If the second operand is less than zero, an with short operands (SQER) is illustrated by
HFP-square-root exception is recognized. the examples in the following table:

If the second operand is normalized and greater Operand Decimal Result Decimal
than zero, the characteristic, fraction, and sign of (hex) Value (hex) Value
the result are produced as follows:
42 1925. 41 55.
The result characteristic is one-half of the sum 4 4 .25 4 8.5
of the operand characteristic and either 64, if 4 8 .5 4 B54F3.771...
the operand characteristic is even, or 65, if it 41 8 8. 41 2D413D2.8284...
is odd.

If the operand characteristic is odd, the 2. The result fraction is correctly normalized
operand fraction is shifted right one digit posi- without any further left or right shifts of the
tion, the rightmost digit entering the guard-digit intermediate-result fraction and without any
position. further exponent adjustment. Rounding
cannot cause a carry out of the leftmost digit.
An intermediate-result fraction is produced by
computing without rounding the square root of 3. Although a characteristic greater than 127 or
the operand fraction, after any right shift as less than zero may temporarily be generated
described. The intermediate-result fraction during the operation, the result characteristic
consists of the 29 most significant is always within the representable range, and
hexadecimal digits of the square-root result in no HFP exponent overflow or underflow
the extended format, 15 in the long format, or occurs.
seven in the short format, where all three Specifically, the smallest nonzero operand in
formats include a guard digit on the right. the long format consists of a one bit, preceded
A one is added to the leftmost bit of the guard on the left by 63 zeros. This operand is an
digit of the intermediate result, any carry is unnormalized number with a value of 16-78,
propagated to the left, and the guard digit is and its square root is 16-39. The normalized
dropped to produce the result fraction. representation of this result has a character-
istic of 26 (decimal). Similarly, the square root
The result sign is made plus. of the largest representable operand has a
If the second operand is unnormalized and greater characteristic of 96 (decimal). The instruction,
than zero, the operand is first normalized. The therefore, cannot produce a nonzero result
operation then proceeds as for normalized oper- with a characteristic outside the range of 26 to
ands. 96.

For SQXR, the R fields must designate valid


floating-point-register pairs; otherwise, a specifica-
tion exception is recognized.

Condition Code: The code remains unchanged.

18-20 z/Architecture Principles of Operation


SUBTRACT NORMALIZED SUBTRACT UNNORMALIZED
Mnemonic1 R,R [RR] Mnemonic1 R,R [RR]


Op Code R R Op Code R R

8 12 15 8 12 15

Mnemonic1 Op Code Operands Mnemonic1 Op Code Operands


SER '3B' Short HFP SUR '3F' Short HFP
SDR '2B' Long HFP SWR '2F' Long HFP
SXR '37' Extended HFP
Mnemonic2 R,D(X,B) [RX]
Mnemonic2 R,D(X,B) [RX]

Op Code R X B D
Op Code R X B D
8 12 16 2 31
8 12 16 2 31
Mnemonic2 Op Code Operands
Mnemonic2 Op Code Operands SU '7F' Short HFP
SE '7B' Short HFP SW '6F' Long HFP
SD '6B' Long HFP
The second operand is subtracted from the first
The second operand is subtracted from the first operand, and the unnormalized difference is
operand, and the normalized difference is placed placed at the first-operand location.
at the first-operand location.
The execution of SUBTRACT UNNORMALIZED is
The execution of SUBTRACT NORMALIZED is identical to that of ADD UNNORMALIZED, except
identical to that of ADD NORMALIZED, except that the second operand participates in the opera-
that the second operand participates in the opera- tion with its sign bit inverted.
tion with its sign bit inverted.
Resulting Condition Code:
For SXR, the R fields must designate valid
floating-point-register pairs; otherwise, a specifica- 0 Result fraction zero
tion exception is recognized. 1 Result less than zero
2 Result greater than zero
Resulting Condition Code: 3 --

0 Result is zero Program Exceptions:


1 Result is less than zero
2 Result is greater than zero Access (fetch, operand 2 of SU and SW only)
3 -- Data with DXC 1, AFP register
HFP exponent overflow
Program Exceptions: HFP significance

Access (fetch, operand 2 of SE and SD only)


Data with DXC 1, AFP register
HFP exponent overflow
HFP exponent underflow
HFP significance
Specification (SXR only)

Chapter 18. Hexadecimal-Floating-Point Instructions 18-21


18-22 z/Architecture Principles of Operation
Chapter 19. Binary-Floating-Point Instructions
Binary-Floating-Point Facility . . . . . . . . . . 19-1 IEEE Inexact . . . . . . . . . . . . . . . 19-12
Floating-Point-Control (FPC) Register . . . 19-2 Result Figures . . . . . . . . . . . . . . . . . 19-13
IEEE Masks and Flags . . . . . . . . . . 19-3 Data-Exception Codes (DXC) and
FPC DXC Byte . . . . . . . . . . . . . . 19-3 Abbreviations . . . . . . . . . . . . . . 19-14
Operations on the FPC Register . . . . 19-3 Instructions . . . . . . . . . . . . . . . . . . . 19-14
BFP Arithmetic . . . . . . . . . . . . . . . . . . 19-4 ADD . . . . . . . . . . . . . . . . . . . . . 19-18
BFP Data Formats . . . . . . . . . . . . . . 19-4 COMPARE . . . . . . . . . . . . . . . . . 19-23
BFP Short Format . . . . . . . . . . . . . 19-4 COMPARE AND SIGNAL . . . . . . . . . 19-24
BFP Long Format . . . . . . . . . . . . . 19-4 CONVERT FROM FIXED . . . . . . . . . 19-26
BFP Extended Format . . . . . . . . . . 19-4 CONVERT TO FIXED . . . . . . . . . . . 19-26
Biased Exponent . . . . . . . . . . . . . 19-4 DIVIDE . . . . . . . . . . . . . . . . . . . 19-29
Significand . . . . . . . . . . . . . . . . . 19-4 DIVIDE TO INTEGER . . . . . . . . . . . 19-29
Values of Nonzero Numbers . . . . . . 19-4 EXTRACT FPC . . . . . . . . . . . . . . . 19-34
Classes of BFP Data . . . . . . . . . . . . 19-5 LOAD AND TEST . . . . . . . . . . . . . 19-35
Zeros . . . . . . . . . . . . . . . . . . . . 19-6 LOAD COMPLEMENT . . . . . . . . . . . 19-35
Denormalized Numbers . . . . . . . . . 19-6 LOAD FP INTEGER . . . . . . . . . . . . 19-36
Normalized Numbers . . . . . . . . . . . 19-6 LOAD FPC . . . . . . . . . . . . . . . . . 19-37
Infinities . . . . . . . . . . . . . . . . . . 19-6 LOAD LENGTHENED . . . . . . . . . . . 19-38
Signaling and Quiet NaNs . . . . . . . . 19-6 LOAD NEGATIVE . . . . . . . . . . . . . 19-38
BFP-Format Conversion . . . . . . . . . . . 19-7 LOAD POSITIVE . . . . . . . . . . . . . . 19-39
BFP Rounding . . . . . . . . . . . . . . . . 19-7 LOAD ROUNDED . . . . . . . . . . . . . 19-39
Rounding Mode . . . . . . . . . . . . . . 19-7 MULTIPLY . . . . . . . . . . . . . . . . . 19-40
Normalization and Denormalization . . . . 19-8 MULTIPLY AND ADD . . . . . . . . . . . 19-42
BFP Comparison . . . . . . . . . . . . . . . 19-8 MULTIPLY AND SUBTRACT . . . . . . . 19-42
Condition Codes for BFP Instructions . . . 19-9 SET FPC . . . . . . . . . . . . . . . . . . 19-44
Remainder . . . . . . . . . . . . . . . . . . 19-9 SET ROUNDING MODE . . . . . . . . . 19-44
IEEE Exception Conditions . . . . . . . . 19-10 SQUARE ROOT . . . . . . . . . . . . . . 19-45
IEEE Invalid Operation . . . . . . . . . 19-10 STORE FPC . . . . . . . . . . . . . . . . 19-45
IEEE Division-By-Zero . . . . . . . . . 19-11 SUBTRACT . . . . . . . . . . . . . . . . . 19-46
IEEE Overflow . . . . . . . . . . . . . . 19-11 TEST DATA CLASS . . . . . . . . . . . . 19-46
IEEE Underflow . . . . . . . . . . . . . 19-12

Special entities of infinity and


Binary-Floating-Point Facility Not-a-Number (NaN), which are accepted
The binary-floating-point (BFP) facility provides and handled by arithmetic operations in a rea-
instructions to operate on binary (radix-2) floating- sonable fashion. They provide better defaults
point data. for exponent overflow and invalid operations
(such as division of zero by zero). This allows
BFP provides a number of important advantages most programs to continue running without
over hexadecimal floating point (HFP): hiding such errors and without using special-
Greater precision and exponent range (except ized exception handlers.
for numbers in the short format where HFP Exponent underflow gives denormalized
has the greater range). numbers as the default, which provides more
Automatic rounding to the nearest value for all consistent results than the abrupt result of
arithmetic operations. There are directed- zero produced by the HFP instructions.
rounding options that may be used instead. The greater exponent range makes exponent
overflow and underflow in correctly written

Copyright IBM Corp. 1990, 2000 19-1


programs very unlikely, so that programmers left-to-right bit sequence, the standard only defines
may often be able to ignore these conditions. the meaning of the bits without specifying how
they appear in storage; the storage arrangement
Both mask and flag bits are provided for all
is left to the implementation. Several implementa-
arithmetic exception conditions. The mask
tions in fact use other sequences; this may affect
bits enable or disable interruptions. When
programs which are dependent on the bit repre-
interruptions are disabled, the flag bits keep
sentation of floating-point data in storage.
track of exception conditions during execution
so that warning messages may be issued.
Programs can be migrated from and to work-
Floating-Point-Control (FPC)
stations and other systems using different Register
architectures and still give consistent results,
provided that floating-point operations on the The floating-point-control (FPC) register is a 32-bit
other systems also conform to the IEEE register that contains mask bits, flag bits, a data-
standard. This does not mean, however, that exception code, and rounding-mode bits. An over-
bit-wise compatible results can be guaranteed, view of the FPC register is shown in Figure 19-1.
because the standard allows implementation Details are shown in Figure 19-2 on page 19-3
flexibility, especially in the presence of and in Figure 19-3 on page 19-3. (In
exceptions. Figure 19-2, the abbreviations IM and SF are
based on the terms interruption mask and status
Programming Note: The bit representation of flag, respectively.)
the BFP data formats in storage is defined to be
left-to-right in a manner that is uniform for all The bits of the FPC register are often referred to
numeric operands in the z/Architecture architec- as, for example, FPC 1.0, meaning bit 0 of byte 1
ture. Although the format diagrams in the IEEE of the register.
floating-point standard appear to use the same

%masks5 %flags5 %DXC5

I I I I I S S S S S
M M M M M F F F F F i z o u x y RM
i z o u x i z o u x

% Byte 5% Byte 1 5% Byte 2 5% Byte 3 5


Figure 19-1. FPC Register Overview

19-2 z/Architecture Principles of Operation


mask bits are ignored, and the flag bits remain
Byte Bit(s) Name Abbr.
unchanged, when arithmetic exceptions are recog-
0 0 IEEE-invalid-operation mask IMi nized for floating-point-support (FPS) and HFP
instructions.
0 1 IEEE-division-by-zero mask IMz
0 2 IEEE-overflow mask IMo The IEEE flag bits in the FPC register are set to
zero only by explicit program action, clear reset, or
0 3 IEEE-underflow mask IMu
power-on reset.
0 4 IEEE-inexact mask IMx
0 5-7 (Reserved) 0 FPC DXC Byte
Byte 2 of the FPC register contains the data-
1 0 IEEE-invalid-operation flag SFi exception code (DXC), which is an eight-bit code
1 1 IEEE-division-by-zero flag SFz indicating the specific cause of a data exception.
When the AFP-register-control bit, bit 45 of control
1 2 IEEE-overflow flag SFo register 0, is one and a program interruption
1 3 IEEE-underflow flag SFu causes the DXC to be placed at real location 147,
the DXC is also placed in the DXC field of the
1 4 IEEE-inexact flag SFx FPC register. The DXC field in the FPC register
1 5-7 (Reserved) 0 remains unchanged when the AFP-register-control
bit is zero or when any other program exception is
2 0-7 Data-exception code DXC
reported. The DXC is described in Data-
3 0-5 (Reserved) 0 Exception Code (DXC) on page 6-14.
3 6-7 Rounding mode RM
The DXC is a code, meaning it should be treated
as an integer rather than as individual bits.
Figure 19-2. FPC-Register Bit Assignments However, when bits 6 and 7 are zero, bits 0-5 are
bit significant; bits 0-4 (i,z,o,u,x) are trap flags and
correspond to the same bits in bytes 0 and 1 of
FPC the FPC register (IEEE masks and IEEE flags),
Byte 3 and bit 5 (y) is used in conjunction with bit 4,
Bits 6-7 Rounding Mode inexact (x), to indicate that the result has been
incremented in magnitude. The trap flag for an
00 Round to nearest
exception, instead of the IEEE flag, is set to one
01 Round toward 0 when an interruption for the exception is enabled
by the corresponding IEEE mask bit.
10 Round toward +
11 Round toward Operations on the FPC Register
The following unprivileged BFP instructions allow
Figure 19-3. Rounding Mode problem-state programs to operate on the FPC
register:
IEEE Masks and Flags EXTRACT FPC
The FPC register contains five IEEE mask bits LOAD FPC
and five IEEE flag bits that each correspond to SET FPC
one of the five arithmetic exception conditions that SET ROUNDING MODE
may occur when a BFP instruction is executed. STORE FPC
The masks bits, when one, cause an interruption
to occur if an exception condition is recognized. If These instructions are subject to the
the mask bit for an exception condition is zero, the AFP-register-control bit, bit 45 of control register 0.
recognition of the condition causes the corre- An attempt to execute any of the above
sponding flag bit to be set to one. Thus, a flag bit instructions when the AFP-register-control bit is
indicates whether the corresponding exception zero results in a BFP-instruction data exception,
condition has been recognized at least once since DXC 2.
the program last set the flag bit to zero. The

Chapter 19. Binary-Floating-Point Instructions 19-3


Biased Exponent
BFP Arithmetic For each format, the bias that is used to allow all
exponents to be expressed as unsigned numbers
BFP Data Formats is shown in the Figure 19-7 on page 19-5.
Biased exponents are similar to the characteristics
Binary-floating-point numbers and NaNs may be of the HFP format, except that special meanings
represented in any of three formats: short, long, or are attached to biased exponents of all zeros and
extended. all ones, which are discussed in the section
Classes of BFP Data on page 19-5.
BFP Short Format
Significand
/ In each format, the binary point of a BFP number
Exponent + 127 Fraction
S (8 bits) (23 bits) is considered to be to the left of the leftmost frac-
/ tion bit. To the left of the binary point there is an
1 9 31 implied unit bit, which is considered to be one for
normalized numbers and zero for zeros and
Figure 19-4. BFP Short Format (4 bytes)
denormalized numbers. The fraction with the
When a number or NaN in the BFP short format is implied unit bit appended on the left is the
loaded into a floating-point register, it occupies the significand of the number.
left half of the register, and the right half remains
The value of a normalized BFP number is the
unchanged.
significand multiplied by the radix 2 raised to the
power of the unbiased exponent. The value of a
BFP Long Format
denormalized BFP number is the significand multi-
/ plied by the radix 2 raised to the power of the
Exponent + 123 Fraction minimum exponent.
S (11 bits) (52 bits)
/ A value of one in the rightmost bit position of the
1 12 63 significand in each format is sometimes referred to
Figure 19-5. BFP Long Format (8 bytes) as one ulp (unit in the last place).

When a number or NaN in the BFP long format is Values of Nonzero Numbers
loaded into a floating-point register, it occupies the The values of nonzero numbers in the various
entire register. formats are shown in Figure 19-8.

BFP Extended Format


Number Class Format Value
/
Exponent + 16383 Fraction Normalized Short 2e127(1.f)
S (15 bits) (112 bits) Long 2e1023(1.f)
/
1 16 127 Extended 2e16383(1.f)
Figure 19-6. BFP Extended Format (16 bytes) Denormalized Short 2126(0.f)
Long 21022(0.f)
A number or NaN in the BFP extended format
occupies a register pair. The sign and biased Extended 216382(0.f)
exponent are in the leftmost 16 bits of the left reg- Explanation:
ister and are followed by the leftmost 48 bits of e Biased exponent (shown in decimal).
the fraction. The rightmost 64 bits of the fraction f Fraction (in binary).
are in the right register of the pair.
Figure 19-8. Values of Nonzero Numbers
The properties of the three formats are tabulated
in Figure 19-7 on page 19-5. Programming Note: The IEEE standard speci-
fies minimum requirements for the extended

19-4 z/Architecture Principles of Operation


Format
Property Short Long Extended
Format length (bits) 32 64 128
Biased-exponent length 8 11 15
(bits)
Fraction length (bits) 23 52 112
Precision (p) 24 53 113
Maximum exponent (Emax) 127 1023 16383
Minimum exponent (Emin) -126 -1022 -16382
Exponent bias 127 1023 16383
Nmax (1-2-24)2128 (1-2-53)21024 (1-2-113)216384
3.41038 1.810308 1.2104932
Nmin 1.02-126 1.02-1022 1.02-16382
1.210-38 2.210-308 3.410-4932
Dmin 1.02-149 1.02-1074 1.02-16494
1.410-45 4.910-324 6.510-4966
Explanation:
Value is approximate.
Dmin Smallest (in magnitude) representable denormalized number.
Nmax Largest (in magnitude) representable number.
Nmin Smallest (in magnitude) representable normalized number.

Figure 19-7. Summary of BFP Data Formats

format but does not include details. The BFP All finite nonzero numbers within the normalized
extended format meets these requirements, far range permitted by a given format have a unique
exceeding them in the area of precision. BFP representation. There are no unnormalized
numbers, which numbers might allow multiple
Classes of BFP Data representations for the same values, and there are
no unnormalized arithmetic operations. Tiny
There are six classes of BFP data, which include numbers of a magnitude below the minimum nor-
numeric and related nonnumeric entities. Each malized number in a given format are represented
data item consists of a sign, an exponent, and a as denormalized numbers, but those values are
significand. The exponent is biased such that all also represented uniquely. The implied unit bit of
biased exponents are nonnegative unsigned a normalized number is one, and that of a a
numbers and the minimum biased exponent is denormalized number or a zero is zero.
zero. The significand consists of an explicit frac-
The six classes of BFP data are summarized in
tion and an implicit unit bit to the left of the binary
Figure 19-9 on page 19-6.
point. The sign bit is zero for plus and one for
minus.

Chapter 19. Binary-Floating-Point Instructions 19-5


Biased Infinities
Data Class Sign Exponent Unit Bit* Fraction An infinity is represented by a biased exponent of
all ones and a zero fraction. Infinities can partic-
Zero 0 0 0
ipate in most arithmetic operations and give a con-
Denormalized 0** 0 Not 0 sistent result, usually infinity. In comparisons, +
numbers compares greater than any finite number, and
Normalized Not 0, not 1 Any compares less than any finite number.
numbers all ones
Infinity All ones 0 Signaling and Quiet NaNs
A NaN (not-a-number) entity is represented by a
Quiet NaN All ones F0=1,
Fr=any biased exponent of all ones and a nonzero frac-
tion. NaNs are produced in place of a numeric
Signaling NaN All ones F0=0, result after an invalid operation when there is no
Fr0
interruption. NaNs may also be used by the
Explanation: program to flag special operands, such as the
Does not apply. contents of an uninitialized storage area.
* The unit bit is implied.
** The biased exponent is treated arithmetically There are two types of NaNs, signaling and quiet.
as if it had the value one. A signaling NaN (SNaN) is distinguished from the
F0 Leftmost bit of fraction. corresponding quiet NaN (QNaN) by the leftmost
Fr Remaining bits of fraction. fraction bit: zero for the SNaN and one for the
NaN Not-a-number. QNaN. A special QNaN is supplied as the default
result for an IEEE-invalid-operation condition; it
Figure 19-9. Classes of BFP Data has a plus sign and a leftmost fraction bit of one,
with the remaining fraction bits being set to zeros.
The instruction TEST DATA CLASS may be used
to determine the class of a BFP operand. Normally, QNaNs are just propagated during com-
putations so that they will remain visible at the
Zeros end. An SNaN operand causes an
Zeros have a biased exponent of zero and a zero IEEE-invalid-operation exception. If the
fraction. The implied unit bit is zero. A +0 is dis- IEEE-invalid-operation mask (FPC 0.0) is zero, the
tinct from 0, except that comparison treats them result is the corresponding QNaN, which is
as equal. produced by setting the leftmost fraction bit to
one, and the IEEE-invalid-operation flag (FPC 1.0)
Denormalized Numbers is set to one. If the IEEE-invalid-operation mask
Denormalized numbers are numbers which are (FPC 0.0) is one, the operation is suppressed, and
smaller than the smallest normalized number and a data exception for IEEE-invalid operation occurs.
greater than zero in magnitude. They have a
biased exponent of zero and a nonzero fraction. Programming Notes:
The biased exponent is treated arithmetically as if 1. The program can generate and assign
it were one, which causes the exponent to be the meanings to any nonzero fraction values of a
minimum exponent. The implied unit bit is zero. NaN. The CPU propagates those values
unchanged, except that an SNaN is changed
Normalized Numbers to the corresponding QNaN if the
Normalized numbers have a biased exponent IEEE-invalid-operation mask bit is zero, and
greater than zero but less than all ones. The conversion to a narrower format may truncate
implied unit bit is one, and the fraction may have significant bits on the right.
any value.
2. The standard requires SNaNs to signal the
invalid-operation exception for the arithmetic,
comparison, and conversion operations that
are part of the standard, but it makes it an
implementation option whether copying an
SNaN without a change of format signals the

19-6 z/Architecture Principles of Operation


exception. In the appendix, the standard also When a denormalized number is converted to a
makes it an implementation option whether wider format, the biased exponent of the source
SNaNs should signal the invalid-operation operand is treated as if it had the value one. The
exception for the recommended functions of result is normalized.
copying the sign, taking the absolute value,
reversing the sign, and testing the data class Programming Notes:
of a number. 1. When a NaN is converted to a narrower
The above functions generally correspond to format, the appropriate number of fraction bits
the instructions LOAD, LOAD COMPLEMENT, on the right are simply dropped with no indi-
LOAD NEGATIVE, LOAD POSITIVE, and cation. This is unlike the conversion of
TEST DATA CLASS. These instructions do nonzero numbers, where the loss of nonzero
not signal the invalid-operation exception but, fraction bits causes an IEEE-inexact condition.
instead, treat SNaNs like any other data; Thus, programs which encode NaN fraction
giving an exception would be disruptive when bits for specific purposes must ensure that the
the intention is to include SNaNs. TEST distinguishing bits are placed in the left part of
DATA CLASS does not give an exception the fraction.
since it is the instruction with which to test for 2. Converting a NaN from a wide format to a
the presence of SNaNs. narrower format cannot turn the NaN into an
3. LOAD AND TEST signals the invalid-operation infinity because an SNaN either causes an
exception when the operand is an SNaN. interruption or turns into a QNaN, and all
This instruction, in conjunction with the above QNaNs have a leftmost fraction bit of one.
instructions, gives the program the choice of
either option permitted by the standard. BFP Rounding
4. Load-type instructions which change the preci-
sion signal the invalid-operation exception Arithmetic and conversion operations are per-
when the operand is an SNaN, as this is formed as if they first produced an intermediate
required by the standard. result correct to infinite precision and with
unbounded range. If this intermediate result can
be represented exactly in the target format, then it
BFP-Format Conversion is given exactly. Otherwise, the intermediate
result is replaced by one of the two closest values
The instructions LOAD LENGTHENED and LOAD
that can be represented, the choice depending on
ROUNDED perform conversions of numbers
the rounding mode.
between the short, long, and extended formats.
For BFP formats, conversion involves adjustments Rounding is performed automatically as part of
to both the fraction and the exponent. When con- every arithmetic and conversion operation. The
verting a normalized number to a wider format precision of the target (short, long, or extended) is
(short to long, long to extended, or short to specified by the operation code.
extended), the fraction is adjusted by appending
sufficient zeros on the right. Conversion to a nar-
Rounding Mode
rower format requires rounding of the fraction
There are four rounding modes. The current
before dropping excess bits on the right, and an
rounding mode is specified by the value of two
IEEE-inexact condition may result.
rounding-mode bits in the FPC register, as follows:
The exponent is adjusted by adding or subtracting 00 Round to nearest (default). Round the inter-
the difference in the biases of the two formats. mediate result up or down to the nearest
When converting to a narrower format, this adjust- representable value; that is, add, ignoring
ment causes IEEE underflow if the resultant the sign, a one to the bit just beyond the last
biased exponent would be less than one, or IEEE result bit to be retained, propagate the carry,
overflow if the resultant exponent would be equal and discard the bits beyond the last one to
to or greater than the maximum exponent for the be retained. If the difference was exactly
new format. one-half ulp (a one in the bit position just
beyond the last place, with all zeros beyond

Chapter 19. Binary-Floating-Point Instructions 19-7


that), the nearest even number is chosen; while introducing zero bits on the left, and in
that is, after the rounding addition, the last increasing the exponent by one for each bit of
result bit retained is set to zero. shift. When the biased exponent reaches +1, the
significand is rounded according to the current
If the absolute value of the intermediate
rounding mode. If all bits of the rounded
result is equal to or greater than the largest
significand are zeros, the result is made zero. If
representable number plus one-half ulp, that
rounding produces a carry into the units bit posi-
is, if the absolute value is equal to or greater
tion of the significand, the biased exponent
than 2Emax (2 2 p), the result is rounded to
remains +1, since this result is a normalized
infinity with the same sign as the interme-
number (2Emin). Otherwise, the units bit remains
diate result.
zero, the biased exponent is set to zero, and the
01 Round toward 0. Discard all bits to the right result is considered denormalized.
of the last intermediate-result bit to be
retained. Arithmetic operations on denormalized operands
are performed as if the operands had first been
10 Round toward +. If the intermediate result
normalized.
is positive and there are any ones to the
right of the last result bit to be retained, add
Intermediate results are first normalized or denor-
one to that bit. Then, for either sign, discard
malized, as required, and then rounded. This
the bits beyond the last one to be retained.
avoids double rounding of a single operation,
11 Round toward . If the intermediate result which might increase the rounding error. (Any
is negative and there are any ones to the right shift required after a carry from rounding to
right of the last result bit to be retained, sub- renormalize the result does not require a second
tract one from that bit (that is, add one to the rounding, because the bit shifted off on the right is
magnitude). Then, for either sign, discard always zero.)
the bits beyond the last one to be retained.

Programming Notes:
BFP Comparison
1. Rounding a finite result toward zero cannot Comparisons are always exact and cannot cause
give infinity. an IEEE-inexact condition.
2. Rounding a result toward + can give + but
Comparison ignores the sign of zero, that is, +0
not .
equals 0.
3. Rounding a result toward can give but
not +. Infinities with like sign compare equal, that is, +
equals +, and equals .
Normalization and A NaN compares as unordered with any other
Denormalization operand, whether a finite number, an infinity, or
another NaN, including itself.
Every arithmetic or conversion operation is consid-
ered to produce an intermediate result as if the Two sets of instructions are provided: COMPARE
precision and exponent range were unbounded, and COMPARE AND SIGNAL. In the absence of
unless the result is defined to be zero, infinity, or QNaNs, these instructions work the same. These
NaN. The final result is produced by normalizing instructions work differently only when both of the
and then rounding this intermediate result. When following are true:
there is exponent underflow, that is, the biased
Neither operand of the instruction is an SNaN
exponent of the normalized intermediate result is
less than one, then the intermediate result is At least one operand of the instruction is a
denormalized to produce the final result, as QNaN
described below.
In this case, COMPARE simply sets condition
code 3, but COMPARE AND SIGNAL recognizes
Denormalization consists in shifting the
the IEEE-invalid-operation condition. If any
significand, including the units bit, to the right

19-8 z/Architecture Principles of Operation


operand is an SNaN, both instructions recognize Remainder
the IEEE-invalid-operation condition.
The instruction DIVIDE TO INTEGER produces
The action when the IEEE-invalid-operation condi-
two floating-point results, an exact integer quotient
tion is recognized depends on the
and the corresponding remainder. The remainder
IEEE-invalid-operation mask bit in the FPC reg-
is defined as follows:
ister. If the mask bit is zero, then the instruction
execution is completed by setting condition code Let
3, and the IEEE-invalid-operation flag in the FPC
register is set to one. If the mask bit is one, then a = Dividend
b = Divisor
the condition is reported as a program interruption
q = Exact quotient (ab)
for a data exception with DXC 80 hex (IEEE
r = Remainder
invalid operation).
in the selected floating-point format. Then
Programming Note: A compiler can select either r = abn
COMPARE or COMPARE AND SIGNAL for a
comparison, depending on whether the IEEE where n is an integer. If q is an integer, then n
standard or a relevant language standard requires equals q. Otherwise, n is obtained by rounding q
a QNaN to be recognized as an exception condi- according to a specified quotient rounding mode.
tion.
When the specified quotient rounding mode is
round to nearest or round toward zero, the
Condition Codes for BFP remainder is exact for any finite dividend and any
Instructions nonzero divisor. The remainder cannot overflow.

For arithmetic operations with finite or infinite If the integer quotient has a value that lies outside
numeric results, condition codes 0, 1, and 2 are the range of the operand format, a wrapped result
set to indicate that the result is a zero of either is provided.
sign, less than zero, or greater than zero, respec-
tively. The condition-code setting depends only In certain cases where the number of bits in the
on an inspection of the rounded result. For com- integer quotient exceeds or may exceed the
parison operations, condition codes 0, 1, and 2 maximum number of bits provided in the precision
indicate equal, low, or high, respectively. These of the operand format, partial results are
settings are the same as for the HFP instructions. produced, and more than one execution of the
instruction is required to obtain the final result; this
Condition code 3 can also be set. After an arith- may be done with a simple instruction loop.
metic operation, condition code 3 indicates a NaN
result of either sign. After a comparison, it indi- Partial results are produced when the precise quo-
cates that a NaN was involved in the comparison tient is not an integer and the two integers closest
(the unordered condition). See Figure 19-10. to this precise quotient cannot both be repres-
ented exactly in the precision of the quotient. This
situation exists when the precise quotient is
CC Arithmetic Comparison greater than 2P, where P is the precision of the
operand format, and the remainder is not zero.
0 0 Equal
1 <0 Low
When the remainder is zero, then the quotient is
2 >0 High an integer, and the number of bits required to rep-
3 NaN Unordered resent the quotient is never more than the preci-
sion of the target.
Figure 19-10. Condition Codes Programming Note: The remainder result of
DIVIDE TO INTEGER with a specified quotient
rounding mode of round to nearest corresponds to
the Remainder function in the IEEE standard.
This function is similar to the MOD function found
in some languages and to the mathematical

Chapter 19. Binary-Floating-Point Instructions 19-9


modulo function, but they are not the same. They IEEE Exception Conditions
differ in the definition of n:
Remainder n is q rounded to nearest. The results of each of the IEEE exception condi-
modulo n is q rounded toward . tions are controlled by a mask bit in the FPC reg-
MOD n is q rounded toward 0. ister. When an IEEE exception condition is
recognized, one of two actions is taken:
Another important difference is that implementa-
If the corresponding mask bit in the FPC reg-
tions of modulo and MOD may put range
ister is zero, a default action is taken, as
restrictions on the result because they may simply
specified for each condition, and the corre-
use the DIVIDE instruction and accept its range
sponding flag bit in the FPC register is set to
restrictions.
one. Program execution then continues
normally.
The MOD definition provides an exact result, as
does Remainder, but the modulo definition may If the corresponding mask bit in the FPC reg-
result in rounding errors. ister is one, a program interruption for a data
exception occurs, the operation is suppressed
The differences between the various methods may or completed, depending on the condition, and
be illustrated by the simple example of computing the data-exception code (DXC) assigned for
a divided by b to obtain an integer quotient n, that condition is provided.
where a is a series of integers, and b is +4 or 4.
Figure 19-11 on page 19-11 shows the results for IEEE Invalid Operation
the three definitions. An IEEE-invalid-operation condition is recognized
when, in the execution of a BFP instruction, any of
The result of Remainder lies in the range of zero the following occurs:
to one-half the divisor, inclusive, in magnitude. A
zero result is defined to have the sign of the divi- 1. An SNaN is encountered in any BFP arith-
dend. A zero divisor is invalid. metic, comparison, or conversion operation or
by LOAD AND TEST.
The modulo and MOD results can both be com- 2. A QNaN is encountered in a BFP comparison
puted from the Remainder result; the reverse may by COMPARE AND SIGNAL.
not be true, because of rounding errors and,
depending on the implementation, range 3. A BFP difference is undefined (addition of
restrictions. infinities of opposite sign, or subtraction of
infinities of like sign).
An extreme example of the rounding error that can 4. A BFP product is undefined (zero times
occur with the modulo definition is the following, infinity).
where the result is restricted to two significant
decimal digits: 5. A BFP quotient is undefined (DIVIDE instruc-
tion with both operands zero or both operands
modulo(.1,-95) = -94.99, which rounds to -95 infinity).
Remainder(.1,-95) = .1 6. A BFP remainder is undefined (DIVIDE TO
INTEGER with a dividend of infinity or a
The properly rounded modulo result is completely
divisor of zero).
wrong since it is equal to the divisor instead of
being smaller in magnitude. The Remainder result 7. A BFP square root is undefined (negative
is exact and can be used to compute the theore- nonzero operand).
tical result of modulo.
If the IEEE-invalid-operation mask bit in the FPC
Remainder is included as an arithmetic operation register is zero, the IEEE-invalid-operation flag bit
because of its usefulness in argument reduction in the FPC register is set to one. The completion
when computing elementary transcendental func- of the operation depends on the type of operation
tions. Thus, SIN(X) can be computed to full preci- and the operands.
sion for any value of X in degrees by first reducing
the argument to Remainder(X,360).

19-10 z/Architecture Principles of Operation



a
-8 -7 -6 -5 -4 -3 -2 -1 - + +1 +2 +3 +4 +5 +6 +7 +8

Remainder
b=+4: n -2 -2 -2 -1 -1 -1 - - - + + + +1 +1 +1 +2 +2 +2
r - +1 +2 -1 - 1 -2 -1 - + +1 +2 -1 + +1 -2 -1 +
b=-4: n +2 +2 +2 +1 +1 +1 + + + - - - -1 -1 -1 -2 -2 -2
r - +1 +2 -1 - +1 -2 -1 - + +1 +2 -1 + +1 -2 -1 +

MOD
b=+4: n -2 -1 -1 -1 -1 +1 +1 +1 +1 +2
r -3 -2 -1 -3 -2 -1 +1 +2 +3 +1 +2 +3
b=-4: n +2 +1 +1 +1 +1 -1 -1 -1 -1 -2
r -3 -2 -1 -3 -2 -1 +1 +2 +3 +1 +2 +3

modulo
b=+4: n -2 -2 -2 -2 -1 -1 -1 -1 +1 +1 +1 +1 +2
r +1 +2 +3 +1 +2 +3 +1 +2 +3 +1 +2 +3
b=-4: n +2 +1 +1 +1 +1 -1 -1 -1 -1 -2 -2 -2 -2
r -3 -2 -1 -3 -2 -1 -3 -2 -1 -3 -2 -1

Explanation:

a Dividend.
b Divisor.
n Integer quotient.
r Result (Remainder, MOD, or modulo).

Figure 19-11. Comparison of Remainder with MOD and Modulo

If the instruction performs a comparison and no sign that is the EXCLUSIVE OR of the dividend
program interruption occurs, the comparison result and divisor signs.
is unordered.
If the IEEE-division-by-zero mask bit in the FPC
If the instruction is one that produces a BFP register is one, the operation is suppressed, and
result, if no program interruption occurs, and if the condition is reported as a program interruption
none of the operands is a NaN, the result is the for a data exception with DXC 40 hex.
default QNaN. If one of the operands is a NaN,
that operand becomes the result unchanged, IEEE Overflow
except that an SNaN is first converted to the cor- An IEEE-overflow condition is recognized when
responding QNaN by setting the leftmost fraction the exponent of the rounded result of a BFP oper-
bit to one. ation would be greater than the maximum expo-
nent of the target format if the exponent range
If the IEEE-invalid-operation mask bit in the FPC were unbounded.
register is one, the operation is suppressed, and
the condition is reported as a program interruption If the IEEE-overflow mask bit in the FPC register
for a data exception with DXC 80 hex. is zero, the IEEE-overflow flag bit in the FPC reg-
ister is set to one. The result of the operation
IEEE Division-By-Zero depends on the sign of the intermediate result and
An IEEE-division-by-zero condition is recognized on the current rounding mode:
when in BFP division the divisor is zero and the
1. When rounding to nearest, the result is infinity
dividend is a finite nonzero number.
with the sign of the intermediate result.
If the IEEE-division-by-zero mask bit in the FPC 2. When rounding toward 0, the result is the
register is zero, the IEEE-division-by-zero flag bit largest finite number of the format, with the
in the FPC register is set to one. The operation is sign of the intermediate result.
completed using as the result an infinity with a

Chapter 19. Binary-Floating-Point Instructions 19-11


3. When rounding toward +, the result is + if IEEE Inexact
the sign is plus, or it is the finite negative An IEEE-inexact condition is recognized when the
number with the largest magnitude if the sign rounded result of a BFP operation differs in value
is minus. from the intermediate result computed as if expo-
4. When rounding toward , the result is the nent range and precision were unbounded. The
largest finite positive number if the sign is plus condition is also recognized if rounding the result
or if the sign is minus. causes IEEE overflow and the IEEE-overflow
mask bit is zero. The operation is completed
If the IEEE-overflow mask bit in the FPC register using the rounded result or, in case of overflow or
is one, the operation is completed by producing a underflow, the result specified for IEEE overflow or
wrapped result, and the condition is reported as a IEEE underflow.
program interruption for a data exception with
DXC 20, 28, or 2C hex, depending on whether the If the IEEE-inexact mask bit in the FPC register is
wrapped result is exact, inexact and truncated, or zero, the IEEE-inexact flag bit in the FPC register
inexact and incremented, respectively. is set to one.

If the IEEE-inexact mask bit in the FPC register is


IEEE Underflow
one, the operation is completed, and the condition
An IEEE-underflow condition is recognized when
is reported as a program interruption for a data
the exponent of the exact result of a BFP opera-
exception with DXC 08 or 0C hex, depending on
tion would be less than the minimum exponent of
whether the result is inexact and truncated or
the target format.
inexact and incremented, respectively.
If the IEEE-underflow mask bit in the FPC register
Programming Notes:
is zero, then the action depends on whether the
result can be represented exactly and, if not, also 1. All IEEE traps are reported by means of a
on the setting of the IEEE-inexact mask bit in the program interruption for a data exception with
FPC register. If the result can be represented a data-exception code. The use of data
exactly, the operation is completed by denormal- exception provides the application program
izing the intermediate result. If the result cannot with a convenient interface since this excep-
be represented exactly and the IEEE-inexact mask tion is one of the original 15 exceptions in the
bit in the FPC register is zero, the operation is System/360 architecture and is supported by
completed by denormalizing and rounding the most control programs that support the
intermediate result, and the IEEE-underflow and ESA/390 architecture.
IEEE-inexact flag bits in the FPC register are set
2. The IEEE standard includes recommendations
to ones. If the result cannot be represented
for the trap handler. When a system traps,
exactly and the IEEE-inexact mask bit in the FPC
the trap handler should be able to determine:
register is one, the IEEE-underflow flag bit in the
FPC register is set to one, and the inexact condi- a. Which exception(s) occurred on this oper-
tion is reported as a program interruption for a ation.
data exception with DXC 08 or 0C hex, depending b. The kind of operation that was being per-
on whether the result is inexact and truncated or formed.
inexact and incremented, respectively.
c. The destination's format.
If the IEEE-underflow mask bit in the FPC register d. For overflow, underflow, and inexact
is one, then, regardless of whether the result exceptions, the correctly rounded result,
could have been represented exactly, the opera- including information that might not fit in
tion is completed by producing a wrapped result, the destination's format.
and the condition is reported as a program inter-
ruption for a data exception with DXC 10, 18, or e. For invalid-operation and divide-by-zero
1C hex, depending on whether the wrapped result exceptions, the operand values.
is exact, inexact and truncated, or inexact and Items a and d are supplied as part of the
incremented, respectively. interruption action. Items b, c, and e can be
obtained starting with the instruction address

19-12 z/Architecture Principles of Operation


in the old PSW and from this finding the rounded intermediate value, which is
instruction (which indicates the operation and obtained by rounding the precise interme-
format) and then the operands. diate value to the precision of the result
but with unbounded exponent range.
3. The description of underflow is one of the
Inexact result is said to occur when the
most difficult parts of the standard to under-
delivered result differs from the precise
stand. This is because:
intermediate value. Denormalization loss
a. The condition is described as two corre- is said to occur when the delivered result
lated events tininess and loss of differs from the rounded intermediate
accuracy. value. The two options differ in the case
b. For tininess, the standard provides two when the delivered result is equal in value
options for detection: after rounding or to the rounded intermediate value but
before rounding. these are not equal to the precise interme-
diate value. Although the standard uses
c. For loss of accuracy, the standard pro- the term denormalization loss, this condi-
vides two options for detection: denormal- tion includes a case in which the delivered
ization loss or inexact result. result is normalized.
d. Implementation of the trap is optional. The option selected in the ESA/390 BFP
e. The conditions to signal underflow are dif- architecture (and the RS/6000) is to detect
ferent depending on whether or not the loss of accuracy as an inexact result.
trap is taken. d. Although the standard does not require
Each of the above items is discussed below. traps to be implemented for underflow or
the other arithmetic exceptions, it does
a. Tininess refers to a nonzero number state that with each exception should be
strictly between 2Emin. (All denormalized associated a trap under user control.
numbers are in this range.) Loss of accu- Since it also defines should as that
racy means that the result cannot be which is strongly recommended as being
represented exactly. in keeping with the intent of the standard,
b. Detection of tininess after or before the ESA/390 BFP architecture provides
rounding differs only for the case when traps by means of program interruptions.
rounding would increase the magnitude e. When the underflow trap is enabled,
of the result to exactly 2Emin. It must be underflow is to be signaled when tininess
noted, however, that the action which the is detected regardless of loss of accuracy.
standard here calls rounding is not the When the underflow trap is not enabled,
rounding to produce the delivered result the underflow flag bit is to be set only
but rounding to compute an intermediate when both tininess and loss of accuracy
value having the precision of the result but have been detected. Add and subtract
as though the exponent range were can result in tiny or inexact results, but not
unbounded. In fact, it is possible that the both. Thus, when underflow is disabled,
delivered result may not be tiny even add and subtract never set the underflow
though the intermediate value after flag bit.
rounding is tiny.
The option selected in the ESA/390 BFP
architecture (and the RS/6000) is to detect Result Figures
tininess before rounding. Concise descriptions of the results produced by
c. The difference between detection of loss many of the BFP instructions are made by means
of accuracy as a denormalization loss or of figures which contain columns and rows repres-
as an inexact result can best be under- enting all possible combinations of BFP data class
stood by considering two intermediate for the source operands of an instruction. The
values: (1) a precise intermediate value, information shown at the intersection of a row and
which has unbounded precision and a column is one or more symbols representing the
unbounded exponent range, and (2) a result or results produced for that particular combi-

Chapter 19. Binary-Floating-Point Instructions 19-13


nation of source-operand data classes. Explana- symbols Xi: and Xz: that are used in the
tions of the symbols used are contained in each figures. Bits 0-4 (i,z,o,u,x) of the eight-bit data-
figure. In many cases, the explanation of a partic- exception code (DXC) in byte 2 of the FPC reg-
ular result is in the form of a cross reference to ister are trap flags and correspond to the same
another figure. In many cases, the information bits in bytes 0 and 1 of the register (IEEE masks
shown at the intersection consists of several and IEEE flags). The trap flag for an exception,
symbols separated by commas. All such results instead of the IEEE flag, is set to one when an
are produced unless one of the results is a interruption for the exception is enabled by the
program interruption. In the case of a program corresponding IEEE mask bit. Bit 5 of byte 2 (y)
interruption, the operation is suppressed or com- is used in conjunction with bit 4, inexact (x), to
pleted as shown in Figure 19-13. indicate that the result has been incremented in
magnitude.
Data-Exception Codes (DXC) and Figure 19-13 shows the various DXCs that can be
Abbreviations indicated, the associated instruction endings, and
abbreviations that are used for the DXCs in the
Figure 19-12 on page 19-15 shows IEEE result figures. (The abbreviation PID stands for
exception-condition and flag abbreviations that are program interruption for a data exception.)
used in the result figures, and it explains the

DXC
Abbr. (Hex) Data-Exception-Code Name Instruction Ending
PIDx 08 IEEE inexact and truncated Complete
PIDy 0C IEEE inexact and incremented Complete
PIDu 10 IEEE underflow, exact Complete, wrap exponent
PIDux 18 IEEE underflow, inexact and truncated Complete, wrap exponent
PIDuy 1C IEEE underflow, inexact and incremented Complete, wrap exponent
PIDo 20 IEEE overflow, exact Complete, wrap exponent
PIDox 28 IEEE overflow, inexact and truncated Complete, wrap exponent
PIDoy 2C IEEE overflow, inexact and incremented Complete, wrap exponent
PIDz 40 IEEE division by zero Suppress
PIDi 80 IEEE invalid operation Suppress

Figure 19-13. IEEE Data-Exception Codes (DXC) and Abbreviations

fully, the AFP-register-control bit must be one; oth-


Instructions erwise, a BFP-instruction data exception, DXC 2,
The BFP instructions and their mnemonics and is recognized.
operation codes are listed in Figure 19-14 on
page 19-16. The figure indicates, in the column Mnemonics for the BFP instructions are distin-
labeled Characteristics, the instruction format, guished from the corresponding HFP instructions
when the condition code is set, the instruction by a B in the mnemonic. Mnemonics for the BFP
fields that designate access registers, and the instructions have an R as the last letter when the
exceptional conditions in operand designations, instruction is in the RRE or RRF format. Certain
data, or results that cause a program interruption. letters are used for BFP instructions to represent
operand-format length, as follows:
All BFP instructions are subject to the
F Thirty-two-bit fixed point
AFP-register-control bit, bit 45 of control register 0.
G Sixty-four-bit fixed point
For the BFP instructions to be executed success-
D Long

19-14 z/Architecture Principles of Operation


E Short
X Extended
Exception Condition FPC IEEE Flag
IEEE Note: In the detailed descriptions of the indi-
Mask FPC vidual instructions, the mnemonic and the sym-
Name Abbr. Bit Bit Abbr. bolic operand designation for the assembler
language are shown with each instruction. For a
IEEE invalid operation Xi 0.0 1.0 SFi
register-to-register operation using COMPARE
IEEE division by zero Xz 0.1 1.1 SFz (short), for example, CEBR is the mnemonic and
R,R the operand designation.
IEEE overflow Xo 0.2 1.2 SFo
IEEE underflow Xu 0.3 1.3 SFu
IEEE inexact Xx 0.4 1.4 SFx
Explanation:
The symbol Xi: followed by a list of results
in a figure indicates that, when FPC 0.0 is
zero, then instruction execution is completed
by setting SFi (FPC 1.0) to one and
producing the indicated results; and when
FPC 0.0 is one, then instruction execution is
suppressed, the data exception code (DXC)
is set to 80 hex, and a program interruption
for a data exception occurs.
The symbol Xz: followed by a list of results
in a figure indicates that, when FPC 0.1 is
zero, then instruction execution is completed
by setting SFz (FPC 1.1) to one and
producing the indicated results; and when
FPC 0.1 is one, then instruction execution is
suppressed, the data exception code (DXC)
is set to 40 hex, and a program interruption
for a data exception occurs.

Figure 19-12. IEEE Exception-Condition and Flag


Abbreviations

Chapter 19. Binary-Floating-Point Instructions 19-15



Mne- Op
Name monic Characteristics Code

ADD (extended BFP) AXBR RRE C SPDb Xi Xo Xu Xx B34A


ADD (long BFP) ADBR RRE C Db Xi Xo Xu Xx B31A
ADD (long BFP) ADB RXE C A Db Xi Xo Xu Xx BED1A
ADD (short BFP) AEBR RRE C Db Xi Xo Xu Xx B3A
ADD (short BFP) AEB RXE C A Db Xi Xo Xu Xx BEDA

COMPARE (extended BFP) CXBR RRE C SPDb Xi B349


COMPARE (long BFP) CDBR RRE C Db Xi B319
COMPARE (long BFP) CDB RXE C A Db Xi BED19
COMPARE (short BFP) CEBR RRE C Db Xi B39
COMPARE (short BFP) CEB RXE C A Db Xi BED9

COMPARE AND SIGNAL (extended BFP) KXBR RRE C SPDb Xi B348


COMPARE AND SIGNAL (long BFP) KDBR RRE C Db Xi B318
COMPARE AND SIGNAL (long BFP) KDB RXE C A Db Xi BED18
COMPARE AND SIGNAL (short BFP) KEBR RRE C Db Xi B38
COMPARE AND SIGNAL (short BFP) KEB RXE C A Db Xi BED8

CONVERT FROM FIXED (32 to ext. BFP) CXFBRRRE SPDb B396


CONVERT FROM FIXED (32 to long BFP) CDFBRRRE Db B395
CONVERT FROM FIXED (32 to short BFP)CEFBRRRE Db Xx B394
CONVERT FROM FIXED (64 to ext. BFP) CXGBRRRE N SPDb B3A6
CONVERT FROM FIXED (64 to long BFP) CDGBRRRE N Db Xx B3A5

CONVERT FROM FIXED (64 to short BFP)CEGBRRRE N Db Xx B3A4


CONVERT TO FIXED (ext. BFP to 32) CFXBRRRF C SPDb Xi Xx B39A
CONVERT TO FIXED (long BFP to 32) CFDBRRRF C SPDb Xi Xx B399
CONVERT TO FIXED (short BFP to 32) CFEBRRRF C SPDb Xi Xx B398
CONVERT TO FIXED (ext. BFP to 64) CGXBRRRF C N SPDb Xi Xx B3AA

CONVERT TO FIXED (long BFP to 64) CGDBRRRF C N SPDb Xi Xx B3A9


CONVERT TO FIXED (short BFP to 64) CGEBRRRF C N SPDb Xi Xx B3A8
DIVIDE (extended BFP) DXBR RRE SPDb Xi Xz Xo Xu Xx B34D
DIVIDE (long BFP) DDBR RRE Db Xi Xz Xo Xu Xx B31D
DIVIDE (long BFP) DDB RXE A Db Xi Xz Xo Xu Xx BED1D

DIVIDE (short BFP) DEBR RRE Db Xi Xz Xo Xu Xx B3D


DIVIDE (short BFP) DEB RXE A Db Xi Xz Xo Xu Xx BEDD
DIVIDE TO INTEGER (long BFP) DIDBRRRF C SPDb Xi Xu Xx B35B
DIVIDE TO INTEGER (short BFP) DIEBRRRF C SPDb Xi Xu Xx B353
EXTRACT FPC EFPC RRE Db B38C

LOAD AND TEST (extended BFP) LTXBRRRE C SPDb Xi B342


LOAD AND TEST (long BFP) LTDBRRRE C Db Xi B312
LOAD AND TEST (short BFP) LTEBRRRE C Db Xi B32
LOAD COMPLEMENT (extended BFP) LCXBRRRE C SPDb B343
LOAD COMPLEMENT (long BFP) LCDBRRRE C Db B313

Figure 19-14 (Part 1 of 3). Summary of BFP Instructions

19-16 z/Architecture Principles of Operation



Mne- Op
Name monic Characteristics Code

LOAD COMPLEMENT (short BFP) LCEBRRRE C Db B33


LOAD FP INTEGER (extended BFP) FIXBRRRF SPDb Xi Xx B347
LOAD FP INTEGER (long BFP) FIDBRRRF SPDb Xi Xx B35F
LOAD FP INTEGER (short BFP) FIEBRRRF SPDb Xi Xx B357
LOAD FPC LFPC S A SPDb BB29D

LOAD LENGTHENED (long to ext. BFP) LXDBRRRE SPDb Xi B35


LOAD LENGTHENED (long to ext. BFP) LXDB RXE A SPDb Xi BED5
LOAD LENGTHENED (short to ext. BFP) LXEBRRRE SPDb Xi B36
LOAD LENGTHENED (short to ext. BFP) LXEB RXE A SPDb Xi BED6
LOAD LENGTHENED (short to long BFP) LDEBRRRE Db Xi B34

LOAD LENGTHENED (short to long BFP) LDEB RXE A Db Xi BED4


LOAD NEGATIVE (extended BFP) LNXBRRRE C SPDb B341
LOAD NEGATIVE (long BFP) LNDBRRRE C Db B311
LOAD NEGATIVE (short BFP) LNEBRRRE C Db B31
LOAD POSITIVE (extended BFP) LPXBRRRE C SPDb B34

LOAD POSITIVE (long BFP) LPDBRRRE C Db B31


LOAD POSITIVE (short BFP) LPEBRRRE C Db B3
LOAD ROUNDED (extended to long BFP) LDXBRRRE SPDb Xi Xo Xu Xx B345
LOAD ROUNDED (extended to short BFP)LEXBRRRE SPDb Xi Xo Xu Xx B346
LOAD ROUNDED (long to short BFP) LEDBRRRE Db Xi Xo Xu Xx B344

MULTIPLY (extended BFP) MXBR RRE SPDb Xi Xo Xu Xx B34C


MULTIPLY (long BFP) MDBR RRE Db Xi Xo Xu Xx B31C
MULTIPLY (long BFP) MDB RXE A Db Xi Xo Xu Xx BED1C
MULTIPLY (long to extended BFP) MXDBRRRE SPDb Xi B37
MULTIPLY (long to extended BFP) MXDB RXE A SPDb Xi BED7

MULTIPLY (short BFP) MEEBRRRE Db Xi Xo Xu Xx B317


MULTIPLY (short BFP) MEEB RXE A Db Xi Xo Xu Xx BED17
MULTIPLY (short to long BFP) MDEBRRRE Db Xi B3C
MULTIPLY (short to long BFP) MDEB RXE A Db Xi BEDC
MULTIPLY AND ADD (long BFP) MADBRRRF Db Xi Xo Xu Xx B31E

MULTIPLY AND ADD (long BFP) MADB RXF A Db Xi Xo Xu Xx BED1E


MULTIPLY AND ADD (short BFP) MAEBRRRF Db Xi Xo Xu Xx B3E
MULTIPLY AND ADD (short BFP) MAEB RXF A Db Xi Xo Xu Xx BEDE
MULTIPLY AND SUBTRACT (long BFP) MSDBRRRF Db Xi Xo Xu Xx B31F
MULTIPLY AND SUBTRACT (long BFP) MSDB RXF A Db Xi Xo Xu Xx BED1F

MULTIPLY AND SUBTRACT (short BFP) MSEBRRRF Db Xi Xo Xu Xx B3F


MULTIPLY AND SUBTRACT (short BFP) MSEB RXF A Db Xi Xo Xu Xx BEDF
SET FPC SFPC RRE SPDb B384
SET ROUNDING MODE SRNM S Db B299
SQUARE ROOT (extended BFP) SQXBRRRE SPDb Xi Xx B316

Figure 19-14 (Part 2 of 3). Summary of BFP Instructions

Chapter 19. Binary-Floating-Point Instructions 19-17



Mne- Op
Name monic Characteristics Code

SQUARE ROOT (long BFP) SQDBRRRE Db Xi Xx B315


SQUARE ROOT (long BFP) SQDB RXE A Db Xi Xx BED15
SQUARE ROOT (short BFP) SQEBRRRE Db Xi Xx B314
SQUARE ROOT (short BFP) SQEB RXE A Db Xi Xx BED14
STORE FPC STFPCS A Db ST BB29C

SUBTRACT (extended BFP) SXBR RRE C SPDb Xi Xo Xu Xx B34B


SUBTRACT (long BFP) SDBR RRE C Db Xi Xo Xu Xx B31B
SUBTRACT (long BFP) SDB RXE C A Db Xi Xo Xu Xx BED1B
SUBTRACT (short BFP) SEBR RRE C Db Xi Xo Xu Xx B3B
SUBTRACT (short BFP) SEB RXE C A Db Xi Xo Xu Xx BEDB

TEST DATA CLASS (extended BFP) TCXB RXE C SPDb ED12


TEST DATA CLASS (long BFP) TCDB RXE C Db ED11
TEST DATA CLASS (short BFP) TCEB RXE C Db ED1

Explanation:

A Access exceptions for logical addresses.
B B field designates an access register in the access-register mode.
BF BFP facility.
C Condition code is set.
Db BFP-instruction data exception.
N Instruction is new in z/Architecture as compared to ESA/39.
RRE RRE instruction format.
RRF RRF instruction format.
RXE RXE instruction format.
RXF RXF instruction format.
SP Specification exception.
ST PER storage-alteration event.
Xi IEEE invalid-operation condition.
Xo IEEE overflow condition.
Xu IEEE underflow condition.
Xx IEEE inexact condition.
Xz IEEE division-by-zero condition.

Figure 19-14 (Part 3 of 3). Summary of BFP Instructions

ADD Mnemonic2 R,D(X,B) [RXE]

/
Mnemonic1 R,R [RRE] Op Code R X B D ////////Op Code
/
8 12 16 2 32 4 47
Op Code //////// R R
Mnemonic2 Op Code Operands
16 24 28 31 AEB 'EDA' Short BFP
ADB 'ED1A' Long BFP
Mnemonic1 Op Code Operands
AEBR 'B3A' Short BFP
ADBR 'B31A' Long BFP
AXBR 'B34A' Extended BFP

19-18 z/Architecture Principles of Operation


The second operand is added to the first operand, Program Exceptions:
and the sum is placed at the first-operand
Access (fetch, operand 2 of AEB and ADB
location.
only)
Data with DXC 2, BFP instruction
If both operands are numeric and finite, they are
Data with DXC for IEEE exception condition
added algebraically, forming an intermediate sum.
Operation (if the BFP facility is not installed)
The intermediate sum, if nonzero, is normalized
Specification (AXBR only)
and rounded to the operand format according to
the current rounding mode. The sum is then Programming Note: Interchanging the two oper-
placed at the result location. ands in a BFP addition does not affect the value
of the sum when the result is numeric. This is not
The sign of the sum is determined by the rules of true, however, when both operands are QNaNs, in
algebra. This also applies to a result of zero: which case the result is the first operand; or when
If the result of rounding a nonzero interme- both operands are SNaNs and the
diate sum is zero, the sign of the zero result is IEEE-invalid-operation mask bit in the FPC reg-
the sign of the intermediate sum. ister is zero, in which case the result is the QNaN
derived from the first operand.
If the sum of two operands with opposite signs
is exactly zero, the sign of the result is plus in
all rounding modes except round toward ,
Value of Result (r) Condition Code
in which mode the sign is minus.
r=0 cc0
The sign of the sum x plus x is the sign of x,
even when x is zero. r<0 cc1
r>0 cc2
If one operand is an infinity and the other is finite
and numeric, the result is that infinity. If both Explanation:
operands are infinities of the same sign, the result ccn Condition code is set to n.
is the same infinity. If the two operands are infin-
ities of opposite signs, an IEEE-invalid-operation
condition is recognized. Figure 19-15. Condition Code for Resultant Sum

See Figure 19-16 on page 19-20 for a detailed


description of the results of this instruction.
(Figure 19-15 is referred to by Figure 19-16.)

For AXBR, the R fields must designate valid


floating-point-register pairs; otherwise, a specifica-
tion exception is recognized.

Resulting Condition Code:


0 Result is zero
1 Result is less than zero
2 Result is greater than zero
3 Result is a NaN

IEEE Exception Conditions:


Invalid operation
Overflow
Underflow
Inexact

Chapter 19. Binary-Floating-Point Instructions 19-19


Results for ADD (a+b)
First
when Second Operand (b) Is
Operand
(a) Is Nn Dn 0 +0 +Dn +Nn + QNaN SNaN
T(), T(), T(), T(), T(), T(), T(), Xi: T(b), Xi:
cc1 cc1 cc1 cc1 cc1 cc1 cc1 T(dNaN), cc3 T(b*),
cc3 cc3
Nn T(), R(a+b), R(a+b), T(a), T(a), R(a+b), R(a+b), T(+), T(b), Xi:
cc1 cc1 cc1 cc1 cc1 cc1 ccrs cc2 cc3 T(b*),
cc3
Dn T(), R(a+b), R(a+b), R(a), R(a), R(a+b), R(a+b), T(+), T(b), Xi:
cc1 cc1 cc1 cc1 cc1 ccrs cc2 cc2 cc3 T(b*),
cc3
0 T(), T(b), R(b), T(0), Rezd, R(b), T(b), T(+), T(b), Xi:
cc1 cc1 cc1 cc0 cc0 cc2 cc2 cc2 cc3 T(b*),
cc3
+0 T(), T(b), R(b), Rezd, T(+0), R(b), T(b), T(+), T(b), Xi:
cc1 cc1 cc1 cc0 cc0 cc2 cc2 cc2 cc3 T(b*),
cc3
+Dn T(), R(a+b), R(a+b), R(a), R(a), R(a+b), R(a+b), T(+), T(b), Xi:
cc1 cc1 ccrs cc2 cc2 cc2 cc2 cc2 cc3 T(b*),
cc3
+Nn T(), R(a+b), R(a+b), T(a), T(a), R(a+b), R(a+b), T(+), T(b), Xi:
cc1 ccrs cc2 cc2 cc2 cc2 cc2 cc2 cc3 T(b*),
cc3
+ Xi: T(+), T(+), T(+), T(+), T(+), T(+), T(+), T(b), Xi:
T(dNaN), cc2 cc2 cc2 cc2 cc2 cc2 cc2 cc3 T(b*),
cc3 cc3
QNaN T(a), T(a), T(a), T(a), T(a), T(a), T(a), T(a), T(a), Xi:
cc3 cc3 cc3 cc3 cc3 cc3 cc3 cc3 cc3 T(b*),
cc3
SNaN Xi: Xi: Xi: Xi: Xi: Xi: Xi: Xi: Xi: Xi:
T(a*), T(a*), T(a*), T(a*), T(a*), T(a*), T(a*), T(a*), T(a*), T(a*),
cc3 cc3 cc3 cc3 cc3 cc3 cc3 cc3 cc3 cc3
Explanation:
* The SNaN is converted to the corresponding QNaN before it is placed at the target operand
location.
ccn Condition code is set to n.
ccrs Condition code is set according to the resultant sum. See Figure 19-15 on page 19-19.
dNaN Default quiet NaN.
Dn Denormalized number.
Nn Normalized nonzero number.
R(v) Rounding and range action is performed on the value v. See Figure 19-17 on page 19-21.
Rezd Exact zero-difference result. See Figure 19-17 on page 19-21.
T(x) The value x is placed at the target operand location.
Xi: IEEE invalid-operation exception. The results shown are produced only when FPC 0.0 is zero.

Figure 19-16. Results: ADD

19-20 z/Architecture Principles of Operation


Normal Result (r)
when Rounding Mode Is
To Toward Toward Toward
Range of v Case Nearest 0 +
v < Nmax, p < Nmax Overflow Nmax Nmax
v < Nmax, p = Nmax Normal Nmax Nmax Nmax
Nmax v Nmin Normal p p p p
Nmin < v Dmin Tiny d* d d d*
Dmin < v < Dmin/2 Tiny Dmin 0 0 Dmin
Dmin/2 v < 0 Tiny 0 0 0 Dmin
v=0 Exact zero difference +0 +0 +0 0
0 < v +Dmin/2 Tiny +0 +0 +Dmin +0
+Dmin/2 < v < +Dmin Tiny +Dmin +0 +Dmin +0
+Dmin v < +Nmin Tiny d* d d* d
+Nmin v +Nmax Normal p p p p
+Nmax < v, p = +Nmax Normal +Nmax +Nmax +Nmax
+Nmax < v, +Nmax < p Overflow + +Nmax + +Nmax
Explanation:
This situation cannot occur.
* The rounded value, in the extreme case, may be Nmin. In this case, the exception condi-
tions are underflow, inexact and incremented.
The normal result r is considered to have been incremented.
The exact-zero-difference case applies only to ADD, SUBTRACT, MULTIPLY AND ADD,
and MULTIPLY AND SUBTRACT. For all other operations, a zero result is detected by
inspection of the source operands without use of the R(v) function.
d The value derived when the exact result v is rounded to the format of the target, including
both precision and bounded exponent range. Except as explained in note *, this is a
denormalized number.
p The value derived when the exact result v is rounded to the precision of the target, but
assuming an unbounded exponent range.
v Exact result before rounding, assuming unbounded precision and an unbounded exponent
range. For LOAD ROUNDED, v is the source value a.
Dmin Smallest (in magnitude) representable denormalized number in the target format.
Nmax Largest (in magnitude) representable finite number in the target format.
Nmin Smallest (in magnitude) representable normalized number in the target format.

Figure 19-17 (Part 1 of 2). Action for R(v): Rounding and Range Function

Chapter 19. Binary-Floating-Point Instructions 19-21


Is r Overflow Underflow Inexact Is r Inc- Is p Is p Inc-
Inexact Mask Mask Mask remented Inexact remented
Case (rv) (FPC 0.2) (FPC 0.3) (FPC 0.4) (|r|>|v|) (pv) (|p|>|v|) Results
Overflow Yes 0 0 T(r), SFo1, SFx1
Overflow Yes 0 1 No T(r), SFo1, PIDx(08)
Overflow Yes 0 1 Yes T(r), SFo1, PIDy(0C)
Overflow Yes 1 No No Tw(p), PIDo(20)
Overflow Yes 1 Yes No Tw(p), PIDox(28)
Overflow Yes 1 Yes Yes Tw(p), PIDoy(2C)
Normal No T(r)
Normal Yes 0 T(r), SFx1
Normal Yes 1 No T(r), PIDx(08)
Normal Yes 1 Yes T(r), PIDy(0C)
Tiny No 0 T(r)
Tiny No 1 No No Tw(p), PIDu(10)
Tiny Yes 0 0 T(r), SFu1, SFx1
Tiny Yes 0 1 No T(r), SFu1, PIDx(08)
Tiny Yes 0 1 Yes T(r), SFu1, PIDy(0C)
Tiny Yes 1 No No Tw(p), PIDu(10)
Tiny Yes 1 Yes No Tw(p), PIDux(18)
Tiny Yes 1 Yes Yes Tw(p), PIDuy(1C)
Explanation:
The results do not depend on this condition or mask bit.
This condition is true by virtue of the state of some condition to the left of this column.
Wrap adjust, which depends on the type of operation and operand format. For all operations except
LOAD ROUNDED, the wrap adjust depends on the target format: = 2, where is 192 for short, 1536
for long, and 24576 for extended. For LOAD ROUNDED, the wrap adjust depends on the source format:
= 2, where is 512 for long and 8192 for extended.
p The value derived when the exact result v is rounded to the precision of the target, but assuming an
unbounded exponent range.
r Normal result as defined in Part 1 of this figure.
v Exact result before rounding, assuming unbounded precision and unbounded exponent range.
PIDc(h) Program interruption for data exception, condition c, with DXC of h in hex. See Figure 19-13 on
page 19-14.
SFo IEEE overflow flag, FPC 1.2.
SFu IEEE underflow flag, FPC 1.3.
SFx IEEE inexact flag, FPC 1.4.
T(x) The value x is placed at the target operand location.
Tw(x) The wrapped result x is placed at the target operand location. For all operations except LOAD
ROUNDED, the wrapped result is in the same format and length as normal results at the target location.
For LOAD ROUNDED, the wrapped result is in the same format and length as the source, but rounded to
the precision of the target.

Figure 19-17 (Part 2 of 2). Action for R(v): Rounding and Range Function

19-22 z/Architecture Principles of Operation


COMPARE If either or both operands are SNaNs, an
IEEE-invalid-operation condition is recognized. If
Mnemonic1 R,R [RRE] the IEEE invalid-operation mask bit is one, a
program interruption for a data exception with
DXC 80 hex (IEEE invalid operation) occurs. If
Op Code //////// R R the IEEE-invalid-operation mask bit is zero, the

16 24 28 31 IEEE-invalid-operation flag bit is set to one, and


instruction execution is completed by setting con-
Mnemonic1 Op Code Operands dition code 3.
CEBR 'B39' Short BFP
CDBR 'B319' Long BFP See Figure 19-18 on page 19-24 for a detailed
CXBR 'B349' Extended BFP description of the results of this instruction.
Mnemonic2 R,D(X,B) [RXE]
For CXBR, the R fields must designate valid
/ floating-point-register pairs; otherwise, a specifica-
Op Code R X B D ////////Op Code tion exception is recognized.
/
8 12 16 2 32 4 47 Resulting Condition Code:
Mnemonic2 Op Code Operands 0 Operands equal
CEB 'ED9' Short BFP 1 First operand low
CDB 'ED19' Long BFP 2 First operand high
3 Operands unordered
The first operand is compared with the second
operand, and the condition code is set to indicate IEEE Exception Conditions:
the result.
Invalid operation
If both operands are numeric and finite, the com-
parison is algebraic and follows the procedure for Program Exceptions:
BFP subtraction, except that the difference is dis- Access (fetch, operand 2 of CEB and CDB
carded after setting the condition code, and both only)
operands remain unchanged. If the difference is Data with DXC 2, BFP instruction
exactly zero with either sign, the operands are Data with DXC for IEEE exception condition
equal; this includes zero operands (so +0 equals Operation (if the BFP facility is not installed)
0). If a nonzero difference is positive or nega- Specification (CXBR only)
tive, the first operand is high or low, respectively.
Programming Notes:
+ compares greater than any finite number, and
1. COMPARE may be used by a compiler to
all finite numbers compare greater than . Two
implement those comparisons which are
infinity operands of like sign compare equal.
required by the IEEE standard to not recog-
Numeric comparison is exact, and the condition nize an exception condition when the result is
code is determined for finite operands as if range unordered due to a QNaN.
and precision were unlimited. No overflow or 2. The IEEE standard requires that it be possible
underflow condition can occur. to compare BFP operands in different formats.
To accomplish this, LOAD LENGTHENED
If either or both operands are QNaNs and neither may be used before COMPARE to convert the
operand is an SNaN, the comparison result is shorter operand to the same format as the
unordered, and condition code 3 is set. longer.

Chapter 19. Binary-Floating-Point Instructions 19-23


Results for COMPARE (a:b)
First
when Second Operand (b) Is
Operand
(a) Is Fn 0 +0 +Fn + QNaN SNaN
cc0 cc1 cc1 cc1 cc1 cc1 cc3 Xi: cc3
Fn cc2 C(a:b) cc1 cc1 cc1 cc1 cc3 Xi: cc3
0 cc2 cc2 cc0 cc0 cc1 cc1 cc3 Xi: cc3
+0 cc2 cc2 cc0 cc0 cc1 cc1 cc3 Xi: cc3
+Fn cc2 cc2 cc2 cc2 C(a:b) cc1 cc3 Xi: cc3
+ cc2 cc2 cc2 cc2 cc2 cc0 cc3 Xi: cc3
QNaN cc3 cc3 cc3 cc3 cc3 cc3 cc3 Xi: cc3
SNaN Xi: cc3 Xi: cc3 Xi: cc3 Xi: cc3 Xi: cc3 Xi: cc3 Xi: cc3 Xi: cc3
Explanation:
ccn Condition code is set to n.
C(a:b) Basic compare results. See Figure 19-19.
Fn Finite nonzero number (includes both denormalized and normalized).
Xi: IEEE invalid-operation exception. The results shown are produced only when FPC 0.0 is zero.

Figure 19-18. Results: COMPARE

Mnemonic2 R,D(X,B) [RXE]


Relation of Value Condition Code
(a) to Value (b) for C(a:b) /
Op Code R X B D ////////Op Code
a=b cc0 /
a<b cc1 8 12 16 2 32 4 47

a>b cc2 Mnemonic2 Op Code Operands


KEB 'ED8' Short BFP
Explanation: KDB 'ED18' Long BFP
ccn Condition code is set to n.
The first operand is compared with the second
operand, and the condition code is set to indicate
Figure 19-19. Basic Compare Results the result. The operation is the same as for
COMPARE except that QNaN operands cause an
COMPARE AND SIGNAL IEEE-invalid-operation condition to be recognized.
Thus, QNaN operands are treated as if they were
Mnemonic1 R,R [RRE] SNaNs.

See Figure 19-20 on page 19-25 for a detailed


Op Code //////// R R
description of the results of this instruction.
16 24 28 31
For KXBR, the R fields must designate valid
Mnemonic1 Op Code Operands floating-point-register pairs; otherwise, a specifica-
KEBR 'B38' Short BFP tion exception is recognized.
KDBR 'B318' Long BFP
KXBR 'B348' Extended BFP

19-24 z/Architecture Principles of Operation


Resulting Condition Code: Operation (if the BFP facility is not installed)
Specification (KXBR only)
0 Operands equal
1 First operand low
Programming Notes:
2 First operand high
3 Operands unordered 1. COMPARE AND SIGNAL may be used by a
compiler to implement those comparisons
IEEE Exception Conditions: which are required by the IEEE standard to
recognize an exception condition when the
Invalid operation
result is unordered due to a QNaN.
Program Exceptions: 2. The IEEE standard requires that it be possible
Access (fetch, operand 2 of KEB and KDB to compare BFP operands in different formats.
only) To accomplish this, LOAD LENGTHENED
Data with DXC 2, BFP instruction may be used before COMPARE AND SIGNAL
Data with DXC for IEEE exception condition to convert the shorter operand to the same
format as the longer.

Results for COMPARE AND SIGNAL (a:b)


First
when Second Operand (b) Is
Operand
(a) Is Fn 0 +0 +Fn + NaN
cc0 cc1 cc1 cc1 cc1 cc1 Xi: cc3
Fn cc2 C(a:b) cc1 cc1 cc1 cc1 Xi: cc3
0 cc2 cc2 cc0 cc0 cc1 cc1 Xi: cc3
+0 cc2 cc2 cc0 cc0 cc1 cc1 Xi: cc3
+Fn cc2 cc2 cc2 cc2 C(a:b) cc1 Xi: cc3
+ cc2 cc2 cc2 cc2 cc2 cc0 Xi: cc3
NaN Xi: cc3 Xi: cc3 Xi: cc3 Xi: cc3 Xi: cc3 Xi: cc3 Xi: cc3
Explanation:
ccn Condition code is set to n.
C(a:b) Basic compare results. See Figure 19-19 on page 19-24.
Fn Finite nonzero number (includes both denormalized and normalized).
Xi: IEEE invalid-operation exception. The results shown are produced only when FPC 0.0 is zero.

Figure 19-20. Results: COMPARE AND SIGNAL

Chapter 19. Binary-Floating-Point Instructions 19-25


CONVERT FROM FIXED CONVERT TO FIXED
Mnemonic R,R [RRE] Mnemonic R,M,R [RRF]


Op Code //////// R R Op Code M //// R R

16 24 28 31 16 2 24 28 31
Mnemonic Op Code Operands Mnemonic Op Code Operands
CEFBR 'B394' 32-bit binary-integer CFEBR 'B398' Short BFP operand, 32-bit
operand, short BFP result binary-integer result
CDFBR 'B395' 32-bit binary-integer CFDBR 'B399' Long BFP operand, 32-bit
operand, long BFP result binary-integer result
CXFBR 'B396' 32-bit binary-integer CFXBR 'B39A' Extended BFP operand, 32-
operand, extended BFP bit binary-integer result
result CGEBR 'B3A8' Short BFP operand, 64-bit
CEGBR 'B3A4' 64-bit binary-integer binary-integer result
operand, short BFP result CGDBR 'B3A9' Long BFP operand, 64-bit
CDGBR 'B3A5' 64-bit binary-integer binary-integer result
operand, long BFP result CGXBR 'B3AA' Extended BFP operand, 64-
CXGBR 'B3A6' 64-bit binary-integer bit binary-integer result
operand, extended BFP
result The BFP second operand is rounded to an integer
value and then converted to the fixed-point format.
The fixed-point second operand is converted to The result is placed at the first-operand location.
the BFP format, and the result is placed at the
first-operand location. The result is a signed binary integer that is placed
in the general register designated by R. A 32-bit
The second operand is a signed binary integer result replaces bits 32-63 of the register, and bits
that is located in the general register designated 0-31 of the register remain unchanged.
by R. A 32-bit operand is in bit positions 32-63
of the register. If the second operand is numeric and finite, it is
rounded to an integer value by rounding as speci-
The result is rounded according to the current fied by the modifier in the M field:
rounding mode before it is placed at the first-
operand location. M Rounding Method
0 According to current rounding mode
See Figure 19-21 on page 19-27 for a detailed 1 Biased round to nearest
description of the results of this instruction. 4 Round to nearest
5 Round toward 0
For CXFBR and CXGBR, the R field must desig-
6 Round toward +
nate a valid floating-point-register pair; otherwise,
7 Round toward
a specification exception is recognized.
A modifier other than 0, 1, or 4-7 is invalid.
Condition Code: The code remains unchanged.
When the modifier field is zero, rounding is con-
IEEE Exception Conditions:
trolled by the current rounding mode specified in
Inexact (CEFBR, CDGBR, CEGBR) the FPC register. When the field is not zero,
rounding is performed as specified by the modifier,
Program Exceptions: regardless of the current rounding mode.
Data with DXC 2, BFP instruction Rounding for modifiers 4-7 is the same as for
Data with DXC for IEEE exception condition rounding modes 0-3 (binary 00-11), respectively.
Operation (if the BFP facility is not installed) Biased round to nearest (modifier 1) is the same
Specification (CXFBR and CXGBR) as round to nearest (modifier 4), except when the
second operand is exactly halfway between two
integers, in which case the result for biased

19-26 z/Architecture Principles of Operation


Results for Instructions with a Single Operand (a)
when Operand (a) Is
Instruction Fn 0 +0 +Fn + QNaN SNaN
CONVERT FROM Rf(a) T(+0) Rf(a)
FIXED
LOAD AND TEST T() T(a) T(0) T(+0) T(a) T(+) T(a) Xi: T(a*)
LOAD LENGTHENED T() T(a) T(0) T(+0) T(a) T(+) T(a) Xi: T(a*)
LOAD ROUNDED T() R(a) T(0) T(+0) R(a) T(+) T(a) Xi: T(a*)
SQUARE ROOT Xi: Xi: T(0) T(+0) R( a) T(+) T(a) Xi: T(a*)
T(dNaN) T(dNaN)
Explanation:
This situation cannot occur.
* The SNaN is converted to the corresponding QNaN before it is placed at the target operand
location.
The operand is extended to the longer format by appending zeros on the right before it is
placed at the target operand location.
The NaN is shortened to the target format by truncating the rightmost bits.
dNaN Default quiet NaN.
Fn Finite nonzero number (includes both denormalized and normalized).
R(v) Rounding and range action is performed on the value v. See Figure 19-17 on page 19-21.
Rf(a) The value a is converted to the exact floating-point number v, and then action R(v) is per-
formed.
T(x) The value x is placed in the target operand location.
Xi: IEEE invalid-operation exception. The results shown are produced only when FPC 0.0 is zero.

Figure 19-21. Results: Single-Operand Instructions

rounding is the next integer that is greater in mag- IEEE Exception Conditions:
nitude.
Invalid operation
Inexact
The sign of the result is the sign of the second
operand, except that a zero result has a plus sign.
Program Exceptions:
See Figure 19-22 on page 19-28 for a detailed Data with DXC 2, BFP instruction
description of the results of this instruction. Data with DXC for IEEE exception condition
Operation (if the BFP facility is not installed)
The M field must designate a valid modifier; oth- Specification
erwise, a specification exception is recognized.
For CFXBR and CGXBR, the R field must desig-
nate a valid floating-point-register pair; otherwise,
a specification exception is recognized.

Resulting Condition Code:


0 Source was zero
1 Source was less than zero
2 Source was greater than zero
3 Special case

Chapter 19. Binary-Floating-Point Instructions 19-27


Inv.-Op. Inexact
Is n Mask Mask Is n Inc-
Inexact (FPC (FPC remented
Operand (a) (na) 0.0) 0.4) (|n|>|a|) Results
a < MN, p < MN 0 0 T(MN), SFi1, SFx1, cc3
a < MN, p < MN 0 1 T(MN), SFi1, cc3, PIDx(08)
a < MN, p < MN 1 PIDi(80)
< a < MN, p = MN 0 T(MN), SFx1, cc1
< a < MN, p = MN 1 T(MN), cc1, PIDx(08)
MN a < 0 No T(n), cc1
MN a < 0 Yes 0 T(n), SFx1, cc1
MN a < 0 Yes 1 No T(n), cc1, PIDx(08)
MN a < 0 Yes 1 Yes T(n), cc1, PIDy(0C)
0 No T(0), cc0
+0 No T(0), cc0
0 < a MP No T(n), cc2
0 < a MP Yes 0 T(n), SFx1, cc2
0 < a MP Yes 1 No T(n), cc2, PIDx(08)
0 < a MP Yes 1 Yes T(n), cc2, PIDy(0C)
MP < a < +, p = MP 0 T(MP), SFx1, cc2
MP < a < +, p = MP 1 T(MP), cc2, PIDx(08)
MP < a +, p > MP 0 0 T(MP), SFi1, SFx1, cc3
MP < a +, p > MP 0 1 T(MP), SFi1, cc3, PIDx(08)
MP < a +, p > MP 1 PIDi(80)
NaN 0 0 T(MN), SFi1, SFx1, cc3
NaN 0 1 T(MN), SFi1, cc3, PIDx(08)
NaN 1 PIDi(80)
Explanation:
The results do not depend on this condition or mask bit.
This condition is true by virtue of the state of some condition to the left of this column.
ccn Condition code is set to n.
n The value p converted to a fixed-point result.
p The value derived when the source value a is rounded to an integer using the specified
rounding mode.
MN Maximum negative number representable in the target fixed-point format.
MP Maximum positive number representable in the target fixed-point format.
PIDc(h) Program interruption for data exception, condition c, with DXC of h in hex. See Figure 19-13
on page 19-14.
SFi IEEE invalid-operation flag, FPC 1.0.
SFx IEEE inexact flag, FPC 1.4.
T(x) The value x is placed at the target operand location.

19-28 z/Architecture Principles of Operation


Figure 19-22. Results: CONVERT TO FIXED

DIVIDE IEEE Exception Conditions:


Invalid operation
Mnemonic1 R,R [RRE]
Division by zero
Overflow
Op Code //////// R R Underflow
Inexact
16 24 28 31
Program Exceptions:
Mnemonic1 Op Code Operands
DEBR 'B3D' Short BFP Access (fetch, operand 2 of DEB and DDB
DDBR 'B31D' Long BFP only)
DXBR 'B34D' Extended BFP Data with DXC 2, BFP instruction
Data with DXC for IEEE exception condition
Mnemonic2 R,D(X,B) [RXE]
Operation (if the BFP facility is not installed)
/ Specification (DXBR only)
Op Code R X B D ////////Op Code
/
8 12 16 2 32 4 47 DIVIDE TO INTEGER
Mnemonic2 Op Code Operands Mnemonic R,R,R,M [RRF]
DEB 'EDD' Short BFP
DDB 'ED1D' Long BFP
Op Code R M R R

The first operand (the dividend) is divided by the
16 2 24 28 31
second operand (the divisor), and the quotient is
placed at the first-operand location. No remainder Mnemonic Op Code Operands
is preserved. DIEBR 'B353' Short BFP
DIDBR 'B35B' Long BFP
If the divisor is nonzero and both the dividend and
divisor are numeric and finite, the first operand is The first operand (the dividend) is divided by the
divided by the second operand to form an interme- second operand (the divisor). An integer quotient
diate quotient. The intermediate quotient, if in BFP form is produced and placed at the third-
nonzero, is normalized and rounded to the target operand location. The remainder replaces the div-
format according to the current rounding mode. idend at the first-operand location. The first,
second, and third operands must be in different
The sign of the quotient is the EXCLUSIVE OR of registers. The condition code indicates whether
the operand signs. This includes the sign of a partial or complete results have been produced
zero quotient. and whether the quotient is numeric and finite.

If the divisor is zero but the dividend is nonzero The remainder result is
and finite, an IEEE-division-by-zero condition is r = abn
recognized. If the dividend and divisor are both
zero, or if both are infinite, regardless of sign, an where a is the dividend, b the divisor, and n an
IEEE-invalid-operation condition is recognized. integer obtained by rounding the precise quotient
q = ab.
See Figure 19-23 on page 19-30 for a detailed
description of the results of this instruction. The first-operand result is r with the sign deter-
mined by the above expression. The third-
For DXBR, the R fields must designate valid operand result is n with a sign that is the
floating-point-register pairs; otherwise, a specifica- EXCLUSIVE OR of the dividend and divisor signs.
tion exception is recognized.
If the precise quotient is not an integer and the
Condition Code: The code remains unchanged. two integers closest to this precise quotient cannot
both be represented exactly in the precision of the

Chapter 19. Binary-Floating-Point Instructions 19-29


Results for DIVIDE (ab)
when Divisor (b) Is
Dividend
(a) Fn 0 +0 +Fn + QNaN SNaN
Xi: T(+) T(+) T() T() Xi: T(b) Xi: T(b*)
T(dNaN) T(dNaN)
Fn T(+0) R(ab) Xz: T(+) Xz: T() R(ab) T(0) T(b) Xi: T(b*)
0 T(+0) T(+0) Xi: Xi: T(0) T(0) T(b) Xi: T(b*)
T(dNaN) T(dNaN)
+0 T(0) T(0) Xi: Xi: T(+0) T(+0) T(b) Xi: T(b*)
T(dNaN) T(dNaN)
+Fn T(0) R(ab) Xz: T() Xz: T(+) R(ab) T(+0) T(b) Xi: T(b*)
+ Xi: T() T() T(+) T(+) Xi: T(b) Xi: T(b*)
T(dNaN) T(dNaN)
QNaN T(a) T(a) T(a) T(a) T(a) T(a) T(a) Xi: T(b*)
SNaN Xi: T(a*) Xi: T(a*) Xi: T(a*) Xi: T(a*) Xi: T(a*) Xi: T(a*) Xi: T(a*) Xi: T(a*)
Explanation:
* The SNaN is converted to the corresponding QNaN before it is placed at the target operand
location.
Fn Finite nonzero number (includes both denormalized and normalized).
R(v) Rounding and range action is performed on the value v. See Figure 19-17 on page 19-21.
T(x) The value x is placed at the target operand location.
Xi: IEEE invalid-operation exception. The results shown are produced only when FPC 0.0 is zero.
Xz: IEEE division-by-zero exception. The results shown are produced only when FPC 0.1 is zero.

Figure 19-23. Results: DIVIDE

quotient, then a partial quotient and partial quotient rounding mode affects only the final quo-
remainder are formed. This partial quotient n and tient; partial quotients are rounded toward zero.
the corresponding partial remainder
Since the partial quotient is rounded toward zero,
r = abn
the partial remainder is always exact. For the
are used as the results. The sign of a partial specified quotient rounding modes of round toward
remainder is the same as the sign of the dividend. 0, round to nearest, and biased round to nearest,
The sign of a partial quotient is the EXCLUSIVE the final remainder is exact. For the specified
OR of the dividend and divisor signs. quotient rounding modes of round toward + and
round toward , the final remainder may not be
If the remainder is zero, then the precise quotient exact.
is an integer and can be represented exactly in
the precision of the quotient. The final quotient is rounded to an integer by
rounding as specified by the modifier in the M
The M field, called the modifier field, specifies field:
rounding of the final quotient. This rounding is
called the specified quotient rounding mode as M Rounding Method
contrasted to the current rounding mode speci- 0 According to current rounding mode
fied by the rounding-mode bits in the FPC register. 1 Biased round to nearest
The final quotient is rounded according to the 4 Round to nearest
specified quotient rounding mode. The specified 5 Round toward 0

19-30 z/Architecture Principles of Operation


6 Round toward + Resulting Condition Code:
7 Round toward
0 Remainder complete; normal quotient
1 Remainder complete; quotient overflow or
A modifier other than 0, 1, or 4-7 is invalid.
NaN
When the modifier field is zero, rounding of the 2 Remainder incomplete; normal quotient
final quotient is controlled by the current rounding 3 Remainder incomplete; quotient overflow or
mode specified in the FPC register. When the NaN
field is not zero, rounding is performed as speci-
IEEE Exception Conditions:
fied by the modifier, regardless of the current
rounding mode. Rounding for modifiers 4-7 is the Invalid operation
same as for rounding modes 0-3 (binary 00-11), Underflow
respectively. Biased round to nearest (modifier 1) Inexact
is the same as round to nearest (modifier 4),
except when the final quotient is exactly halfway Program Exceptions:
between two integers, in which case the result for Data with DXC 2, BFP instruction
biased rounding is the next integer that is greater Data with DXC for IEEE exception condition
in magnitude. Operation (if the BFP facility is not installed)
Specification
Underflow is recognized only on the final
remainder, not on the partial remainder. Programming Notes:
For the specified quotient rounding modes of 1. The Remainder operation, as defined in the
round toward + and round toward , the final IEEE standard, is produced by issuing DIVIDE
remainder may not be exact. When, in these TO INTEGER in an iterative loop, with the M
cases, the final remainder is inexact, it is rounded field set to 4.
according to the current rounding mode specified 2. The rounding specifications of round to
in the FPC register. nearest, round toward 0, and round toward
permit the instruction to be used directly to
The sign of a zero quotient is the EXCLUSIVE OR
produce the Remainder, MOD, and modulo
of the divisor and dividend signs.
functions, respectively.
A zero remainder has the sign of the dividend. 3. When DIVIDE TO INTEGER is used in an iter-
ative loop, all quotients are produced in BFP
See Figure 19-24 on page 19-32 for a detailed format but may be considered as portions of a
description of the results of this instruction. multiple-precision fixed-point number.

If the quotient exponent is greater than the largest 4. In the case when the resulting remainder is
exponent that can be represented in the operand denormalized, the IEEE standard requires that
format, the correct remainder or partial remainder if traps are implemented and the underflow
still is produced, and the third-operand result is mask is one, then an underflow trap must
the correct value, but with the exponent reduced occur. To accomplish this, DIVIDE TO
by 192 or 1536 for short or long operands, respec- INTEGER recognizes underflow on the final
tively. The condition code indicates this out-of- remainder but not on the partial remainder.
range condition. Since in all cases when underflow occurs on
the partial remainder it will occur again on the
The M field must designate a valid modifier, and final remainder, recognizing overflow on only
the R, R, and R fields must designate different the final remainder avoids two underflow traps
registers; otherwise, a specification exception is to be reported for what the standard considers
recognized. a single Remainder operation.

Chapter 19. Binary-Floating-Point Instructions 19-31


Results for DIVIDE TO INTEGER (ab)
when Divisor (b) Is
Dividend
(a) Fn 0 +0 +Fn + QNaN SNaN
Xi: Xi: Xi: Xi: Xi: Xi: T(b), cc1 Xi: T(b*),
T(dNaN), T(dNaN), T(dNaN), T(dNaN), T(dNaN), T(dNaN), cc1
cc1 cc1 cc1 cc1 cc1 cc1
Fn T(a,+0), D(a,b) Xi: Xi: D(a,b) T(a,0), T(b), cc1 Xi: T(b*),
cc0 T(dNaN), T(dNaN), cc0 cc1
cc1 cc1
0 T(0,+0), T(0,+0), Xi: Xi: T(0,0), T(0,0), T(b), cc1 Xi: T(b*),
cc0 cc0 T(dNaN), T(dNaN), cc0 cc0 cc1
cc1 cc1
+0 T(+0,0), T(+0,0), Xi: Xi: T(+0,+0), T(+0,+0), T(b), cc1 Xi: T(b*),
cc0 cc0 T(dNaN), T(dNaN), cc0 cc0 cc1
cc1 cc1
+Fn T(a,0), D(a,b) Xi: Xi: D(a,b) T(a,+0), T(b), cc1 Xi: T(b*),
cc0 T(dNaN), T(dNaN), cc0 cc1
cc1 cc1
+ Xi: Xi: Xi: Xi: Xi: Xi: T(b), cc1 Xi: T(b*),
T(dNaN), T(dNaN), T(dNaN), T(dNaN), T(dNaN), T(dNaN), cc1
cc1 cc1 cc1 cc1 cc1 cc1
QNaN T(a), cc1 T(a), cc1 T(a), cc1 T(a), cc1 T(a), cc1 T(a), cc1 T(a), cc1 Xi: T(b*),
cc1
SNaN Xi: T(a*), Xi: T(a*), Xi: T(a*), Xi: T(a*), Xi: T(a*), Xi: T(a*), Xi: T(a*), Xi: T(a*),
cc1 cc1 cc1 cc1 cc1 cc1 cc1 cc1
Explanation:
* The SNaN is converted to the corresponding QNaN before it is placed at the target operand
location.
ccn Condition code is set to n.
D(a,b) Basic divide-to-integer results. See Part 2 of this figure.
Fn Finite nonzero number (includes both denormalized and normalized).
T(r,q) Results r (the remainder) and q (the quotient) are placed in target operands 1 and 3, respec-
tively.
T(x) Value x is placed in both target operands 1 and 3.
Xi: IEEE invalid-operation exception. The results shown are produced only when FPC 0.0 is zero.

Figure 19-24 (Part 1 of 2). Results: DIVIDE TO INTEGER

19-32 z/Architecture Principles of Operation


Inexact
Underflow mask Is r
r= Is r Is r Mask (FPC Quotient Incre-
|q| < 2P 0 Case Tiny Inexact (FPC 0.3) 0.4) Overflow mented Results for D(a,b)
Yes Yes Final No No No T(r,n), cc0
Yes No Final No No No T(r,n), cc0
Yes No Final Yes No 0 No T(r,n), cc0
Yes No Final Yes No 1 No No T(r, n), cc0,
PIDu(10)
Yes No Final No Yes 0 No T(r,n), SFx1, cc0
Yes No Final No Yes 1 No No T(r,n), cc0, PIDx(08)
Yes No Final No Yes 1 No Yes T(r,n), cc0, PIDy(0C)
No Yes Final No No No T(r,n), cc0
No Yes Final No No Yes T(r,n), cc1
No No Partial No No T(r,n), cc2
No No Partial No Yes T(r, n), cc3

Chapter 19. Binary-Floating-Point Instructions 19-33


Explanation:
The results do not depend on this condition or mask bit.
This condition is true by virtue of the state of some condition to the left of this column. That
is, when |q| < 2P, there cannot be a quotient overflow; the cases of remainder is zero, tiny, or
inexact are mutually exclusive; and when r is exact, it is not incremented.
Underflow is not recognized for a partial remainder.
Wrap adjust, which depends on the target format: = 2, where is 192 for short and 1536
for long.
|q| The absolute value of q., where q is the exact result of ab before rounding, assuming
unbounded precision and unbounded exponent range.
cc0 Condition code is set to 0 (remainder complete; normal quotient).
cc1 Condition code is set to 1 (remainder complete; quotient overflow).
cc2 Condition code is set to 2 (remainder incomplete; normal quotient).
cc3 Condition code is set to 3 (remainder incomplete; quotient overflow).
n Integer quotient. n = q, rounded toward 0 for partial results and rounded according to the
specified quotient rounding mode for final results. The sign of the integer quotient, including
the cases of partial and final, wrapped-around overflow and zero, is the EXCLUSIVE OR of
the signs of the dividend (a) and divisor (b).
r Remainder. r = abn. A partial remainder is always exact; no rounding is necessary. The
sign of a partial remainder is always the same as the sign of the dividend (a). A final
remainder is rounded according to the current rounding mode (if necessary). The sign of a
zero remainder is the same as the sign of the dividend (a). The sign of a nonzero final
remainder is determined by the rules of algebra.
P Precision of the operand, which depends on the target format: P = 24 for short and 53 for
long.
PIDc(h) Program interruption for data exception, condition c, with DXC of h in hex. See Figure 19-13
on page 19-14.
SFi IEEE invalid-operation flag, FPC 1.0.
SFu IEEE underflow flag, FPC 1.3.
SFx IEEE inexact flag, FPC 1.4.
T(r,n) Results r (the remainder) and n (the integer quotient) are placed in target operands 1 and 3,
respectively.

Figure 19-24 (Part 2 of 2). Results: DIVIDE TO INTEGER

EXTRACT FPC IEEE Exception Conditions: None.

EFPC R [RRE] Program Exceptions:

'B38C' //////// R //// Data with DXC 2, BFP instruction


Operation (if the BFP facility is not installed)
16 24 28 31

The contents of the FPC (floating-point-control)


register are placed in bit positions 32-63 of the
general register designated by R. Bit positions
0-31 of the general register remain unchanged.

Condition Code: The code remains unchanged.

19-34 z/Architecture Principles of Operation


LOAD AND TEST LOAD COMPLEMENT
Mnemonic R,R [RRE] Mnemonic R,R [RRE]


Op Code //////// R R Op Code //////// R R

16 24 28 31 16 24 28 31

Mnemonic Op Code Operands Mnemonic Op Code Operands


LTEBR 'B32' Short BFP LCEBR 'B33' Short BFP
LTDBR 'B312' Long BFP LCDBR 'B313' Long BFP
LTXBR 'B342' Extended BFP LCXBR 'B343' Extended BFP

The second operand is placed at the first-operand The second operand is placed at the first-operand
location, and its sign and magnitude are tested to location with the sign bit inverted.
determine the setting of the condition code. The
condition code is set the same as for a compar- The sign bit is inverted even if the operand is
ison of the second operand with zero. zero. The rest of the second operand is placed
unchanged at the first-operand location. The sign
The second operand is placed unchanged at the is inverted for any operand, including a QNaN or
first-operand location. If the second operand is an SNaN, without causing an arithmetic exception.
SNaN, an IEEE-invalid-operation condition is
recognized; if there is no interruption, the result is For LCXBR, the R fields must designate valid
the corresponding QNaN. floating-point-register pairs; otherwise, a specifica-
tion exception is recognized.
See Figure 19-21 on page 19-27 for a detailed
description of the results of this instruction. Resulting Condition Code:
0 Result is zero
For LTXBR, the R fields must designate valid
1 Result is less than zero
floating-point-register pairs; otherwise, a specifica-
2 Result is greater than zero
tion exception is recognized.
3 Result is a NaN
Resulting Condition Code:
IEEE Exception Conditions: None.
0 Result is zero
1 Result is less than zero Program Exceptions:
2 Result is greater than zero Data with DXC 2, BFP instruction
3 Result is a NaN Operation (if the BFP facility is not installed)
Specification (LCXBR only)
IEEE Exception Conditions:
Programming Note: The IEEE standard makes
Invalid operation
it optional whether operations such as LOAD
COMPLEMENT signal invalid operation when the
Program Exceptions:
operand is an SNaN. LOAD AND TEST may be
Data with DXC 2, BFP instruction used in conjunction with this instruction if signal-
Data with DXC for IEEE exception condition ling is desired.
Operation (if the BFP facility is not installed)
Specification (LTXBR only)
Programming Note: The IEEE standard makes
it optional whether operations such as LOAD AND
TEST signal invalid operation when the operand is
an SNaN. TEST DATA CLASS may be used to
test an operand if signaling is not desired.

Chapter 19. Binary-Floating-Point Instructions 19-35


LOAD FP INTEGER in which case the result for biased rounding is the
next integer that is greater in magnitude.
Mnemonic R,M,R [RRF]
In the absence of an interruption, if the second
operand is an infinity or a QNaN, the result is that
Op Code M //// R R operand; if the second operand is an SNaN, the
result is the corresponding QNaN.
16 2 24 28 31

Mnemonic Op Code Operands The sign of the result is the sign of the second
FIEBR 'B357' Short BFP operand, even when the result is zero.
FIDBR 'B35F' Long BFP
FIXBR 'B347' Extended BFP See Figure 19-25 on page 19-37 for a detailed
description of the results of this instruction.
The second operand is rounded to an integer
value in the same floating-point format, and the The M field must designate a valid modifier, and,
result is placed at the first-operand location. for FIXBR, the R fields must designate valid
floating-point-register pairs. Otherwise, a specifi-
The second operand, if numeric, is rounded to an cation exception is recognized.
integer value as specified by the modifier in the
M field: Condition Code: The code remains unchanged.

M Rounding Method IEEE Exception Conditions:


0 According to current rounding mode
Invalid operation
1 Biased round to nearest
Inexact
4 Round to nearest
5 Round toward 0
Program Exceptions:
6 Round toward +
7 Round toward Data with DXC 2, BFP instruction
Data with DXC for IEEE exception condition
A modifier other than 0, 1, or 4-7 is invalid. Operation (if the BFP facility is not installed)
Specification
When the modifier field is zero, rounding is con-
trolled by the current rounding mode in the FPC Programming Notes:
register. When the field is not zero, rounding is
1. LOAD FP INTEGER rounds a BFP number to
performed as specified by the modifier, regardless
an integer value. These integers, which
of the current rounding mode. Rounding for modi-
remain in the BFP format, should not be con-
fiers 4-7 is the same as for rounding modes 0-3
fused with binary integers, which have a fixed-
(binary 00-11), respectively. Biased round to
point format.
nearest (modifier 1) is the same as round to
nearest (modifier 4), except when the second 2. If the BFP operand is numeric with a large
operand is exactly halfway between two integers, enough exponent so that it is already an
integer, the result value remains the same.

19-36 z/Architecture Principles of Operation


Inv.-Op. Inexact
Is n Mask Mask Is n Inc-
Operand Inexact (FPC (FPC remented
(a) (na) 0.0) 0.4) (|n|>|a|) Results
No T()
Fn No T(n)
Fn Yes 0 T(n), SFx1
Fn Yes 1 No T(n), PIDx(08)
Fn Yes 1 Yes T(n), PIDy(0C)
0 No T(0)
+0 No T(+0)
+Fn No T(n)
+Fn Yes 0 T(n), SFx1
+Fn Yes 1 No T(n), PIDx(08)
+Fn Yes 1 Yes T(n), PIDy(0C)
+ No T(+)
QNaN No T(a)
SNaN No 0 T(a*), SFi1
SNaN No 1 PIDi(80)
Explanation:
The results do not depend on this condition or mask bit.
* The SNaN is converted to the corresponding QNaN before it is placed at the target operand
location.
This condition is true by virtue of the state of some condition to the left of this column.
n The value derived when the source value, a, is rounded to an integer using the specified
rounding mode.
Fn Finite nonzero number (includes both denormalized and normalized).
PIDc(h) Program interruption for data exception, condition c, with DXC of h in hex. See Figure 19-13
on page 19-14.
SFi IEEE invalid-operation flag, FPC 1.0.
SFx IEEE inexact flag, FPC 1.4.
T(x) The value x is placed at the target operand location.

Figure 19-25. Results: LOAD FP INTEGER

LOAD FPC The four-byte second operand in storage is loaded


into the FPC (floating-point-control) register.
LFPC D(B) [S]
Bits corresponding to unassigned bit positions in
'B29D' B D the FPC register must be zero; otherwise, a spec-
ification exception is recognized.
16 2 31
Condition Code: The code remains unchanged.

Chapter 19. Binary-Floating-Point Instructions 19-37


IEEE Exception Conditions: None. See Figure 19-21 on page 19-27 for a detailed
description of the results of this instruction.
Program Exceptions:
For LXDB, LXDBR, LXEB, and LXEBR, the R
Access (fetch, operand 2)
field must designate a valid floating-point-register
Data with DXC 2, BFP instruction
pair; otherwise, a specification exception is recog-
Operation (if the BFP facility is not installed)
nized.
Specification
Condition Code: The code remains unchanged.
LOAD LENGTHENED
IEEE Exception Conditions:
Mnemonic1 R,R [RRE]
Invalid operation

Op Code //////// R R Program Exceptions:

16 24 28 31 Access (fetch, operand 2 of LDEB, LXEB, and


LXDB only)
Mnemonic1 Op Code Operands Data with DXC 2, BFP instruction
LDEBR 'B34' Short BFP operand 2, Data with DXC for IEEE exception condition
long BFP operand 1 Operation (if the BFP facility is not installed)
LXDBR 'B35' Long BFP operand 2,
extended BFP operand 1 Specification (LXEB, LXEBR, LXDB, LXDBR)
LXEBR 'B36' Short BFP operand 2,
extended BFP operand 1 LOAD NEGATIVE
Mnemonic2 R,D(X,B) [RXE]
Mnemonic R,R [RRE]
/

Op Code R X B D ////////Op Code
Op Code //////// R R
/

8 12 16 2 32 4 47
16 24 28 31
Mnemonic2 Op Code Operands
Mnemonic Op Code Operands
LDEB 'ED4' Short BFP operand 2,
LNEBR 'B31' Short BFP
long BFP operand 1
LNDBR 'B311' Long BFP
LXDB 'ED5' Long BFP operand 2,
LNXBR 'B341' Extended BFP
extended BFP operand 1
LXEB 'ED6' Short BFP operand 2,
extended BFP operand 1 The second operand is placed at the first-operand
location with the sign bit made one.
The second operand is extended to a longer
format, and the result is placed at the first-operand The sign bit is made one even if the operand is
location. zero. The rest of the second operand is placed
unchanged at the first-operand location. The sign
The sign of the result is the same as the sign of is set for any operand, including a QNaN or
the source. The exponent of the second operand SNaN, without causing an arithmetic exception.
is converted to the corresponding exponent in the
result format, and the fraction is extended by For LNXBR, the R fields must designate valid
appending zeros on the right. If the second floating-point-register pairs; otherwise, a specifica-
operand is an infinity, the result is an infinity of the tion exception is recognized.
same sign. If the second operand is an SNaN, an
IEEE-invalid-operation condition is recognized; if Resulting Condition Code:
there is no interruption, the result is the corre- 0 Result is zero
sponding QNaN with the fraction extended. 1 Result is less than zero
2 --
3 Result is a NaN

19-38 z/Architecture Principles of Operation


IEEE Exception Conditions: None. Programming Note: The IEEE standard makes
it optional whether operations such as LOAD
Program Exceptions: POSITIVE signal invalid operation when the
Data with DXC 2, BFP instruction operand is an SNaN. LOAD AND TEST may be
Operation (if the BFP facility is not installed) used in conjunction with this instruction if signal-
Specification (LNXBR only) ling is desired.

Programming Note: The IEEE standard makes


it optional whether operations such as LOAD
LOAD ROUNDED
NEGATIVE signal invalid operation when the Mnemonic R,R [RRE]
operand is an SNaN. LOAD AND TEST may be
used in conjunction with this instruction if signal-
ling is desired. Op Code //////// R R

16 24 28 31
LOAD POSITIVE
Mnemonic Op Code Operands
Mnemonic R,R [RRE] LEDBR 'B344' Long BFP source,
short BFP target
LDXBR 'B345' Extended BFP source,
Op Code //////// R R long BFP target
LEXBR 'B346' Extended BFP source,
16 24 28 31 short BFP target

Mnemonic Op Code Operands The second operand, in the format of the source,
LPEBR 'B3' Short BFP is rounded to the precision of the target, and the
LPDBR 'B31' Long BFP
LPXBR 'B34' Extended BFP result is placed at the first-operand location. The
sign of the result is the same as the sign of the
The second operand is placed at the first-operand second operand.
location with the sign bit made zero.
The second operand, if numeric, is rounded to the
The sign bit is made zero, and the rest of the precision of the target fraction according to the
second operand is placed unchanged at the first- current rounding mode. Normally, the result is in
operand location. The sign is set for any operand, the format and length of the target. However,
including a QNaN or SNaN, without causing an when an IEEE overflow or an IEEE underflow
arithmetic exception. occurs and the corresponding mask bit is one, the
operation is completed by producing a wrapped
For LPXBR, the R fields must designate valid result in the same format and length as the source
floating-point-register pairs; otherwise, a specifica- but rounded to the precision of the target.
tion exception is recognized.
See Figure 19-21 on page 19-27 for a detailed
Resulting Condition Code: description of the results of this instruction.

0 Result is zero For LDXBR and LEXBR, the R and R fields


1 -- must designate valid floating-point-register pairs;
2 Result is greater than zero otherwise, a specification exception is recognized.
3 Result is a NaN
Condition Code: The code remains unchanged.
IEEE Exception Conditions: None.
IEEE Exception Conditions:
Program Exceptions:
Invalid operation
Data with DXC 2, BFP instruction Overflow
Operation (if the BFP facility is not installed) Underflow
Specification (LPXBR only) Inexact

Chapter 19. Binary-Floating-Point Instructions 19-39


Program Exceptions: Mnemonic2 R,D(X,B) [RXE]
Data with DXC 2, BFP instruction /
Data with DXC for IEEE exception condition Op Code R X B D ////////Op Code
Operation (if the BFP facility is not installed) /
Specification (LDXBR and LEXBR) 8 12 16 2 32 4 47

Mnemonic2 Op Code Operands


Programming Notes: MEEB 'ED17' Short BFP
1. The sign of the rounded result is the same as MDB 'ED1C' Long BFP
MDEB 'EDC' Short BFP multiplier and
the sign of the operand, even when the result
multiplicand, long BFP
is zero. product
2. The R field for LDXBR and LEXBR must MXDB 'ED7' Long BFP multiplier and
multiplicand, extended
designate a valid floating-point-register pair BFP product
since in certain cases the result is in the
extended format. In normal operation for The product of the second operand (the multiplier)
LDXBR and LEXBR, the result format is long and the first operand (the multiplicand) is placed
or short, respectively, and this result replaces at the first-operand location.
the leftmost 32 bits or 64 bits of the target-
register pair. However, when an IEEE over- The two BFP operands, if numeric and finite, are
flow or an IEEE underflow occurs and the multiplied, forming an intermediate product. For
corresponding mask bit is one, the operation MDEB, MDEBR, MXDB, and MXDBR, the inter-
is completed by placing a result in the mediate product is converted to the longer target
extended format at the target location. Thus, format; the result cannot overflow or underflow
the program must take into account the fact and is exact. For MDB, MDBR, MEEB, MEEBR,
that these instructions sometimes update both and MXBR, the result is rounded to the operand
registers of the pair. format according to the current rounding mode.
For MEEB and MEEBR, the result, as for all short-
MULTIPLY format results, replaces the leftmost 32 bits of the
target register, and the rightmost 32 bit positions
Mnemonic1 R,R [RRE] of the target register remain unchanged.

The sign of the product, if the product is numeric,


Op Code //////// R R is the EXCLUSIVE OR of the operand signs. This

16 24 28 31 includes the sign of a zero or infinite product.

Mnemonic1 Op Code Operands If one operand is a zero and the other an infinity,
MEEBR 'B317' Short BFP an IEEE-invalid-operation condition is recognized.
MDBR 'B31C' Long BFP
MXBR 'B34C' Extended BFP See Figure 19-26 on page 19-41 for a detailed
MDEBR 'B3C' Short BFP multiplier and
description of the results of this instruction.
multiplicand, long BFP
product
MXDBR 'B37' Long BFP multiplier and The R field for MXDB, MXDBR, and MXBR, and
multiplicand, extended the R field for MXBR, must designate valid
BFP product floating-point-register pairs. Otherwise, a specifi-
cation exception is recognized.

Condition Code: The code remains unchanged.

IEEE Exception Conditions:


Invalid operation
Overflow (MDB, MDBR, MEEB, MEEBR,
MXBR)

19-40 z/Architecture Principles of Operation


Underflow (MDB, MDBR, MEEB, MEEBR, Specification (MXDB, MXDBR, MXBR)
MXBR)
Programming Note: Interchanging the two oper-
Inexact (MDB, MDBR, MEEB, MEEBR,
ands in a BFP multiplication does not affect the
MXBR)
value of the product when the result is numeric.
This is not true, however, when both operands are
Program Exceptions:
QNaNs, in which case the result is the first
Access (fetch, operand 2 of MDEB, MEEB, operand; or when both operands are SNaNs and
MDB, and MXDB only) the IEEE-invalid-operation mask bit in the FPC
Data with DXC 2, BFP instruction register is zero, in which case the result is the
Data with DXC for IEEE exception condition QNaN derived from the first operand.
Operation (if the BFP facility is not installed)

Results for MULTIPLY (ab)


First
when Second Operand (b) Is
Operand
(a) Is Fn 0 +0 +Fn + QNaN SNaN
T(+) T(+) Xi: Xi: T() T() T(b) Xi: T(b*)
T(dNaN) T(dNaN)
Fn T(+) R(ab) T(+0) T(0) R(ab) T() T(b) Xi: T(b*)
0 Xi: T(+0) T(+0) T(0) T(0) Xi: T(b) Xi: T(b*)
T(dNaN) T(dNaN)
+0 Xi: T(0) T(0) T(+0) T(+0) Xi: T(b) Xi: T(b*)
T(dNaN) T(dNaN)
+Fn T() R(ab) T(0) T(+0) R(ab) T(+) T(b) Xi: T(b*)
+ T() T() Xi: Xi: T(+) T(+) T(b) Xi: T(b*)
T(dNaN) T(dNaN)
QNaN T(a) T(a) T(a) T(a) T(a) T(a) T(a) Xi: T(b*)
SNaN Xi: T(a*) Xi: T(a*) Xi: T(a*) Xi: T(a*) Xi: T(a*) Xi: T(a*) Xi: T(a*) Xi: T(a*)
Explanation:
* The SNaN is converted to the corresponding QNaN before it is placed at the target operand
location.
dNaN Default quiet NaN.
Fn Finite nonzero number (includes both denormalized and normalized).
R(v) Rounding and range action is performed on the value v. See Figure 19-17 on page 19-21.
T(x) The value x is placed at the target operand location.
Xi: IEEE invalid-operation exception. The results shown are produced only when FPC 0.0 is zero.

Figure 19-26. Results: MULTIPLY

Chapter 19. Binary-Floating-Point Instructions 19-41


MULTIPLY AND ADD MULTIPLY AND ADD and MULTIPLY AND SUB-
TRACT operations may be summarized as:
Mnemonic1 R,R,R [RRF]
op = opopop

Op Code R //// R R When the operands are numeric and finite, the
third and second BFP operands are multiplied,
16 2 24 28 31
forming an intermediate product, and the first
Mnemonic1 Op Code Operands operand is then added (or subtracted) algebra-
MAEBR 'B3E' Short BFP ically to (or from) the intermediate product, forming
MADBR 'B31E' Long BFP an intermediate sum. The intermediate sum, if
nonzero, is normalized and rounded to the
Mnemonic2 R,R,D(X,B) [RXF] operand format according to the current rounding
/ mode and then placed at the first-operand
Op Code R X B D R ////Op Code location. The exponent and fraction of the inter-
/ mediate product are maintained exactly; rounding
8 12 16 2 32 36 4 47 and range checking occur only on the intermediate
sum.
Mnemonic2 Op Code Operands
MAEB 'EDE' Short BFP
See Figure 19-27 on page 19-43 for a detailed
MADB 'ED1E' Long BFP
description of the results of MULTIPLY AND ADD.
The results of MULTIPLY AND SUBTRACT are
MULTIPLY AND SUBTRACT the same, except that the first operand partic-
ipates in the operation with its sign bit inverted.
Mnemonic1 R,R,R [RRF]

Condition Code: The code remains unchanged.


Op Code R //// R R
IEEE Exception Conditions:
16 2 24 28 31
Invalid operation
Mnemonic1 Op Code Operands Overflow
MSEBR 'B3F' Short BFP Underflow
MSDBR 'B31F' Long BFP Inexact

Mnemonic2 R,R,D(X,B) [RXF] Program Exceptions:


/ Access (fetch, operand 2 of MAEB, MADB,
Op Code R X B D R ////Op Code MSEB, MSDB)
/ Data with DXC 2, BFP instruction
8 12 16 2 32 36 4 47
Data with DXC for IEEE exception condition
Mnemonic2 Op Code Operands Operation (if the BFP facility is not installed)
MSEB 'EDF' Short BFP Programming Note: MULTIPLY AND ADD and
MSDB 'ED1F' Long BFP
MULTIPLY AND SUBTRACT produce a precise
The third operand is multiplied by the second intermediate result, and a single rounding opera-
operand, and then the first operand is added to or tion is performed after the addition or subtraction.
subtracted from the product. The sum or differ- This definition is consistent with the RS/6000, and,
ence is placed at the first-operand location. The in certain applications, can be used to great
advantage, especially in algorithms used in math
libraries.

19-42 z/Architecture Principles of Operation


Results, Part 1, for
MULTIPLY AND ADD (ab+c)
Third
when Second Operand (b) Is
Operand
(a) Is Fn 0 +0 +Fn + QNaN SNaN
P(+) P(+) Xi: Xi: P() P() P(b) Xi: T(b*)
T(dNaN) T(dNaN)
Fn P(+) P(ab) P(+0) P(0) P(ab) P() P(b) Xi: T(b*)
0 Xi: P(+0) P(+0) P(0) P(0) Xi: P(b) Xi: T(b*)
T(dNaN) T(dNaN)
+0 Xi: P(0) P(0) P(+0) P(+0) Xi: P(b) Xi: T(b*)
T(dNaN) T(dNaN)
+Fn P() P(ab) P(0) P(+0) P(ab) P(+) P(b) Xi: T(b*)
+ P() P() Xi: Xi: P(+) P(+) P(b) Xi: T(b*)
T(dNaN) T(dNaN)
QNaN P(a) P(a) P(a) P(a) P(a) P(a) P(a) Xi: T(b*)
SNaN Xi: T(a*) Xi: T(a*) Xi: T(a*) Xi: T(a*) Xi: T(a*) Xi: T(a*) Xi: T(a*) Xi: T(a*)

Figure 19-27 (Part 1 of 2). Results: MULTIPLY AND ADD

Chapter 19. Binary-Floating-Point Instructions 19-43


Results, Part 2, for
Value
MULTIPLY AND ADD (ab+c)
from Part
when First Operand (c) Is
1
(p) Is Fn 0 +0 +Fn + QNaN SNaN
T() T() T() T() T() Xi: T(c) Xi: T(c*)
T(dNaN)
Fn T() R(p+c) R(p) R(p) R(p+c) T(+) T(c) Xi: T(c*)
0 T() R(c) T(0) Rezd R(c) T(+) T(c) Xi: T(c*)
+0 T() R(c) Rezd T(+0) R(c) T(+) T(c) Xi: T(c*)
+Fn T() R(p+c) R(p) R(p) R(p+c) T(+) T(c) Xi: T(c*)
+ Xi: T(+) T(+) T(+) T(+) T(+) T(c) Xi: T(c*)
T(dNaN)
QNaN T(p) T(p) T(p) T(p) T(p) T(p) T(p) Xi: T(c*)
Explanation:
* The SNaN is converted to the corresponding QNaN before it is placed at the target operand
location.
dNaN Default quiet NaN.
Fn Finite nonzero number (includes both denormalized and normalized).
P(x) The value x is passed to Part 2 of this figure.
R(v) Rounding and range action is performed on the value v. See Figure 19-17 on page 19-21.
Rezd Exact zero-difference result. See Figure 19-17 on page 19-21.
T(x) The value x is placed at the target operand location.
Xi: IEEE invalid-operation exception. The results shown are produced only when FPC 0.0 is zero.

Figure 19-27 (Part 2 of 2). Results: MULTIPLY AND ADD

SET FPC IEEE Exception Conditions: None.

SFPC R [RRE] Program Exceptions:

'B384' //////// R //// Data with DXC 2, BFP instruction


Operation (if the BFP facility is not installed)
16 24 28 31 Specification

The contents of bit positions 32-63 of of the SET ROUNDING MODE


general register designated by R are placed in
the FPC (floating-point-control) register. SRNM D(B) [S]

All of bits 32-63 corresponding to unassigned bit 'B299' B D
positions in the FPC must be zero; otherwise, a
specification exception is recognized. Bits 0-31 of 16 2 31
the general register are ignored.
The rounding-mode bits are set from the second-
Condition Code: The code remains unchanged. operand address.

The second-operand address is not used to


address data; instead, the rounding-mode bits in
the FPC register are set with bits 30 and 31 of the
address.

19-44 z/Architecture Principles of Operation


Bits other than 30 and 31 of the second-operand If the second operand is less than zero, an
address are ignored. IEEE-invalid-operation condition is recognized.

Condition Code: The code remains unchanged. See Figure 19-21 on page 19-27 for a detailed
description of the results of this instruction.
IEEE Exception Conditions: None.
For SQXBR, the R fields must designate valid
Program Exceptions: floating-point-register pairs; otherwise, a specifica-
Data with DXC 2, BFP instruction tion exception is recognized.
Operation (if the BFP facility is not installed)
Condition Code: The code remains unchanged.

SQUARE ROOT IEEE Exception Conditions:

Mnemonic1 R,R [RRE] Invalid operation


Inexact

Op Code //////// R R Program Exceptions:

16 24 28 31 Access (fetch, operand 2 of SQEB and SQDB


only)
Mnemonic1 Op Code Operands Data with DXC 2, BFP instruction
SQEBR 'B314' Short BFP Data with DXC for IEEE exception condition
SQDBR 'B315' Long BFP
SQXBR 'B316' Extended BFP Operation (if the BFP facility is not installed)
Specification (SQXBR only)
Mnemonic2 R,D(X,B) [RXE]

/
STORE FPC
Op Code R X B D ////////Op Code
/ STFPC D(B) [S]
8 12 16 2 32 4 47
'B29C' B D
Mnemonic2 Op Code Operands
SQEB 'ED14' Short BFP 16 2 31
SQDB 'ED15' Long BFP
The contents of the FPC (floating-point-control)
The square root of the second operand is placed register are placed in storage at the second-
at the first-operand location. operand location.

The result rounded according to the current The operand is four bytes in length. All 32 bits of
rounding mode is placed at the first-operand the FPC register are stored.
location.
Condition Code: The code remains unchanged.
If the second operand is a finite positive number,
the result is the square root of that number with a IEEE Exception Conditions: None.
plus sign. If the operand is a zero of either sign,
the result is a zero of the same sign. If the Program Exceptions:
operand is +, the result is +. Access (store, operand 2)
Data with DXC 2, BFP instruction
Operation (if the BFP facility is not installed)

Chapter 19. Binary-Floating-Point Instructions 19-45


SUBTRACT Program Exceptions:
Access (fetch, operand 2 of SEB and SDB
Mnemonic1 R,R [RRE] only)
Data with DXC 2, BFP instruction
Op Code //////// R R Data with DXC for IEEE exception condition
Operation (if the BFP facility is not installed)
16 24 28 31 Specification (SXBR only)

Mnemonic1 Op Code Operands


SEBR 'B3B' Short BFP TEST DATA CLASS
SDBR 'B31B' Long BFP
SXBR 'B34B' Extended BFP Mnemonic R,D(X,B) [RXE]

Mnemonic2 R,D(X,B) [RXE] /


Op Code R X B D ////////Op Code
/ /
Op Code R X B D ////////Op Code 8 12 16 2 32 4 47
/
8 12 16 2 32 4 47 Mnemonic Op Code Operands
TCEB 'ED1' Short BFP
Mnemonic2 Op Code Operands TCDB 'ED11' Long BFP
SEB 'EDB' Short BFP TCXB 'ED12' Extended BFP
SDB 'ED1B' Long BFP
The class and sign of the first operand are exam-
The second operand is subtracted from the first ined to select one bit from the second-operand
operand, and the difference is placed at the first- address. Condition code 0 or 1 is set according to
operand location. whether the selected bit is zero or one, respec-
tively.
The execution of SUBTRACT is identical to that of
ADD, except that the second operand participates The second-operand address is not used to
in the operation with its sign bit inverted. See address data; instead, the rightmost 12 bits of the
Figure 19-16 on page 19-20 for the detailed address, bits 20-31, are used to specify 12 combi-
results of ADD. nations of operand class and sign. Bits 0-19 of
the second-operand address are ignored.
For SXBR, the R fields must designate valid
floating-point-register pairs; otherwise, a specifica- As shown in Figure 19-28, BFP operands are
tion exception is recognized. divided into six classes: zero, normalized number,
denormalized number, infinity, quiet NaN, and sig-
Resulting Condition Code: naling NaN.
0 Result is zero
1 Result is less than zero
2 Result is greater than zero Bit Used
3 Result is a NaN when Sign
Is
IEEE Exception Conditions: BFP Operand Class +
Invalid operation Zero 20 21
Overflow Normalized number 22 23
Underflow
Denormalized number 24 25
Inexact
Infinity 26 27
Quiet NaN 28 29
Signaling NaN 30 31

Figure 19-28. Second-Operand-Address Bits for TEST


DATA CLASS

19-46 z/Architecture Principles of Operation


One or more of the second-operand-address bits 0 Selected bit is 0 (no match)
may be set to one. If the second-operand- 1 Selected bit is 1 (match)
address bit corresponding to the class and sign of 2 --
the first operand is one, condition code 1 is set; 3 --
otherwise, condition code 0 is set.
IEEE Exception Conditions: None.
Operands, including SNaNs and QNaNs, are
examined without causing an arithmetic exception. Program Exceptions:
Data with DXC 2, BFP instruction
For TCXB, the R field must designate a valid
Operation (if the BFP facility is not installed)
floating-point-register pair; otherwise, a specifica-
Specification (TCXB only)
tion exception is recognized.
Programming Note: TEST DATA CLASS pro-
Resulting Condition Code: vides a way to test an operand without risk of an
exception or setting the IEEE flags.

Chapter 19. Binary-Floating-Point Instructions 19-47


19-48 z/Architecture Principles of Operation
Appendix A. Number Representation and Instruction-Use
Examples
Number Representation . . . . . . . . . . . . A-2 EXECUTE (EX) . . . . . . . . . . . . . . . A-21
Binary Integers . . . . . . . . . . . . . . . . A-2 INSERT CHARACTERS UNDER MASK
Signed Binary Integers . . . . . . . . . . A-2 (ICM) . . . . . . . . . . . . . . . . . . . A-21
Unsigned Binary Integers . . . . . . . . A-3 LOAD (L, LR) . . . . . . . . . . . . . . . . A-22
Decimal Integers . . . . . . . . . . . . . . . A-4 LOAD ADDRESS (LA) . . . . . . . . . . . A-22
Hexadecimal-Floating-Point Numbers . . . A-5 LOAD HALFWORD (LH) . . . . . . . . . A-23
Conversion Example . . . . . . . . . . . . . A-6 MOVE (MVC, MVI) . . . . . . . . . . . . . A-23
Instruction-Use Examples . . . . . . . . . . . A-6 MVC Example . . . . . . . . . . . . . . A-23
Machine Format . . . . . . . . . . . . . . . A-7 MVI Example . . . . . . . . . . . . . . A-24
Assembler-Language Format . . . . . . . . A-7 MOVE INVERSE (MVCIN) . . . . . . . . A-24
Addressing Mode in Examples . . . . . A-7 MOVE LONG (MVCL) . . . . . . . . . . . A-25
General Instructions . . . . . . . . . . . . . . . A-7 MOVE NUMERICS (MVN) . . . . . . . . A-25
ADD HALFWORD (AH) . . . . . . . . . . . A-7 MOVE STRING (MVST) . . . . . . . . . . A-26
AND (N, NC, NI, NR) . . . . . . . . . . . . A-8 MOVE WITH OFFSET (MVO) . . . . . . A-26
NI Example . . . . . . . . . . . . . . . . A-8 MOVE ZONES (MVZ) . . . . . . . . . . . A-27
Linkage Instructions (BAL, BALR, BAS, MULTIPLY (M, MR) . . . . . . . . . . . . A-27
BASR, BASSM, BSM) . . . . . . . . . . . A-8 MULTIPLY HALFWORD (MH) . . . . . . A-27
Other BALR and BASR Examples . . . A-9 OR (O, OC, OI, OR) . . . . . . . . . . . . A-28
BRANCH AND STACK (BAKR) . . . . . A-10 OI Example . . . . . . . . . . . . . . . A-28
BAKR Example 1 . . . . . . . . . . . . A-10 PACK (PACK) . . . . . . . . . . . . . . . A-28
BAKR Example 2 . . . . . . . . . . . . A-11 SEARCH STRING (SRST) . . . . . . . . A-29
BAKR Example 3 . . . . . . . . . . . . A-11 SRST Example 1 . . . . . . . . . . . . A-29
BRANCH ON CONDITION (BC, BCR) . A-11 SRST Example 2 . . . . . . . . . . . . A-29
BRANCH ON COUNT (BCT, BCTR) . . A-12 SHIFT LEFT DOUBLE (SLDA) . . . . . . A-29
BRANCH ON INDEX HIGH (BXH) . . . . A-12 SHIFT LEFT SINGLE (SLA) . . . . . . . A-30
BXH Example 1 . . . . . . . . . . . . . A-12 STORE CHARACTERS UNDER MASK
BXH Example 2 . . . . . . . . . . . . . A-13 (STCM) . . . . . . . . . . . . . . . . . . A-30
BRANCH ON INDEX LOW OR EQUAL STORE MULTIPLE (STM) . . . . . . . . A-30
(BXLE) . . . . . . . . . . . . . . . . . . A-13 TEST UNDER MASK (TM) . . . . . . . . A-31
BXLE Example 1 . . . . . . . . . . . . A-13 TRANSLATE (TR) . . . . . . . . . . . . . A-31
BXLE Example 2 . . . . . . . . . . . . A-14 TRANSLATE AND TEST (TRT) . . . . . A-32
COMPARE AND FORM CODEWORD UNPACK (UNPK) . . . . . . . . . . . . . A-33
(CFC) . . . . . . . . . . . . . . . . . . . A-14 UPDATE TREE (UPT) . . . . . . . . . . . A-34
COMPARE HALFWORD (CH) . . . . . . A-14 Decimal Instructions . . . . . . . . . . . . . . A-34
COMPARE LOGICAL (CL, CLC, CLI, ADD DECIMAL (AP) . . . . . . . . . . . . A-34
CLR) . . . . . . . . . . . . . . . . . . . . A-14 COMPARE DECIMAL (CP) . . . . . . . . A-34
CLC Example . . . . . . . . . . . . . . A-14 DIVIDE DECIMAL (DP) . . . . . . . . . . A-34
CLI Example . . . . . . . . . . . . . . . A-15 EDIT (ED) . . . . . . . . . . . . . . . . . . A-35
CLR Example . . . . . . . . . . . . . . A-15 EDIT AND MARK (EDMK) . . . . . . . . A-36
COMPARE LOGICAL CHARACTERS MULTIPLY DECIMAL (MP) . . . . . . . . A-36
UNDER MASK (CLM) . . . . . . . . . . A-15 SHIFT AND ROUND DECIMAL (SRP) . A-37
COMPARE LOGICAL LONG (CLCL) . . A-16 Decimal Left Shift . . . . . . . . . . . . A-37
COMPARE LOGICAL STRING (CLST) . A-17 Decimal Right Shift . . . . . . . . . . . A-37
CONVERT TO BINARY (CVB) . . . . . . A-18 Decimal Right Shift and Round . . . . A-38
CONVERT TO DECIMAL (CVD) . . . . . A-18 Multiplying by a Variable Power of 10 . A-38
DIVIDE (D, DR) . . . . . . . . . . . . . . . A-19 ZERO AND ADD (ZAP) . . . . . . . . . . A-38
EXCLUSIVE OR (X, XC, XI, XR) . . . . A-19 Hexadecimal-Floating-Point Instructions . . A-39
XC Example . . . . . . . . . . . . . . . A-19 ADD NORMALIZED (AD, ADR, AE, AER,
XI Example . . . . . . . . . . . . . . . A-20 AXR) . . . . . . . . . . . . . . . . . . . . A-39

Copyright IBM Corp. 1990, 2000 A-1


ADD UNNORMALIZED (AU, AUR, AW, Conditional Swapping Instructions (CS,
AWR) . . . . . . . . . . . . . . . . . . . A-39 CDS) . . . . . . . . . . . . . . . . . . . A-44
COMPARE (CD, CDR, CE, CER) . . . . A-40 Setting a Single Bit . . . . . . . . . . . A-44
DIVIDE (DD, DDR, DE, DER) . . . . . . A-40 Updating Counters . . . . . . . . . . . A-45
HALVE (HDR, HER) . . . . . . . . . . . . A-41 Bypassing Post and Wait . . . . . . . . . A-45
MULTIPLY (MD, MDR, MDE, MDER, Bypass Post Routine . . . . . . . . . . A-45
MXD, MXDR, MXR) . . . . . . . . . . . A-41 Bypass Wait Routine . . . . . . . . . . A-46
Hexadecimal-Floating-Point-Number Lock/Unlock . . . . . . . . . . . . . . . . . A-46
Conversion . . . . . . . . . . . . . . . . A-42 Lock/Unlock with LIFO Queuing for
Fixed Point to Hexadecimal Floating Contentions . . . . . . . . . . . . . . A-46
Point . . . . . . . . . . . . . . . . . . A-42 Lock/Unlock with FIFO Queuing for
Hexadecimal Floating Point to Fixed Contentions . . . . . . . . . . . . . . A-47
Point . . . . . . . . . . . . . . . . . . A-42 Free-Pool Manipulation . . . . . . . . . . A-48
Multiprogramming and Multiprocessing PERFORM LOCKED OPERATION (PLO) A-50
Examples . . . . . . . . . . . . . . . . . . A-43 Sorting Instructions . . . . . . . . . . . . . . A-51
Example of a Program Failure Using OR Tree Format . . . . . . . . . . . . . . . . . A-51
Immediate . . . . . . . . . . . . . . . . A-43 Example of Use of Sort Instructions . . . A-53

This appendix is the same as in Enterprise Negative binary integers are formed in two's-
Systems Architecture/390 Principles of Operation, complement notation by inverting each bit of the
SA22-7201; it has not been revised to show the positive binary integer and adding one. As an
enlargement of register sizes or the 64-bit example using the halfword format, the binary
addressing mode. number with the decimal value +26 is made nega-
tive (-26) in the following manner:
+26 1 11
Number Representation Invert 1 111 1111 111 11
Add 1 1

Binary Integers -26 1 111 1111 111 11 (Two's comple-
ment form)
Signed Binary Integers (S is the sign bit.)
Signed binary integers are most commonly repres- This is equivalent to subtracting the number:
ented as halfwords (16 bits) or words (32 bits). In
111
both lengths, the leftmost bit (bit 0) is the sign of from
the number. The remaining bits (bits 1-15 for 1
halfwords and 1-31 for words) are used to specify
the magnitude of the number. Binary integers are Negative binary integers are changed to positive
also referred to as fixed-point numbers, because in the same manner.
the radix point (binary point) is considered to be
The following addition examples illustrate two's-
fixed at the right, and any scaling is done by the
complement arithmetic and overflow conditions.
programmer.
Only eight bit positions are used.
Positive binary integers are in true binary notation 1. +57 = 11 11
with a zero sign bit. Negative binary integers are +35 = 1 11
in two's-complement notation with a one bit in the
+92 = 11 11
sign position. In all cases, the bits between the
sign bit and the leftmost significant bit of the 2. +57 = 11 11
integer are the same as the sign bit (that is, all -35 = 111 111

zeros for positive numbers, all ones for negative +22 = 1 11 No overflow -- carry into
numbers). leftmost position and
carry out

A-2 z/Architecture Principles of Operation


3. +35 = 1 11 1. If there is no carry into the leftmost bit
-57 = 11 111 position and no carry out (examples 1 and
3).
-22 = 111 11 Sign change only -- no
carry into leftmost posi- 2. If there is a carry into the leftmost position
tion and no carry out and also a carry out (examples 2 and 4).
4. -57 = 11 111
-35 = 111 111 There is an overflow:
1. If there is a carry into the leftmost position
-92 = 11 1 No overflow -- carry into but no carry out (example 5).
leftmost position and
carry out 2. If there is no carry into the leftmost posi-
5. +57 = 11 11 tion but there is a carry out (example 6).
+92 = 11 11
The following are 16-bit signed binary integers.

+149 =\11 11 \Overflow -- carry into The first is the maximum positive 16-bit binary
leftmost position, no integer. The last is the maximum negative 16-bit
carry out binary integer (the negative 16-bit binary integer
6. -57 = 11 111 with the greatest absolute value).
-92 = 11 1 2-1 = 32,767 = 111 1111 1111 1111
2 = 1 = 1
-149 =\11 111 \Overflow -- no carry into = =
leftmost position but carry -2 = -1 = 1 111 1111 1111 1111
out -2 = -32,768 = 1
The presence or absence of an overflow condition Figure A-1 illustrates several 32-bit signed binary
may be recognized from the carries: integers arranged in descending order. The first is
There is no overflow: the maximum positive binary integer that can be
represented by 32 bits, and the last is the
maximum negative binary integer that can be
represented by 32 bits.

2-1 = 2 147 483 647 = 111 1111 1111 1111 1111 1111 1111 1111
2 = 65 536 = 1
2 = 1 = 1
= =
-2 = -1 = 1 111 1111 1111 1111 1111 1111 1111 1111
-2 = -2 = 1 111 1111 1111 1111 1111 1111 1111 111
-2 = -65 536 = 1 111 1111 1111 1111
-2+1 = -2 147 483 647 = 1 1
-2 = -2 147 483 648 = 1

Figure A-1. 32-Bit Signed Binary Integers

Unsigned Binary Integers are used. The examples are numbered the same
Certain instructions, such as ADD LOGICAL, treat as the corresponding examples for signed binary
binary integers as unsigned rather than signed. integers.
Unsigned binary integers have the same format as 1. 57 = 11 11
signed binary integers, except that the leftmost bit 35 = 1 11
is interpreted as another numeric bit rather than a
sign bit. There is no complement notation 92 = 11 11
because all unsigned binary integers are consid- 2. 57 = 11 11
ered positive. 221 = 111 111

The following examples illustrate the addition of 278 =\1 11 \Carry out of leftmost
position
unsigned binary integers. Only eight bit positions

Appendix A. Number Representation and Instruction-Use Examples A-3


3. 35 = 1 11 6. 199 = 11 111
199 = 11 111 164 = 11 1

234 = 111 11 363 =\11 111 \Carry out of leftmost
position
4. 199 = 11 111
221 = 111 111 A carry out of the leftmost bit position may or may
not imply an overflow, depending on the applica-
42 =\11 1 \Carry out of leftmost
position tion.

5. 57 = 11 11 Figure A-2 illustrates several 32-bit unsigned


92 = 11 11 binary integers arranged in descending order.

149 = 11 11

2-1 = 4 294 967 295 = 1111 1111 1111 1111 1111 1111 1111 1111
2 = 2 147 483 648 = 1
2-1 = 2 147 483 647 = 111 1111 1111 1111 1111 1111 1111 1111
2 = 65 536 = 1
2 = 1 = 1
= =

Figure A-2. 32-Bit Unsigned Binary Integers

Decimal Integers desired, a leading zero must be inserted on the


left.
Decimal integers consist of one or more decimal
digits and a sign. Each digit and the sign are In the zoned format, each byte consists of a
represented by a 4-bit code. The decimal digits decimal digit on the right and the zone code 1111
are in binary-coded decimal (BCD) form, with the (F hex) on the left, except for the rightmost byte
values 0-9 encoded as 0000-1001. The sign is where the sign code replaces the zone code.
usually represented as 1100 (C hex) for plus and Thus, a decimal integer in the zoned format can
1101 (D hex) for minus. These are the preferred have from one to 16 digits. The zoned format
sign codes, which are generated by the machine may be used directly for input and output in the
for the results of decimal-arithmetic operations. extended binary-coded-decimal interchange code
There are also several alternate sign codes (1010, (EBCDIC), except that the sign must be separated
1110, and 1111 for plus; 1011 for minus). The from the rightmost digit and handled as a separate
alternate sign codes are accepted by the machine character. For positive (unsigned) numbers,
as valid in source operands but are not generated however, the sign can simply be represented by
for results. the zone code of the rightmost digit because the
zone code is one of the acceptable alternate
Decimal integers may have different lengths, from codes for plus.
one to 16 bytes. There are two decimal formats:
packed and zoned. In the packed format, each In either format, negative decimal integers are
byte contains two decimal digits, except for the represented in true notation with a separate sign.
rightmost byte, which contains the sign code in the As for binary integers, the radix point (decimal
right half. For decimal arithmetic, the number of point) of decimal integers is considered to be fixed
decimal digits in the packed format can vary from at the right, and any scaling is done by the pro-
one to 31. Because decimal integers must consist grammer.
of whole bytes and there must be a sign code on
the right, the number of decimal digits is always The following are some examples of decimal inte-
odd. If an even number of significant digits is gers shown in hexadecimal notation:

A-4 z/Architecture Principles of Operation


Decimal Short HFP Number
Value Packed Format Zoned Format /
SCharacteristic6-Digit Fraction
+123 12 3C F1 F2 C3 /
or or 1 8 31
12 3F F1 F2 F3

-4321 4 32 1D F4 F3 F2 D1 Long HFP Number


/
+5 5 C F F F F F5 C SCharacteristic 14-Digit Fraction
or or /
5 F F F F F F5 F 1 8 63

-7 7D D7
Extended HFP Number
C F F F F C High-Order Part
or or /
F F F F F F High-Order Leftmost 14 Digits
SCharacteristicof 28-Digit Fraction
Under some circumstances, a zero with a minus /
sign (negative zero) is produced. For example, 1 8 63
the multiplicand:
Low-Order Part
12 3D (-123) /
Low-Order Rightmost 14 Digits
times the multiplier: SCharacteristicof 28-Digit Fraction
C (+) /
64 72 127
generates the product:
D (-) An HFP number has two signs: one for the frac-
because the product sign follows the algebraic tion and one for the exponent. The fraction sign,
rule of signs even when the value is zero. A neg- which is also the sign of the entire number, is the
ative zero, however, is equivalent to a positive leftmost bit of each format (0 for plus, 1 for
zero in that they compare equal in a decimal com- minus). The numeric part of the fraction is in true
parison. notation regardless of the sign. The numeric part
is contained in bits 8-31 for the short format, in
bits 8-63 for the long format, and in bits 8-63 fol-
Hexadecimal-Floating-Point lowed by bits 72-127 for the extended format.
Numbers
The exponent sign is obtained by expressing the
A hexadecimal-floating-point (HFP) number is exponent in excess-64 notation; that is, the expo-
expressed as a hexadecimal fraction multiplied by nent is added as a signed number to 64. The
a separate power of 16. The term floating point resulting number is called the characteristic. It is
indicates that the placement, of the radix located in bits 1-7 for all formats. The character-
(hexadecimal) point, or scaling, is automatically istic can vary from 0 to 127, permitting the expo-
maintained by the machine. nent to vary from -64 through 0 to +63. This
provides a scale multiplier in the range of 16- to
The part of an HFP number which represents the 16+. A nonzero fraction, if normalized, has a
significant digits of the number is called the frac- value less than one and greater than or equal to
tion. A second part specifies the power (expo- 1/16, so that the range covered by the magnitude
nent) to which 16 is raised and indicates the M of a normalized floating-point number is:
location of the radix point of the number. The
16- M < 16
fraction and exponent may be represented by 32
bits (short format), 64 bits (long format), or 128 In decimal terms:
bits (extended format). 16- is approximately 5.4 x 1-

16 is approximately 7.2 x 1

Appendix A. Number Representation and Instruction-Use Examples A-5


More precisely, 10, and 11) is nonzero. It is unnormalized if the
leftmost digit contains all zeros.
In the short format:
16- M (1 - 16-) x 16 If normalization of the operand is desired, the HFP
instructions that provide automatic normalization
In the long format: are used. This automatic normalization is accom-
16- M (1 - 16-) x 16 plished by left-shifting the fraction (four bits per
shift) until a nonzero digit occupies the leftmost
In the extended format:
digit position. The characteristic is reduced by
16- M (1 - 16-) x 16 one for each digit shifted.
Within a given fraction length (6, 14, or 28 digits),
Figure A-3 illustrates sample normalized short
an HFP operation will provide the greatest preci-
HFP numbers. The last two numbers represent
sion if the fraction is normalized. A fraction is nor-
the smallest and the largest positive normalized
malized when the leftmost digit (bit positions 8, 9,
numbers.

1. = +1/16x16 = 1 1 1
.5 = +8/16x16 = 1 1
1/64 = +4/16x16- = 11 1111 1
. = + x16- =
-15. = -15/16x16 = 1 1 1 1111
5.4x1- +1/16x16- = 1
7.2x1 (1-16-)x16 = 111 1111 1111 1111 1111 1111 1111 1111

Figure A-3. Normalized Short Hexadecimal-Floating-Point Numbers

Conversion Example 6. The fraction is converted to binary and


grouped hexadecimally.
Convert the decimal number 59.25 to a short HFP .3B4 = .11 111 1
number. (In another appendix are tables for the
conversion of hexadecimal and decimal integers 7. The characteristic and the fraction are stored
and fractions.) in the short format. The sign position contains
the sign of the fraction.
1. The number is separated into a decimal
S Char Fraction
integer and a decimal fraction. 11 11 111 1
59.25 = 59 plus .25
Examples of instruction sequences that may be
2. The decimal integer is converted to its used to convert between signed binary integers
hexadecimal representation. and HFP numbers are shown in Hexadecimal-
59 = 3B Floating-Point-Number Conversion on page A-42.

3. The decimal fraction is converted to its


hexadecimal representation. Instruction-Use Examples
.25 = .4 The following examples illustrate the use of many
4. The integral and fractional parts are combined of the unprivileged instructions. Before studying
and expressed as a fraction times a power of one of these examples, the reader should consult
16 (exponent). the instruction description.
3B.4 = .3B4 x 16 The instruction-use examples are written princi-
5. The characteristic is developed from the expo- pally for assembler-language programmers, to be
nent and converted to binary. used in conjunction with the appropriate
assembler-language publications.
base + exponent = characteristic
64 + 2 = 66 = 11

A-6 z/Architecture Principles of Operation


Most examples present one particular instruction, labels that designate instruction fields, the letter
both as it is written in an assembler-language S is used to indicate the combination of base
statement and as it appears when assembled in and displacement fields for an operand address.
storage (machine format). (For example, S2 represents the combination of
B2 and D2.) In the machine-language format, the
Machine Format base and displacement address components are
shown as asterisks (****).
All machine-format values are given in
hexadecimal notation unless otherwise specified. Addressing Mode in Examples
Storage addresses are also given in hexadecimal. Except where otherwise specified, the examples
Hexadecimal operands are shown converted into assume the 24-bit addressing mode.
binary, decimal, or both if such conversion helps
to clarify the example for the reader.
General Instructions
Assembler-Language Format (See Chapter 7, General Instructions for a com-
plete description of the general instructions.)
In assembler-language statements, registers and
lengths are presented in decimal. Displacements, ADD HALFWORD (AH)
immediate operands, and masks may be shown in
decimal, hexadecimal, or binary notation; for The ADD HALFWORD instruction algebraically
example, 12, X'C', and B'1100' represent the adds the contents of a two-byte field in storage to
same value. Whenever the value in a register or the contents of a register. The storage operand is
storage location is referred to as not significant, expanded to 32 bits after it is fetched and before it
this value is replaced during the execution of the is used in the add operation. The expansion con-
instruction. sists in propagating the leftmost (sign) bit 16 posi-
tions to the left. For example, assume that the
When SS-format instructions are written in the contents of storage locations 2000-2001 are to be
assembler language, lengths are given as the total added to register 5. Initially:
number of bytes in the field. This differs from the
machine definition, in which the length field speci- Register 5 contains 00 00 00 19 = 25.
fies the number of bytes to be added to the field Storage locations 2000-2001 contain FF FE =
address to obtain the address of the last byte of -2.
the field. Thus, the machine length is one less
than the assembler-language length. The assem- Register 12 contains 00 00 18 00.
bler program automatically subtracts one from the Register 13 contains 00 00 01 50.
length specified when the instruction is assem-
The format of the required instruction is:
bled.
Machine Format
In some of the examples, symbolic addresses are
Op Code R X B D
used in order to simplify the examples. In
assembler-language statements, a symbolic 4A 5 D C 6B
address is represented as a mnemonic term
written in all capitals, such as FLAGS, which may
denote the address of a storage location con- Assembler Format
taining data or program-control information. When Op Code R,D(X,B)
symbolic addresses are used, the assembler sup-
plies actual base and displacement values AH 5,X'6B'(13,12)
according to the programmer's specifications.
Therefore, the actual values for base and dis- After the instruction is executed, register 5 con-
placement are not shown in the assembler- tains 00 00 00 17 = 23. Condition code 2 is set
language format or in the machine-language to indicate a result greater than zero.
format. For assembler-language formats, in the

Appendix A. Number Representation and Instruction-Use Examples A-7


AND (N, NC, NI, NR) mask of 15), to provide linkage between subrou-
tines. BRANCH AND LINK (BAL or BALR) is pro-
When the Boolean operator AND is applied to two vided primarily for compatibility with programs
bits, the result is one when both bits are one; oth- written for System/370; BRANCH AND SAVE
erwise, the result is zero. When two bytes are (BAS or BASR) is recommended instead for pro-
ANDed, each pair of bits is handled separately; grams which are to be executed using ESA/370.
there is no connection from one bit position to The instructions BRANCH AND SAVE AND SET
another. The following is an example of ANDing MODE (BASSM) and BRANCH AND SET MODE
two bytes: (BSM) provide subroutine linkage together with
switching between the 24-bit and the 31-bit
First-operand byte: 11 11 addressing modes. The use of these instructions
Second-operand byte: 11 11
is discussed in a programming note at the end of
Result byte: 1 1 Subroutine Linkage without the Linkage Stack.
(See also the semiprivileged instruction BRANCH
NI Example AND STACK.)
A frequent use of the AND instruction is to set a
particular bit to zero. For example, assume that The following example compares the operation of
storage location 4891 contains 0100 0011. To these instructions and of the unconditional-branch
set the rightmost bit of this byte to zero without instruction BRANCH ON CONDITION (BC or BCR
affecting the other bits, the following instruction with a mask of 15). Assume that each instruction
can be used (assume that register 8 contains 00 in turn is located at the current instruction
00 48 90): address, ready to be executed next. For the first
set of examples, the addressing-mode bit, PSW
Machine Format bit 32, is initially zero (24-bit addressing in effect).
Op Code I B D For the second set, PSW bit 32 is initially one
(31-bit addressing). Assume also that general
94 FE 8 1 register 5 is to receive the linkage information, and
that general register 6 contains the branch
address.
Assembler Format
Op Code D(B),I The format of the BALR instruction is:

NI 1(8),X'FE' Machine Format


Op Code R R
When this instruction is executed, the byte in
5 5 6
storage is ANDed with the immediate byte (the I
field of the instruction):
Location 4891: 1 11 Assembler Format
Immediate byte: 1111 111 Op Code R,R

Result: 1 1 BALR 5,6
The resulting byte, with bit 7 set to zero, is stored
back in location 4891. Condition code 1 is set. The other linkage instructions in the RR format
have the same format but different op codes:
Linkage Instructions (BAL, BALR, BASR D
BAS, BASR, BASSM, BSM) BASSM C
BSM B
Four unprivileged instructions (BRANCH AND
LINK, BRANCH AND SAVE, BRANCH AND SAVE For comparison with the RR-format instructions,
AND SET MODE, and BRANCH AND SET the results of two RX-format instructions are also
MODE) are available, together with the uncondi- shown.
tional branch (BRANCH ON CONDITION with a
The format of the BAL instruction is:

A-8 z/Architecture Principles of Operation


Machine Format 31-Bit Mode Initially
Op Code R X B D
Instruction Register 5 PSW (32-63)
45 5 6
Before BB BB BB BB 8 1 D6

BCR 15,6 BB BB BB BB 82 46 8A CE
Assembler Format BAL 5,(,6) 8 1 DA 82 46 8A CE
Op Code R,D(X,B) BAS 5,(,6) 8 1 DA 82 46 8A CE
BALR 5,6 8 1 D8 82 46 8A CE
BAL 5,(,6) BASR 5,6 8 1 D8 82 46 8A CE
BASSM 5,6 8 1 D8 82 46 8A CE
BSM 5,6 BB BB BB BB 82 46 8A CE
The BAS instruction has the same format, but the
op code is 4D.
Note that a value of zero in the R field of any of
The BCR instruction specifies only one register: the RR-format instructions indicates that the
branching function is not to be performed; it does
Machine Format not refer to register 0. Likewise, a value of zero in
Op Code M R the R field of the BSM instruction indicates that
the old value of PSW bit 32 is not to be saved and
7 F 6
that register 0 is to be left unchanged. Register 0
can be designated by the R field of instructions
BAL, BALR, BAS, BASR, and BASSM, however.
Assembler Format In the RX-format branch instructions, branching
Op Code M,R
occurs independent of whether there is a value of

BCR 15,6 zero in the B field or X field of the instruction.


However, when the field is zero, instead of using
the contents of general register 0, a value of zero
Assume that: is used for that component of address generation.
Register 5 contains BB BB BB BB. Programming Note: It should be noted that exe-
Register 6 contains 82 46 8A CE. cution of BAL in the 24-bit addressing mode
results in bit 0 of register 5 being set to one. This
PSW bits 32-63 contain
is because the ILC for an RX-format instruction is
00 00 10 D6 (for 24-bit addressing). 10. This is the only case in which bit zero of the
80 00 10 D6 (for 31-bit addressing). return register does not correctly reflect the
addressing mode of the caller. Thus, BSM may
Condition code is 01.
be used to return for BALR, BAS, BASR, and
Program mask is 1100. BASSM in both the 24-bit and the 31-bit
The effect of executing each instruction in turn is addressing modes, but it cannot be used to return
as follows: if the program was called by using BAL in the
24-bit addressing mode.
24-Bit Mode Initially
Other BALR and BASR Examples
Instruction Register 5 PSW (32-63) The BALR or BASR instruction with the R field
Before BB BB BB BB 1 D6 set to zero may be used to load a register for use
as a base register. For example, in the assembler
BCR 15,6 BB BB BB BB 46 8A CE language, the two statements:
BAL 5,(,6) 9C 1 DA 46 8A CE
BAS 5,(,6) 1 DA 46 8A CE BALR 15,
BALR 5,6 5C 1 D8 46 8A CE USING \,15
BASR 5,6 1 D8 46 8A CE or
BASSM 5,6 1 D8 82 46 8A CE
BSM 5,6 3B BB BB BB 82 46 8A CE BASR 15,
USING \,15

Appendix A. Number Representation and Instruction-Use Examples A-9


indicate that the address of the next sequential operation. If the R field of the instruction is zero,
instruction following the BALR or BASR instruction the operation is performed without branching.
will be placed in register 15, and that the assem-
bler may use register 15 as a base register until In addition to saving a complete PSW (except with
otherwise instructed. (The USING statement is an an unpredictable PER mask) in the state entry,
assembler instruction and is thus not a part of BRANCH AND STACK saves the new value of
the object program.) bits 32-63 of the current PSW in the state entry.
Bits 32-63 are referred to in the following exam-
ples as the branch value.
BRANCH AND STACK (BAKR)
The following examples contain cases in which bit
The semiprivileged BRANCH AND STACK instruc-
32 of the current PSW is either zero or one (24-bit
tion facilitates linkage between subroutines by
or 31-bit addressing) before BRANCH AND
saving status in a linkage-stack state entry (some-
STACK is executed and in which bit 0 of the
times called a branch state entry to distinguish it
general register designated by a nonzero R or R
from a program-call state entry). When BRANCH
field is either zero or one.
AND STACK has been used, the return from the
called program is made by means of the
PROGRAM RETURN instruction. PROGRAM
BAKR Example 1
This example shows BAKR used in a calling
RETURN restores access registers 2-14, general
program. BAKR performs a branch, and the
registers 2-14, and the PSW with values saved in
return is to be to the next sequential instruction.
the state entry, except that it leaves the PER
mask unchanged and sets the condition code to
The format of the BAKR instruction is:
an unpredictable value. The use of BRANCH
AND STACK is discussed in Branching Using the Machine Format
Linkage Stack on page 5-62. Op Code R R

BRANCH AND STACK can be used to perform a B24 6
calling linkage, or it can be used at or near the
entry point of the called program, depending on
whether the R field of the instruction is zero or Assembler Format
nonzero, respectively. If the R field is zero, bits Op Code R,R
32-63 of the PSW saved in the state entry indicate
the current addressing mode (24-bit or 31-bit) and BAKR ,6
the address of the next sequential instruction after
the BRANCH AND STACK instruction or an Assume four cases of initial values, as follows:
EXECUTE instruction. If the R field is nonzero,
bits 32-63 of the PSW saved in the state entry are PSW (32-63) Register 6
set with a value generated from the contents of
1. 1 D6 2 46 8A CE
general register R: bit 32 of the PSW is set equal 2. 1 D6 82 46 8A CE
to bit 0 of the register, and bits 1-31 of the PSW 3. 8 1 D6 2 46 8A CE
are set with an address generated from bits 1-31 4. 8 1 D6 82 46 8A CE
of the register under the control of bit 0 of the reg-
ister. Bits 32-63 of the PSW saved in the state
The results in the four cases are as follows:
entry are referred to in the following examples as
the return value. Return Branch Value
Value and PSW (32-63)
The branch address for the instruction is gener-
ated from the contents of general register R 1. 1 DA 46 8A CE
under the control of the current addressing mode. 2. 1 DA 46 8A CE
3. 8 1 DA 82 46 8A CE
Bit 0 of general register R does not affect the 4. 8 1 DA 82 46 8A CE

A-10 z/Architecture Principles of Operation


BAKR Example 2 Assume eight cases of initial values, as follows:
This example shows BAKR used in a called
Register 5 Register 6 PSW (32-63)
program. BAKR does not perform a branch, and
the return is to be as specified in general register 1. 4 1 D6 6 99 99 46 8A CE
R. 2. 4 1 D6 6 99 99 82 46 8A CE
3. 4 1 D6 86 99 99 46 8A CE
The format of the BAKR instruction is: 4. 4 1 D6 86 99 99 82 46 8A CE
5. 84 1 D6 6 99 99 46 8A CE
Machine Format 6. 84 1 D6 6 99 99 82 46 8A CE
Op Code R R 7. 84 1 D6 86 99 99 46 8A CE
8. 84 1 D6 86 99 99 82 46 8A CE
B24 5
The results in the eight cases are as follows:

Assembler Format Return Branch Value


Op Code R,R Value and PSW (32-63)

BAKR 5, 1. 1 D6 99 99
2. 1 D6 86 99 99
3. 1 D6 99 99
Assume four cases of initial values, as follows: 4. 1 D6 86 99 99
5. 84 1 D6 99 99
Register 5 PSW (32-63) 6. 84 1 D6 86 99 99
7. 84 1 D6 99 99
1. 4 1 D6 46 8A CE 8. 84 1 D6 86 99 99
2. 4 1 D6 82 46 8A CE
3. 84 1 D6 46 8A CE
4. 84 1 D6 82 46 8A CE BRANCH ON CONDITION (BC,
BCR)
The results in the four cases are as follows:
The BRANCH ON CONDITION instruction tests
Return Branch Value the condition code to see whether a branch should
Value and PSW (32-63) or should not occur. The branch occurs only if the
1. 1 D6 46 8A D2 current condition code corresponds to a one bit in
2. 1 D6 82 46 8A D2 a mask specified by the instruction.
3. 84 1 D6 46 8A D2
4. 84 1 D6 82 46 8A D2 Condition Instruction
Code (Mask) Bit Mask Value
0 8 8
BAKR Example 3
1 9 4
This example shows BAKR used in a called
2 10 2
program. BAKR performs a branch, and the
3 11 1
return is to be as specified in general register R.
For example, assume that an ADD (A or AR)
The format of the BAKR instruction is:
operation has been performed and that a branch
Machine Format to address 6050 is desired if the sum is zero or
Op Code R R less (condition code is 0 or 1). Also assume:
Register 10 contains 00 00 50 00.
B24 5 6
Register 11 contains 00 00 10 00.
The RX form of the instruction performs the
Assembler Format required test (and branch if necessary) when
Op Code R,R written as:

BAKR 5,6

Appendix A. Number Representation and Instruction-Use Examples A-11


Machine Format Assembler Format
Op Code M X B D Op Code R,D(X,B)

47 C B A 5 BCT 6,X'26'(,1)

The effect of the coding is to execute three times


Assembler Format the loop defined by the instructions labeled LUPE
Op Code M,D(X,B) through BACK, while register 6 is decremented

BC 12,X'5'(11,1) from three to zero.

A mask of 12 means that there are ones in BRANCH ON INDEX HIGH (BXH)
instruction bits 8 and 9 and zeros in bits 10 and
11, so that branching takes place when the condi- BXH Example 1
tion code is either 0 or 1. The BRANCH ON INDEX HIGH instruction is an
index-incrementing and loop-controlling instruction
A mask of 15 would indicate a branch on any con- that causes a branch whenever the sum of an
dition (an unconditional branch). A mask of zero index value and an increment value is greater
would indicate that no branch is to occur (a no- than some compare value. For example, assume
operation). that:
Register 4 contains 00 00 00 8A = 138 =
(See also Linkage Instructions (BAL, BALR, BAS, the index.
BASR, BASSM, BSM) on page A-8 for an
example of the BCR instruction.) Register 6 contains 00 00 00 02 = 2 = the
increment.
BRANCH ON COUNT (BCT, Register 7 contains 00 00 00 AA = 170 =
BCTR) the compare value.
Register 10 contains 00 00 71 30 = the
The BRANCH ON COUNT instruction is often branch address.
used to execute a program loop for a specified
number of times. For example, assume that the The format of the BXH instruction is:
following represents some lines of coding in an
Machine Format
assembler-language program: Op Code R R B D
..
.
LUPE AR 8,1 86 4 6 A
..
.
BACK BCT 6,LUPE
..
. Assembler Format
Op Code R,R,D(B)
where register 6 contains 00 00 00 03 and the
address of LUPE is 6826. Assume that, in order BXH 4,6,(1)
to address this location, register 10 is used as a
base register and contains 00 00 68 00. When the instruction is executed, first the contents
of register 6 are added to register 4, second the
The format of the BCT instruction is:
sum is compared with the contents of register 7,
and third the decision whether to branch is made.
Machine Format
Op Code R X B D After execution:
Register 4 contains 00 00 00 8C = 140.
46 6 A 26
Registers 6 and 7 are unchanged.
Since the new value in register 4 is not yet greater
than the value in register 7, the branch to address
7130 is not taken. Repeated use of the instruction

A-12 z/Architecture Principles of Operation


will eventually cause the branch to be taken when found, the BXH instruction will be executed seven
the value in register 4 reaches 172. times. Each time BXH is executed, a value of -4
is added to register 10, thus reducing the value in
BXH Example 2 register 10 by 4. The new value in register 10 is
When the register used to contain the increment is compared with the -4 value in register 9. The
odd, that register also becomes the compare- branch is taken each time until the value in reg-
value register. The following assembler-language ister 10 is -4. Then the branch is not taken, and
subroutine illustrates how this may be used to the SR instruction sets register 8 to zero.
search a table.
BRANCH ON INDEX LOW OR
Table EQUAL (BXLE)

2 Bytes 2 Bytes
The BRANCH ON INDEX LOW OR EQUAL
ARG1 FUNCT1 instruction performs the same operation as
ARG2 FUNCT2 BRANCH ON INDEX HIGH, except that branching
ARG3 FUNCT3 occurs when the sum is lower than or equal to
ARG4 FUNCT4 (instead of higher than) the compare value. As
ARG5 FUNCT5
ARG6 FUNCT6 the instruction which increments and tests an
index value in a program loop, BXLE is useful at
the end of the loop and BXH at the beginning.
Assume that: The following assembler-language routines illus-
Register 8 contains the search argument. trate loops with BXLE.
Register 9 contains the width of the table in
bytes (00 00 00 04).
BXLE Example 1
Assume that a group of ten 32-bit signed binary
Register 10 contains the length of the table in integers are stored at consecutive locations,
bytes (00 00 00 18). starting at location GROUP. The integers are to
Register 11 contains the starting address of be added together, and the sum is to be stored at
the table. location SUM.
SR 5,5 Set sum to zero
Register 14 contains the return address to the
LA 6,GROUP Load first address
main program.
SR 7,7 Set index to zero
As the following subroutine is executed, the argu- LA 8,4 Load increment 4
ment in register 8 is successively compared with LA 9,39 Load compare value
the arguments in the table, starting with argument LOOP A 5,(7,6) Add integer to sum
6 and working backward to argument 1. If an BXLE 7,8,LOOP Test end of loop
equality is found, the corresponding function ST 5,SUM Store sum
replaces the argument in register 8. If an equality The two-instruction loop contains an ADD (A)
is not found, zero replaces the argument in reg- instruction which adds each integer to the con-
ister 8. tents of general register 5. The ADD instruction
SEARCH LNR 9,9 uses the contents of general register 7 as an
NOTEQUAL BXH 1,9,LOOP index value to modify the starting address
NOTFOUND SR 8,8 obtained from register 6. Next, BXLE increments
BCR 15,14 the index value by 4, the increment previously
LOOP CH 8,(1,11) loaded into register 8, and compares it with the
BC 7,NOTEQUAL compare value in register 9, the odd register of
LH 8,2(1,11) this even-odd pair. The compare value was previ-
BCR 15,14 ously set to 39, which is one less than the number
The first instruction (LNR) causes the value in reg- of bytes in the data area; this is also the address,
ister 9 to be made negative. After execution of relative to the starting address, of the rightmost
this instruction, register 9 contains FF FF FF FC = byte of the last integer to be added. When the
-4. Considering the case when no equality is last integer has been added, BXLE increments the
index value to the next relative address (40),

Appendix A. Number Representation and Instruction-Use Examples A-13


which is found to be greater than the compare as in Example 1, or starting at the end and step-
value (39) so that no branching takes place. ping downward through the data area with a nega-
tive increment.
BXLE Example 2
The technique illustrated in Example 1 is restricted COMPARE AND FORM
to loops containing instructions in the RX instruc-
tion format. That format allows both a base reg-
CODEWORD (CFC)
ister and an index register to be specified (double
See Sorting Instructions on page A-51.
indexing).

For instructions in other formats, where an index COMPARE HALFWORD (CH)


register cannot be specified, the previous tech-
nique may be modified by having the address The COMPARE HALFWORD instruction compares
itself serve as the index value in a BXLE instruc- a 16-bit signed binary integer in storage with the
tion and by using as the compare value the contents of a register. For example, assume that:
address of the last byte rather than its relative Register 4 contains FF FF 80 00 = -32,768.
address. The base register then provides the
address directly at each iteration of the loop, and Register 13 contains 00 01 60 50.
it is not necessary to specify a second register to Storage locations 16080-16081 contain 8000
hold the index value (single indexing). = -32,768.

In the following example, an AND (NI) instruction When the instruction:


in the SI instruction format sets to zero the right-
most bit of each of the same group of integers as Machine Format
Op Code R X B D
in Example 1, thus making all of them even. The
I field of the NI instruction contains the byte 49 4 D 3
X'FE', which consists of seven ones and a zero.
That byte is ANDed into byte 3, the rightmost
byte, of each of the integers in turn. Assembler Format
LA 6,GROUP Load first address Op Code R,D(X,B)
LA 8,4 Load increment 4
LA 9,GROUP+39 Load compare value CH 4,X'3'(,13)
LOOP NI 3(6),X'FE' AND immediate
BXLE 6,8,LOOP Test end of loop is executed, the contents of locations
The technique shown in Example 2 does not work, 16080-16081 are fetched, expanded to 32 bits
however, on an ESA/370 system when it is in the (the sign bit is propagated to the left), and com-
31-bit addressing mode and the data is located at pared with the contents of register 4. Because the
the rightmost end of a 31-bit address space. In two numbers are equal, condition code 0 is set.
this case, the compare value would be set to
2-1, which is the largest possible 32-bit signed COMPARE LOGICAL (CL, CLC,
binary value. The reason the technique does not CLI, CLR)
work is that the BXLE and BXH instructions treat
their operands as 32-bit signed binary integers. The COMPARE LOGICAL instruction differs from
When the address in general register 6 reaches the signed-binary comparison instructions (C, CH,
the value 2-4, BXLE increments it to a value CR) in that all quantities are handled as unsigned
that is interpreted as -2, rather than 2, and binary integers or as unstructured data.
the comparison remains low, which causes
looping to continue indefinitely. CLC Example
The COMPARE LOGICAL (CLC) instruction can
This situation can be avoided by not allowing data
be used to perform the byte-by-byte comparison of
areas to extend to the rightmost location in a
storage fields up to 256 bytes in length. For
31-bit address space or by using other techniques;
example, assume that the following two fields of
these may include double indexing when possible,
data are in storage:

A-14 z/Architecture Principles of Operation


Field 1 Machine Format
1886 1891 Op Code I B D

D1D6C8D5E2D6D56BC14BC24B 95 AF A 3

Field 2 Assembler Format


19 19B Op Code D(B),I

D1D6C8D5E2D6D56BC14BC34B CLI 3(1),X'AF'

sets condition code 1, indicating that the first


Also assume: operand (the quantity in main storage) is lower
Register 9 contains 00 00 18 80. than the second (immediate) operand.

Register 7 contains 00 00 19 00. CLR Example


Execution of the instruction: Assume that:
Register 4 contains 00 00 00 01 = 1.
Machine Format
Op Code L B D B D Register 7 contains FF FF FF FF = 2 - 1.

D5 B 9 6 7 Execution of the instruction:

Machine Format
Op Code R R
Assembler Format
Op Code D(L,B),D(B) 15 4 7

CLC 6(12,9),(7)

Assembler Format
sets condition code 1, indicating that the contents Op Code R,R
of field 1 are lower in value than the contents of
field 2. CLR 4,7

Because the collating sequence of the EBCDIC sets condition code 1. Condition code 1 indicates
code is determined simply by a logical comparison that the first operand is lower than the second.
of the bits in the code, the CLC instruction can be
used to collate EBCDIC-coded fields. For If, instead, the signed-binary comparison instruc-
example, in EBCDIC, the above two data fields tion COMPARE (CR) had been executed, the con-
are: tents of register 4 would have been interpreted as
Field 1: JOHNSON,A.B. +1 and the contents of register 7 as -1. Thus, the
Field 2: JOHNSON,A.C. first operand would have been higher, so that con-
dition code 2 would have been set.
Condition code 1 indicates that JOHNSON,A.B.
should precede JOHNSON,A.C. for the fields to
be in alphabetic sequence. COMPARE LOGICAL
CHARACTERS UNDER MASK
CLI Example (CLM)
The COMPARE LOGICAL (CLI) instruction com-
pares a byte from the instruction stream with a The COMPARE LOGICAL CHARACTERS
byte from storage. For example, assume that: UNDER MASK (CLM) instruction provides a
Register 10 contains 00 00 17 00. means of comparing bytes selected from a
general register to a contiguous field of bytes in
Storage location 1703 contains 7E. storage. The M field of the CLM instruction is a
Execution of the instruction:

Appendix A. Number Representation and Instruction-Use Examples A-15


four-bit mask that selects zero to four bytes from a operand it covers, and the leftmost byte of the
general register, each mask bit corresponding, left second-operand odd register contains a padding
to right, to a register byte. In the comparison, the byte which is used to extend the shorter operand,
register bytes corresponding to ones in the mask if any, to the same length as the longer operand.
are treated as a contiguous field. The operation
proceeds left to right. For example, assume that: The following illustrates the assignment of regis-
ters in the 24-bit addressing mode:
Storage locations 10200-10202 contain F0 BC
7B.
R ////////First-Operand Address
Register 12 contains 00 01 00 00.
(even)
Register 6 contains F0 BC 5C 7B. 8 31

Execution of the instruction:



R+1 //////// First-Operand Length
Machine Format (odd)
Op Code R M B D 8 31

BD 6 D C 2

R ////////Second-Operand Address
(even)
Assembler Format 8 31
Op Code R,M,D(B)

CLM 6,B'111',X'2'(12)
R+1 Pad ByteSecond-Operand Length
(odd)
causes the following comparison: 8 31
Register 6: F BC 5C 7B
Mask M: 1 1 1 In the 31-bit addressing mode, the operand
-- -- --
addresses would be in bit positions 1-31 of the
F BC 7B even registers shown above.

Storage Since the CLCL instruction may be interrupted
locations during execution, the interrupting program must
12-122: F BC 7B preserve the contents of the four registers for use

when the instruction is resumed.
Because the selected bytes are equal, condition
code 0 is set. The following instructions set up two register pairs
to control a text-string comparison. For example,
assume:
COMPARE LOGICAL LONG
Operand 1
(CLCL) Address: 28
Length: 1
The COMPARE LOGICAL LONG instruction is
used to compare two operands in storage, byte by Operand 2
byte. Each operand can be of any length. Two Address: 2A
even-odd pairs of general registers (four registers Length: 132
in all) are used to locate the operands and to Padding Byte
control the execution of the CLCL instruction, as Address: 23
illustrated in the following diagram. The first reg- Length: 1
ister of each pair must be an even register, and it Value: 4
contains the storage address of an operand. The Register 12 contains 00 02 00 00.
odd register of each pair contains the length of the
The setup instructions are:

A-16 z/Architecture Principles of Operation


LA 4,X'800'(12) Set register 4 to start of incremented to X'2083C' and X'20A3C'; the left-
first operand most byte of registers 4 and 8 will have been set
LA 5,100 Set register 5 to length to zero. The padding byte X'40' remains in reg-
of first operand ister 9. When the CLCL instruction is reexecuted
LA 8,X'A00'(12) Set register 8 to start of with these register contents, the comparison
second operand resumes at the point of interruption.
LA 9,132 Set register 9 to length
of second operand Now, assume that the instruction is interrupted
ICM 9,B'1000',3(12) Insert padding byte in after 110 bytes. That is, the first 100 bytes of the
leftmost byte position of second operand have compared equal to the first
register 9 operand, and the next 10 bytes of the second
operand have compared equal to the padding byte
Register pair 4,5 defines the first operand. Bits (blank). The residual operand lengths in registers
8-31 of register 4 contain the storage address of 5 and 9 are 0 and 22, respectively, and the
the start of an EBCDIC text string, and bits 8-31 of operand addresses in registers 4 and 8 are
register 5 contain the length of the string, in this X'20864' (the value when the first operand was
case 100 bytes. exhausted) and X'20A6E' (the current value for
the second operand).
Register pair 8,9 defines the second operand, with
bits 8-31 of register 8 containing the starting When the comparison ends, the condition code is
location of the second operand and bits 8-31 of set to 0, 1, or 2, depending on whether the first
register 9 containing the length of the second operand is equal to, less than, or greater than the
operand, in this case 132 bytes. Bits 0-7 of reg- second operand, respectively.
ister 9 contain an EBCDIC blank character
(X'40') to pad the shorter operand. In this When the operands are unequal, the addresses in
example, the padding byte is used in the first registers 4 and 8 indicate the bytes that caused
operand, after the 100th byte, to compare with the the mismatch.
remaining bytes in the second operand.
COMPARE LOGICAL STRING
With the register pairs thus set up, the format of
the CLCL instruction is:
(CLST)
The COMPARE LOGICAL STRING instruction is
Machine Format
Op Code R R used to compare a first operand designated by
general register R and a second operand desig-
F 4 8 nated by general register R. The comparison is
made left to right, byte by byte, until unequal bytes
are compared, an ending character specified in
Assembler Format general register 0 is encountered in either
Op Code R,R operand, or a CPU-determined number of bytes
have been compared. The condition code is set
CLCL 4,8 to 0 if the two operands are equal, to 1 if the first
operand is low, to 2 if the second operand is low,
When this instruction is executed, the comparison or to 3 if a CPU-determined number of bytes have
starts at the left end of each operand and pro- been compared. If the ending character is found
ceeds to the right. The operation ends as soon as in both operands simultaneously, the operands are
an inequality is detected or the end of the longer equal. If it is found in only one operand, that
operand is reached. operand is low.

If this CLCL instruction is interrupted after 60 When condition code 1 or 2 is set, the addresses
bytes have compared equal, the operand lengths of the last bytes processed in the first and second
in registers 5 and 9 will have been decremented operands are placed in general registers R and
to 40 and 72, respectively. The operand R, respectively. These are the addresses of
addresses in registers 4 and 8 will have been unequal bytes in the two operands, or they are the

Appendix A. Number Representation and Instruction-Use Examples A-17


address of an ending character in one operand Example 8
and of the byte in the corresponding byte position 1 2
in the other operand. When condition code 3 is 4 4 4 4 4 4 4
set, the addresses of the next bytes to be proc- CC: 2; (R): 1; (R): 2
essed are placed in the registers. When condition
Example 9
code 0 is set, the contents of the registers remain
1 2
unchanged. 4 4 4 4 4 4

Following are examples of first and second oper- CC: ; (R): 1; (R): 2
ands beginning at decimal locations 1000 and
2000, respectively. The addresses in general reg-
CONVERT TO BINARY (CVB)
isters R and R are 1000 and 2000, respectively.
The ending character in general register 0 is 00 The CONVERT TO BINARY instruction converts
hex (as in the C programming language). The an eight-byte, packed-decimal number into a
values of the operand bytes are shown in hex, signed binary integer and loads the result into a
and the resulting condition code and final contents general register. After the conversion operation is
of general registers R and R are shown. completed, the number is in the proper form for
Example 1 use as an operand in signed binary arithmetic.
1 2 For example, assume:
C1 C2 C3 C1 C2 C3
Storage locations 7608-760F contain a
CC: ; (R): 1; (R): 2 decimal number in the packed format: 00 00
Example 2 00 00 00 25 59 4C (+25,594).
1 2
4 4 4 C1 4 4 4 C2 The contents of register 7 are not significant.
Register 13 contains 00 00 76 00.
CC: 1; (R): 13; (R): 23
The format of the conversion instruction is:
Example 3
1 2
4 4 4 C2 4 4 4 C1 Machine Format
Op Code R X B D
CC: 2; (R): 13; (R): 23
4F 7 D 8
Example 4
1 2
C1 C2 C3 C1 C2 C3 C4
Assembler Format
CC: 1; (R): 13; (R): 23 Op Code R,D(X,B)

Example 5 CVB 7,8(,13)
1 2
C1 C2 C3 C4 C1 C2 C3
After the instruction is executed, register 7 con-
CC: 2; (R): 13; (R): 23 tains 00 00 63 FA.
Example 6
Assuming that the CPU-determined number of
bytes compared is 256: CONVERT TO DECIMAL (CVD)
1 1256 2 2256 The CONVERT TO DECIMAL instruction is the
4 .. 4 4 .. 4 opposite of the CONVERT TO BINARY instruc-
tion. CVD converts a signed binary integer in a
CC: 3; (R): 1256; (R): 2256
register to packed decimal and stores the eight-
Example 7 byte result. For example, assume:
1 2
4 4 4 4 4 4 4 Register 1 contains the signed binary integer:
00 00 0F 0F.
CC: 1; (R): 1; (R): 2
Register 13 contains 00 00 76 00.

A-18 z/Architecture Principles of Operation


The format of the instruction is: Machine Format
Op Code R X B D
Machine Format
Op Code R X B D 5D 6 8 4

4E 1 D 8

After the instructions listed above are executed:


Register 6 contains 00 00 00 14 = 20 = the
Assembler Format
Op Code R,D(X,B) remainder.
Register 7 contains 00 00 00 2D = 45 = the
CVD 1,8(,13)
quotient.
Note that if the dividend had not been first placed
After the instruction is executed, storage locations
in register 6 and shifted into register 7, register 6
7608-760F contain 00 00 00 00 00 03 85 5C
might not have been filled with the proper
(+3855).
dividend-sign bits (zeros in this example), and the
The plus sign generated is the preferred plus sign, DIVIDE instruction might not have given the
1100. expected results.

DIVIDE (D, DR) EXCLUSIVE OR (X, XC, XI, XR)

The DIVIDE instruction divides the dividend in an When the Boolean operator EXCLUSIVE OR is
even-odd register pair by the divisor in a register applied to two bits, the result is one when either,
or in storage. Since the instruction assumes the but not both, of the two bits is one; otherwise, the
dividend to be 64 bits long, it is important first to result is zero. When two bytes are EXCLUSIVE
extend a 32-bit dividend on the left with bits equal ORed, each pair of bits is handled separately;
to the sign bit. For example, assume that: there is no connection from one bit position to
another. The following is an example of the
Storage locations 3550-3553 contain 00 00 08 EXCLUSIVE OR of two bytes:
DE = 2270 (the dividend).
First-operand byte: 11 11
Storage locations 3554-3557 contain 00 00 00 Second-operand byte: 11 11
32 = 50 (the divisor).
Result byte: 11 11
The initial contents of registers 6 and 7 are
not significant. XC Example
Register 8 contains 00 00 35 50. The EXCLUSIVE OR (XC) instruction can be used
to exchange the contents of two areas in storage
The following assembler-language statements load without the use of an intermediate storage area.
the registers properly and perform the divide oper- For example, assume two three-byte fields in
ation: storage:
359 35B
Statement Comments
Field 1 179
L 6,(,8) Places 8 DE into reg-
ister 6.
SRDA 6,32() Shifts 8 DE into reg- 36 362
ister 7. Register 6 is
filled with zeros (sign Field 2 141
bits).
D 6,4(,8) Performs the division.
Execution of the instruction (assume that register
The machine format of the above DIVIDE instruc- 7 contains 00 00 03 58):
tion is:

Appendix A. Number Representation and Instruction-Use Examples A-19


Machine Format Assembler Format
Op Code L B D B D Op Code D(L,B),D(B)

D7 2 7 1 7 8 XC 1(3,7),8(7)

produces the following result:


Assembler Format Field 1: 11 111 = 3 91
Op Code D(L,B),D(B) Field 2: 1111 11 = 17 9

XC 1(3,7),8(7) Result: 11 1 = 14 1

The result of this operation replaces the former


Field 1 is EXCLUSIVE ORed with field 2 as contents of field 1. Field 1 now contains the ori-
follows: ginal value of field 2. Condition code 1 is set to
Field 1: 1111 11 = 17 9 indicate a nonzero result.
Field 2: 11 1 = 14 1

Result: 11 111 = 3 91 XI Example


A frequent use of the EXCLUSIVE OR (XI)
The result replaces the former contents of field 1. instruction is to invert a bit (change a zero bit to a
Condition code 1 is set to indicate a nonzero one or a one bit to a zero). For example, assume
result. that storage location 8082 contains 0110 1001.
To invert the leftmost and rightmost bits without
Now, execution of the instruction:
affecting any of the other bits, the following
instruction can be used (assume that register 9
Machine Format
Op Code L B D B D contains 00 00 80 80):

D7 2 7 8 7 1 Machine Format
Op Code I B D

97 81 9 2
Assembler Format
Op Code D(L,B),D(B)

XC 8(3,7),1(7) Assembler Format


Op Code D(B),I

produces the following result: XI 2(9),X'81'
Field 1: 11 111 = 3 91
Field 2: 11 1 = 14 1
When the instruction is executed, the byte in
Result: 1111 11 = 17 9 storage is EXCLUSIVE ORed with the immediate
byte (the I field of the instruction):
The result of this operation replaces the former
contents of field 2. Field 2 now contains the ori- Location 882: 11 11
ginal value of field 1. Condition code 1 is set to Immediate byte: 1 1

indicate a nonzero result. Result: 111 1
Lastly, execution of the instruction: The resulting byte is stored back in location 8082.
Condition code 1 is set to indicate a nonzero
Machine Format result.
Op Code L B D B D
Notes:
D7 2 7 1 7 8
1. With the XC instruction, fields up to 256 bytes
in length can be exchanged.
2. With the XR instruction, the contents of two
registers can be exchanged.
3. Because the X instruction operates storage to

A-20 z/Architecture Principles of Operation


register only, an exchange cannot be made When the instruction at 5000 is executed, the
solely by the use of X. rightmost byte of register 1 is ORed with the
second byte of the target instruction:
4. A field EXCLUSIVE ORed with itself is cleared
to zeros. Instruction byte: =
Register byte: 11 = 3
5. For additional examples of the use of EXCLU-
SIVE OR, see Hexadecimal-Floating-Point- Result: 11 = 3
Number Conversion on page A-42. causing the instruction at 3820 to be executed as
if it originally were:
EXECUTE (EX)
Machine Format
The EXECUTE instruction causes one target Op Code L B D B D
instruction in main storage to be executed out of
D2 3 C 3 D
sequence without actually branching to the target
instruction. Unless the R field of the EXECUTE
instruction is zero, bits 8-15 of the target instruc-
tion are ORed with bits 24-31 of the R register Assembler Format
Op Code D(L,B),D(B)
before the target instruction is executed. Thus,

EXECUTE may be used to supply the length field MVC 3(4,12),(13)
for an SS instruction without modifying the SS
instruction in storage. For example, assume that
However, after execution:
a MOVE (MVC) instruction is the target that is
located at address 3820, with a format as follows: Register 1 is unchanged.
The instruction at 3820 is unchanged.
Machine Format
Op Code L B D B D The contents of the four bytes starting at
location 90A0 have been moved to the four
D2 C 3 D
bytes starting at location 8916.
The CPU next executes the instruction at
Assembler Format address 5004 (PSW bits 40-63 contain 00 50
Op Code D(L,B),D(B) 04).

MVC 3(1,12),(13)
INSERT CHARACTERS UNDER
where register 12 contains 00 00 89 13 and reg-
MASK (ICM)
ister 13 contains 00 00 90 A0.
The INSERT CHARACTERS UNDER MASK
(ICM) instruction may be used to replace all or
Further assume that at storage address 5000, the
selected bytes in a general register with bytes
following EXECUTE instruction is located:
from storage and to set the condition code to indi-
Machine Format cate the value of the inserted field.
Op Code R X B D
For example, if it is desired to insert a three-byte
44 1 A address from FIELDA into register 5 and leave the
leftmost byte of the register unchanged, assume:

Assembler Format Machine Format


Op Code R,D(X,B) Op Code R M S

EX 1,(,1) BF 5 7 \ \ \ \

where register 10 contains 00 00 38 20 and reg-


ister 1 contains 00 0F F0 03.

Appendix A. Number Representation and Instruction-Use Examples A-21


Assembler Format The contents of register 10 are not significant.
Op Code R,M,S
Storage locations 21003-21006 contain 00 00
ICM 5,B'111',FIELDA AB CD.
To load register 10, the RX form of the instruction
FIELDA: FE DC BA can be used:
Register 5 (before): 12 34 56 78
Register 5 (after): 12 FE DC BA Machine Format
Condition code (after): 1 (leftmost bit of Op Code R X B D
inserted field
is one) 58 A 5 6

As another example:
Assembler Format
Machine Format Op Code R,D(X,B)
Op Code R M S
L 1,(5,6)
BF 6 9 \ \ \ \

After the instruction is executed, register 10 con-


tains 00 00 AB CD.
Assembler Format
Op Code R,M,S
LOAD ADDRESS (LA)
ICM 6,B'11',FIELDB
The LOAD ADDRESS instruction provides a con-
FIELDB: 12 34 venient way to place a nonnegative binary integer
Register 6 (before): up to 4095 in a register without first defining a
Register 6 (after): 12 34 constant and then using it as an operand. For
Condition code (after): 2 (inserted field is
nonzero with left- example, the following instruction places the
most zero bit) number 2048 in register 1:

Machine Format
When the mask field contains 1111, the ICM Op Code R X B D
instruction produces the same result as LOAD (L)
(provided that the indexing capability of the RX 41 1 8
format is not needed), except that ICM also sets
the condition code. The condition-code setting is
useful when an all-zero field (condition code 0) or Assembler Format
a leftmost one bit (condition code 1) is used as a Op Code R,D(X,B)
flag.
LA 1,248(,)

LOAD (L, LR)


The LOAD ADDRESS instruction can also be
The LOAD instruction takes four bytes from used to increment a register by an amount up to
storage or from a general register and place them 4095 specified in the D field. Depending on
unchanged into a general register. For example, the addressing mode, only the rightmost 24 or 31
assume that the four bytes starting with location bits of the sum are retained, however. The left-
21003 are to be loaded into register 10. Initially: most bits of the 32-bit result are set to zeros. For
example, assume that register 5 contains 00 12
Register 5 contains 00 02 00 00. 34 56.
Register 6 contains 00 00 10 03.
The instruction:

A-22 z/Architecture Principles of Operation


Machine Format After the instruction is executed, register 6 con-
Op Code R X B D tains 00 00 00 20. If locations 1803-1804 had
contained a negative number, for example, A7 B6,
41 5 5 A
a minus sign would have been propagated to the
Assembler Format left, giving FF FF A7 B6 as the final result in reg-
Op Code R,D(X,B) ister 6.

LA 5,1(,5)
MOVE (MVC, MVI)
adds 10 (decimal) to the contents of register 5 as MVC Example
follows: The MOVE (MVC) instruction can be used to
Register 5 (old): 12 34 56 move data from one storage location to another.
D field: A For example, assume that the following two fields
are in storage:
Register 5 (new): 12 34 6
248 252
The register may be specified as either B or X. Field
Thus, the instruction LA 5,10(5,0) produces the 1 C1C2C3C4C5C6C7C8C9CACB
same result.
384 3848
As the most general example, the instruction LA Field
6,10(5,4) forms the sum of three values: the con- 2 F1F2F3F4F5F6F7F8F9
tents of register 4, the contents of register 5, and
a displacement of 10 and places the 24-bit or Also assume:
31-bit sum with zeros appended on the left in reg-
Register 1 contains 00 00 20 48.
ister 6.
Register 2 contains 00 00 38 40.
LOAD HALFWORD (LH) With the following instruction, the first eight bytes
of field 2 replace the first eight bytes of field 1:
The LOAD HALFWORD instruction places
unchanged a halfword from storage into the right Machine Format
half of a register. The left half of the register is Op Code L B D B D
loaded with zeros or ones according to the sign
D2 7 1 2
(leftmost bit) of the halfword.

For example, assume that the two bytes in
storage locations 1803-1804 are to be loaded into Assembler Format
register 6. Also assume: Op Code D(L,B),D(B)

The contents of register 6 are not significant. MVC (8,1),(2)
Register 14 contains 00 00 18 03.
After the instruction is executed, field 1 becomes:
Locations 1803-1804 contain 00 20.
248 252
The instruction required to load the register is: Field
1 F1F2F3F4F5F6F7F8C9CACB
Machine Format
Op Code R X B D
Field 2 is unchanged.
48 6 E
MVC can also be used to propagate a byte
through a field by starting the first-operand field
one byte location to the right of the second-
Assembler Format
Op Code R,D(X,B) operand field. For example, suppose that an area
in storage starting with address 358 contains the
LH 6,(,14) following data:

Appendix A. Number Representation and Instruction-Use Examples A-23


358 36 may be used, in conjunction with the instruction
EDIT AND MARK, to insert the EBCDIC code for
F1F2F3F4F5F6F7F8 a dollar symbol at the storage address contained

in general register 1 (see also the example for


With the following MVC instruction, the zeros in EDIT AND MARK).
location 358 can be propagated throughout the
entire field (assume that register 11 contains 00
MOVE INVERSE (MVCIN)
00 03 58):
The MOVE INVERSE (MVCIN) instruction can be
Machine Format
Op Code L B D B D used to move data from one storage location to
another while reversing the order of the bytes
D2 7 B 1 B within the field. For example, assume that the fol-
lowing two fields are in storage:
248 252
Assembler Format Field
Op Code D(L,B),D(B) 1 C1C2C3C4C5C6C7C8C9CACB

MVC 1(8,11),(11) 384 3848
Field
Because MVC is executed as if one byte were 2 F1F2F3F4F5F6F7F8F9

processed at a time, the above instruction, in
effect, takes the byte at address 358 and stores it Also assume:
at 359 (359 now contains 00), takes the byte at
Register 1 contains 00 00 20 48.
359 and stores it at 35A, and so on, until the
entire field is filled with zeros. Note that an MVI Register 2 contains 00 00 38 40.
instruction could have been used originally to With the following instruction, the first eight bytes
place the byte of zeros in location 358. of field 2 replace the first eight bytes of field 1:
Notes: Machine Format
1. Although the field occupying locations 358-360 Op Code L B D B D

contains nine bytes, the length coded in the
E8 7 1 2 7
assembler format is equal to the number of
moves (one less than the field length).
2. The order of operands is important even Assembler Format
though only one field is involved. Op Code D(L,B),D(B)

MVI Example MVCIN (8,1),7(2)
The MOVE (MVI) instruction places one byte of
information from the instruction stream into After the instruction is executed, field 1 becomes:
storage. For example, the instruction: 248 252
Field
Machine Format 1 F8F7F6F5F4F3F2F1C9CACB
Op Code I B D

92 5B 1 Field 2 is unchanged.

Note: This example uses the same general reg-


isters, storage locations, and original values as the
Assembler Format first example for MVC. For MVCIN, the second-
Op Code D(B),I operand address must designate the rightmost
byte of the field to be moved, in this case location
MVI (1),C'$'
3847. This is accomplished by means of the 7 in
the D field of the instruction.

A-24 z/Architecture Principles of Operation


MOVE LONG (MVCL) Condition code 2 would have been set to indicate
that the first operand was longer than the second.
The MOVE LONG (MVCL) instruction can be used
The technique for setting a field to zeros that is
for moving data in storage as in the first example
illustrated in the second example of MVC cannot
of the MVC instruction, provided that the two oper-
be used with MVCL. If the registers were set up
ands do not overlap. MVCL differs from MVC in
to attempt such an operation with MVCL, no data
that the address and length of each operand are
movement would take place and condition code 3
specified in an even-odd pair of general registers.
would indicate destructive overlap.
Consequently, MVCL can be used to move more
than 256 bytes of data with one instruction. As an
Instead, MVCL may be used to clear a storage
example, assume:
area to zeros as follows. Assume register 8 and 9
Register 2 contains 00 0A 00 00. are set up as before. Register 3 contains only
zeros, specifying zero length for the second
Register 3 contains 00 00 08 00.
operand and a zero padding byte. Register 2 is
Register 8 contains 00 06 00 00. not used to access storage, and its contents are
Register 9 contains 00 00 08 00. not significant. Executing the instruction MVCL
8,2 causes locations 60000-607FF to be filled with
Execution of the instruction: zeros. Bits 8-31 of register 8 are incremented by
800, and bits 0-7 of registers 2 and 8 are set to
Machine Format zeros. Bits 8-31 of register 9 are decremented to
Op Code R R
zero, and condition code 2 is set to indicate that
E 8 2 the first operand is longer than the second.

MOVE NUMERICS (MVN)


Assembler Format
Op Code R,R Two related instructions, MOVE NUMERICS and
MOVE ZONES, may be used with decimal data in
MVCL 8,2 the zoned format to operate separately on the
rightmost four bits (the numeric bits) and the left-
moves 2,048 bytes from locations A0000-A07FF most four bits (the zone bits) of each byte. Both
to locations 60000-607FF. Assuming that the are similar to MOVE (MVC), except that MOVE
CPU is in the 24-bit addressing mode, bits 8-31 of NUMERICS moves only the numeric bits and
registers 2 and 8 are incremented by 800, and MOVE ZONES moves only the zone bits.
bits 0-7 of registers 2 and 8 are set to zeros. Bits
8-31 of registers 3 and 9 are decremented to zero. To illustrate the operation of the MOVE
Condition code 0 is set to indicate that the NUMERICS instruction, assume that the following
operand lengths are equal. two fields are in storage:
79 793
If register 3 had contained F0 00 04 00, only the
1,024 bytes from locations A0000-A03FF would Field A C6C7C8C9
have been moved to locations 60000-603FF. The
remaining locations 60400-607FF of the first 741 746
operand would have been filled with 1,024 copies
of the padding byte X'F0', as specified by the Field B FF1F2F3F4F5
leftmost byte of register 3. Bits 8-31 of register 2
would have been incremented by 400, bits 8-31 Also assume:
of register 8 would have been incremented by
Register 14 contains 00 00 70 90.
800, and bits 0-7 of registers 2 and 8 would
have been set to zeros. Bits 8-31 of registers 3 Register 15 contains 00 00 70 40.
and 9 would still have been decremented to zero.
After the instruction:

Appendix A. Number Representation and Instruction-Use Examples A-25


Machine Format hex (as in the C programming language). The
Op Code L B D B D program is not written for execution in the access-
register mode.
D1 3 F 1 E
L 4,STRAADR
L 5,STRBADR
SR ,
Assembler Format LOOP1 MVST 4,5
Op Code D(L,B),D(B) BC 1,LOOP1
L 5,STRCADR
MVN 1(4,15),(14) LOOP2 MVST 4,5
BC 1,LOOP2
[Any instruction]
is executed, field B becomes:
741 746
MOVE WITH OFFSET (MVO)
F6F7F8F9F4F5
MOVE WITH OFFSET may be used to shift a
packed-decimal number an odd number of digit
The numeric bits of the bytes at locations
positions or to concatenate a sign to an unsigned
7090-7093 have been stored in the numeric bits of
packed-decimal number.
the bytes at locations 7041-7044. The contents of
locations 7090-7093 and 7045-7046 are Assume that the three-byte unsigned packed-
unchanged. decimal number in storage locations 4500-4502 is
to be moved to locations 5600-5603 and given the
MOVE STRING (MVST) sign of the packed-decimal number ending at
location 5603. Also assume:
The MOVE STRING instruction is used to move a
Register 12 contains 00 00 56 00.
second operand designated by general register R
to a first-operand location designated by general Register 15 contains 00 00 45 00.
register R. The movement is made left to right
Storage locations 5600-5603 contain 77 88 99
until an ending character specified in general reg-
0C.
ister 0 has been moved or a CPU-determined
number of bytes have been moved. The condition Storage locations 4500-4502 contain 12 34
code is set to 1 if the ending character was moved 56.
or to 3 if a CPU-determined number of bytes were After the instruction:
moved.
Machine Format
When condition code 1 is set, the address of the Op Code L L B D B D
ending character in the first operand is placed in
general register R, and the contents of general F1 3 2 C F
register R remain unchanged. When condition
code 3 is set, the address of the next byte to be
processed in the first and second operands is Assembler Format
placed in general registers R and R, respec- Op Code D(L,B),D(L,B)
tively.
MVO (4,12),(3,15)
Following is an example program that sets string
A equal to the concatenation of string B followed is executed, the storage locations 5600-5603
by string C, where the length of each of strings B contain 01 23 45 6C. Note that the second
and C is unknown, and the end of each of strings operand is extended on the left with one zero to
B and C is indicated by an ending character of 00 fill out the first-operand field.

A-26 z/Architecture Principles of Operation


MOVE ZONES (MVZ) The instruction required for performing the multipli-
cation is:
The MOVE ZONES instruction can operate on
Machine Format
overlapping or nonoverlapping fields, as can the
Op Code R X B D
instructions MOVE (MVC) and MOVE NUMERICS.
When operating on nonoverlapping fields, MOVE 5C 4 B C 15
ZONES works like the MOVE NUMERICS instruc-
tion (see its example), except that MOVE ZONES
moves only the zone bits of each byte. To illus- Assembler Format
trate the use of MOVE ZONES with overlapping Op Code R,D(X,B)
fields, assume that the following data field is in
storage: M 4,X'15'(11,12)
8 85
After the instruction is executed, the product is in
F1C2F3C4F5C6 the register pair 4 and 5:

Register 4 contains 00 00 00 00.


Also assume that register 15 contains 00 00 08
00. The instruction: Register 5 contains 00 00 4E CE = 20,174.
Storage locations 3750-3753 are unchanged.
Machine Format
Op Code L B D B D The RR format of the instruction can be used to
square the number in a register. Assume that
D3 4 F 1 F register 7 contains 00 01 00 05. The contents of

register 6 are not significant. The instruction:

Assembler Format Machine Format


Op Code D(L,B),D(B) Op Code R R

MVZ 1(5,15),(15) 1C 6 7

propagates the zone bits from the byte at address
800 through the entire field, so that the field Assembler Format
becomes: Op Code R,R

8 85 MR 6,7

F1F2F3F4F5F6
multiplies the number in register 7 by itself and
places the result in the pair of registers 6 and 7:
MULTIPLY (M, MR) Register 6 contains 00 00 00 01.
Register 7 contains 00 0A 00 19.
Assume that a number in register 5 is to be multi-
plied by the contents of a four-byte field at
address 3750. Initially: MULTIPLY HALFWORD (MH)
The contents of register 4 are not significant. The MULTIPLY HALFWORD instruction is used to
Register 5 contains 00 00 00 9A = 154 = multiply the contents of a register by a two-byte
the multiplicand. field in storage. For example, assume that:
Register 11 contains 00 00 06 00. Register 11 contains 00 00 00 15 =21 = the
multiplicand.
Register 12 contains 00 00 30 00.
Register 14 contains 00 00 01 00.
Storage locations 3750-3753 contain 00 00 00
83 = 131 = the multiplier. Register 15 contains 00 00 20 00.

Appendix A. Number Representation and Instruction-Use Examples A-27


Storage locations 2102-2103 contain FF D9 = Assembler Format
-39 = the multiplier. Op Code D(B),I

The instruction: OI 1(8),X'1'

Machine Format
Op Code R X B D When this instruction is executed, the byte in
storage is ORed with the immediate byte (the I
4C B E F 2 field of the instruction):

Location 4891: 1 1
Immediate byte: 1
Assembler Format
Op Code R,D(X,B) Result: 1 11
The resulting byte with bit 7 set to one is stored
MH 11,2(14,15)
back in location 4891. Condition code 1 is set.

multiplies the two numbers. The product, FF FF


FC CD = -819, replaces the original contents of
PACK (PACK)
register 11.
Assume that storage locations 1000-1003 contain
Only the rightmost 32 bits of a product are stored the following zoned-decimal number that is to be
in a register; any significant bits on the left are converted to a packed-decimal number and left in
lost. No program interruption occurs on overflow. the same location:
1 13

OR (O, OC, OI, OR) Zoned number F1F2F3C4

When the Boolean operator OR is applied to two
Also assume that register 12 contains 00 00 10
bits, the result is one when either bit is one; other-
00. After the instruction:
wise, the result is zero. When two bytes are
ORed, each pair of bits is handled separately;
Machine Format
there is no connection from one bit position to Op Code L L B D B D
another. The following is an example of ORing
two bytes: F2 3 3 C C

First-operand byte: 11 11
Second-operand byte: 11 11
Assembler Format
Result byte: 111 111 Op Code D(L,B),D(L,B)

OI Example PACK (4,12),(4,12)
A frequent use of the OR instruction is to set a
particular bit to one. For example, assume that is executed, the result in locations 1000-1003 is in
storage location 4891 contains 0100 0010. To the packed-decimal format:
set the rightmost bit of this byte to one without
1 13
affecting the other bits, the following instruction
can be used (assume that register 8 contains 00 Packed number 1234C
00 48 90):

Machine Format Notes:


Op Code I B D
1. This example illustrates the operation of
96 1 8 1 PACK when the first- and second-operand
fields overlap completely.
2. During the operation, the second operand was
extended on the left with zeros.

A-28 z/Architecture Principles of Operation


SEARCH STRING (SRST) SRST Example 2
Following is an example program that determines
The SEARCH STRING instruction is used to the address of the first character equal to C1 hex
search a second operand designated by general in the string A whose length is known. The
register R for a character specified in general program is not written for execution in the access-
register 0. The length of the second operand is register mode.
known -- the address of the first byte after the L 5,STRAADR
second operand is in general register R. L 4,STRALEN
AR 4,5
When the specified character is found, condition LA ,X'C1'
code 1 is set, the address of the character is LOOP1 SRST 4,5
BC 1,LOOP1
placed in general register R, and the contents of BC 2,NOTFND
general register R remain unchanged. When the FOUND [Any instruction]
address of the next second-operand byte to be ...
examined equals the address in general register NOTFND [Any instruction]
R, condition code 2 is set, and the contents of In this example, the value in STRALEN may be a
general register R and R remain unchanged. length that either does or does not include an
When a CPU-determined number of second- ending character at the end of the string, provided
operand bytes have been examined, condition that the ending character is not the character for
code 3 is set, the address of the next byte to be which the search is made.
processed in the second operand is placed in
general register R, and the contents of general
register R remain unchanged. SHIFT LEFT DOUBLE (SLDA)
The SHIFT LEFT DOUBLE instruction shifts the
SRST Example 1
63 numeric bits of an even-odd register pair to the
Following is an example program that determines
left, leaving the sign bit unchanged. Thus, the
the end of string A, as indicated by an ending
instruction performs an algebraic left shift of a
character equal to 00 hex (as in the C program-
64-bit signed binary integer.
ming language), and then determines the address
of the first character equal to C1 hex in the string.
For example, if the contents of registers 2 and 3
The program is based on the assumption that the
are:
second operand does not begin at location 0 or
wrap around in storage, and, therefore, condition 7F A 72 FE DC BA 98 =
1111111 11 1111
code 2 will not be set by the first SEARCH
1111111 11111 11111 111
STRING instruction because of the address in
general register 0. The program is not written for The instruction:
execution in the access-register mode.
Machine Format
L 5,STRAADR Op Code R B D
SR ,
LOOP1 SRST ,5 8F 2 //// 1F
BC 1,LOOP1
L 5,STRAADR
LR 4,
LA ,X'C1' Assembler Format
LOOP2 SRST 4,5 Op Code R,D(B)
BC 1,LOOP2
BC 2,NOTFND SLDA 2,31()
FOUND [Any instruction]
...
NOTFND [Any instruction] results in registers 2 and 3 both being left-shifted
31 bit positions, so that their new contents are:
7F 6E 5D 4C =
1111111 11111 11111 111

Appendix A. Number Representation and Instruction-Use Examples A-29


Because significant bits are shifted out of bit posi- Machine Format
tion 1 of register 2, overflow is indicated by setting Op Code R M S
condition code 3, and, if the fixed-point-overflow
BE 8 7 \ \ \ \
mask bit in the PSW is one, a fixed-point-overflow
program interruption occurs.

Register Format
SHIFT LEFT SINGLE (SLA) Op Code R,M,S

The SHIFT LEFT SINGLE instruction is similar to STCM 8,B'111',FIELD3
SHIFT LEFT DOUBLE, except that it shifts only
the 31 numeric bits of a single register. There- Register 8: 12 34 56 78
fore, this instruction performs an algebraic left shift FIELD3 (before): not significant
of a 32-bit signed binary integer. FIELD3 (after): 34 56 78
As another example:
For example, if the contents of register 2 are:
7F A 72 = 1111111 11 1111 Machine Format
Op Code R M S
The instruction:
BE 9 5 \ \ \ \
Machine Format
Op Code R B D

8B 2 //// 8 Register Format


Op Code R,M,S

STCM 9,B'11',FIELD2
Assembler Format
Op Code R,D(B)
Register 9: 1 23 45 67
SLA 2,8() FIELD2 (before): not significant
FIELD2 (after): 23 67

results in register 2 being shifted left eight bit posi-


tions so that its new contents are: STORE MULTIPLE (STM)
7F A 72 = 1111111 11 1111
Assume that the contents of general registers 14,
Condition code 2 is set to indicate that the result 15, 0, and 1 are to be stored in consecutive four-
is greater than zero. byte fields starting with location 4050 and that:
Register 14 contains 00 00 25 63.
If a left shift of nine places had been specified, a
significant bit would have been shifted out of bit Register 15 contains 00 01 27 36.
position 1. Condition code 3 would have been set Register 0 contains 12 43 00 62.
to indicate this overflow and, if the fixed-point-
overflow mask bit in the PSW were one, a fixed- Register 1 contains 73 26 12 57.
point overflow interruption would have occurred. Register 6 contains 00 00 40 00.
The initial contents of locations 4050-405F are
STORE CHARACTERS UNDER not significant.
MASK (STCM)
The STORE MULTIPLE instruction allows the use
STORE CHARACTERS UNDER MASK (STCM) of just one instruction to store the contents of the
may be used to place selected bytes from a reg- four registers:
ister into storage. For example, if it is desired to
Machine Format
store a three-byte address from general register 8 Op Code R R B D
into location FIELD3, assume:
9 E 1 6 5

A-30 z/Architecture Principles of Operation


Assembler Format If location 9999 had contained 3C, the test would
Op Code R,R,D(B) have been:

STM 14,1,X'5'(6) 3C = 11 11
Mask = 11 11

After the instruction is executed: Test = xx xx
Locations 4050-4053 contain 00 00 25 63. Condition code 0 is set: all selected bits are
zeros.
Locations 4054-4057 contain 00 01 27 36.
Note: Storage location 9999 remains unchanged.
Locations 4058-405B contain 12 43 00 62.
Locations 405C-405F contain 73 26 12 57. TRANSLATE (TR)
TEST UNDER MASK (TM) The TRANSLATE instruction can be used to trans-
late data from any character code to any other
The TEST UNDER MASK instruction examines desired code, provided that each character code
selected bits of a byte and sets the condition code consists of eight bits or fewer. An appropriate
accordingly. For example, assume that: translation table is required in storage.
Storage location 9999 contains FB.
In the following example, EBCDIC code is trans-
Register 7 contains 00 00 99 90. lated to ASCII code. The first step is to create a
256-byte table in storage locations 1000-10FF.
Assume the instruction to be:
This table contains the characters of the ASCII
Machine Format code in the sequence of the binary representation
Op Code I B D of the EBCDIC code; that is, the ASCII represen-
tation of a character is placed in storage at the
91 C3 7 9 starting address of the table plus the binary value
of the EBCDIC representation of the same char-
acter.
Assembler Format
Op Code D(B),I For simplicity, the example shows only the part of
the table containing the decimal digits:
TM 9(7),B'1111'
1F 1F9

The instruction tests only those bits of the byte in 3313233343536373839
storage for which the mask bits are ones:
FB = 1111 111 Assume that the four-byte field at storage location
Mask = 11 11 2100 contains the EBCDIC code for the digits
1984:
Test = 11xx xx11
Locations 2100-2103 contain F1 F9 F8 F4.
Condition code 3 is set: all selected bits in the
test result are ones. (The bits marked x are Register 12 contains 00 00 21 00.
ignored.) Register 15 contains 00 00 10 00.
If location 9999 had contained B9, the test would As the instruction:
have been:
Machine Format
B9 = 111 11 Op Code L B D B D
Mask = 11 11
DC 3 C F
Test = 1xx xx1
Condition code 1 is set: the selected bits are both
zeros and ones.

Appendix A. Number Representation and Instruction-Use Examples A-31


Assembler Format 1 2 3 4 5 6 7 8 9 A B C D E F

Op Code D(L,B),D(B) 2_4444444444444444

TR (4,12),(15) 21_4444444444444444

22_4444444444444444

is executed, the binary value of each EBCDIC 23_4444444444444444
byte is added to the starting address of the table,
24_4444444444484C14
and the resulting address is used to fetch an
ASCII byte: 25_144444444444181C244

Table starting address: 1 26_24284444444442C4444
First EBCDIC byte: F1
27_44444444444334383C4

Address of ASCII byte: 1F1 28_4444444444444444

After execution of the instruction: 29_4444444444444444

Locations 2100-2103 contain 31 39 38 34. 2A_4444444444444444

Thus, the ASCII code for the digits 1984 has 2B_4444444444444444

replaced the EBCDIC code in the four-byte field at 2C_4444444
storage location 2100.
2D_4444444

TRANSLATE AND TEST (TRT) 2E_44444444

2F_444444
The TRANSLATE AND TEST instruction can be

used to scan a data field for characters with a Note: If the character codes in the statement
special meaning. To indicate which characters being translated occupy a range smaller than 00
have a special meaning, a table similar to the one through FF, a table of fewer than 256 bytes can
used for the TRANSLATE instruction is set up, be used.
except that zeros in the table indicate characters Figure A-4. Translate and Test Table
without any special meaning and nonzero values
indicate characters with a special meaning. The table entries for the alphameric characters in
EBCDIC are 00; thus, the letter A (code C1) corre-
Figure A-4 has been set up to distinguish alpha- sponds to byte location 20C1, which contains 00.
meric characters (A to Z and 0 to 9) from blanks,
certain special symbols, and all other characters The 15 special symbols have nonzero entries from
which are considered invalid. EBCDIC coding is 04 to 3C in increments of 4. Thus, the blank
assumed. The 256-byte table is assumed stored (code 40) has the entry 04, the period (code 4B)
at locations 2000-20FF. has the entry 08, and so on.

All other table positions have the entry 40 to


indicate an invalid character.

The table entries are chosen so that they may be


used to select one of a list of 16 words containing
addresses of different routines to be entered for
each special symbol or invalid character encount-
ered during the scan.

Assume that this list of 16 branch addresses is


stored at locations 3004-3043.

Starting at storage location CA80, there is the fol-


lowing sequence of 21 EBCDIC characters,
where b stands for a blank.

A-32 z/Architecture Principles of Operation


Locations CA80-CA94: scan. When this routine is completed, program
UNPKbPROUT(9),WORD(5) control may return to the TRANSLATE AND TEST
instruction to continue the scan, except that the
Also assume:
length must first be adjusted for the characters
Register 1 contains 00 00 CA 7F. already scanned.
Register 2 contains 00 00 30 00.
For this purpose, the TRANSLATE AND TEST
Register 15 contains 00 00 20 00. may be executed by the use of an EXECUTE
As the instruction: instruction, which supplies the length specification
from a general register. In this way, a complete
Machine Format statement scan can be performed with a single
Op Code L B D B D TRANSLATE AND TEST instruction used repeat-
edly by means of EXECUTE, and without modi-
DD 14 1 1 F fying any instructions in storage. In the example,
after the first execution of TRANSLATE AND
TEST, register 1 contains the address of the last
Assembler Format source byte translated. It is then a simple matter
Op Code D(L,B),D(B) to subtract this address from the address of the
last source byte (CA94) to produce a length spec-
TRT 1(21,1),(15)
ification. This length minus one is placed in the
register that is referenced as the R field of the
is executed, the value of the first source byte, the EXECUTE instruction. (Note that the length code
EBCDIC code for the letter U, is added to the in the machine format is one less than the total
starting address of the table to produce the number of bytes in the field.) The second-
address of the table entry to be examined: operand address of the EXECUTE instruction
Table starting address 2 points to the TRANSLATE AND TEST instruction,
First source byte (U) E4 which is the same as illustrated above, except for
the length (L) which is set to zero.
Address of table entry 2E4
Because zeros were placed in storage location UNPACK (UNPK)
20E4, no special action occurs. The operation
continues with the second and subsequent source Assume that storage locations 2501-2502 contain
bytes until it reaches the blank in location CA84. a signed, packed-decimal number that is to be
When this symbol is reached, its value is added to unpacked and placed in storage locations
the starting address of the table, as usual: 1000-1004. Also assume:
Table starting address 2 Register 12 contains 00 00 10 00.
Source byte (blank) 4
Register 13 contains 00 00 25 00.
Address of table entry 24
Storage locations 2501-2502 contain 12 3D.
Because location 2040 contains a nonzero value,
the following actions occur: The initial contents of storage locations
1000-1004 are not significant.
The address of the source byte, 00CA84, is
placed in the rightmost 24 bits of register 1. After the instruction:

The table entry, 04, is placed in the rightmost Machine Format


eight bits of register 2, which now contains 00 Op Code L L B D B D
00 30 04.
F3 4 1 C D 1
Condition code 1 is set (scan not completed).
The TRANSLATE AND TEST instruction may be
followed by instructions to branch to the routine at Assembler Format
the address found at location 3004, which corre- Op Code D(L,B),D(L,B)

sponds to the blank character encountered in the UNPK (5,12),1(2,13)

Appendix A. Number Representation and Instruction-Use Examples A-33


is executed, the storage locations 1000-1004 COMPARE DECIMAL (CP)
contain F0 F0 F1 F2 D3.
Assume that the signed, packed-decimal contents
UPDATE TREE (UPT) of storage locations 700-703 are to be algebra-
ically compared with the signed, packed-decimal
See Sorting Instructions on page A-51. contents of locations 500-502. Also assume:
Register 12 contains 00 00 06 00.
Decimal Instructions Register 13 contains 00 00 03 00.
(See Chapter 8, Decimal Instructions for a com- Storage locations 700-703 contain 17 25 35
plete description of the decimal instructions.) 6D.
Storage locations 500-502 contain 72 14 2D.
ADD DECIMAL (AP) After the instruction:
Assume that the signed, packed-decimal number
Machine Format
at storage locations 500-503 is to be added to the Op Code L L B D B D
signed, packed-decimal number at locations
2000-2002. Also assume: F9 3 2 C 1 D 2

Register 12 contains 00 00 20 00.
Register 13 contains 00 00 05 00. Assembler Format
Storage locations 2000-2002 contain 38 46 0D Op Code D(L,B),D(L,B)

(a negative number). CP X'1'(4,12),X'2'(3,13)
Storage locations 500-503 contain 01 12 34
5C (a positive number). is executed, condition code 1 is set, indicating that
After the instruction: the first operand (the contents of locations
700-703) is less than the second.
Machine Format
Op Code L L B D B D DIVIDE DECIMAL (DP)

FA 2 3 C D
Assume that the signed, packed-decimal number
at storage locations 2000-2004 (the dividend) is to
be divided by the signed, packed-decimal number
Assembler Format
Op Code D(L,B),D(L,B) at locations 3000-3001 (the divisor). Also
assume:
AP (3,12),(4,13) Register 12 contains 00 00 20 00.
Register 13 contains 00 00 30 00.
is executed, the storage locations 2000-2002
contain 73 88 5C; condition code 2 is set to indi- Storage locations 2000-2004 contain 01 23 45
cate that the result is greater than zero. Note 67 8C.
that: Storage locations 3000-3001 contain 32 1D.
1. Because the two numbers had different signs, After the instruction:
they were in effect subtracted.
2. Although the second operand is longer than Machine Format
the first operand, no overflow interruption Op Code L L B D B D

occurs because the result can be entirely con- FD 4 1 C D
tained within the first operand.

A-34 z/Architecture Principles of Operation


Assembler Format and that the source and pattern fields are:
Op Code D(L,B),D(L,B)
Source
DP (5,12),(2,13) 12 123

257426C
is executed, the dividend is entirely replaced by
the signed quotient and remainder, as follows: &
2 24
+
Locations 2-24 3846D18C

quotient remainder Pattern
1 1C

4226B22124B224C3D9
Notes:
1. Because the dividend and divisor have dif- b d d , d ( d . d d b C R
ferent signs, the quotient receives a negative
sign. Execution of the instruction:
2. The remainder receives the sign of the divi-
Machine Format
dend and the length of the divisor. Op Code L B D B D
3. If an attempt were made to divide the dividend
DE C C C 2
by the one-byte field at location 3001, the
quotient would be too long to fit within the four
bytes allotted to it. A decimal-divide exception
would exist, causing a program interruption. Assembler Format
Op Code D(L,B),D(B)

EDIT (ED) ED (13,12),X'2'(12)

Before decimal data in the packed format can be alters the pattern field as follows:
used in a printed report, digits and signs must be

converted to printable characters. Moreover, Significance
punctuation marks, such as commas and decimal Indicator
points, may have to be inserted in appropriate (Before/ Location
PatternDigit After) Rule 1-1C
places. The highly flexible EDIT instruction per-
forms these functions in a single instruction exe- b off/off leave(1)bdd,d(d.ddbCR
cution. d off/off fill bbd,d(d.ddbCR
d 2 off/on(2) digit bb2,d(d.ddbCR
, on/on leave same
This example shows step-by-step one way that d 5 on/on digit bb2,5(d.ddbCR
the EDIT instruction can be used. The field to be ( 7 on/on digit bb2,57d.ddbCR
edited (the source) is four bytes long; it is edited d 4 on/on digit bb2,574.ddbCR
. on/on leave same
against a pattern 13 bytes long. The following d 2 on/on digit bb2,574.2dbCR
symbols are used: d 6+ on/off(3) digit bb2,574.26bCR
b off/off fill same
C off/off fill bb2,574.26bbR
Symbol Meaning R off/off fill bb2,574.26bbb

b (Hexadecimal 4) Blank character Notes:
( (Hexadecimal 21) Significance starter
d (Hexadecimal 2) Digit selector 1. This character is the fill byte.

2. First nonzero decimal source digit turns on
Assume that register 12 contains: significance indicator.

1 3. Plus sign in the four rightmost bits of the
byte turns off significance indicator.

Appendix A. Number Representation and Instruction-Use Examples A-35


Thus, after the instruction is executed, the pattern first digit position that is forced to print if no signif-
field contains the result as follows: icant digits occur to the left.

Pattern The instructions:


1 1C
LA 1,6(0,12) Load address of
44F26BF5F7F44BF2F6444 forced significant

b b 2 , 5 7 4 . 2 6 b b b digit into GR1


EDMK 0(13,12),X'200'(12) Leave address of
first significant digit
This pattern field prints as: in GR1
2,574.26 BCTR 1,0 Subtract 1 from
address in GR1
The source field remains unchanged. Condition
MVI 0(1),C'$' Store dollar sign at
code 2 is set because the number was greater
address in GR1
than zero.
produce the following results for the two examples
If the number in the source field is changed to the
under EDIT:
negative number 00 00 02 6D and the original
pattern is used, the edited result this time is:
Pattern
1 1C
Pattern
1 1C 45BF26BF5F7F44BF2F6444

444444F4BF2F64C3D9 b $ 2 , 5 7 4 . 2 6 b b b

b b b b b b . 2 6 b C R
This pattern field prints as:
This pattern field prints as: $2,574.26
.26 CR Condition code 2 is set to indicate that the number
edited was greater than zero.
The significance starter forces the significance
indicator to the on state and hence causes a
Pattern
leading zero and the decimal point to be pre- 1 1C
served. Because the minus-sign code has no
effect on the significance indicator, the characters 444445BF4BF2F64C3D9
CR are printed to show a negative (credit)
amount. b b b b b $ . 2 6 b C R

Condition code 1 is set (number less than zero). This pattern field prints as:
$.26 CR
EDIT AND MARK (EDMK) Condition code 1 is set because the number is
less than zero.
The EDIT AND MARK instruction may be used, in
addition to the functions of EDIT, to insert a cur-
rency symbol, such as a dollar sign, at the appro- MULTIPLY DECIMAL (MP)
priate position in the edited result. Assume the
same source in storage locations 1200-1203, the Assume that the signed, packed-decimal number
same pattern in locations 1000-100C, and the in storage locations 1202-1204 (the multiplicand)
same contents of general register 12 as for the is to be multiplied by the signed, packed-decimal
EDIT instruction above. The previous contents of number in locations 500-501 (the multiplier).
general register 1 (GR1) are not significant; a 122 124
LOAD ADDRESS instruction is used to set up the
Multiplicand 3846D

A-36 z/Architecture Principles of Operation


5 51 Machine Format
Op Code L I S B D
Multiplier 321D
F 5 \\\\ 3

The multiplicand must first be extended to have at
least two bytes of leftmost zeros, corresponding to
the multiplier length, so as to avoid a data excep- Assembler Format
tion during the multiplication. ZERO AND ADD Op Code S(L),S,I

can be used to move the multiplicand into a longer SRP FIELD1(6),3,
field. Assume:
Register 4 contains 00 00 12 00. FIELD1 (before): 1 23 45 67 8C
Register 6 contains 00 00 05 00. FIELD1 (after): 12 34 56 78 C
Then execution of the instruction:
ZAP X'1'(5,4),2(3,4) The second-operand address in this instruction
specifies the shift amount (three places). The
sets up a new multiplicand in storage locations
rounding digit, I, is not used in a left shift, but it
1300-1304:
must be a valid decimal digit. After execution,
13 134 condition code 2 is set to show that the result is
greater than zero.
Multiplicand (new) 3846D

Decimal Right Shift
Now, after the instruction: In this example, the contents of storage location
FIELD2 are shifted one place to the right, effec-
Machine Format tively dividing the contents of FIELD2 by 10 and
Op Code L L B D B D
discarding the remainder. FIELD2 is five bytes in
FC 4 1 4 1 6 length. The following instruction performs this
operation:

Machine Format
Assembler Format Op Code L I S B D
Op Code D(L,B),D(L,B)
F 4 \\\\ 3F
MP X'1'(5,4),(2,6)

is executed, storage locations 1300-1304 contain

the product: 01 23 45 66 0C.
111111

SHIFT AND ROUND DECIMAL

(SRP) 6-bit two's
complement
The SHIFT AND ROUND DECIMAL (SRP) for -1
instruction can be used for shifting decimal
numbers in storage to the left or right. When a Assembler Format
number is shifted right, rounding can also be Op Code S(L),S,I
done.
SRP FIELD2(5),64-1,
Decimal Left Shift
In this example, the contents of storage location FIELD 2 (before): 1 23 45 67 8C
FIELD1 are shifted three places to the left, effec-
tively multiplying the contents of FIELD1 by 1000. FIELD 2 (after): 12 34 56 7C
FIELD1 is six bytes long. The following instruction
performs the operation:

Appendix A. Number Representation and Instruction-Use Examples A-37


In the SRP instruction, shifts to the right are speci- Multiplying by a Variable Power of 10
fied in the second-operand address by negative Since the shift value specified by the SRP instruc-
shift values, which are represented as a six-bit tion specifies both the direction and amount of the
value in two's complement form. shift, the operation is equivalent to multiplying the
decimal first operand by 10 raised to the power
The six-bit two's complement of a number, n, can specified by the shift value.
be specified as 64 - n. In this example, a right
shift of one is represented as 64 - 1. If the shift value is to be variable, it may be speci-
fied by the B field instead of the displacement D
Condition code 2 is set. of the SRP instruction. The general register des-
ignated by B should contain the shift value
Decimal Right Shift and Round (power of 10) as a signed binary integer.
In this example, the contents of storage location
FIELD3 are shifted three places to the right and A fixed scale factor modifying the variable power
rounded, in effect dividing by 1000 and rounding of 10 may be specified by using both the B field
up. FIELD3 is four bytes in length. (variable part in a general register) and the D
field (fixed part in the displacement).
Machine Format
Op Code L I S B D The SRP instruction uses only the rightmost six
bits of the effective address D(B) and interprets
F 3 5 \\\\ 3D
them as a six-bit signed binary integer to control
the left or right shift as in the preceding shift
examples.

11111
ZERO AND ADD (ZAP)

Assume that the signed, packed-decimal number
6-bit two's at storage locations 4500-4502 is to be moved to
complement locations 4000-4004 with four leading zeros in the
for -3
result field. Also assume:

Assembler Format Register 9 contains 00 00 40 00.


Op Code S(L),S,I Storage locations 4000-4004 contain 12 34 56

78 90.
SRP FIELD3(4),64-3,5
Storage locations 4500-4502 contain 38 46
FIELD 3 (before): 12 39 6 D 0D.
After the instruction:
FIELD 3 (after): 1 24 D
Machine Format
The shift amount (three places) is specified in the Op Code L L B D B D
D field. The I field specifies a rounding digit of
5. The rounding digit is added to the last digit F8 4 2 9 9 5

shifted out (which is a 6), and the carry is propa-
gated to the left. The sign is ignored during the
addition. Assembler Format
Op Code D(L,B),D(L,B)
Condition code 1 is set because the result is less
ZAP (5,9),X'5'(3,9)
than zero.

is executed, the storage locations 4000-4004


contain 00 00 38 46 0D; condition code 1 is set to
indicate a negative result without overflow.

A-38 z/Architecture Principles of Operation


Note that, because the first operand is not The characteristics of the two numbers (43 and
checked for valid sign and digit codes, it may 41) are compared. Since the number in storage
contain any combination of hexadecimal digits has a characteristic that is smaller by 2, it is right-
before the operation. shifted two hexadecimal digit positions. One
guard digit is retained on the right. The fractions
of the two numbers are then added algebraically:
Hexadecimal-Floating-Point Fraction GD
Instructions FPR6 -43 8 21
Shifted number from storage +43 12 34 5
(See Chapter 9, Floating-Point Overview and
Support Instructions for a complete description of Intermediate sum -43 8 E CB B
the hexadecimal-floating-point instructions.) Left-shifted sum -42 8 EC BB

In this section, the abbreviations FPR0, FPR2, Guard digit


FPR4, and FPR6 stand for floating-point registers Because the intermediate sum is unnormalized, it
0, 2, 4, and 6 respectively. is left-shifted to form the normalized HFP number
-80.ECBB = -128.92 approximately. Com-
ADD NORMALIZED (AD, ADR, bining the sign with the characteristic, the result is
C2 80 EC BB, which replaces the left half of
AE, AER, AXR) FPR6. The right half of FPR6 and the contents of
storage locations 2000-2007 are unchanged.
The ADD NORMALIZED instruction performs the
Condition code 1 is set to indicate a result less
addition of two HFP numbers and places the nor-
than zero.
malized result in a floating-point register. Neither
of the two numbers to be added must necessarily
If the long-precision instruction AD were used, the
be in normalized form before addition occurs. For
result in FPR6 would be C2 80 EC BA A0 00 00
example, assume that:
00. Note that use of the long-precision instruction
FPR6 contains the unnormalized number C3 would avoid a loss of precision in this example.
08 21 00 00 00 00 00 = -82.1 = -130.06
approximately. ADD UNNORMALIZED (AU, AUR,
Storage locations 2000-2007 contain the nor- AW, AWR)
malized number 41 12 34 56 00 00 00 00 =
+1.23456 = +1.14 approximately. The ADD UNNORMALIZED instruction operates
Register 13 contains 00 00 20 00. the same as the ADD NORMALIZED instruction,
except that the final result is not normalized. For
The instruction: example, using the the same operands as in the
example for ADD NORMALIZED, when the short-
Machine Format precision instruction:
Op Code R X B D

7A 6 D Machine Format
Op Code R X B D

7E 6 D
Assembler Format
Op Code R,D(X,B)

AE 6,(,13) Assembler Format


Op Code R,D(X,B)

performs the short-precision addition of the two AU 6,(,13)
operands, as follows.
is executed, the two numbers are added as
follows:

Appendix A. Number Representation and Instruction-Use Examples A-39


Fraction GD FPR6 contains 34 12 34 56 78 9A BC DE, the
FPR6 -43 8 21 operand is right-shifted 15 positions, leaving all
Shifted number from storage +43 12 34 5 fraction digits and the guard digit as zeros. Condi-

Intermediate sum -43 8 E CB B tion code 0 is set, indicating equality. This


example shows that two HFP numbers with dif-
Guard digit ferent characteristics or fractions may compare
equal if the numbers are unnormalized or zero.
The guard digit participates in the addition but is
discarded. The unnormalized sum replaces the
As another example of comparing unnormalized
left half of FPR6. Condition code 1 is set because
HFP numbers, 41 00 12 34 56 78 9A BC com-
the result is less than zero.
pares equal to all numbers of the form 3F 12 34
56 78 9A BC 0X (X represents any hexadecimal
The truncated result in FPR6 (C3 08 0E CB 00 00
digit). When the COMPARE instruction is exe-
00 00) shows a loss of a significant digit when
cuted, the two rightmost digits are shifted right two
compared to the result of short-precision normal-
places, the 0 becomes the guard digit, and the X
ized addition.
does not participate in the comparison.

COMPARE (CD, CDR, CE, CER) However, when two normalized HFP numbers are
compared, the relationship between numbers that
Assume that FPR4 contains 43 00 00 00 00 00 00 compare equal is unique: each digit in one
00 (zero), and FPR6 contains 35 12 34 56 78 9A number must be the same as the corresponding
BC DE (a positive number). The contents of the digit in the other number.
two registers are to be compared using a long-
precision COMPARE instruction.
DIVIDE (DD, DDR, DE, DER)
Machine Format
Op Code R R Assume that the first operand (the dividend) is in
FPR2 and the second operand (the divisor) in
29 4 6 FPR0. If the operands are in the short-precision
format, the resulting quotient is returned to FPR2
by the instruction:
Assembler Format
Op Code R,R Machine Format
Op Code R R
CDR 4,6
3D 2

The number with the smaller characteristic, which
is in register FPR6, is right-shifted 43 - 35 hex
Assembler Format
(67 - 53 decimal) or 14 digit positions, so that the
Op Code R,R
two characteristics agree. The shifted number is
43 00 00 00 00 00 00 00, with a guard digit of DER 2,
one. Therefore, when the two numbers are com-
pared, condition code 1 is set, indicating that
Several examples of short-precision HFP division,
operand 1 in FPR4 is less than operand 2 in
with the dividend in FPR2 and the divisor in FPR0,
FPR6.
are shown below. For case A, the result, which
replaces the dividend, is obtained in the following
If the example is changed to a second operand
steps.
with a characteristic of 34 instead of 35, so that

A-40 z/Architecture Principles of Operation


7.2522F

MULTIPLY (MD, MDR, MDE,
.1234.821 MDER, MXD, MXDR, MXR)
7F6C
For this example, the following long-precision
2A4 operands are in FPR0 and FPR2:
2468
FPR: -33 666 6666
5D8 FPR2: -5A 2 22
5B4
A long-precision product is generated by the
27C instruction:
246 8
Machine Format
35 8 Op Code R R
24 68
2C 2
11 18
11 1C

74 Assembler Format
Op Code R,R
FPR2 Before FPR FPR2 After
Case (Dividend) (Divisor) (Quotient) MDR ,2
A -43 821 +43 1234 -42 72522F
B +42 111 +45 111111 +3D FFF If the operands were not already normalized, the
C +48 3F +41 4 +47 C3C instruction would first normalize them. It then gen-
D +48 3F +41 2 +48 187
E +48 187 +41 2 +47 C38 erates an intermediate result consisting of the full
28-digit hexadecimal product fraction obtained by
Case C shows a number being divided by 4.0. multiplying the 14-digit hexadecimal operand frac-
Case D divides the same number by 2.0, and tions, together with the appropriate sign and a
case E divides the result of case D again by 2.0. characteristic that is the sum of the operand char-
The results of cases C and E differ in the right- acteristics less 64 (40 hex):
most hexadecimal digit position, which illustrates
an effect of result truncation. The fraction multiplication is performed as follows:
.6666666
HALVE (HDR, HER) .222

CCCCCCC
HALVE produces the same result as HFP DIVIDE
CCCCCCC
with a divisor of 2.0. Assume FPR2 contains the CCCCCCC
long-precision number +48 30 00 00 00 00 00 0F.
The following HALVE instruction produces the .CCC18181824181818CCC
result +48 18 00 00 00 00 00 07 in FPR2:
Attaching the sign and characteristic to the fraction
gives:
Machine Format
Op Code R R +4D CCC 18181824 181818C CC

24 2 2 Because this intermediate product has a leading


zero, it is then normalized. The truncated final
result placed in FPR0 is:
Assembler Format +4C CCC1 81818241
Op Code R,R

HDR 2,2

Appendix A. Number Representation and Instruction-Use Examples A-41


Hexadecimal-Floating-Point-Number The EXCLUSIVE OR (X) instruction inverts the
leftmost bit in general register 9, using the right
Conversion half of the constant as the source for a leftmost
one bit. The next two instructions assemble the
The following examples illustrate one method of
modified number in an unnormalized long HFP
converting between binary fixed-point numbers
format, using the left half of the constant as the
(32-bit signed binary integers) and normalized
plus sign, the characteristic, and the leading zeros
HFP numbers. Conversion must provide for the
of the fraction. LOAD (LD) places the number
different representations used with negative
unchanged in floating-point register 2. The SUB-
numbers: the two's-complement form for signed
TRACT NORMALIZED (SD) instruction performs
binary integers, and the signed-absolute-value
the final two steps by subtracting 2 in HFP form
form for the fractions of HFP numbers.
and normalizing the result.

Fixed Point to Hexadecimal Floating Hexadecimal Floating Point to Fixed


Point Point
The method used here inverts the leftmost bit of
The procedure described here consists basically in
the 32-bit signed binary integer, which is equiv-
reversing the steps of the previous procedure.
alent to adding 2 to the number and considering
Two additional considerations must be taken into
the result to be positive. This changes the
account. First: the HFP number may not be an
number from a signed integer in the range 2 - 1
exact integer. Truncating the excess hexadecimal
through -2 to an unsigned integer in the range
digits on the right requires shifting the number one
2 - 1 through 0. After conversion to the long
digit position farther to the right than desired for
HFP format, the value 2 is subtracted again.
the final result, so that the units digit occupies the
position of the guard digit. Second: the HFP
Assume that general register 9 (GR9) contains the
number may have to be tested as to whether it is
integer -59 in two's-complement form:
outside the range of numbers representable as a
GR9: FF FF FF C5 32-bit signed binary integer.
Further, assume two eight-byte fields in storage:
TEMP, for use as temporary storage, and TWO31, Assume that floating-point register 6 contains the
which contains the floating-point constant 2 in number 59.25 = 3B.4 in normalized form:
the following format: FPR6: 42 3B 4
TWO31: 4E 8 Further, assume three eight-byte fields in storage:
This is an unnormalized long HFP number with TEMP, for use as temporary storage, and the con-
the characteristic 4E, which corresponds to a radix stants 2 (TWO32) and 2 (TWO31R) in the fol-
point (hexadecimal point) to the right of the lowing formats:
number. TWO32: 4E 1
TWO31R: 4F 8
The following instruction sequence performs the
The constant TWO31R is shifted right one more
conversion:
position than the constant TWO31 of the previous
example, so as to force the units digit into the
Result
guard-digit position.
X 9,TWO31+4 GR9:
7FFF FFC5
The following instruction sequence performs the
ST 9,TEMP+4 TEMP:
integer truncation, range tests, and conversion to
xxxx xxxx 7FFF FFC5
a signed binary integer in general register 8
MVC TEMP(4),TWO31 TEMP:
(GR8):
4E00 0000 7FFF FFC5
LD 2,TEMP FPR2:
4E00 0000 7FFF FFC5
SD 2,TWO31 FPR2:
C23B 0000 0000 0000

A-42 z/Architecture Principles of Operation


Result bit in the common-storage area for testing by
SD 6,TWO31R FPR6: another program. It should be noted that the
C87F FFFF C500 0000 instructions AND (NI or NC), EXCLUSIVE OR (XI
BC 11,OVERFLOW Branch to overflow or XC), and OR (OI or OC) could be used to set
routine if result is flag bits in a multiprogramming environment; but
greater than or equal to the same instructions may cause program logic
zero errors in a multiprocessing configuration where
AW 6,TWO32 FPR6: two or more CPUs can fetch, modify, and store
4E00 0000 8000 003B data in the same storage locations simultaneously.
BC 4,OVERFLOW Branch to overflow
routine if result is less Example of a Program Failure
than zero
STD 6,TEMP TEMP:
Using OR Immediate
4E00 0000 8000 003B
Assume that two independent programs try to set
XI TEMP+4,X'80' TEMP:
different bits to one in a common byte in storage.
4E00 0000 0000 003B
The following example shows how the use of the
L 8,TEMP+4 GR8:
instruction OR immediate (OI) can fail to accom-
0000 003B
plish this, if the programs are executed simultane-
ously on two different CPUs. One of the possible
The SUBTRACT NORMALIZED (SD) instruction
error situations is depicted.
shifts the fraction of the number to the right until it
lines up with TWO31R, which causes the fraction
digit 4 to fall to the right of the guard digit and be Execution of Execution of
instruction instruction
lost; the result of subtracting 2 from the OI FLAGS,X'1' FLAGS OI FLAGS,X'8'
remaining digits is renormalized. The result on CPU A on CPU B
should be less than zero; if not, the original
number was too large in the positive direction. X'' Fetch
The first BRANCH ON CONDITION (BC) performs FLAGS X''
Fetch X''
this test.
FLAGS X''
X'' OR X'8'
The ADD UNNORMALIZED (AW) instruction adds into X''
2: 2 to correct for the previous subtraction OR X'1' X''
and another 2 to change to an all-positive into X''
range. The second BC tests for a result less than X'8' Store X'8'
into FLAGS
zero, showing that the original number was too
Store X'1' X'1'
large in the negative direction. The unnormalized into FLAGS
result is placed in temporary storage by the
STORE (STD) instruction. There the leftmost bit FLAGS should have value of X'81' follow-
of the binary integer is inverted by the EXCLU- ing both updates.
SIVE OR (XI) instruction to subtract 2 and thus
convert the unsigned number to the signed format. The problem shown here is that the value stored
The final result is loaded into GR8. by the OI instruction executed on CPU A overlays
the value that was stored by CPU B. The X'80'
flag bit was erroneously turned off, and the data is
Multiprogramming and now invalid.
Multiprocessing Examples
The COMPARE AND SWAP instruction has been
When two or more programs sharing common provided to overcome this and similar problems.
storage locations are being executed concurrently
in a multiprogramming or multiprocessing environ-
ment, one program may, for example, set a flag

Appendix A. Number Representation and Instruction-Use Examples A-43


Conditional Swapping Setting a Single Bit
The following instruction sequence shows how the
Instructions (CS, CDS)
COMPARE AND SWAP instruction can be used to
The COMPARE AND SWAP (CS) and COMPARE set a single bit in storage to one. Assume that the
DOUBLE AND SWAP (CDS) instructions can be first byte of a word in storage called WORD con-
used in multiprogramming or multiprocessing envi- tains eight flag bits.
ronments to serialize access to counters, flags, LA 6,X'8' Put bit to be ORed into GR6
control words, and other common storage areas. SLL 6,24 Shift left 24 places to
align the byte to be ORed
with the location of the
The following examples of the use of the
flag bits within WORD
COMPARE AND SWAP and COMPARE DOUBLE L 7,WORD Fetch current flag values
AND SWAP instructions illustrate the applications RETRY LR 8,7 Load flags into GR8
for which the instructions are intended. It is OR 8,6 Set bit to one
important to note that these are examples of func- CS 7,8,WORD Store new flags if current
tions that can be performed by programs while the flags unchanged, or re-
fetch current flag values
CPU is enabled for interruption (multiprogram- if changed
ming) or by programs that are being executed in a BC 4,RETRY If new flags are not stored,
multiprocessing configuration. That is, the routine try again
allows a program to modify the contents of a
The format of the COMPARE AND SWAP instruc-
storage location while the CPU is enabled, even
tion is:
though the routine may be interrupted by another
program on the same CPU that will update the Machine Format
location, and even though the possibility exists Op Code R R S
that another CPU may simultaneously update the
same location. BA 7 8 \\\\

The COMPARE AND SWAP instruction first
checks the value of a storage location and then Assembler Format
modifies it only if the value is what the program Op Code R,R,S
expects; normally this would be a previously
fetched value. If the value in storage is not what CS 7,8,WORD
the program expects, then the location is not mod-
ified; instead, the current value of the location is The COMPARE AND SWAP instruction compares
loaded into a general register, in preparation for the first operand (general register 7 containing the
the program to loop back and try again. During current flag values) to the second operand in
the execution of COMPARE AND SWAP, no other storage (WORD) while no CPU other than the one
CPU can perform a store access or interlocked- executing the COMPARE AND SWAP instruction
update access at the specified location. is permitted to perform a store access or
interlocked-update access at the specified storage
To ensure successful updating of a common location.
storage field by two or more CPUs, all updates
must be done by means of an interlocked-update If the comparison is successful, indicating that the
reference. See the programming notes of flag bits have not been changed since they were
COMPARE AND SWAP for an example of how fetched, the modified copy in general register 8 is
COMPARE AND SWAP can be unsuccessful due stored into WORD. If the flags have been
to an OR IMMEDIATE instruction executed by changed, the compare will not be successful, and
another CPU. their new values are loaded into general register
7.

The conditional branch (BC) instruction tests the


condition code and reexecutes the flag-modifying
instructions if the COMPARE AND SWAP instruc-
tion indicated an unsuccessful comparison (condi-

A-44 z/Architecture Principles of Operation


tion code 1). When the COMPARE AND SWAP LA 6,1 Put increment (1) into GR6
instruction is successful (condition code 0), the L 7,CNTR Put original counter value
flags contain valid data, and the program exits into GR7
LOOP LR 8,7 Set up copy in GR8 to modify
from the loop. AR 8,6 Increment copy
CS 7,8,CNTR Update counter in storage
The branch to RETRY will be taken only if some BC 4,LOOP If original value had changed,
other program modifies the contents of WORD. update new value
This type of a loop differs from the typical bit- The following shows two CPUs, A and B, exe-
spin loop. In a bit-spin loop, the program con- cuting this instruction sequence simultaneously:
tinues to loop until the bit changes. In this both CPUs attempt to add one to CNTR.
example, the program continues to loop only if the
value does change during each iteration. If a CPU A CPU B Comments
GR7 GR8 CNTR GR7 GR8
number of CPUs simultaneously attempt to modify
a single location by using the sample instruction 16
sequence, one CPU will fall through on the first 16 16 CPU A loads GR7 and
try, another will loop once, and so on until all GR8 from CNTR
CPUs have succeeded. 16 16 CPU B loads GR7 and
GR8 from CNTR
17 CPU B adds one to GR8
Updating Counters 17 CPU A adds one to GR8
In this example, a 32-bit counter is updated by a 17 CPU A executes CS;
program using the COMPARE AND SWAP successful match,
instruction to ensure that the counter will be cor- store
17 CPU B executes CS; no
rectly updated. The original value of the counter
match, GR7 changed
is obtained by loading the word containing the to CNTR value
counter into general register 7. This value is 18 CPU B loads GR8 from
moved into general register 8 to provide a modifi- GR7, adds one to GR8
able copy, and general register 6 (containing an 18 CPU B executes CS;
increment to the counter) is added to the modifi- successful match,
store
able copy to provide the updated counter value.
The COMPARE AND SWAP instruction is used to
ensure valid storing of the counter. Bypassing Post and Wait
The program updating the counter checks the Bypass Post Routine
result by examining the condition code. The con- The following routine allows the SVC POST as
dition code 0 indicates a successful update, and used in MVS/ESA to be bypassed whenever the
the program can proceed. If the counter had been corresponding WAIT has not yet been executed,
changed between the time that the program provided that the supervisor WAIT and POST rou-
loaded its original value and the time that it exe- tines use COMPARE AND SWAP to manipulate
cuted the COMPARE AND SWAP instruction, the event control blocks (ECBs).
execution would have loaded the new counter
value into general register 7 and set the condition Initial Conditions:
code to 1, indicating an unsuccessful update. The GR0 contains the POST code.
program must then repeat the update sequence
until the execution of the COMPARE AND SWAP GR1 contains the address of the ECB.
instruction results in a successful update. GR5 contains 40 00 00 00

The following instruction sequence performs the


above procedure:

Appendix A. Number Representation and Instruction-Use Examples A-45


HSPOST OR ,5 Set bit 1 of GR to be used as the interlock mechanism for updating
one an SRR of any complexity.
L 3,(1) GR3 = contents of ECB
LTR 3,3 ECB marked 'waiting'?
The lock/unlock functions are based on the use of
BC 4,PSVC Yes, execute post
SVC a header associated with the SRR. The header
CS 3,,(1) No, store post code is the common starting point for determining the
BC 8,EXITHP Continue states of the SRR, either free or in use, and also
PSVC POST (1),() ECB address is in GR1, is used for queuing requests when contentions
post code in GR occur. Contentions are resolved using WAIT and
EXITHP [Any instruction]
POST. The general programming technique
The following routine may be used in place of the requires that the program that encounters a
previous HSPOST routine if it is assumed that bit locked SRR must leave a mark on the wall indi-
1 of the contents of GR0 is already set to one and cating the address of an ECB on which it will
if the ECB is assumed to contain zeros when it is WAIT. The unlocking program sees the mark
not marked WAITING. and posts the ECB, thus permitting the waiting
HSPOST SR 3,3 program to continue. In the two examples given,
CS 3,,(1) all programs using a particular SRR must use
BC 8,EXITHP either the LIFO queuing scheme or the FIFO
POST (1),() scheme; the two cannot be mixed. When more
EXITHP [Any instruction]
complex queuing is required, it is suggested that
the queue for the SRR be locked using one of the
Bypass Wait Routine two methods shown.
A BYPASS WAIT function, corresponding to the
BYPASS POST, does not use the CS instruction,
Lock/Unlock with LIFO Queuing for
but the FIFO LOCK/UNLOCK routines which
Contentions
follow assume its use.
The header consists of a word, that is, a four-byte
HSWAIT TM(1),X'4' field aligned on a word boundary. The word can
BC1,EXITHW If bit 1 is one, then contain zero, a positive value, or a negative value.
ECB is already posted;
branch to exit A zero value indicates that the serially reus-
WAIT ECB=(1) able resource (SRR) is free.
EXITHW [Any instruction]
A negative value indicates that the SRR is in
use but no additional programs are waiting for
Lock/Unlock the SRR.
When a common storage area larger than a A positive value indicates that the SRR is in
doubleword is to be updated, it is usually neces- use and that one or more additional programs
sary to provide special interlocks to ensure that a are waiting for the SRR. Each waiting
single program at a time updates the common program is identified by an element in a
area. Such an area is called a serially reusable chained list. The positive value in the header
resource (SRR). is the address of the element most recently
added to the list.
In general, updating a list, or even scanning a list,
Each element consists of two words. The first
cannot be safely accomplished without first
word is used as an ECB; the second word is used
freezing the list. However, the COMPARE AND
as a pointer to the next element in the list. A neg-
SWAP and COMPARE DOUBLE AND SWAP
ative value in a pointer indicates that the element
instructions can be used in certain restricted situ-
is the last element in the list. The element is
ations to perform queuing and list manipulation.
required only if the program finds the SRR locked
Of prime importance is the capability to perform
and desires to be placed in the list.
the lock/unlock functions and to provide sufficient
queuing to resolve contentions, either in a LIFO or
The following chart describes the action taken for
FIFO manner. The lock/unlock functions can then
LIFO LOCK and LIFO UNLOCK routines. The
routines following the chart allow enabled code to
perform the actions described in the chart.

A-46 z/Architecture Principles of Operation


LUNLK L 1,(2)GR1 = the contents of the
Action
header
Header ContainsHeader ContainsHeader Contains A LTR 1,1 Does the header contain a
Function Zero Positive Value Negative Value
BC 4,B negative value?
LIFO LOCK SRR is free. SRR is in use. Store the L ,4(1) No, load the pointer from
(the incomingSet the header contents of the header into
element is atto a negative location A+4. Store address A CS 1,,(2) the "last in" element and
location A) value. Use the into the header. WAIT; the ECB store it in the header
SRR. is at location A. BC 7,A Did the header get updated?

LIFO UNLOCK Error Some program isThe list is POST (1) Yes, post the "last in"
waiting for theempty. Store element
SRR. Move the zeros into the
pointer from header. The SRR BC 15,EXIT Continue
the "last in" is free. B SR , The header contains a neg-
element into
the header. CS 1,,(2) ative value; free the
POST; the ECB BC 7,A header and continue
is in the "last EXIT [Any instruction]
in" element.

Note that the LOAD instruction L 1,0(2) at location


LIFO LOCK Routine: LUNLK would have to be CS 1,1,0(2) if it were not
for the rule concerning storage-operand consist-
Initial Conditions: ency. This rule requires the LOAD instruction to
fetch a four-byte operand aligned on a word
GR1 contains the address of the incoming boundary such that, if another CPU changes the
element. word being fetched by an operation which is also
GR2 contains the address of the header. at least word-consistent, either the entire new or
the entire old value of the word is obtained, and
LLOCK SR 3,3 GR3 =
ST 3,(1)Initialize the ECB not a combination of the two. (See Storage-
LNR ,1 GR = a negative value Operand Consistency on page 5-86.)
TRYAGN CS 3,,(2)
Set the header to a nega-
tive value if the header Lock/Unlock with FIFO Queuing for
contains zeros
BC 8,USE Did the header contain
Contentions
zeros? The header always contains the address of the
ST 3,4(1) No, store the value of the most recently entered element. The header is ori-
header into the pointer ginally initialized to contain the address of a
in the incoming element posted ECB. Each program using the serially
CS 3,1,(2) Store the address of the reusable resource (SRR) must provide an element
incoming element into
the header regardless of whether contention occurs. Each
LA 3,() GR3 = program then enters the address of the element
BC 7,TRYAGN Did the header get up- which it has provided into the header, while simul-
dated? taneously it removes the address previously con-
WAIT ECB=(1) Yes, wait for the re- tained in the header. Thus, associated with any
source; the ECB is in
particular program attempting to use the SRR are
the incoming element
USE [Any instruction] two elements, called the entered element and
the removed element. The entered element of
LIFO UNLOCK Routine: one program becomes the removed element for
the immediately following program. Each program
Initial Conditions: then waits on the removed element, uses the
SRR, and then posts the entered element.
GR2 contains the address of the header.
When no contention occurs, that is, when the
second program does not attempt to use the SRR
until after the first program is finished, then the
POST of the first program occurs before the WAIT
of the second program. In this case, the bypass-
post and bypass-wait routines described in the
preceding section are applicable. For simplicity,

Appendix A. Number Representation and Instruction-Use Examples A-47


these two routines are shown only by name rather GR4 contains the address, A, of the element
than as individual instructions. currently owned by this program. This
element becomes the entered element.
In the example, the element need be only a single FLOCK LR 2,4 GR2 now contains address
word, that is, an ECB. However, in actual prac- of element to be
tice, the element could be made larger to include entered
a pointer to the previous element, along with a SR 1,1 GR1 =
program identification. Such information would be ST 1,(2) Initialize the ECB
useful in an error situation to permit starting with L 1,(3) GR1 = contents of the
header
the header and chaining through the list of ele- TRYAGN CS 1,2,(3) Enter address A into
ments to find the program currently holding the header while remember-
SRR. BC 7,TRYAGN ing old contents of
header into GR1; GR1
It should be noted that the element provided by now contains address
the program remains pointed to by the header of removed element
LR 4,1 Removed element becomes
until the next program attempts to lock. Thus, in new currently owned
general, the entered element cannot be reused by element
the program. However, the removed element is HSWAIT Perform bypass-wait
available, so each program gives up one element routine; if ECB al-
and gains a new one. It is expected that the ready posted, con-
tinue; if not, wait;
element removed by a particular program during
GR1 contains the ad-
one use of the SRR would then be used by that dress of the ECB
program as the entry element for the next request USE [Any instruction]
to the SRR.
FIFO Unlock Routine:
It should be noted that, since the elements are
exchanged from one program to the next, the ele- Initial conditions:
ments cannot be allocated from storage that would
GR2 contains the address of the removed
be freed and reused when the program ends. It is
element, obtained during the FLOCK routine.
expected that a program would obtain its first
element and release its last element by means of GR5 contains 40 00 00 00
the routines described in Free-Pool Manipulation. FUNLK LR 1,2
Place address of entered
element in GR1; GR1 = ad-
The following chart describes the action taken for dress of ECB to be posted
FIFO LOCK and FIFO UNLOCK. SR , GR = ; GR has a post code
of zero
OR ,5 Set bit 1 of GR to one
Function Action HSPOST Perform bypass-post routine;
if ECB has not been waited
FIFO LOCK Store address A into the on, then mark posted and
header. continue; if it has been
(the incoming WAIT; the ECB is at the waited on, then post
element is at location addressed by the CONTINUE [Any instruction]
location A) old contents of the header.

FIFO UNLOCK POST; the ECB is at loca- Free-Pool Manipulation


tion A.
It is anticipated that a program will need to add
The following routines allow enabled code to and delete items from a free list without using the
perform the actions described in the previous lock/unlock routines. This is especially likely since
chart. the lock/unlock routines require storage elements
for queuing and may require working storage.
FIFO Lock Routine: The lock/unlock routines discussed previously
allow simultaneous lock routines but permit only
Initial conditions: one unlock routine at a time. In such a situation,
multiple additions and a single deletion to the list
GR3 contains the address of the header.

A-48 z/Architecture Principles of Operation


may all occur simultaneously, but multiple tains a pointer to the next element in the list. A
deletions cannot occur at the same time. In the zero value indicates the end of the list.
case of a chain of pointers containing free storage
buffers, multiple deletions along with additions can The following chart describes the free-pool-list
occur simultaneously. In this case, the removal manipulation.
cannot be done using the COMPARE AND SWAP
instruction without a certain degree of exposure. Action

Function Header = ,Count Header = A,Count
Consider a chained list of the type used in the
ADD TO LIST Store the first word of the header into
LIFO lock/unlock example. Assume that the first (the incominglocation A. Store the address A into the
two elements are at locations A and B, respec- element is atfirst word of the header. Decrement the
location A) second word of the header by one.
tively. If one program attempted to remove the
first element and was interrupted between the DELETE FROM The list is empty.Set the first word of
LIST the header to the value
fourth and fifth instructions of the LUNLK routine, of the contents of loca-
the list could be changed so that elements A and tion A. Use element A.

C are the first two elements when the interrupted
program resumes execution. The COMPARE The following routines allow enabled code to
AND SWAP instruction would then succeed in perform the free-pool-list manipulation described in
storing the value B into the header, thereby the above chart.
destroying the list.
ADD TO FREE LIST Routine:
The probability of the occurrence of such list
destruction can be reduced to near zero by Initial Conditions:
appending to the header a counter that indicates GR2 contains the address of the element to
the number of times elements have been added to be added.
the list. The use of a 32-bit counter guarantees
that the list will not be destroyed unless the fol- GR4 contains the address of the header.
lowing events occur, in the exact sequence: ADDQ LM ,1,(4) GR,GR1 = contents of the
header
1. An unlock routine is interrupted between the TRYAGN ST ,(2) Point the new element to
fetch of the pointer from the first element and the top of the list
the update of the header. LR 3,1 Move the count to GR3
BCTR 3, Decrement the count
2. The list is manipulated, including the deletion CDS ,2,(4) Update the header
of the element referenced in 1, and exactly BC 7,TRYAGN
2 (or an integer multiple of 2) additions to
the list are performed. Note that this takes on DELETE FROM FREE LIST Routine:
the order of days to perform in any practical
situation. Initial conditions:
3. The element referenced in 1 is added to the GR4 contains the address of the header.
list. DELETQ LM 2,3,(4) GR2,GR3 = contents of
4. The unlock routine interrupted in 1 resumes the header
TRYAGN LTR 2,2 Is the list empty?
execution. BC 8,EMPTY Yes, get help
The following routines use such a counter in order L ,(2) No, GR = the pointer
from the first ele-
to allow multiple, simultaneous additions and
ment
removals at the head of a chain of pointers. LR 1,3 Move the count to GR1
CDS 2,,(4) Update the header
The list consists of a doubleword header and a BC 7,TRYAGN
chain of elements. The first word of the header USE [Any instruction] The address of the re-
contains a pointer to the first element in the list. moved element is in
GR2
The second word of the header contains a 32-bit
counter indicating the number of additions that Note that the LM (LOAD MULTIPLE) instructions
have been made to the list. Each element con- at locations ADDQ and DELETQ would have to be
CDS (COMPARE DOUBLE AND SWAP)

Appendix A. Number Representation and Instruction-Use Examples A-49


instructions if it were not for the rule concerning incremented anytime the queue is changed; H (for
storage-operand consistency. This rule requires head), which is the address of the first element on
the LOAD MULTIPLE instructions to fetch an the queue; and C, which is a count of the number
eight-byte operand aligned on a doubleword of elements on the queue. Assume a queue
boundary such that, if another CPU changes the element contains a variable, F (for forward), which
doubleword being fetched by an operation which is the address of the next element on the queue.
is also at least doubleword-consistent, either the If a new element, N, is to be enqueued at the
entire new or the entire old value of the head of the queue, that can be done by setting F
doubleword is obtained, and not a combination of in N to H and then performing the following atomic
the two. (See Storage-Operand Consistency on set of operations:
page 5-86.) S+1 5 S
A(N) 5 H
PERFORM LOCKED OPERATION C+1 5 C
(PLO) where A(N) is the address of N.

The PERFORM LOCKED OPERATION instruction The enqueueing of N can be done by means of
can be used in a multiprogramming or multiproc- the following steps:
essing environment to perform compare, load, 1. Obtain consistent values of S, H, and C,
compare-and-swap, and store operations on two meaning obtain S and obtain the H and C that
or more discontiguous locations that can be words are consistent with that value of S.
or doublewords. The operations are performed as
an atomic set of operations under the control of a 2. Store H in N.F.
lock that is held only for the duration of the exe- 3. By means of PLO.csdst (PERFORM LOCKED
cution of a single PERFORM LOCKED OPERA- OPERATION performing compare and swap
TION instruction, as opposed to across the and double store), with S as the swap variable
execution of multiple instructions. Since lock con- and H and C as the store variables, add one
tention is resolved by the CPU and is very brief, to S, set H to A(N), and add one to C, pro-
the program need not include a method for vided that S still has the value obtained in
dealing with the case when the lock to be used is step 1. If S has already been changed, go
held by a program being executed by another back to step 1.
CPU. Also, there need be no concern that the
program may be interrupted while it holds a lock, Consistent values of S, H, and C cannot neces-
since PERFORM LOCKED OPERATION will com- sarily be obtained simply by using three LOAD
plete its operation and release its lock before an instructions because a PERFORM LOCKED
interruption can occur. OPERATION instruction being executed by
another CPU may have completed an update of S
PERFORM LOCKED OPERATION can be thought but not yet of H or C. In this case, the three
of as performing concurrent interlocked updates of LOAD instructions will obtain the new S but the
multiple operands. However, the instruction does old H or C. However, as will be described, it may
not actually perform any interlocked update, and a be possible to use three LOAD instructions.
serially reusable resource cannot be updated pre-
dictably through the use of both PERFORM If S is obtained while holding the lock, meaning by
LOCKED OPERATION and conditional-swapping means of PERFORM LOCKED OPERATION, then
instructions (CS and CDS). H and C can be obtained by LOAD instructions
since no other CPU can subsequently change H
Following is an example of how PERFORM or C without changing S, as observed when the
LOCKED OPERATION can be used to add an lock is held.
element at the beginning of a queue.
The parameter list used by the PLO.csdst is as
Assume the following variables associated with follows, assuming the access-register mode is not
the queue: S, which is a sequence number that is used:

A-50 z/Architecture Principles of Operation


the lock is held. It is unnecessary to test the con-
dition code to determine which load occurred.

8
The above program may be a simplification. If the
/ /
48 queue has associated with it a variable, T (for tail),
that is the address of the last element on the
56 A(N) queue, and the queue is currently empty, T also
must be set when N is added to the queue. This
64 would require a different program using a

72 A(H) compare-and-swap-and-triple-store operation.

8 If the queue is added to, deleted from, and rear-
ranged by means of PERFORM LOCKED OPER-
88 C+1 ATION instructions in which the sequence
number, S, is always the second operand, then,
96
since the definition of PERFORM LOCKED
14 A(C) OPERATION specifies that the second operand is
always stored last, the first PERFORM LOCKED
OPERATION instruction in the above program can
The program is as follows: be replaced by a LOAD instruction. The three
instructions within the dashed lines would be
LA RT,H Initialize addresses in PL replaced by L RS,S.
(T = temp)
ST RT,PL+76 Op4 address (address of H)
LA RT,C
ST RT,PL+18 Op6 address (address of C) Sorting Instructions
LA RN,N Address of N
ST RN,PL+6 Initialize op3 in PL
(address of N) Tree Format
LA R1,S PLT address = address of S
------------------------------------------------ Two instructions, COMPARE AND FORM
SR RS,RS Dummy S. CC1 will CODEWORD and UPDATE TREE, refer to a
probably be set
SR R,R Function code (compare tree -- a data structure with a specific format. A
and load) tree consists of some number (always odd) of
PLO RS,S,RS,S Obtain S while holding consecutively numbered nodes. Node 1 is the
lock root of the tree. Every node except the root has
------------------------------------------------ one parent node in the same tree. Every parent
LA R,16 Function code 16 (csdst) node has two son nodes. Every even-numbered
LOOP L RT,H Consistent H
ST RT,OFSTF(,RN) OFSTF = offset of F node is the leftson of its parent node, and every
in N odd-numbered node (except node 1) is the
L RT,C Consistent C rightson of its parent node. Division by two
LA RT,1(,RT) C+1 (ignoring remainder) of the node number gives the
ST RT,PL+92 Initialize op5 in PL (C+1) parent node number. Nodes with sons are also
LA RSP,1(,RS) RS/RSP = even/odd pair.
S+1 in RSP called internal nodes, and nodes without sons are
PLO RS,S,,PL called terminal nodes. Figure A-5 on page A-53
BNZ LOOP Br if S changed (if CC not illustrates schematically a 21-node tree with
) arrows drawn from each parent node to each son
Note the following about the first PERFORM node.
LOCKED OPERATION instruction (PLO.cl). If S is
A tree is used for merging several sorted
not zero (which is probably true), S (the second
sequences of records into a single merged
operand, op2) is loaded into RS (the first-operand
sequence of records. At each step in the merging
comparison value, op1c). If S is zero, S (the
process, there exists the initial part of the merged
fourth operand, op4) is loaded into RS (the third
sequence and the remaining parts of each of the
operand, op3). Either of these loads occurs while
sorted sequences that are being merged. Each

Appendix A. Number Representation and Instruction-Use Examples A-51


step consists in selecting the lowest record (the Rather than comparing the actual keys of records,
record with the lowest key when sorting in much of the merge logic can be performed using
ascending sequence) from all of the as yet codewords to represent a record key rather than
unmerged parts of the sorted sequences and referring to actual keys. The value of a codeword
adding it to the merged sequence. Each terminal at a node in the tree depends not only on the
node in the tree represents one of the sorted record's key but also on the key of the winning
sequences. The number of internal nodes in the record in the last comparison at that node. The
tree is one less than the number of sorted codeword consists of two parts:
sequences. Each internal node conceptually con-
1. Bits 16-31 contain the one's complement of
tains one record from each of the sorted
the first halfword in which the record key
sequences but one; these are the lowest records,
differs from that of the node's winning record.
from all but one of the sorted sequences, that
have not yet been added to the merged sequence. 2. Bits 0-15 specify the byte offset of the
In addition, there is the lowest record from the one halfword in this record's key just beyond the
remaining sorted sequence. This additional record halfword value (complemented) in bit positions
is compared and interchanged with nodes of the 16-31.
tree to select the record to be added next to the When comparing records in the path of the last
merged sequence. This processing begins with winner record, if the new record is also repres-
the parent of the terminal node that represents the ented by a codeword resulting from a comparison
one remaining sorted sequence, and it continues with the last winner, all codewords in the update
from that node along the path to the root of the path are with respect to the same winner. When
tree. The selected record emerges from the root comparing such codewords, a high codeword
of the tree. represents a low key and vice versa. Thus, when
codewords are unequal, a node entry with a high
The tree may perhaps be most easily explained by
codeword (representing a low actual key) should
considering each node to represent a comparison
move up the tree.
operation in an elimination tournament to find the
lowest record. After the tournament has been In the case of a tie value of codewords, it is nec-
completed, each node has an associated loser essary to refer to the actual keys. This is done by
record which had a higher key in the comparison the instruction COMPARE AND FORM
represented by that node. Besides a loser record CODEWORD, which resolves the ambiguity and
at each node, there is one record (the winner) computes a new codeword for the high-key (loser)
which is not associated with any node since it record.
never compared high. The next step would be to
introduce a new record from the same sorted The eight bytes at each node of a tree consist of
sequence from which the winner record originated (1) a codeword for this record, computed with
and replay the tournament with the new record in respect to the last record which compared low
place of the former winner. It can be seen that it against this record and (2) a parameter usable to
is unnecessary to do all the comparisons repres- locate this record, for example, a direct or indirect
ented by all the nodes in the tree -- most of them address.
are unaffected by the new record replacing the
former winner. In fact, it is sufficient to redo only The instruction UPDATE TREE is so defined that
those node comparisons in which the former tree updating stops after equal codewords are
winner record participated. Each new record is detected and the tie-breaking instruction
inserted into the tree at the terminal node that COMPARE AND FORM CODEWORD can be
represents the sorted sequence containing the used, after which UPDATE TREE can resume tree
record. The use of the tree assumes that pro- updating at the point where equal codewords were
gramming provides a method of remembering at previously found.
which terminal node each winning record origi-
nated. The instruction UPDATE TREE allows for COMPARE AND FORM CODEWORD may alter-
a new record to be inserted at a terminal node natively be used for merging in descending
and the tree to be updated so that a new winner sequence. In that case, bits 16-31 of the
record is left in the general registers. codeword at a node contain the true value of the
first halfword in which the record key differs from

A-52 z/Architecture Principles of Operation


that of the node's winning record. When the Byte Offset
descending option of COMPARE AND FORM (hexadecimal) Field
CODEWORD is used, the higher of two
0-5 Six-byte record key.
codewords represents the higher key.
6-7 Halfword node index specifying

1 the input sequence of the next


record of this input sequence.

8-B Address of the next record in the

6 6 same input sequence.

2

3
C-F This chaining field is initially
zero. At the completion of the

merge, this field is to contain the
address of the next record in the
6 6 6 6
merged sequence.
4 5 6 7









The merge process forms a single sorted
sequence from five input sequences, each of
6 6 6 6 6 6 6 6
which is in sorted order. This process can be
8 9 1 11 12 13 14 15 subdivided into three steps:


1. A priming step takes the first record from each

6 6 6 6 6 6 of the five input sequences and places them
in the tree data structure. For each record to
16171819221
be introduced into the tree, first its codeword
Figure A-5. Schematic Diagram of Merge Control Tree value is computed with respect to the lowest
with 21 Nodes possible key value of all zeros. This
codeword, with a second word which contains
the address of the actual record, forms a
Example of Use of Sort doubleword node value that can be placed at
Instructions the appropriate node. After priming, the node
values, one each from each of the five input
An example illustrates how the instructions sequences, will have been placed in the tree
UPDATE TREE and COMPARE AND FORM so that each of the four internal nodes con-
CODEWORD may be used in the merge operation tains one node value and the node value for a
within a sort program. A five-way merge requires winner record has emerged from the root of
a tree data structure with four internal nodes and the tree.
five terminal-node positions. The schematic
diagram shown later in this section illustrates such 2. After each winner emerges from the tree, the
a tree, containing four internal nodes (not counting main merge process is performed repeatedly.
the dummy node) and five input sequences for a Each iteration introduces the node value for
merge, one sequence at each terminal-node posi- one new record into the tree and produces a
tion. Each record in an input sequence in the node value for a new winner record. The tree
diagram is indicated by its address. The actual plus the winner must at all times contain pre-
record contents are shown in Figure A-7 on cisely one node value from each input
page A-57. Each record contains 16 bytes, con- sequence being merged. Therefore, the new
sisting of the following fields: node value that is introduced into the tree on
each iteration must come from the same input
sequence from which the winner node value in
the preceding iteration originated.
3. When the node value for the last record of an
input sequence emerges as a winner, there is
no successor record from that input sequence
to be introduced into the tree on the next iter-
ation. Hence, the order of the merge must be
reduced by one for each such occurrence.

Appendix A. Number Representation and Instruction-Use Examples A-53


This runout process will consist of one or general registers are as shown on the first line of
more iterations for each of a four-way, Figure A-8 on page A-58.
three-way, two-way, and one-way merge. The
onset of runout occurs in the example when it The figure illustrating the program for the main
is found that the next input record from a merge is divided into three groups of columns,
sequence is lower than its predecessor (a containing the absolute program, the general-
sequence break). register trace, and the symbolic program. The first
part of the program extends from symbolic
The priming process is discussed next, and the
locations L1 through L2; it introduces a new
state of the tree is shown after priming is com-
record into the tree and executes an UPDATE
plete. Then, a short program that uses the
TREE instruction. If no tied codewords are
instructions UPDATE TREE and COMPARE AND
encountered in UPDATE TREE, then the
FORM CODEWORD to perform the main merge is
BRANCH ON CONDITION instruction following
described. An abbreviated trace is then presented
UPDATE TREE loops back to L1 to introduce the
to show the status of the tree and certain general
next record into the tree. This BRANCH ON
registers for 16 iterations of the main merge. The
CONDITION instruction is suitable for use when
runout process is not discussed in this example.
UPDATE TREE operates in accordance with
either its method 1 (setting condition code 1) or its
Priming begins by forming the node value for the
method 2 (setting condition code 3). (The pre-
first record of each input sequence. The first word
ceding sentence applies to 370-XA. In ESA/370
of the node value is the codeword formed by exe-
and ESA/390, UPDATE TREE operates in accord-
cuting COMPARE AND FORM CODEWORD on a
ance with only method 2, which is not to say that
record key containing all binary zeros. The
it cannot set condition code 1. Method 2, but not
second word of the node value is the address of
method 1, tests for the condition that sets condi-
the record represented by that node value. The
tion code 3.)
node values for the first record of each input
sequence are:
If UPDATE TREE encounters tied codewords,
Sequence Index Node Values then the UPDATE TREE instruction is completed,
the subsequent BRANCH ON CONDITION
28 6 FFFC 13
3 6 FFFB 14 instruction does not branch, and control falls
38 6 FFFA 15 through to the second part of the program, which
4 4 FFFE 18 handles entries with tied codewords. This part
48 6 FFF 16 then branches back to UPDATE TREE at L2,
In the example, the tree data structure is assumed which resumes the tree updating. It is possible for
to have base address X'1000', which is kept in tied codewords to be encountered at any level in
general register 4 (to match the expected use in the tree (or indeed at all levels), so that the tied-
UPDATE TREE). Similarly, internal-node index codeword part of the program may be entered up
values and input-sequence index values are to three times for each record introduced.
always used from general register 5.
The general-register trace for the first part of the
Although the tree-priming program is not part of main merge shows the contents of the first seven
this example, the UPDATE TREE instruction is general registers after each instruction is executed
used in creating it as follows. First, the codeword during the first iteration. Note that the merged-
position for each internal node of the tree is initial- chain field (at 1140) serves as the anchor for the
ized to all ones (X'FFFF FFFF'). This artifice fills merged-chain address chain through the records.
the tree with dummy low records. Then, for each The trace shows only the lower half of certain
record in the table, (1) the sequence index is general registers, whose upper half is always
loaded into general register 5, (2) the node value zero.
is loaded into general registers 0 and 1, and
Figure A-9 on page A-59 gives an abbreviated
(3) UPDATE TREE is executed. At the com-
trace of the entire main merge of 16 records. For
pletion of this priming process, the tree-node con-
each record introduced into the tree, there are one
tents in the example are as shown on line 0 of
or more lines (always an odd number) given in the
Figure A-9 on page A-59. The contents of the
figure to show the tree updating, which results

A-54 z/Architecture Principles of Operation


finally in a winner in GR0 and GR1. The first line loses or wins means that the node loses or
for each record shows the values of GR5, GR2, wins, respectively.
and GR3 before the first or only execution of
UPDATE TREE. For the even-numbered lines, The tie-break trace part of Figure A-8 on page
the storage updating by UPDATE TREE of tree A-58 shows the treatment of the third record (that
nodes is shown (read left to right to follow the is, the first record for which UPDATE TREE
order of swapping). For example, consider line 10 encounters a tied codeword). This corresponds to
and the corresponding UPDATE TREE: since line 31 in Figure A-9 on page A-59.
GR5 contains 28, the first storage node examined
is 1010 (refer to the schematic diagram). Since The following is a summary of the steps that are
the codeword in GR0 is 0004 FFFE (same as for needed to use this example for verification pur-
GR2), which is less than that of the word at 1010 poses:
(0006 FFF0), the doubleword at 1010 is swapped 1. Initialize storage as follows:
with that in GR0 and GR1. A second comparison
at 1008 in the same execution of UPDATE TREE a. 1008 through 102F from line 0 of
causes another register-storage doubleword swap, Figure A-9 on page A-59
which leaves the winner (record 1040) in GR1 at b. 1030 through 114F from Figure A-7 on
the completion of UPDATE TREE (see the column page A-57
at the far right of Figure A-9 on page A-59).
c. 1150 through 1189 from Figure A-8 on
When a codeword comparison is made which page A-58
does not result in a tie or a swap (that is, when 2. Initialize GRs per first line in Figure A-8 and
the storage-codeword value is low), an asterisk trace first record per Figure A-8.
appears in the trace for that storage entry.
3. Trace to completion of each UPT or BC 15,L2
When equal codewords are found, the execution (once for each line of Figure A-9). A detailed
of UPDATE TREE is completed. The following trace of the GRs for the tied-codeword part of
line in each such case shows the result of the line 31 of Figure A-9 is given in the lower part
tied-codeword routine, which always stores a new of Figure A-8.
codeword and may also store a new record 4. Verify that addresses in the chain beginning at
address before branching back to L2 to execute 103C and continuing through 114C are as
UPDATE TREE again. In this line, the notation shown in the right-hand column of Figure A-7.

Appendix A. Number Representation and Instruction-Use Examples A-55



: Dummy Node




8: Root Node




1: Node 18: Node

' ' '
' ' '
' ' '
28:Input Seq. 3:Input Seq. 38:Input Seq.
13 14 15
17 1B 19
2: Node 1D 1C 1E
111 114 113
' ' 114 [sequence break]
' ' 15
' '
' '
4:Input Seq. 48:Input Seq.
18 16
1F 1A
112 11
114 114
Note: Each node and input sequence is identified by a number which is the hexadecimal node index.
Each input sequence is given as a list of record addresses (also in hexadecimal).
Figure A-6. Schematic Diagram for Example of Merge to Be Performed

A-56 z/Architecture Principles of Operation



Successor Record
Record Key Merged-Chain
at Hex Byte Offset Index Location Address

Location 1 2 3 4 5 6 7 8 9 A B C D E F

13 3 2 8 1 7 1 4

14 4 3 1 B 1 5

15 5 3 8 1 9 1 6

16 F 4 8 1 A 1 8

17 1F F F F 2 8 1 D 1 9

18 1F F F F 4 1 F 1 7

19 F F F F 3 8 1 E 1 A

1A F F F F 1 4 8 1 1 1 B

1B F F F F 2 3 1 C 1 C

1C F F F F 2 3 1 1 4 1 D

1D 1 2 8 1 1 1 1 E

1E 8 3 8 1 1 3 1 F

1F 8 2 4 4 1 1 2 1 1

11 8 2 5 4 8 1 1 4 1 1 1

111 8 3 2 8 1 1 4 1 1 2

112 9 4 1 1 4 1 1 3

113 F F F FF F F FF F F E 3 8 1 5

114 F F F FF F F FF F F F 1 3

Figure A-7. Contents of Records to Be Merged

Appendix A. Number Representation and Instruction-Use Examples A-57



Absolute General-Register Trace Symbolic Program

Loc INSTR GR GR1 GR2 GR3 GR4 GR5 GR6 Loc Instruction

6FFFC13 1114 Using X'1',4



115516C ' ' ' ' ' ' L1 ST 1,12(,6) Store merged-chain
' ' ' ' 6 ' address
115448516 ' ' ' ' 28 ' LH 5,6(,1) Load node index of
' ' ' ' ' input sequence of
' ' 6 ' ' ' winner
115858318 ' ' 17 ' ' ' L 3,8(,1) Load successor-record
' ' ' ' 6 address
115C1861 ' ' ' ' ' 13 LR 6,1 Save old winner ad-
' ' ' ' ' dress for next
' ' ' ' ' ' merged-chain store
11531B22 ' ' ' ' ' ' SR 2,2 Zero GR2 as initial
' ' ' ' ' ' offset
116B21A4 ' ' 4FFFE ' ' ' ' CFC 4 Compute codeword of
' ' ' ' ' ' new record based
' ' ' ' ' ' ' on last winner
1164472418A ' ' ' ' ' ' ' BC 2,L3 Exit on CC=2 (sequence
' 6 ' ' ' ' ' break
11681813 ' 17 ' ' ' ' ' LR 1,3
6 ' ' ' ' ' > Move new record entry
116A182 4FFFE ' ' ' ' ' ' LR ,2 to GRs -1
6 ' ' ' 6 '
116C12 6FFFB14 ' ' ' ' L2 UPT Update tree data
' ' ' ' structure
116E475415 ' ' ' ' ' ' ' BC 5,L1 If no codeword tie
' ' ' ' ' ' ' found, branch to
6 6 6 6 ' 6 6 next iteration

' \ Fall through on tied codewords


41941B ' 1815 \ %GR values for tie-break trace
'
11728821 ' ' 4 ' ' ' ' SRL 2,16 Shift codeword offset
' ' ' ' ' ' to initial offset
' ' ' ' ' ' position for CFC
1176B21A4 ' ' 6FFFD ' ' ' ' CFC 4 Compute loser codeword
117A5254 ' ' [CC=1] ' ' ' ' ST 2,(5,4) Store loser codeword
' ' ' ' ' ' ' in current storage
' ' 6 ' ' ' ' node
117E47C416C 6 6 branch 6 ' 6 6 BC 12,L2 Resume tree update if
taken ' old storage-node
' entry is loser
118253544 ' ST 3,4(5,4) Store loser record
' address
118647F416C ' BC 15,L2 Resume tree update
118A... 6 L3 ... Control reaches here
at end

Figure A-8. Program for Main Merge

A-58 z/Architecture Principles of Operation



General Regs
after CFC at General Regs
Location 116 Storage Trace of Node Entries after UPT
or BC 15,L2
GR
L#5 GR2 GR3 Comment 12 118 11 18 GR GR1

4FFFE186FFFA156FFF166FFFB146FFFC13

1284FFFE17No tie 4FFFE176FFF166FFFB14

2341BNo tie 41B \ 6FFFA15

338419CC = Tie 419


31 Loses 6FFFD 419
32 No tie 4196FFF16

44841ACC = 41A Tie 4FFFE18


41 Equal 817 4FFFE18
42 No tie \ 4FFFE18

542FF7F1FNo tie 2FF7F1F 41A\\ 81717

6282FFFE1DCC = 2FFFE1D Tie 41A


61 Wins 6FFFE1A419
62 No comp 419

7382FF7F1ENo tie 2FF7F1E 6FFFD1B6FFFE1A

8482FF7F11CC = Tie 2FF7F11


81 Wins 6FFAF11 2FF7F1F
82 No tie 2FF7F1F2FFFE1D6FFFD1B

9381C1CNo tie \ \ 81C1C

132114No tie 2114 2FF7F1E2FFFE1D

11282FF7F111CC = Tie 2FF7F111


111 Wins 4FFFC111 2FF7F1F
112 CC = Tie 2FF7F1F
113 Wins 4FFFD1F2FF7F1E
114 No comp 2FF7F1E

12382113CC = Tie 2113


121 Loses 6 2113
122 No tie 21134FFFD1F

1342FF6F112No tie 2FF6F112 \ \ 6FFAF11

14482114No tie 2114 2FF6F112\ 4FFFC111

15282114No tie 2114\ 2FF6F112

1642114CC = Tie 2114


161 Equal 8114 2114
162 CC = Tie 2114
163 Equal 8114 2114
164 CC = Tie 2114
165 Wins 61142113
166 No comp 2113

1738215Branch

Figure A-9 (Part 1 of 2). Abbreviated Trace of Main Merge Processing

Appendix A. Number Representation and Instruction-Use Examples A-59



Explanation:

Line shows the values in the tree after it is primed.

\ Means no swap.

\\ Means no swap if UPDATE TREE method 1 is used or no examination if
UPDATE TREE method 2 is used. Only method 2 is included in ESA/37
and ESA/39.

CC = UPDATE TREE finds a tie and sets condition code .

Loses The tied-codeword routine finds that the node loses.

Wins The tied-codeword routine finds that the node wins.

Equal The tied-codeword routine finds that the keys are equal.

Branch Branches to terminate at 118A on sequence break.

No comp No compare.

Figure A-9 (Part 2 of 2). Abbreviated Trace of Main Merge Processing

A-60 z/Architecture Principles of Operation


Appendix B. Lists of Instructions
The following figures list instructions by name, Db BFP-instruction data exception.
mnemonic, and operation code. Some models Dd Decimal-operand data exception.
may offer instructions that do not appear in the DF Decimal-overflow exception.
figures, such as those provided for assists or as DK Decimal-divide exception.
part of special or custom features. DM Depending on the model, DIAGNOSE
may generate various program
The operation code for the interpretive execution exceptions and may change the condition
facility is not included in this appendix. See the code.
publication IBM System/370 Extended Architecture E E instruction format.
Interpretive Execution, SA22-7095, for the opera- E2 Extended-translation facility 2.
tion code associated with that facility. EO HFP-exponent-overflow exception.
ES Expanded-storage facility.
The operation code 00 hex with a two-byte EU HFP-exponent-underflow exception.
instruction format is allocated for use by the EX Execute exception.
program when an indication of an invalid operation FC Designation of access registers depends
is required. It is improbable that this operation on the function code of the instruction.
code will ever be assigned to an instruction imple- FK HFP-floating-point-divide exception.
mented in the CPU. G0 Instruction execution includes the implied
use of general register 0.
Explanation of Symbols in Characteristics G1 Instruction execution includes the implied
and Page Columns: use of general register 1.
Causes serialization and checkpoint syn- G2 Instruction execution includes the implied
chronization. use of general register 2.
Causes serialization and checkpoint syn- G4 Instruction execution includes the implied
chronization when the M and R fields use of general register 4.
contain all ones and all zeros, respec- GM Instruction execution includes the implied
tively. use of multiple general registers.
Causes serialization and checkpoint syn- GS Instruction execution includes the implied
chronization when the state entry to be use of general register 1 as the
unstacked is a program-call state entry. subsystem-identification word.
$ Causes serialization. IF Fixed-point-overflow exception.
A Access exceptions for logical addresses. II Interruptible instruction.
A Access exceptions; not all access IK Fixed-point-divide exception.
exceptions may occur; see instruction IS Interruptible instruction and special-
description for details. operation exception.
AI Access exceptions for instruction I1 Access register 1 is implicitly designated
address. in the access-register mode.
AS ASN-translation-specification and special- I4 Access register 4 is implicitly designated
operation exceptions. in the access-register mode.
AT ASN-translation-specification exception. L New condition code is loaded.
B PER branch event. LS HFP-significance exception.
B B field designates an access register in MD Designation of access registers in the
the access-register mode. access-register mode is model-
B B field designates an access register in dependent.
the access-register mode. MO Monitor event.
BP B field designates an access register N Instruction is new in z/Architecture as
when PSW bits 16 and 17 have the value compared to ESA/390.
01. N3 Instruction is new in z/Architecture and
C Condition code is set. has been added to ESA/390.
Da AFP-register data exception. OP Operand exception.

Copyright IBM Corp. 1990, 2000 B-1


P Privileged-operation exception. U R field designates an access register
Q Privileged-operation exception for semi- unconditionally.
privileged instructions. U R field designates an access register
R R field designates an access register in unconditionally.
the access-register mode. UB R and R fields designate access regis-
R R field designates an access register in ters unconditionally, and B field desig-
the access-register mode. nates an access register in the
RI RI instruction format. access-register mode.
RIE RIE instruction format. WE Space-switch event.
RIL RIL instruction format. Xi IEEE invalid-operation condition.
RR RR instruction format. Xo IEEE overflow condition.
RRE RRE instruction format. Xu IEEE underflow condition.
RRF RRF instruction format. Xx IEEE inexact condition.
RS RS instruction format. Xz IEEE division-by-zero condition.
RSE RSE instruction format. Z Additional exceptions and events for
RX RX instruction format. PROGRAM CALL (which include
RXE RXE instruction format. ASX-translation, EX-translation,
RXF RXF instruction format. LX-translation, PC-translation-
S S instruction format. specification, special-operation, stack-full,
SE Special operation, stack-empty, stack- and stack-specification exceptions and
specification, and stack-type exceptions. space-switch event).
SF Special-operation, stack-full, and stack- Z Additional exceptions and events for
specification exceptions. PROGRAM TRANSFER (which include
SI SI instruction format. AFX-translation, ASX-translation, primary-
SO Special-operation exception. authority, and special-operation
SP Specification exception. exceptions and space-switch event).
SQ HFP-square-root exception. Z Additional exceptions for SET SEC-
SS SS instruction format. ONDARY ASN (which include AFX trans-
SSE SSE instruction format. lation, ASX translation, secondary
ST PER storage-alteration event. authority, and special operation).
SU PER store-using-real-address event. Z Additional exceptions and events for
SW Special-operation exception and space- PROGRAM RETURN (which include
switch event. AFX-translation, ASX-translation,
T Trace exceptions (which include trace secondary-authority, special-operation,
table, addressing, and low-address pro- stack-empty, stack-operation, stack-
tection). specification, and stack-type exceptions
U Condition code is unpredictable. and space-switch event).

B-2 z/Architecture Principles of Operation



Mne- Op Page
Name monic Characteristics Code No.

ADD (extended BFP) AXBR RRE C SPDb Xi Xo Xu Xx B34A19-18


ADD (long BFP) ADBR RRE C Db Xi Xo Xu Xx B31A19-18
ADD (long BFP) ADB RXE C A Db Xi Xo Xu Xx BED1A19-18
ADD (short BFP) AEBR RRE C Db Xi Xo Xu Xx B3A19-18
ADD (short BFP) AEB RXE C A Db Xi Xo Xu Xx BEDA19-18

ADD (32) AR RR C IF 1A 7-16


ADD (32) A RX C A IF B5A 7-16
ADD (64<32) AGFR RRE C N IF B9187-16
ADD (64<32) AGF RXE C N A IF BE3187-16
ADD (64) AGR RRE C N IF B987-16

ADD (64) AG RXE C N A IF BE387-16


ADD DECIMAL AP SS C A Dd DF STB BFA 8-5
ADD HALFWORD AH RX C A IF B4A 7-16
ADD HALFWORD IMMEDIATE (32) AHI RI C IF A7A 7-16
ADD HALFWORD IMMEDIATE (64) AGHI RI C N IF A7B 7-16

ADD LOGICAL (32) ALR RR C 1E 7-17


ADD LOGICAL (32) AL RX C A B5E 7-17
ADD LOGICAL (64<32) ALGFRRRE C N B91A7-17
ADD LOGICAL (64<32) ALGF RXE C N A BE31A7-17
ADD LOGICAL (64) ALGR RRE C N B9A7-17

ADD LOGICAL (64) ALG RXE C N A BE3A7-17


ADD LOGICAL WITH CARRY (32) ALCR RRE C N3 B9987-17
ADD LOGICAL WITH CARRY (32) ALC RXE C N3 A BE3987-17
ADD LOGICAL WITH CARRY (64) ALCGRRRE C N B9887-17
ADD LOGICAL WITH CARRY (64) ALCG RXE C N A BE3887-18

ADD NORMALIZED (extended HFP) AXR RR C SPDa EU EO LS 36 18-8


ADD NORMALIZED (long HFP) ADR RR C Da EU EO LS 2A 18-8
ADD NORMALIZED (long HFP) AD RX C A Da EU EO LS B6A 18-8
ADD NORMALIZED (short HFP) AER RR C Da EU EO LS 3A 18-8
ADD NORMALIZED (short HFP) AE RX C A Da EU EO LS B7A 18-8

ADD UNNORMALIZED (long HFP) AWR RR C Da EO LS 2E 18-9


ADD UNNORMALIZED (long HFP) AW RX C A Da EO LS B6E 18-9
ADD UNNORMALIZED (short HFP) AUR RR C Da EO LS 3E 18-9
ADD UNNORMALIZED (short HFP) AU RX C A Da EO LS B7E 18-9
AND (character) NC SS C A STB BD4 7-18

AND (immediate) NI SI C A STB 94 7-18


AND (32) NR RR C 14 7-18
AND (32) N RX C A B54 7-18
AND (64) NGR RRE C N B987-18
AND (64) NG RXE C N A BE387-18

AND IMMEDIATE (high high) NIHH RI C N A54 7-19


AND IMMEDIATE (high low) NIHL RI C N A55 7-19
AND IMMEDIATE (low high) NILH RI C N A56 7-19
AND IMMEDIATE (low low) NILL RI C N A57 7-19
BRANCH AND LINK BALR RR T B 5 7-19

Figure B-1 (Part 1 of 13). Instructions Arranged by Name

Appendix B. Lists of Instructions B-3



Mne- Op Page
Name monic Characteristics Code No.

BRANCH AND LINK BAL RX B 45 7-19


BRANCH AND SAVE BASR RR T B D 7-2
BRANCH AND SAVE BAS RX B 4D 7-2
BRANCH AND SAVE AND SET MODE BASSMRR T B C 7-21
BRANCH AND SET AUTHORITY BSA RRE Q A SO T B B25A1-6

BRANCH AND SET MODE BSM RR T B B 7-22


BRANCH AND STACK BAKR RRE A Z T B ST B241-1
BRANCH IN SUBSPACE GROUP BSG RRE A SO T B RB2581-13
BRANCH ON CONDITION BCR RR B 7 7-23
BRANCH ON CONDITION BC RX B 47 7-23

BRANCH ON COUNT (32) BCTR RR B 6 7-24


BRANCH ON COUNT (32) BCT RX B 46 7-24
BRANCH ON COUNT (64) BCTGRRRE N B B9467-24
BRANCH ON COUNT (64) BCTG RXE N B E3467-24
BRANCH ON INDEX HIGH (32) BXH RS B 86 7-24

BRANCH ON INDEX HIGH (64) BXHG RSE N B EB447-24


BRANCH ON INDEX LOW OR EQUAL (32) BXLE RS B 87 7-25
BRANCH ON INDEX LOW OR EQUAL (64) BXLEGRSE N B EB457-25
BRANCH RELATIVE AND SAVE BRAS RI B A75 7-26
BRANCH RELATIVE AND SAVE LONG BRASLRIL N3 B C5 7-26

BRANCH RELATIVE ON CONDITION BRC RI B A74 7-26


BRANCH RELATIVE ON CONDITION LONG BRCL RIL N3 B C4 7-26
BRANCH RELATIVE ON COUNT (32) BRCT RI B A76 7-27
BRANCH RELATIVE ON COUNT (64) BRCTGRI N B A77 7-27
BRANCH RELATIVE ON INDEX HIGH (32) BRXH RSI B 84 7-28

BRANCH RELATIVE ON INDEX HIGH (64) BRXHGRIE N B EC447-28


BRANCH RELATIVE ON INDEX L OR E (32)BRXLERSI B 85 7-28
BRANCH RELATIVE ON INDEX L OR E (64)BRXLGRIE N B EC457-28
CANCEL SUBCHANNEL XSCH S C P OP GS B27614-4
CHECKSUM CKSM RRE C A SP RB2417-29

CLEAR SUBCHANNEL CSCH S C P OP GS B2314-4


COMPARE (extended BFP) CXBR RRE C SPDb Xi B34919-23
COMPARE (extended HFP) CXR RRE C SPDa B36918-1
COMPARE (long BFP) CDBR RRE C Db Xi B31919-23
COMPARE (long BFP) CDB RXE C A Db Xi BED1919-23

COMPARE (long HFP) CDR RR C Da 29 18-1


COMPARE (long HFP) CD RX C A Da B69 18-1
COMPARE (short BFP) CEBR RRE C Db Xi B3919-23
COMPARE (short BFP) CEB RXE C A Db Xi BED919-23
COMPARE (short HFP) CER RR C Da 39 18-1

COMPARE (short HFP) CE RX C A Da B79 18-1


COMPARE (32) CR RR C 19 7-33
COMPARE (32) C RX C A B59 7-33
COMPARE (64<32) CGFR RRE C N B937-33
COMPARE (64<32) CGF RXE C N A BE337-33

Figure B-1 (Part 2 of 13). Instructions Arranged by Name

B-4 z/Architecture Principles of Operation



Mne- Op Page
Name monic Characteristics Code No.

COMPARE (64) CGR RRE C N B927-33


COMPARE (64) CG RXE C N A BE327-33
COMPARE AND FORM CODEWORD CFC S C A SPII GM I1 B21A7-33
COMPARE AND SIGNAL (extended BFP) KXBR RRE C SPDb Xi B34819-24
COMPARE AND SIGNAL (long BFP) KDBR RRE C Db Xi B31819-24

COMPARE AND SIGNAL (long BFP) KDB RXE C A Db Xi BED1819-24


COMPARE AND SIGNAL (short BFP) KEBR RRE C Db Xi B3819-24
COMPARE AND SIGNAL (short BFP) KEB RXE C A Db Xi BED819-24
COMPARE AND SWAP (32) CS RS C A SP $ ST BBA 7-4
COMPARE AND SWAP (64) CSG RSE C N A SP $ ST BEB37-4

COMPARE AND SWAP AND PURGE CSP RRE C P A SP $ ST RB251-18


COMPARE DECIMAL CP SS C A Dd B BF9 8-6
COMPARE DOUBLE AND SWAP (32) CDS RS C A SP $ ST BBB 7-4
COMPARE DOUBLE AND SWAP (64) CDSG RSE C N A SP $ ST BEB3E7-4
COMPARE HALFWORD CH RX C A B49 7-42

COMPARE HALFWORD IMMEDIATE (32) CHI RI C A7E 7-42


COMPARE HALFWORD IMMEDIATE (64) CGHI RI C N A7F 7-42
COMPARE LOGICAL (character) CLC SS C A B BD5 7-43
COMPARE LOGICAL (immediate) CLI SI C A B 95 7-43
COMPARE LOGICAL (32) CLR RR C 15 7-42

COMPARE LOGICAL (32) CL RX C A B55 7-43


COMPARE LOGICAL (64<32) CLGFRRRE C N B9317-43
COMPARE LOGICAL (64<32) CLGF RXE C N A BE3317-43
COMPARE LOGICAL (64) CLGR RRE C N B9217-43
COMPARE LOGICAL (64) CLG RXE C N A BE3217-43

COMPARE LOGICAL C. UNDER MASK (high)CLMH RSE C N A BEB27-43


COMPARE LOGICAL C. UNDER MASK (low) CLM RS C A BBD 7-43
COMPARE LOGICAL LONG CLCL RR C A SPII R RF 7-44
COMPARE LOGICAL LONG EXTENDED CLCLERS C A SP R RA9 7-46
COMPARE LOGICAL LONG UNICODE CLCLURSE C E2 A SP R REB8F7-5

COMPARE LOGICAL STRING CLST RRE C A SP G R RB25D7-53


COMPARE UNTIL SUBSTRING EQUAL CUSE RRE C A SPII GM R RB2577-54
COMPRESSION CALL CMPSCRRE C A SPII D GM STR RB2637-58
CONVERT BFP TO HFP (long) THDR RRE C Da B3599-1
CONVERT BFP TO HFP (short to long) THDERRRE C Da B3589-1

CONVERT FROM FIXED (32 to ext. BFP) CXFBRRRE SPDb B39619-26


CONVERT FROM FIXED (32 to ext. HFP) CXFR RRE SPDa B3B618-11
CONVERT FROM FIXED (32 to long BFP) CDFBRRRE Db B39519-26
CONVERT FROM FIXED (32 to long HFP) CDFR RRE Da B3B518-11
CONVERT FROM FIXED (32 to short BFP)CEFBRRRE Db Xx B39419-26

CONVERT FROM FIXED (32 to short HFP)CEFR RRE Da B3B418-11


CONVERT FROM FIXED (64 to ext. BFP) CXGBRRRE N SPDb B3A619-26
CONVERT FROM FIXED (64 to ext. HFP) CXGR RRE N SPDa B3C618-11
CONVERT FROM FIXED (64 to long BFP) CDGBRRRE N Db Xx B3A519-26
CONVERT FROM FIXED (64 to long HFP) CDGR RRE N Da B3C518-11

Figure B-1 (Part 3 of 13). Instructions Arranged by Name

Appendix B. Lists of Instructions B-5



Mne- Op Page
Name monic Characteristics Code No.

CONVERT FROM FIXED (64 to short BFP)CEGBRRRE N Db Xx B3A419-26


CONVERT FROM FIXED (64 to short HFP)CEGR RRE N Da B3C418-11
CONVERT HFP TO BFP (long to short) TBEDRRRF C SPDa B359-11
CONVERT HFP TO BFP (long) TBDR RRF C SPDa B3519-11
CONVERT TO BINARY (32) CVB RX A Dd IK B4F 7-7

CONVERT TO BINARY (64) CVBG RXE N A Dd IK BE3E7-7


CONVERT TO DECIMAL (32) CVD RX A ST B4E 7-7
CONVERT TO DECIMAL (64) CVDG RXE N A ST BE32E7-7
CONVERT TO FIXED (ext. BFP to 32) CFXBRRRF C SPDb Xi Xx B39A19-26
CONVERT TO FIXED (ext. BFP to 64) CGXBRRRF C N SPDb Xi Xx B3AA19-26

CONVERT TO FIXED (ext. HFP to 32) CFXR RRF C SPDa B3BA18-11


CONVERT TO FIXED (ext. HFP to 64) CGXR RRF C N SPDa B3CA18-11
CONVERT TO FIXED (long BFP to 32) CFDBRRRF C SPDb Xi Xx B39919-26
CONVERT TO FIXED (long BFP to 64) CGDBRRRF C N SPDb Xi Xx B3A919-26
CONVERT TO FIXED (long HFP to 32) CFDR RRF C SPDa B3B918-11

CONVERT TO FIXED (long HFP to 64) CGDR RRF C N SPDa B3C918-11


CONVERT TO FIXED (short BFP to 32) CFEBRRRF C SPDb Xi Xx B39819-26
CONVERT TO FIXED (short BFP to 64) CGEBRRRF C N SPDb Xi Xx B3A819-26
CONVERT TO FIXED (short HFP to 32) CFER RRF C SPDa B3B818-11
CONVERT TO FIXED (short HFP to 64) CGER RRF C N SPDa B3C818-11

CONVERT UNICODE TO UTF-8 CUUTFRRE C A SP STR RB2A67-71


CONVERT UTF-8 TO UNICODE CUTFURRE C A SP STR RB2A77-74
COPY ACCESS CPYA RRE U UB24D7-77
DIAGNOSE DM P DM MD83 1-2
DIVIDE (extended BFP) DXBR RRE SPDb Xi Xz Xo Xu Xx B34D19-29

DIVIDE (extended HFP) DXR RRE SPDa EU EO FK B22D18-12


DIVIDE (long BFP) DDBR RRE Db Xi Xz Xo Xu Xx B31D19-29
DIVIDE (long BFP) DDB RXE A Db Xi Xz Xo Xu Xx BED1D19-29
DIVIDE (long HFP) DDR RR Da EU EO FK 2D 18-12
DIVIDE (long HFP) DD RX A Da EU EO FK B6D 18-12

DIVIDE (short BFP) DEBR RRE Db Xi Xz Xo Xu Xx B3D19-29


DIVIDE (short BFP) DEB RXE A Db Xi Xz Xo Xu Xx BEDD19-29
DIVIDE (short HFP) DER RR Da EU EO FK 3D 18-12
DIVIDE (short HFP) DE RX A Da EU EO FK B7D 18-12
DIVIDE (32<64) DR RR SP IK 1D 7-77

DIVIDE (32<64) D RX A SP IK B5D 7-77


DIVIDE DECIMAL DP SS A SPDd DK STB BFD 8-6
DIVIDE LOGICAL (32<64) DLR RRE N3 SP IK B9977-77
DIVIDE LOGICAL (32<64) DL RXE N3 A SP IK BE3977-78
DIVIDE LOGICAL (64<128) DLGR RRE N SP IK B9877-77

DIVIDE LOGICAL (64<128) DLG RXE N A SP IK BE3877-78


DIVIDE SINGLE (64<32) DSGFRRRE N SP IK B91D7-78
DIVIDE SINGLE (64<32) DSGF RXE N A SP IK BE31D7-78
DIVIDE SINGLE (64) DSGR RRE N SP IK B9D7-78
DIVIDE SINGLE (64) DSG RXE N A SP IK BE3D7-78

Figure B-1 (Part 4 of 13). Instructions Arranged by Name

B-6 z/Architecture Principles of Operation



Mne- Op Page
Name monic Characteristics Code No.

DIVIDE TO INTEGER (long BFP) DIDBRRRF C SPDb Xi Xu Xx B35B19-29


DIVIDE TO INTEGER (short BFP) DIEBRRRF C SPDb Xi Xu Xx B35319-29
EDIT ED SS C A Dd STB BDE 8-7
EDIT AND MARK EDMK SS C A Dd G1 STB BDF 8-9
EXCLUSIVE OR (character) XC SS C A STB BD7 7-79

EXCLUSIVE OR (immediate) XI SI C A STB 97 7-79


EXCLUSIVE OR (32) XR RR C 17 7-79
EXCLUSIVE OR (32) X RX C A B57 7-79
EXCLUSIVE OR (64) XGR RRE C N B9827-79
EXCLUSIVE OR (64) XG RXE C N A BE3827-79

EXECUTE EX RX AI SP EX 44 7-8
EXTRACT ACCESS EAR RRE UB24F7-81
EXTRACT AND SET EXTENDED AUTHORITY ESEA RRE N P B99D1-2
EXTRACT FPC EFPC RRE Db B38C19-34
EXTRACT PRIMARY ASN EPAR RRE Q SO B2261-2

EXTRACT PSW EPSW RRE N3 B98D7-81


EXTRACT SECONDARY ASN ESAR RRE Q SO B2271-21
EXTRACT STACKED REGISTERS (32) EREG RRE A SE U UB2491-21
EXTRACT STACKED REGISTERS (64) EREGGRRE N A SE U UB9E1-21
EXTRACT STACKED STATE ESTA RRE C A SPSE B24A1-23

HALT SUBCHANNEL HSCH S C P OP GS B23114-5


HALVE (long HFP) HDR RR Da EU 24 18-13
HALVE (short HFP) HER RR Da EU 34 18-13
INSERT ADDRESS SPACE CONTROL IAC RRE C Q SO B2241-26
INSERT CHARACTER IC RX A B43 7-81

INSERT CHARACTERS UNDER MASK (high) ICMH RSE C N A BEB87-81


INSERT CHARACTERS UNDER MASK (low) ICM RS C A BBF 7-81
INSERT IMMEDIATE (high high) IIHH RI N A5 7-82
INSERT IMMEDIATE (high low) IIHL RI N A51 7-82
INSERT IMMEDIATE (low high) IILH RI N A52 7-82

INSERT IMMEDIATE (low low) IILL RI N A53 7-82


INSERT PROGRAM MASK IPM RRE B2227-83
INSERT PSW KEY IPK S Q G2 B2B1-27
INSERT STORAGE KEY EXTENDED ISKE RRE P A B2291-27
INSERT VIRTUAL STORAGE KEY IVSK RRE Q A SO RB2231-28

INVALIDATE PAGE TABLE ENTRY IPTE RRE P A $ B2211-29


LOAD (extended) LXR RRE SPDa B3659-12
LOAD (long) LDR RR Da 28 9-12
LOAD (long) LD RX A Da B68 9-12
LOAD (short) LER RR Da 38 9-12

LOAD (short) LE RX A Da B78 9-12


LOAD (32) LR RR 18 7-83
LOAD (32) L RX A B58 7-83
LOAD (64<32) LGFR RRE N B9147-83
LOAD (64<32) LGF RXE N A BE3147-83

Figure B-1 (Part 5 of 13). Instructions Arranged by Name

Appendix B. Lists of Instructions B-7



Mne- Op Page
Name monic Characteristics Code No.

LOAD (64) LGR RRE N B947-83


LOAD (64) LG RXE N A BE347-83
LOAD ACCESS MULTIPLE LAM RS A SP UB9A 7-84
LOAD ADDRESS LA RX 41 7-84
LOAD ADDRESS EXTENDED LAE RX U BP51 7-84

LOAD ADDRESS RELATIVE LONG LARL RIL N3 C 7-85


LOAD ADDRESS SPACE PARAMETERS LASP SSE C P A SPSO B E51-3
LOAD AND TEST (extended BFP) LTXBRRRE C SPDb Xi B34219-35
LOAD AND TEST (extended HFP) LTXR RRE C SPDa B36218-14
LOAD AND TEST (long BFP) LTDBRRRE C Db Xi B31219-35

LOAD AND TEST (long HFP) LTDR RR C Da 22 18-14


LOAD AND TEST (short BFP) LTEBRRRE C Db Xi B3219-35
LOAD AND TEST (short HFP) LTER RR C Da 32 18-14
LOAD AND TEST (32) LTR RR C 12 7-86
LOAD AND TEST (64<32) LTGFRRRE C N B9127-86

LOAD AND TEST (64) LTGR RRE C N B927-86


LOAD COMPLEMENT (extended BFP) LCXBRRRE C SPDb B34319-35
LOAD COMPLEMENT (extended HFP) LCXR RRE C SPDa B36318-14
LOAD COMPLEMENT (long BFP) LCDBRRRE C Db B31319-35
LOAD COMPLEMENT (long HFP) LCDR RR C Da 23 18-14

LOAD COMPLEMENT (short BFP) LCEBRRRE C Db B3319-35


LOAD COMPLEMENT (short HFP) LCER RR C Da 33 18-14
LOAD COMPLEMENT (32) LCR RR C IF 13 7-86
LOAD COMPLEMENT (64<32) LCGFRRRE C N IF B9137-86
LOAD COMPLEMENT (64) LCGR RRE C N IF B937-86

LOAD CONTROL (32) LCTL RS P A SP BB7 1-39


LOAD CONTROL (64) LCTLGRSE N P A SP BEB2F1-39
LOAD FP INTEGER (extended BFP) FIXBRRRF SPDb Xi Xx B34719-36
LOAD FP INTEGER (extended HFP) FIXR RRE SPDa B36718-15
LOAD FP INTEGER (long BFP) FIDBRRRF SPDb Xi Xx B35F19-36

LOAD FP INTEGER (long HFP) FIDR RRE Da B37F18-15


LOAD FP INTEGER (short BFP) FIEBRRRF SPDb Xi Xx B35719-36
LOAD FP INTEGER (short HFP) FIER RRE Da B37718-15
LOAD FPC LFPC S A SPDb BB29D19-37
LOAD HALFWORD (32) LH RX A B48 7-87

LOAD HALFWORD (64) LGH RXE N A BE3157-87


LOAD HALFWORD IMMEDIATE (32) LHI RI A78 7-87
LOAD HALFWORD IMMEDIATE (64) LGHI RI N A79 7-87
LOAD LENGTHENED (long to ext. BFP) LXDBRRRE SPDb Xi B3519-38
LOAD LENGTHENED (long to ext. BFP) LXDB RXE A SPDb Xi BED519-38

LOAD LENGTHENED (long to ext. HFP) LXDR RRE SPDa B32518-15


LOAD LENGTHENED (long to ext. HFP) LXD RXE A SPDa BED2518-15
LOAD LENGTHENED (short to ext. BFP) LXEBRRRE SPDb Xi B3619-38
LOAD LENGTHENED (short to ext. BFP) LXEB RXE A SPDb Xi BED619-38
LOAD LENGTHENED (short to ext. HFP) LXER RRE SPDa B32618-15

Figure B-1 (Part 6 of 13). Instructions Arranged by Name

B-8 z/Architecture Principles of Operation



Mne- Op Page
Name monic Characteristics Code No.

LOAD LENGTHENED (short to ext. HFP) LXE RXE A SPDa BED2618-15


LOAD LENGTHENED (short to long BFP) LDEBRRRE Db Xi B3419-38
LOAD LENGTHENED (short to long BFP) LDEB RXE A Db Xi BED419-38
LOAD LENGTHENED (short to long HFP) LDER RRE Da B32418-15
LOAD LENGTHENED (short to long HFP) LDE RXE A Da BED2418-15

LOAD LOGICAL (64<32) LLGFRRRE N B9167-87


LOAD LOGICAL (64<32) LLGF RXE N A BE3167-87
LOAD LOGICAL CHARACTER LLGC RXE N A BE397-87
LOAD LOGICAL HALFWORD LLGH RXE N A BE3917-88
LOAD LOGICAL IMMEDIATE (high high) LLIHHRI N A5C 7-88

LOAD LOGICAL IMMEDIATE (high low) LLIHLRI N A5D 7-88


LOAD LOGICAL IMMEDIATE (low high) LLILHRI N A5E 7-88
LOAD LOGICAL IMMEDIATE (low low) LLILLRI N A5F 7-88
LOAD LOGICAL THIRTY ONE BITS LLGTRRRE N B9177-88
LOAD LOGICAL THIRTY ONE BITS LLGT RXE N A BE3177-88

LOAD MULTIPLE (32) LM RS A B98 7-88


LOAD MULTIPLE (64) LMG RSE N A BEB47-89
LOAD MULTIPLE DISJOINT LMD SS N A B BEF 7-89
LOAD MULTIPLE HIGH LMH RSE N A BEB967-89
LOAD NEGATIVE (extended BFP) LNXBRRRE C SPDb B34119-38

LOAD NEGATIVE (extended HFP) LNXR RRE C SPDa B36118-16


LOAD NEGATIVE (long BFP) LNDBRRRE C Db B31119-38
LOAD NEGATIVE (long HFP) LNDR RR C Da 21 18-16
LOAD NEGATIVE (short BFP) LNEBRRRE C Db B3119-38
LOAD NEGATIVE (short HFP) LNER RR C Da 31 18-16

LOAD NEGATIVE (32) LNR RR C 11 7-9


LOAD NEGATIVE (64<32) LNGFRRRE C N B9117-9
LOAD NEGATIVE (64) LNGR RRE C N B917-9
LOAD PAIR FROM QUADWORD LPQ RXE N A SP BE38F7-9
LOAD POSITIVE (extended BFP) LPXBRRRE C SPDb B3419-39

LOAD POSITIVE (extended HFP) LPXR RRE C SPDa B3618-16


LOAD POSITIVE (long BFP) LPDBRRRE C Db B3119-39
LOAD POSITIVE (long HFP) LPDR RR C Da 2 18-16
LOAD POSITIVE (short BFP) LPEBRRRE C Db B319-39
LOAD POSITIVE (short HFP) LPER RR C Da 3 18-16

LOAD POSITIVE (32) LPR RR C IF 1 7-9


LOAD POSITIVE (64<32) LPGFRRRE C N IF B917-91
LOAD POSITIVE (64) LPGR RRE C N IF B97-91
LOAD PSW LPSW S L P A SP B82 1-39
LOAD PSW EXTENDED LPSWES L N P A SP BB2B21-4

LOAD REAL ADDRESS (32) LRA RX C P A SO BPB1 1-41


LOAD REAL ADDRESS (64) LRAG RXE C N P A BPE331-41
LOAD REVERSED (16) LRVH RXE N3 A BE31F7-91
LOAD REVERSED (32) LRVR RRE N3 B91F7-91
LOAD REVERSED (32) LRV RXE N3 A BE31E7-91

Figure B-1 (Part 7 of 13). Instructions Arranged by Name

Appendix B. Lists of Instructions B-9



Mne- Op Page
Name monic Characteristics Code No.

LOAD REVERSED (64) LRVGRRRE N B9F7-91


LOAD REVERSED (64) LRVG RXE N A BE3F7-91
LOAD ROUNDED (extended to long BFP) LDXBRRRE SPDb Xi Xo Xu Xx B34519-39
LOAD ROUNDED (extended to long HFP) LDXR RR SPDa EO 25 18-17
LOAD ROUNDED (extended to long HFP) LRDR RR Da EO 25 18-17

LOAD ROUNDED (extended to short BFP)LEXBRRRE SPDb Xi Xo Xu Xx B34619-39


LOAD ROUNDED (extended to short HFP)LEXR RRE SPDa EO B36618-17
LOAD ROUNDED (long to short BFP) LEDBRRRE Db Xi Xo Xu Xx B34419-39
LOAD ROUNDED (long to short HFP) LEDR RR Da EO 35 18-17
LOAD ROUNDED (long to short HFP) LRER RR Da EO 35 18-17

LOAD USING REAL ADDRESS (32) LURA RRE P A SP B24B1-46


LOAD USING REAL ADDRESS (64) LURAGRRE N P A SP B951-46
LOAD ZERO (extended) LZXR RRE SPDa B3769-13
LOAD ZERO (long) LZDR RRE Da B3759-13
LOAD ZERO (short) LZER RRE Da B3749-13

MODIFY STACKED STATE MSTA RRE A SPSE ST B2471-46


MODIFY SUBCHANNEL MSCH S C P A SPOP GS BB23214-7
MONITOR CALL MC SI SP MO AF 7-92
MOVE (character) MVC SS A STB BD2 7-93
MOVE (immediate) MVI SI A STB 92 7-93

MOVE INVERSE MVCINSS A STB BE8 7-93


MOVE LONG MVCL RR C A SPII STR RE 7-94
MOVE LONG EXTENDED MVCLERS C A SP STR RA8 7-97
MOVE LONG UNICODE MVCLURSE C E2 A SP STR REB8E7-11
MOVE NUMERICS MVN SS A STB BD1 7-14

MOVE PAGE MVPG RRE C Q A SP G STR RB2541-48


MOVE STRING MVST RRE C A SP G STR RB2557-14
MOVE TO PRIMARY MVCP SS C Q A SO ST DA 1-5
MOVE TO SECONDARY MVCS SS C Q A SO ST DB 1-5
MOVE WITH DESTINATION KEY MVCDKSSE Q A GM STB BE5F1-52

MOVE WITH KEY MVCK SS C Q A STB BD9 1-52


MOVE WITH OFFSET MVO SS A STB BF1 7-16
MOVE WITH SOURCE KEY MVCSKSSE Q A GM STB BE5E1-54
MOVE ZONES MVZ SS A STB BD3 7-16
MULTIPLY (extended BFP) MXBR RRE SPDb Xi Xo Xu Xx B34C19-4

MULTIPLY (extended HFP) MXR RR SPDa EU EO 26 18-18


MULTIPLY (long to extended BFP) MXDBRRRE SPDb Xi B3719-4
MULTIPLY (long to extended BFP) MXDB RXE A SPDb Xi BED719-4
MULTIPLY (long to extended HFP) MXDR RR SPDa EU EO 27 18-18
MULTIPLY (long to extended HFP) MXD RX A SPDa EU EO B67 18-18

MULTIPLY (long BFP) MDBR RRE Db Xi Xo Xu Xx B31C19-4


MULTIPLY (long BFP) MDB RXE A Db Xi Xo Xu Xx BED1C19-4
MULTIPLY (long HFP) MDR RR Da EU EO 2C 18-18
MULTIPLY (long HFP) MD RX A Da EU EO B6C 18-18
MULTIPLY (short to long BFP) MDEBRRRE Db Xi B3C19-4

Figure B-1 (Part 8 of 13). Instructions Arranged by Name

B-10 z/Architecture Principles of Operation



Mne- Op Page
Name monic Characteristics Code No.

MULTIPLY (short to long BFP) MDEB RXE A Db Xi BEDC19-4


MULTIPLY (short to long HFP) MDER RR Da EU EO 3C 18-18
MULTIPLY (short to long HFP) MER RR Da EU EO 3C 18-18
MULTIPLY (short to long HFP) MDE RX A Da EU EO B7C 18-18
MULTIPLY (short to long HFP) ME RX A Da EU EO B7C 18-18

MULTIPLY (short BFP) MEEBRRRE Db Xi Xo Xu Xx B31719-4


MULTIPLY (short BFP) MEEB RXE A Db Xi Xo Xu Xx BED1719-4
MULTIPLY (short HFP) MEER RRE Da EU EO B33718-18
MULTIPLY (short HFP) MEE RXE A Da EU EO BED3718-18
MULTIPLY (64<32) MR RR SP 1C 7-17

MULTIPLY (64<32) M RX A SP B5C 7-17


MULTIPLY AND ADD (long BFP) MADBRRRF Db Xi Xo Xu Xx B31E19-42
MULTIPLY AND ADD (long BFP) MADB RXF A Db Xi Xo Xu Xx BED1E19-42
MULTIPLY AND ADD (short BFP) MAEBRRRF Db Xi Xo Xu Xx B3E19-42
MULTIPLY AND ADD (short BFP) MAEB RXF A Db Xi Xo Xu Xx BEDE19-42

MULTIPLY AND SUBTRACT (long BFP) MSDBRRRF Db Xi Xo Xu Xx B31F19-42


MULTIPLY AND SUBTRACT (long BFP) MSDB RXF A Db Xi Xo Xu Xx BED1F19-42
MULTIPLY AND SUBTRACT (short BFP) MSEBRRRF Db Xi Xo Xu Xx B3F19-42
MULTIPLY AND SUBTRACT (short BFP) MSEB RXF A Db Xi Xo Xu Xx BEDF19-42
MULTIPLY DECIMAL MP SS A SPDd STB BFC 8-11

MULTIPLY HALFWORD (32) MH RX A B4C 7-17


MULTIPLY HALFWORD IMMEDIATE (32) MHI RI A7C 7-18
MULTIPLY HALFWORD IMMEDIATE (64) MGHI RI N A7D 7-18
MULTIPLY LOGICAL (128<64) MLGR RRE N SP B9867-18
MULTIPLY LOGICAL (128<64) MLG RXE N A SP BE3867-18

MULTIPLY LOGICAL (64<32) MLR RRE N3 SP B9967-18


MULTIPLY LOGICAL (64<32) ML RXE N3 A SP BE3967-18
MULTIPLY SINGLE (32) MSR RRE B2527-19
MULTIPLY SINGLE (32) MS RX A B71 7-19
MULTIPLY SINGLE (64<32) MSGFRRRE N B91C7-19

MULTIPLY SINGLE (64<32) MSGF RXE N A BE31C7-19


MULTIPLY SINGLE (64) MSGR RRE N B9C7-19
MULTIPLY SINGLE (64) MSG RXE N A BE3C7-19
OR (character) OC SS C A STB BD6 7-11
OR (immediate) OI SI C A STB 96 7-11

OR (32) OR RR C 16 7-11
OR (32) O RX C A B56 7-11
OR (64) OGR RRE C N B9817-11
OR (64) OG RXE C N A BE3817-11
OR IMMEDIATE (high high) OIHH RI C N A58 7-111

OR IMMEDIATE (high low) OIHL RI C N A59 7-111


OR IMMEDIATE (low high) OILH RI C N A5A 7-111
OR IMMEDIATE (low low) OILL RI C N A5B 7-111
PACK PACK SS A STB BF2 7-111
PACK ASCII PKA SS E2 A SP STB BE9 7-112

Figure B-1 (Part 9 of 13). Instructions Arranged by Name

Appendix B. Lists of Instructions B-11



Mne- Op Page
Name monic Characteristics Code No.

PACK UNICODE PKU SS E2 A SP STB BE1 7-113


PAGE IN PGIN RRE C ESP A B22E1-55
PAGE OUT PGOUTRRE C ESP A B22F1-56
PERFORM LOCKED OPERATION PLO SS C A SP $ GM ST FCEE 7-114
PROGRAM CALL PC S Q A Z T GM B ST B2181-57

PROGRAM RETURN PR E L A SPZ T B ST 111-7


PROGRAM TRANSFER PT RRE Q A SPZ T B B2281-74
PURGE ALB PALB RRE P $ B2481-8
PURGE TLB PTLB S P $ B2D1-8
RESET CHANNEL PATH RCHP S C P OP G1 B23B14-8

RESET REFERENCE BIT EXTENDED RRBE RRE C P A B22A1-8


RESUME PROGRAM RP S L Q A SPWE T B BB2771-81
RESUME SUBCHANNEL RSCH S C P OP GS B23814-9
ROTATE LEFT SINGLE LOGICAL (32) RLL RSE N3 EB1D7-129
ROTATE LEFT SINGLE LOGICAL (64) RLLG RSE N EB1C7-129

SEARCH STRING SRST RRE C A SP G RB25E7-13


SET ACCESS SAR RRE U B24E7-131
SET ADDRESS LIMIT SAL S P OP G1 B23714-11
SET ADDRESS SPACE CONTROL SAC S Q SPSW B2191-83
SET ADDRESS SPACE CONTROL FAST SACF S Q SPSW B2791-83

SET ADDRESSING MODE (24) SAM24E N3 SP T 1C7-131


SET ADDRESSING MODE (31) SAM31E N3 SP T 1D7-131
SET ADDRESSING MODE (64) SAM64E N T 1E7-131
SET CHANNEL MONITOR SCHM S P OP GM B23C14-12
SET CLOCK SCK S C P A SP BB241-85

SET CLOCK COMPARATOR SCKC S P A SP BB261-86


SET CLOCK PROGRAMMABLE FIELD SCKPFE P SP G 171-86
SET CPU TIMER SPT S P A SP BB281-86
SET FPC SFPC RRE SPDb B38419-44
SET PREFIX SPX S P A SP $ BB211-87

SET PROGRAM MASK SPM RR L 4 7-132


SET PSW KEY FROM ADDRESS SPKA S Q B2A1-87
SET ROUNDING MODE SRNM S Db B29919-44
SET SECONDARY ASN SSAR RRE A Z T B2251-88
SET STORAGE KEY EXTENDED SSKE RRE P A B22B1-91

SET SYSTEM MASK SSM S P A SPSO B8 1-91


SHIFT AND ROUND DECIMAL SRP SS C A Dd DF STB F 8-11
SHIFT LEFT DOUBLE SLDA RS C SP IF 8F 7-132
SHIFT LEFT DOUBLE LOGICAL SLDL RS SP 8D 7-133
SHIFT LEFT SINGLE (32) SLA RS C IF 8B 7-134

SHIFT LEFT SINGLE (64) SLAG RSE C N IF EBB7-134


SHIFT LEFT SINGLE LOGICAL (32) SLL RS 89 7-134
SHIFT LEFT SINGLE LOGICAL (64) SLLG RSE N EBD7-134
SHIFT RIGHT DOUBLE SRDA RS C SP 8E 7-135
SHIFT RIGHT DOUBLE LOGICAL SRDL RS SP 8C 7-135

Figure B-1 (Part 10 of 13). Instructions Arranged by Name

B-12 z/Architecture Principles of Operation



Mne- Op Page
Name monic Characteristics Code No.

SHIFT RIGHT SINGLE (32) SRA RS C 8A 7-136


SHIFT RIGHT SINGLE (64) SRAG RSE C N EBA7-136
SHIFT RIGHT SINGLE LOGICAL (32) SRL RS 88 7-136
SHIFT RIGHT SINGLE LOGICAL (64) SRLG RSE N EBC7-136
SIGNAL PROCESSOR SIGP RS C P $ AE 1-91

SQUARE ROOT (extended BFP) SQXBRRRE SPDb Xi Xx B31619-45


SQUARE ROOT (extended HFP) SQXR RRE SPDa SQ B33618-19
SQUARE ROOT (long BFP) SQDBRRRE Db Xi Xx B31519-45
SQUARE ROOT (long BFP) SQDB RXE A Db Xi Xx BED1519-45
SQUARE ROOT (long HFP) SQDR RRE Da SQ B24418-19

SQUARE ROOT (long HFP) SQD RXE A Da SQ BED3518-19


SQUARE ROOT (short BFP) SQEBRRRE Db Xi Xx B31419-45
SQUARE ROOT (short BFP) SQEB RXE A Db Xi Xx BED1419-45
SQUARE ROOT (short HFP) SQER RRE Da SQ B24518-19
SQUARE ROOT (short HFP) SQE RXE A Da SQ BED3418-19

START SUBCHANNEL SSCH S C P A SPOP GS BB23314-14


STORE (long) STD RX A Da ST B6 9-13
STORE (short) STE RX A Da ST B7 9-13
STORE (32) ST RX A ST B5 7-137
STORE (64) STG RXE N A ST BE3247-137

STORE ACCESS MULTIPLE STAM RS A SP ST UB9B 7-137


STORE CHANNEL PATH STATUS STCPSS P A SP ST BB23A14-15
STORE CHANNEL REPORT WORD STCRWS C P A SP ST BB23914-16
STORE CHARACTER STC RX A ST B42 7-137
STORE CHARACTERS UNDER MASK (high) STCMHRSE N A ST BEB2C7-138

STORE CHARACTERS UNDER MASK (low) STCM RS A ST BBE 7-138


STORE CLOCK STCK S C A $ ST BB257-138
STORE CLOCK COMPARATOR STCKCS P A SP ST BB271-93
STORE CLOCK EXTENDED STCKES C A $ ST BB2787-139
STORE CONTROL (32) STCTLRS P A SP ST BB6 1-93

STORE CONTROL (64) STCTGRSE N P A SP ST BEB251-93


STORE CPU ADDRESS STAP S P A SP ST BB2121-94
STORE CPU ID STIDPS P A SP ST BB221-94
STORE CPU TIMER STPT S P A SP ST BB291-95
STORE FACILITY LIST STFL S N3P B2B11-95

STORE FPC STFPCS A Db ST BB29C19-45


STORE HALFWORD STH RX A ST B4 7-141
STORE MULTIPLE (32) STM RS A ST B9 7-141
STORE MULTIPLE (64) STMG RSE N A ST BEB247-141
STORE MULTIPLE HIGH STMH RSE N A ST BEB267-142

STORE PAIR TO QUADWORD STPQ RXE N A SP ST BE38E7-142


STORE PREFIX STPX S P A SP ST BB2111-95
STORE REAL ADDRESS STRAGSSE N P A B BPE521-96
STORE REVERSED (16) STRVHRXE N3 A ST BE33F7-142
STORE REVERSED (32) STRV RXE N3 A ST BE33E7-142

Figure B-1 (Part 11 of 13). Instructions Arranged by Name

Appendix B. Lists of Instructions B-13



Mne- Op Page
Name monic Characteristics Code No.

STORE REVERSED (64) STRVGRXE N A ST BE32F7-142


STORE SUBCHANNEL STSCHS C P A SPOP GS ST BB23414-17
STORE SYSTEM INFORMATION STSI S C P A SP GM ST BB27D1-97
STORE THEN AND SYSTEM MASK STNSMSI P A STB AC 1-17
STORE THEN OR SYSTEM MASK STOSMSI P A SP STB AD 1-17

STORE USING REAL ADDRESS (32) STURARRE P A SP SU B2461-17


STORE USING REAL ADDRESS (64) STURGRRE N P A SP SU B9251-17
SUBTRACT (extended BFP) SXBR RRE C SPDb Xi Xo Xu Xx B34B19-46
SUBTRACT (long BFP) SDBR RRE C Db Xi Xo Xu Xx B31B19-46
SUBTRACT (long BFP) SDB RXE C A Db Xi Xo Xu Xx BED1B19-46

SUBTRACT (short BFP) SEBR RRE C Db Xi Xo Xu Xx B3B19-46


SUBTRACT (short BFP) SEB RXE C A Db Xi Xo Xu Xx BEDB19-46
SUBTRACT (32) SR RR C IF 1B 7-143
SUBTRACT (32) S RX C A IF B5B 7-143
SUBTRACT (64<32) SGFR RRE C N IF B9197-143

SUBTRACT (64<32) SGF RXE C N A IF BE3197-143


SUBTRACT (64) SGR RRE C N IF B997-143
SUBTRACT (64) SG RXE C N A IF BE397-143
SUBTRACT DECIMAL SP SS C A Dd DF STB BFB 8-12
SUBTRACT HALFWORD SH RX C A IF B4B 7-144

SUBTRACT LOGICAL (32) SLR RR C 1F 7-144


SUBTRACT LOGICAL (32) SL RX C A B5F 7-144
SUBTRACT LOGICAL (64<32) SLGFRRRE C N B91B7-144
SUBTRACT LOGICAL (64<32) SLGF RXE C N A BE31B7-144
SUBTRACT LOGICAL (64) SLGR RRE C N B9B7-144

SUBTRACT LOGICAL (64) SLG RXE C N A BE3B7-144


SUBTRACT LOGICAL WITH BORROW (32) SLBR RRE C N3 B9997-145
SUBTRACT LOGICAL WITH BORROW (32) SLB RXE C N3 A BE3997-145
SUBTRACT LOGICAL WITH BORROW (64) SLBGRRRE C N B9897-145
SUBTRACT LOGICAL WITH BORROW (64) SLBG RXE C N A BE3897-145

SUBTRACT NORMALIZED (extended HFP) SXR RR C SPDa EU EO LS 37 18-21


SUBTRACT NORMALIZED (long HFP) SDR RR C Da EU EO LS 2B 18-21
SUBTRACT NORMALIZED (long HFP) SD RX C A Da EU EO LS B6B 18-21
SUBTRACT NORMALIZED (short HFP) SER RR C Da EU EO LS 3B 18-21
SUBTRACT NORMALIZED (short HFP) SE RX C A Da EU EO LS B7B 18-21

SUBTRACT UNNORMALIZED (long HFP) SWR RR C Da EO LS 2F 18-21


SUBTRACT UNNORMALIZED (long HFP) SW RX C A Da EO LS B6F 18-21
SUBTRACT UNNORMALIZED (short HFP) SUR RR C Da EO LS 3F 18-21
SUBTRACT UNNORMALIZED (short HFP) SU RX C A Da EO LS B7F 18-21
SUPERVISOR CALL SVC RR A 7-146

TEST ACCESS TAR RRE C A U B24C1-18


TEST ADDRESSING MODE TAM E C N3 1B7-146
TEST AND SET TS S C A $ ST B93 7-146
TEST BLOCK TB RRE C P A II $ G B22C1-11
TEST DATA CLASS (extended BFP) TCXB RXE C SPDb ED1219-46

Figure B-1 (Part 12 of 13). Instructions Arranged by Name

B-14 z/Architecture Principles of Operation



Mne- Op Page
Name monic Characteristics Code No.

TEST DATA CLASS (long BFP) TCDB RXE C Db ED1119-46


TEST DATA CLASS (short BFP) TCEB RXE C Db ED119-46
TEST DECIMAL TP RSL C E2 A B EBC8-13
TEST PENDING INTERRUPTION TPI S C P A SP ST BB23614-17
TEST PROTECTION TPROTSSE C P A B E511-113

TEST SUBCHANNEL TSCH S C P A SPOP GS ST BB23514-19


TEST UNDER MASK TM SI C A B 91 7-147
TEST UNDER MASK (high high) TMHH RI C N A72 7-147
TEST UNDER MASK (high low) TMHL RI C N A73 7-147
TEST UNDER MASK (low high) TMLH RI C A7 7-147

TEST UNDER MASK (low low) TMLL RI C A71 7-147


TEST UNDER MASK HIGH TMH RI C A7 7-147
TEST UNDER MASK LOW TML RI C A71 7-147
TRACE (32) TRACERS P A SP T B99 1-115
TRACE (64) TRACGRSE N P A SP T BEBF1-115

TRANSLATE TR SS A STB BDC 7-148


TRANSLATE AND TEST TRT SS C A GM B BDD 7-149
TRANSLATE EXTENDED TRE RRE C A SP STR RB2A57-15
TRANSLATE ONE TO ONE TROO RRE C E2 A SP GM STRM RB9937-152
TRANSLATE ONE TO TWO TROT RRE C E2 A SP GM STRM RB9927-152

TRANSLATE TWO TO ONE TRTO RRE C E2 A SP GM STRM RB9917-152


TRANSLATE TWO TO TWO TRTT RRE C E2 A SP GM STRM RB997-153
TRAP TRAP2E A SO T B ST 1FF1-116
TRAP TRAP4S A SO T B ST B2FF1-116
UNPACK UNPK SS A STB BF3 7-157

UNPACK ASCII UNPKASS C E2 A SP STB BEA 7-158


UNPACK UNICODE UNPKUSS C E2 A SP STB BE2 7-159
UPDATE TREE UPT E C A SPII GM STI4 127-16
ZERO AND ADD ZAP SS C A Dd DF STB BF8 8-13

Figure B-1 (Part 13 of 13). Instructions Arranged by Name

Appendix B. Lists of Instructions B-15



Mne- Op Page
monic Name Characteristics Code No.

DIAGNOSE DM P DM MD83 1-2


A ADD (32) RX C A IF B5A 7-16
AD ADD NORMALIZED (long HFP) RX C A Da EU EO LS B6A 18-8
ADB ADD (long BFP) RXE C A Db Xi Xo Xu Xx BED1A19-18
ADBR ADD (long BFP) RRE C Db Xi Xo Xu Xx B31A19-18

ADR ADD NORMALIZED (long HFP) RR C Da EU EO LS 2A 18-8


AE ADD NORMALIZED (short HFP) RX C A Da EU EO LS B7A 18-8
AEB ADD (short BFP) RXE C A Db Xi Xo Xu Xx BEDA19-18
AEBR ADD (short BFP) RRE C Db Xi Xo Xu Xx B3A19-18
AER ADD NORMALIZED (short HFP) RR C Da EU EO LS 3A 18-8

AG ADD (64) RXE C N A IF BE387-16


AGF ADD (64<32) RXE C N A IF BE3187-16
AGFR ADD (64<32) RRE C N IF B9187-16
AGHI ADD HALFWORD IMMEDIATE (64) RI C N IF A7B 7-16
AGR ADD (64) RRE C N IF B987-16

AH ADD HALFWORD RX C A IF B4A 7-16


AHI ADD HALFWORD IMMEDIATE (32) RI C IF A7A 7-16
AL ADD LOGICAL (32) RX C A B5E 7-17
ALC ADD LOGICAL WITH CARRY (32) RXE C N3 A BE3987-17
ALCG ADD LOGICAL WITH CARRY (64) RXE C N A BE3887-18

ALCGRADD LOGICAL WITH CARRY (64) RRE C N B9887-17


ALCR ADD LOGICAL WITH CARRY (32) RRE C N3 B9987-17
ALG ADD LOGICAL (64) RXE C N A BE3A7-17
ALGF ADD LOGICAL (64<32) RXE C N A BE31A7-17
ALGFRADD LOGICAL (64<32) RRE C N B91A7-17

ALGR ADD LOGICAL (64) RRE C N B9A7-17


ALR ADD LOGICAL (32) RR C 1E 7-17
AP ADD DECIMAL SS C A Dd DF STB BFA 8-5
AR ADD (32) RR C IF 1A 7-16
AU ADD UNNORMALIZED (short HFP) RX C A Da EO LS B7E 18-9

AUR ADD UNNORMALIZED (short HFP) RR C Da EO LS 3E 18-9


AW ADD UNNORMALIZED (long HFP) RX C A Da EO LS B6E 18-9
AWR ADD UNNORMALIZED (long HFP) RR C Da EO LS 2E 18-9
AXBR ADD (extended BFP) RRE C SPDb Xi Xo Xu Xx B34A19-18
AXR ADD NORMALIZED (extended HFP) RR C SPDa EU EO LS 36 18-8

BAKR BRANCH AND STACK RRE A Z T B ST B241-1


BAL BRANCH AND LINK RX B 45 7-19
BALR BRANCH AND LINK RR T B 5 7-19
BAS BRANCH AND SAVE RX B 4D 7-2
BASR BRANCH AND SAVE RR T B D 7-2

BASSMBRANCH AND SAVE AND SET MODE RR T B C 7-21


BC BRANCH ON CONDITION RX B 47 7-23
BCR BRANCH ON CONDITION RR B 7 7-23
BCT BRANCH ON COUNT (32) RX B 46 7-24
BCTG BRANCH ON COUNT (64) RXE N B E3467-24

Figure B-2 (Part 1 of 13). Instructions Arranged by Mnemonic

B-16 z/Architecture Principles of Operation



Mne- Op Page
monic Name Characteristics Code No.

BCTGRBRANCH ON COUNT (64) RRE N B B9467-24


BCTR BRANCH ON COUNT (32) RR B 6 7-24
BRAS BRANCH RELATIVE AND SAVE RI B A75 7-26
BRASLBRANCH RELATIVE AND SAVE LONG RIL N3 B C5 7-26
BRC BRANCH RELATIVE ON CONDITION RI B A74 7-26

BRCL BRANCH RELATIVE ON CONDITION LONG RIL N3 B C4 7-26


BRCT BRANCH RELATIVE ON COUNT (32) RI B A76 7-27
BRCTGBRANCH RELATIVE ON COUNT (64) RI N B A77 7-27
BRXH BRANCH RELATIVE ON INDEX HIGH (32) RSI B 84 7-28
BRXHGBRANCH RELATIVE ON INDEX HIGH (64) RIE N B EC447-28

BRXLEBRANCH RELATIVE ON INDEX L OR E (32)RSI B 85 7-28


BRXLGBRANCH RELATIVE ON INDEX L OR E (64)RIE N B EC457-28
BSA BRANCH AND SET AUTHORITY RRE Q A SO T B B25A1-6
BSG BRANCH IN SUBSPACE GROUP RRE A SO T B RB2581-13
BSM BRANCH AND SET MODE RR T B B 7-22

BXH BRANCH ON INDEX HIGH (32) RS B 86 7-24


BXHG BRANCH ON INDEX HIGH (64) RSE N B EB447-24
BXLE BRANCH ON INDEX LOW OR EQUAL (32) RS B 87 7-25
BXLEGBRANCH ON INDEX LOW OR EQUAL (64) RSE N B EB457-25
C COMPARE (32) RX C A B59 7-33

CD COMPARE (long HFP) RX C A Da B69 18-1


CDB COMPARE (long BFP) RXE C A Db Xi BED1919-23
CDBR COMPARE (long BFP) RRE C Db Xi B31919-23
CDFBRCONVERT FROM FIXED (32 to long BFP) RRE Db B39519-26
CDFR CONVERT FROM FIXED (32 to long HFP) RRE Da B3B518-11

CDGBRCONVERT FROM FIXED (64 to long BFP) RRE N Db Xx B3A519-26


CDGR CONVERT FROM FIXED (64 to long HFP) RRE N Da B3C518-11
CDR COMPARE (long HFP) RR C Da 29 18-1
CDS COMPARE DOUBLE AND SWAP (32) RS C A SP $ ST BBB 7-4
CDSG COMPARE DOUBLE AND SWAP (64) RSE C N A SP $ ST BEB3E7-4

CE COMPARE (short HFP) RX C A Da B79 18-1


CEB COMPARE (short BFP) RXE C A Db Xi BED919-23
CEBR COMPARE (short BFP) RRE C Db Xi B3919-23
CEFBRCONVERT FROM FIXED (32 to short BFP)RRE Db Xx B39419-26
CEFR CONVERT FROM FIXED (32 to short HFP)RRE Da B3B418-11

CEGBRCONVERT FROM FIXED (64 to short BFP)RRE N Db Xx B3A419-26


CEGR CONVERT FROM FIXED (64 to short HFP)RRE N Da B3C418-11
CER COMPARE (short HFP) RR C Da 39 18-1
CFC COMPARE AND FORM CODEWORD S C A SPII GM I1 B21A7-33
CFDBRCONVERT TO FIXED (long BFP to 32) RRF C SPDb Xi Xx B39919-26

CFDR CONVERT TO FIXED (long HFP to 32) RRF C SPDa B3B918-11


CFEBRCONVERT TO FIXED (short BFP to 32) RRF C SPDb Xi Xx B39819-26
CFER CONVERT TO FIXED (short HFP to 32) RRF C SPDa B3B818-11
CFXBRCONVERT TO FIXED (ext. BFP to 32) RRF C SPDb Xi Xx B39A19-26
CFXR CONVERT TO FIXED (ext. HFP to 32) RRF C SPDa B3BA18-11

Figure B-2 (Part 2 of 13). Instructions Arranged by Mnemonic

Appendix B. Lists of Instructions B-17



Mne- Op Page
monic Name Characteristics Code No.

CG COMPARE (64) RXE C N A BE327-33


CGDBRCONVERT TO FIXED (long BFP to 64) RRF C N SPDb Xi Xx B3A919-26
CGDR CONVERT TO FIXED (long HFP to 64) RRF C N SPDa B3C918-11
CGEBRCONVERT TO FIXED (short BFP to 64) RRF C N SPDb Xi Xx B3A819-26
CGER CONVERT TO FIXED (short HFP to 64) RRF C N SPDa B3C818-11

CGF COMPARE (64<32) RXE C N A BE337-33


CGFR COMPARE (64<32) RRE C N B937-33
CGHI COMPARE HALFWORD IMMEDIATE (64) RI C N A7F 7-42
CGR COMPARE (64) RRE C N B927-33
CGXBRCONVERT TO FIXED (ext. BFP to 64) RRF C N SPDb Xi Xx B3AA19-26

CGXR CONVERT TO FIXED (ext. HFP to 64) RRF C N SPDa B3CA18-11


CH COMPARE HALFWORD RX C A B49 7-42
CHI COMPARE HALFWORD IMMEDIATE (32) RI C A7E 7-42
CKSM CHECKSUM RRE C A SP RB2417-29
CL COMPARE LOGICAL (32) RX C A B55 7-43

CLC COMPARE LOGICAL (character) SS C A B BD5 7-43


CLCL COMPARE LOGICAL LONG RR C A SPII R RF 7-44
CLCLECOMPARE LOGICAL LONG EXTENDED RS C A SP R RA9 7-46
CLCLUCOMPARE LOGICAL LONG UNICODE RSE C E2 A SP R REB8F7-5
CLG COMPARE LOGICAL (64) RXE C N A BE3217-43

CLGF COMPARE LOGICAL (64<32) RXE C N A BE3317-43


CLGFRCOMPARE LOGICAL (64<32) RRE C N B9317-43
CLGR COMPARE LOGICAL (64) RRE C N B9217-43
CLI COMPARE LOGICAL (immediate) SI C A B 95 7-43
CLM COMPARE LOGICAL C. UNDER MASK (low) RS C A BBD 7-43

CLMH COMPARE LOGICAL C. UNDER MASK (high)RSE C N A BEB27-43


CLR COMPARE LOGICAL (32) RR C 15 7-42
CLST COMPARE LOGICAL STRING RRE C A SP G R RB25D7-53
CMPSCCOMPRESSION CALL RRE C A SPII D GM STR RB2637-58
CP COMPARE DECIMAL SS C A Dd B BF9 8-6

CPYA COPY ACCESS RRE U UB24D7-77


CR COMPARE (32) RR C 19 7-33
CS COMPARE AND SWAP (32) RS C A SP $ ST BBA 7-4
CSCH CLEAR SUBCHANNEL S C P OP GS B2314-4
CSG COMPARE AND SWAP (64) RSE C N A SP $ ST BEB37-4

CSP COMPARE AND SWAP AND PURGE RRE C P A SP $ ST RB251-18


CUSE COMPARE UNTIL SUBSTRING EQUAL RRE C A SPII GM R RB2577-54
CUTFUCONVERT UTF-8 TO UNICODE RRE C A SP STR RB2A77-74
CUUTFCONVERT UNICODE TO UTF-8 RRE C A SP STR RB2A67-71
CVB CONVERT TO BINARY (32) RX A Dd IK B4F 7-7

CVBG CONVERT TO BINARY (64) RXE N A Dd IK BE3E7-7


CVD CONVERT TO DECIMAL (32) RX A ST B4E 7-7
CVDG CONVERT TO DECIMAL (64) RXE N A ST BE32E7-7
CXBR COMPARE (extended BFP) RRE C SPDb Xi B34919-23
CXFBRCONVERT FROM FIXED (32 to ext. BFP) RRE SPDb B39619-26

Figure B-2 (Part 3 of 13). Instructions Arranged by Mnemonic

B-18 z/Architecture Principles of Operation



Mne- Op Page
monic Name Characteristics Code No.

CXFR CONVERT FROM FIXED (32 to ext. HFP) RRE SPDa B3B618-11
CXGBRCONVERT FROM FIXED (64 to ext. BFP) RRE N SPDb B3A619-26
CXGR CONVERT FROM FIXED (64 to ext. HFP) RRE N SPDa B3C618-11
CXR COMPARE (extended HFP) RRE C SPDa B36918-1
D DIVIDE (32<64) RX A SP IK B5D 7-77

DD DIVIDE (long HFP) RX A Da EU EO FK B6D 18-12


DDB DIVIDE (long BFP) RXE A Db Xi Xz Xo Xu Xx BED1D19-29
DDBR DIVIDE (long BFP) RRE Db Xi Xz Xo Xu Xx B31D19-29
DDR DIVIDE (long HFP) RR Da EU EO FK 2D 18-12
DE DIVIDE (short HFP) RX A Da EU EO FK B7D 18-12

DEB DIVIDE (short BFP) RXE A Db Xi Xz Xo Xu Xx BEDD19-29


DEBR DIVIDE (short BFP) RRE Db Xi Xz Xo Xu Xx B3D19-29
DER DIVIDE (short HFP) RR Da EU EO FK 3D 18-12
DIDBRDIVIDE TO INTEGER (long BFP) RRF C SPDb Xi Xu Xx B35B19-29
DIEBRDIVIDE TO INTEGER (short BFP) RRF C SPDb Xi Xu Xx B35319-29

DL DIVIDE LOGICAL (32<64) RXE N3 A SP IK BE3977-78


DLG DIVIDE LOGICAL (64<128) RXE N A SP IK BE3877-78
DLGR DIVIDE LOGICAL (64<128) RRE N SP IK B9877-77
DLR DIVIDE LOGICAL (32<64) RRE N3 SP IK B9977-77
DP DIVIDE DECIMAL SS A SPDd DK STB BFD 8-6

DR DIVIDE (32<64) RR SP IK 1D 7-77


DSG DIVIDE SINGLE (64) RXE N A SP IK BE3D7-78
DSGF DIVIDE SINGLE (64<32) RXE N A SP IK BE31D7-78
DSGFRDIVIDE SINGLE (64<32) RRE N SP IK B91D7-78
DSGR DIVIDE SINGLE (64) RRE N SP IK B9D7-78

DXBR DIVIDE (extended BFP) RRE SPDb Xi Xz Xo Xu Xx B34D19-29


DXR DIVIDE (extended HFP) RRE SPDa EU EO FK B22D18-12
EAR EXTRACT ACCESS RRE UB24F7-81
ED EDIT SS C A Dd STB BDE 8-7
EDMK EDIT AND MARK SS C A Dd G1 STB BDF 8-9

EFPC EXTRACT FPC RRE Db B38C19-34


EPAR EXTRACT PRIMARY ASN RRE Q SO B2261-2
EPSW EXTRACT PSW RRE N3 B98D7-81
EREG EXTRACT STACKED REGISTERS (32) RRE A SE U UB2491-21
EREGGEXTRACT STACKED REGISTERS (64) RRE N A SE U UB9E1-21

ESAR EXTRACT SECONDARY ASN RRE Q SO B2271-21


ESEA EXTRACT AND SET EXTENDED AUTHORITY RRE N P B99D1-2
ESTA EXTRACT STACKED STATE RRE C A SPSE B24A1-23
EX EXECUTE RX AI SP EX 44 7-8
FIDBRLOAD FP INTEGER (long BFP) RRF SPDb Xi Xx B35F19-36

FIDR LOAD FP INTEGER (long HFP) RRE Da B37F18-15


FIEBRLOAD FP INTEGER (short BFP) RRF SPDb Xi Xx B35719-36
FIER LOAD FP INTEGER (short HFP) RRE Da B37718-15
FIXBRLOAD FP INTEGER (extended BFP) RRF SPDb Xi Xx B34719-36
FIXR LOAD FP INTEGER (extended HFP) RRE SPDa B36718-15

Figure B-2 (Part 4 of 13). Instructions Arranged by Mnemonic

Appendix B. Lists of Instructions B-19



Mne- Op Page
monic Name Characteristics Code No.

HDR HALVE (long HFP) RR Da EU 24 18-13


HER HALVE (short HFP) RR Da EU 34 18-13
HSCH HALT SUBCHANNEL S C P OP GS B23114-5
IAC INSERT ADDRESS SPACE CONTROL RRE C Q SO B2241-26
IC INSERT CHARACTER RX A B43 7-81

ICM INSERT CHARACTERS UNDER MASK (low) RS C A BBF 7-81


ICMH INSERT CHARACTERS UNDER MASK (high) RSE C N A BEB87-81
IIHH INSERT IMMEDIATE (high high) RI N A5 7-82
IIHL INSERT IMMEDIATE (high low) RI N A51 7-82
IILH INSERT IMMEDIATE (low high) RI N A52 7-82

IILL INSERT IMMEDIATE (low low) RI N A53 7-82


IPK INSERT PSW KEY S Q G2 B2B1-27
IPM INSERT PROGRAM MASK RRE B2227-83
IPTE INVALIDATE PAGE TABLE ENTRY RRE P A $ B2211-29
ISKE INSERT STORAGE KEY EXTENDED RRE P A B2291-27

IVSK INSERT VIRTUAL STORAGE KEY RRE Q A SO RB2231-28


KDB COMPARE AND SIGNAL (long BFP) RXE C A Db Xi BED1819-24
KDBR COMPARE AND SIGNAL (long BFP) RRE C Db Xi B31819-24
KEB COMPARE AND SIGNAL (short BFP) RXE C A Db Xi BED819-24
KEBR COMPARE AND SIGNAL (short BFP) RRE C Db Xi B3819-24

KXBR COMPARE AND SIGNAL (extended BFP) RRE C SPDb Xi B34819-24


L LOAD (32) RX A B58 7-83
LA LOAD ADDRESS RX 41 7-84
LAE LOAD ADDRESS EXTENDED RX U BP51 7-84
LAM LOAD ACCESS MULTIPLE RS A SP UB9A 7-84

LARL LOAD ADDRESS RELATIVE LONG RIL N3 C 7-85


LASP LOAD ADDRESS SPACE PARAMETERS SSE C P A SPSO B E51-3
LCDBRLOAD COMPLEMENT (long BFP) RRE C Db B31319-35
LCDR LOAD COMPLEMENT (long HFP) RR C Da 23 18-14
LCEBRLOAD COMPLEMENT (short BFP) RRE C Db B3319-35

LCER LOAD COMPLEMENT (short HFP) RR C Da 33 18-14


LCGFRLOAD COMPLEMENT (64<32) RRE C N IF B9137-86
LCGR LOAD COMPLEMENT (64) RRE C N IF B937-86
LCR LOAD COMPLEMENT (32) RR C IF 13 7-86
LCTL LOAD CONTROL (32) RS P A SP BB7 1-39

LCTLGLOAD CONTROL (64) RSE N P A SP BEB2F1-39


LCXBRLOAD COMPLEMENT (extended BFP) RRE C SPDb B34319-35
LCXR LOAD COMPLEMENT (extended HFP) RRE C SPDa B36318-14
LD LOAD (long) RX A Da B68 9-12
LDE LOAD LENGTHENED (short to long HFP) RXE A Da BED2418-15

LDEB LOAD LENGTHENED (short to long BFP) RXE A Db Xi BED419-38


LDEBRLOAD LENGTHENED (short to long BFP) RRE Db Xi B3419-38
LDER LOAD LENGTHENED (short to long HFP) RRE Da B32418-15
LDR LOAD (long) RR Da 28 9-12
LDXBRLOAD ROUNDED (extended to long BFP) RRE SPDb Xi Xo Xu Xx B34519-39

Figure B-2 (Part 5 of 13). Instructions Arranged by Mnemonic

B-20 z/Architecture Principles of Operation



Mne- Op Page
monic Name Characteristics Code No.

LDXR LOAD ROUNDED (extended to long HFP) RR SPDa EO 25 18-17


LE LOAD (short) RX A Da B78 9-12
LEDBRLOAD ROUNDED (long to short BFP) RRE Db Xi Xo Xu Xx B34419-39
LEDR LOAD ROUNDED (long to short HFP) RR Da EO 35 18-17
LER LOAD (short) RR Da 38 9-12

LEXBRLOAD ROUNDED (extended to short BFP)RRE SPDb Xi Xo Xu Xx B34619-39


LEXR LOAD ROUNDED (extended to short HFP)RRE SPDa EO B36618-17
LFPC LOAD FPC S A SPDb BB29D19-37
LG LOAD (64) RXE N A BE347-83
LGF LOAD (64<32) RXE N A BE3147-83

LGFR LOAD (64<32) RRE N B9147-83


LGH LOAD HALFWORD (64) RXE N A BE3157-87
LGHI LOAD HALFWORD IMMEDIATE (64) RI N A79 7-87
LGR LOAD (64) RRE N B947-83
LH LOAD HALFWORD (32) RX A B48 7-87

LHI LOAD HALFWORD IMMEDIATE (32) RI A78 7-87


LLGC LOAD LOGICAL CHARACTER RXE N A BE397-87
LLGF LOAD LOGICAL (64<32) RXE N A BE3167-87
LLGFRLOAD LOGICAL (64<32) RRE N B9167-87
LLGH LOAD LOGICAL HALFWORD RXE N A BE3917-88

LLGT LOAD LOGICAL THIRTY ONE BITS RXE N A BE3177-88


LLGTRLOAD LOGICAL THIRTY ONE BITS RRE N B9177-88
LLIHHLOAD LOGICAL IMMEDIATE (high high) RI N A5C 7-88
LLIHLLOAD LOGICAL IMMEDIATE (high low) RI N A5D 7-88
LLILHLOAD LOGICAL IMMEDIATE (low high) RI N A5E 7-88

LLILLLOAD LOGICAL IMMEDIATE (low low) RI N A5F 7-88


LM LOAD MULTIPLE (32) RS A B98 7-88
LMD LOAD MULTIPLE DISJOINT SS N A B BEF 7-89
LMG LOAD MULTIPLE (64) RSE N A BEB47-89
LMH LOAD MULTIPLE HIGH RSE N A BEB967-89

LNDBRLOAD NEGATIVE (long BFP) RRE C Db B31119-38


LNDR LOAD NEGATIVE (long HFP) RR C Da 21 18-16
LNEBRLOAD NEGATIVE (short BFP) RRE C Db B3119-38
LNER LOAD NEGATIVE (short HFP) RR C Da 31 18-16
LNGFRLOAD NEGATIVE (64<32) RRE C N B9117-9

LNGR LOAD NEGATIVE (64) RRE C N B917-9


LNR LOAD NEGATIVE (32) RR C 11 7-9
LNXBRLOAD NEGATIVE (extended BFP) RRE C SPDb B34119-38
LNXR LOAD NEGATIVE (extended HFP) RRE C SPDa B36118-16
LPDBRLOAD POSITIVE (long BFP) RRE C Db B3119-39

LPDR LOAD POSITIVE (long HFP) RR C Da 2 18-16


LPEBRLOAD POSITIVE (short BFP) RRE C Db B319-39
LPER LOAD POSITIVE (short HFP) RR C Da 3 18-16
LPGFRLOAD POSITIVE (64<32) RRE C N IF B917-91
LPGR LOAD POSITIVE (64) RRE C N IF B97-91

Figure B-2 (Part 6 of 13). Instructions Arranged by Mnemonic

Appendix B. Lists of Instructions B-21



Mne- Op Page
monic Name Characteristics Code No.

LPQ LOAD PAIR FROM QUADWORD RXE N A SP BE38F7-9


LPR LOAD POSITIVE (32) RR C IF 1 7-9
LPSW LOAD PSW S L P A SP B82 1-39
LPSWELOAD PSW EXTENDED S L N P A SP BB2B21-4
LPXBRLOAD POSITIVE (extended BFP) RRE C SPDb B3419-39

LPXR LOAD POSITIVE (extended HFP) RRE C SPDa B3618-16


LR LOAD (32) RR 18 7-83
LRA LOAD REAL ADDRESS (32) RX C P A SO BPB1 1-41
LRAG LOAD REAL ADDRESS (64) RXE C N P A BPE331-41
LRDR LOAD ROUNDED (extended to long HFP) RR Da EO 25 18-17

LRER LOAD ROUNDED (long to short HFP) RR Da EO 35 18-17


LRV LOAD REVERSED (32) RXE N3 A BE31E7-91
LRVG LOAD REVERSED (64) RXE N A BE3F7-91
LRVGRLOAD REVERSED (64) RRE N B9F7-91
LRVH LOAD REVERSED (16) RXE N3 A BE31F7-91

LRVR LOAD REVERSED (32) RRE N3 B91F7-91


LTDBRLOAD AND TEST (long BFP) RRE C Db Xi B31219-35
LTDR LOAD AND TEST (long HFP) RR C Da 22 18-14
LTEBRLOAD AND TEST (short BFP) RRE C Db Xi B3219-35
LTER LOAD AND TEST (short HFP) RR C Da 32 18-14

LTGFRLOAD AND TEST (64<32) RRE C N B9127-86


LTGR LOAD AND TEST (64) RRE C N B927-86
LTR LOAD AND TEST (32) RR C 12 7-86
LTXBRLOAD AND TEST (extended BFP) RRE C SPDb Xi B34219-35
LTXR LOAD AND TEST (extended HFP) RRE C SPDa B36218-14

LURA LOAD USING REAL ADDRESS (32) RRE P A SP B24B1-46


LURAGLOAD USING REAL ADDRESS (64) RRE N P A SP B951-46
LXD LOAD LENGTHENED (long to ext. HFP) RXE A SPDa BED2518-15
LXDB LOAD LENGTHENED (long to ext. BFP) RXE A SPDb Xi BED519-38
LXDBRLOAD LENGTHENED (long to ext. BFP) RRE SPDb Xi B3519-38

LXDR LOAD LENGTHENED (long to ext. HFP) RRE SPDa B32518-15


LXE LOAD LENGTHENED (short to ext. HFP) RXE A SPDa BED2618-15
LXEB LOAD LENGTHENED (short to ext. BFP) RXE A SPDb Xi BED619-38
LXEBRLOAD LENGTHENED (short to ext. BFP) RRE SPDb Xi B3619-38
LXER LOAD LENGTHENED (short to ext. HFP) RRE SPDa B32618-15

LXR LOAD (extended) RRE SPDa B3659-12


LZDR LOAD ZERO (long) RRE Da B3759-13
LZER LOAD ZERO (short) RRE Da B3749-13
LZXR LOAD ZERO (extended) RRE SPDa B3769-13
M MULTIPLY (64<32) RX A SP B5C 7-17

MADB MULTIPLY AND ADD (long BFP) RXF A Db Xi Xo Xu Xx BED1E19-42


MADBRMULTIPLY AND ADD (long BFP) RRF Db Xi Xo Xu Xx B31E19-42
MAEB MULTIPLY AND ADD (short BFP) RXF A Db Xi Xo Xu Xx BEDE19-42
MAEBRMULTIPLY AND ADD (short BFP) RRF Db Xi Xo Xu Xx B3E19-42
MC MONITOR CALL SI SP MO AF 7-92

Figure B-2 (Part 7 of 13). Instructions Arranged by Mnemonic

B-22 z/Architecture Principles of Operation



Mne- Op Page
monic Name Characteristics Code No.

MD MULTIPLY (long HFP) RX A Da EU EO B6C 18-18


MDB MULTIPLY (long BFP) RXE A Db Xi Xo Xu Xx BED1C19-4
MDBR MULTIPLY (long BFP) RRE Db Xi Xo Xu Xx B31C19-4
MDE MULTIPLY (short to long HFP) RX A Da EU EO B7C 18-18
MDEB MULTIPLY (short to long BFP) RXE A Db Xi BEDC19-4

MDEBRMULTIPLY (short to long BFP) RRE Db Xi B3C19-4


MDER MULTIPLY (short to long HFP) RR Da EU EO 3C 18-18
MDR MULTIPLY (long HFP) RR Da EU EO 2C 18-18
ME MULTIPLY (short to long HFP) RX A Da EU EO B7C 18-18
MEE MULTIPLY (short HFP) RXE A Da EU EO BED3718-18

MEEB MULTIPLY (short BFP) RXE A Db Xi Xo Xu Xx BED1719-4


MEEBRMULTIPLY (short BFP) RRE Db Xi Xo Xu Xx B31719-4
MEER MULTIPLY (short HFP) RRE Da EU EO B33718-18
MER MULTIPLY (short to long HFP) RR Da EU EO 3C 18-18
MGHI MULTIPLY HALFWORD IMMEDIATE (64) RI N A7D 7-18

MH MULTIPLY HALFWORD (32) RX A B4C 7-17


MHI MULTIPLY HALFWORD IMMEDIATE (32) RI A7C 7-18
ML MULTIPLY LOGICAL (64<32) RXE N3 A SP BE3967-18
MLG MULTIPLY LOGICAL (128<64) RXE N A SP BE3867-18
MLGR MULTIPLY LOGICAL (128<64) RRE N SP B9867-18

MLR MULTIPLY LOGICAL (64<32) RRE N3 SP B9967-18


MP MULTIPLY DECIMAL SS A SPDd STB BFC 8-11
MR MULTIPLY (64<32) RR SP 1C 7-17
MS MULTIPLY SINGLE (32) RX A B71 7-19
MSCH MODIFY SUBCHANNEL S C P A SPOP GS BB23214-7

MSDB MULTIPLY AND SUBTRACT (long BFP) RXF A Db Xi Xo Xu Xx BED1F19-42


MSDBRMULTIPLY AND SUBTRACT (long BFP) RRF Db Xi Xo Xu Xx B31F19-42
MSEB MULTIPLY AND SUBTRACT (short BFP) RXF A Db Xi Xo Xu Xx BEDF19-42
MSEBRMULTIPLY AND SUBTRACT (short BFP) RRF Db Xi Xo Xu Xx B3F19-42
MSG MULTIPLY SINGLE (64) RXE N A BE3C7-19

MSGF MULTIPLY SINGLE (64<32) RXE N A BE31C7-19


MSGFRMULTIPLY SINGLE (64<32) RRE N B91C7-19
MSGR MULTIPLY SINGLE (64) RRE N B9C7-19
MSR MULTIPLY SINGLE (32) RRE B2527-19
MSTA MODIFY STACKED STATE RRE A SPSE ST B2471-46

MVC MOVE (character) SS A STB BD2 7-93


MVCDKMOVE WITH DESTINATION KEY SSE Q A GM STB BE5F1-52
MVCINMOVE INVERSE SS A STB BE8 7-93
MVCK MOVE WITH KEY SS C Q A STB BD9 1-52
MVCL MOVE LONG RR C A SPII STR RE 7-94

MVCLEMOVE LONG EXTENDED RS C A SP STR RA8 7-97


MVCLUMOVE LONG UNICODE RSE C E2 A SP STR REB8E7-11
MVCP MOVE TO PRIMARY SS C Q A SO ST DA 1-5
MVCS MOVE TO SECONDARY SS C Q A SO ST DB 1-5
MVCSKMOVE WITH SOURCE KEY SSE Q A GM STB BE5E1-54

Figure B-2 (Part 8 of 13). Instructions Arranged by Mnemonic

Appendix B. Lists of Instructions B-23



Mne- Op Page
monic Name Characteristics Code No.

MVI MOVE (immediate) SI A STB 92 7-93


MVN MOVE NUMERICS SS A STB BD1 7-14
MVO MOVE WITH OFFSET SS A STB BF1 7-16
MVPG MOVE PAGE RRE C Q A SP G STR RB2541-48
MVST MOVE STRING RRE C A SP G STR RB2557-14

MVZ MOVE ZONES SS A STB BD3 7-16


MXBR MULTIPLY (extended BFP) RRE SPDb Xi Xo Xu Xx B34C19-4
MXD MULTIPLY (long to extended HFP) RX A SPDa EU EO B67 18-18
MXDB MULTIPLY (long to extended BFP) RXE A SPDb Xi BED719-4
MXDBRMULTIPLY (long to extended BFP) RRE SPDb Xi B3719-4

MXDR MULTIPLY (long to extended HFP) RR SPDa EU EO 27 18-18


MXR MULTIPLY (extended HFP) RR SPDa EU EO 26 18-18
N AND (32) RX C A B54 7-18
NC AND (character) SS C A STB BD4 7-18
NG AND (64) RXE C N A BE387-18

NGR AND (64) RRE C N B987-18


NI AND (immediate) SI C A STB 94 7-18
NIHH AND IMMEDIATE (high high) RI C N A54 7-19
NIHL AND IMMEDIATE (high low) RI C N A55 7-19
NILH AND IMMEDIATE (low high) RI C N A56 7-19

NILL AND IMMEDIATE (low low) RI C N A57 7-19


NR AND (32) RR C 14 7-18
O OR (32) RX C A B56 7-11
OC OR (character) SS C A STB BD6 7-11
OG OR (64) RXE C N A BE3817-11

OGR OR (64) RRE C N B9817-11


OI OR (immediate) SI C A STB 96 7-11
OIHH OR IMMEDIATE (high high) RI C N A58 7-111
OIHL OR IMMEDIATE (high low) RI C N A59 7-111
OILH OR IMMEDIATE (low high) RI C N A5A 7-111

OILL OR IMMEDIATE (low low) RI C N A5B 7-111


OR OR (32) RR C 16 7-11
PACK PACK SS A STB BF2 7-111
PALB PURGE ALB RRE P $ B2481-8
PC PROGRAM CALL S Q A Z T GM B ST B2181-57

PGIN PAGE IN RRE C ESP A B22E1-55


PGOUTPAGE OUT RRE C ESP A B22F1-56
PKA PACK ASCII SS E2 A SP STB BE9 7-112
PKU PACK UNICODE SS E2 A SP STB BE1 7-113
PLO PERFORM LOCKED OPERATION SS C A SP $ GM ST FCEE 7-114

PR PROGRAM RETURN E L A SPZ T B ST 111-7


PT PROGRAM TRANSFER RRE Q A SPZ T B B2281-74
PTLB PURGE TLB S P $ B2D1-8
RCHP RESET CHANNEL PATH S C P OP G1 B23B14-8
RLL ROTATE LEFT SINGLE LOGICAL (32) RSE N3 EB1D7-129

Figure B-2 (Part 9 of 13). Instructions Arranged by Mnemonic

B-24 z/Architecture Principles of Operation



Mne- Op Page
monic Name Characteristics Code No.

RLLG ROTATE LEFT SINGLE LOGICAL (64) RSE N EB1C7-129


RP RESUME PROGRAM S L Q A SPWE T B BB2771-81
RRBE RESET REFERENCE BIT EXTENDED RRE C P A B22A1-8
RSCH RESUME SUBCHANNEL S C P OP GS B23814-9
S SUBTRACT (32) RX C A IF B5B 7-143

SAC SET ADDRESS SPACE CONTROL S Q SPSW B2191-83


SACF SET ADDRESS SPACE CONTROL FAST S Q SPSW B2791-83
SAL SET ADDRESS LIMIT S P OP G1 B23714-11
SAM24SET ADDRESSING MODE (24) E N3 SP T 1C7-131
SAM31SET ADDRESSING MODE (31) E N3 SP T 1D7-131

SAM64SET ADDRESSING MODE (64) E N T 1E7-131


SAR SET ACCESS RRE U B24E7-131
SCHM SET CHANNEL MONITOR S P OP GM B23C14-12
SCK SET CLOCK S C P A SP BB241-85
SCKC SET CLOCK COMPARATOR S P A SP BB261-86

SCKPFSET CLOCK PROGRAMMABLE FIELD E P SP G 171-86


SD SUBTRACT NORMALIZED (long HFP) RX C A Da EU EO LS B6B 18-21
SDB SUBTRACT (long BFP) RXE C A Db Xi Xo Xu Xx BED1B19-46
SDBR SUBTRACT (long BFP) RRE C Db Xi Xo Xu Xx B31B19-46
SDR SUBTRACT NORMALIZED (long HFP) RR C Da EU EO LS 2B 18-21

SE SUBTRACT NORMALIZED (short HFP) RX C A Da EU EO LS B7B 18-21


SEB SUBTRACT (short BFP) RXE C A Db Xi Xo Xu Xx BEDB19-46
SEBR SUBTRACT (short BFP) RRE C Db Xi Xo Xu Xx B3B19-46
SER SUBTRACT NORMALIZED (short HFP) RR C Da EU EO LS 3B 18-21
SFPC SET FPC RRE SPDb B38419-44

SG SUBTRACT (64) RXE C N A IF BE397-143


SGF SUBTRACT (64<32) RXE C N A IF BE3197-143
SGFR SUBTRACT (64<32) RRE C N IF B9197-143
SGR SUBTRACT (64) RRE C N IF B997-143
SH SUBTRACT HALFWORD RX C A IF B4B 7-144

SIGP SIGNAL PROCESSOR RS C P $ AE 1-91


SL SUBTRACT LOGICAL (32) RX C A B5F 7-144
SLA SHIFT LEFT SINGLE (32) RS C IF 8B 7-134
SLAG SHIFT LEFT SINGLE (64) RSE C N IF EBB7-134
SLB SUBTRACT LOGICAL WITH BORROW (32) RXE C N3 A BE3997-145

SLBG SUBTRACT LOGICAL WITH BORROW (64) RXE C N A BE3897-145


SLBGRSUBTRACT LOGICAL WITH BORROW (64) RRE C N B9897-145
SLBR SUBTRACT LOGICAL WITH BORROW (32) RRE C N3 B9997-145
SLDA SHIFT LEFT DOUBLE RS C SP IF 8F 7-132
SLDL SHIFT LEFT DOUBLE LOGICAL RS SP 8D 7-133

SLG SUBTRACT LOGICAL (64) RXE C N A BE3B7-144


SLGF SUBTRACT LOGICAL (64<32) RXE C N A BE31B7-144
SLGFRSUBTRACT LOGICAL (64<32) RRE C N B91B7-144
SLGR SUBTRACT LOGICAL (64) RRE C N B9B7-144
SLL SHIFT LEFT SINGLE LOGICAL (32) RS 89 7-134

Figure B-2 (Part 10 of 13). Instructions Arranged by Mnemonic

Appendix B. Lists of Instructions B-25



Mne- Op Page
monic Name Characteristics Code No.

SLLG SHIFT LEFT SINGLE LOGICAL (64) RSE N EBD7-134


SLR SUBTRACT LOGICAL (32) RR C 1F 7-144
SP SUBTRACT DECIMAL SS C A Dd DF STB BFB 8-12
SPKA SET PSW KEY FROM ADDRESS S Q B2A1-87
SPM SET PROGRAM MASK RR L 4 7-132

SPT SET CPU TIMER S P A SP BB281-86


SPX SET PREFIX S P A SP $ BB211-87
SQD SQUARE ROOT (long HFP) RXE A Da SQ BED3518-19
SQDB SQUARE ROOT (long BFP) RXE A Db Xi Xx BED1519-45
SQDBRSQUARE ROOT (long BFP) RRE Db Xi Xx B31519-45

SQDR SQUARE ROOT (long HFP) RRE Da SQ B24418-19


SQE SQUARE ROOT (short HFP) RXE A Da SQ BED3418-19
SQEB SQUARE ROOT (short BFP) RXE A Db Xi Xx BED1419-45
SQEBRSQUARE ROOT (short BFP) RRE Db Xi Xx B31419-45
SQER SQUARE ROOT (short HFP) RRE Da SQ B24518-19

SQXBRSQUARE ROOT (extended BFP) RRE SPDb Xi Xx B31619-45


SQXR SQUARE ROOT (extended HFP) RRE SPDa SQ B33618-19
SR SUBTRACT (32) RR C IF 1B 7-143
SRA SHIFT RIGHT SINGLE (32) RS C 8A 7-136
SRAG SHIFT RIGHT SINGLE (64) RSE C N EBA7-136

SRDA SHIFT RIGHT DOUBLE RS C SP 8E 7-135


SRDL SHIFT RIGHT DOUBLE LOGICAL RS SP 8C 7-135
SRL SHIFT RIGHT SINGLE LOGICAL (32) RS 88 7-136
SRLG SHIFT RIGHT SINGLE LOGICAL (64) RSE N EBC7-136
SRNM SET ROUNDING MODE S Db B29919-44

SRP SHIFT AND ROUND DECIMAL SS C A Dd DF STB F 8-11


SRST SEARCH STRING RRE C A SP G RB25E7-13
SSAR SET SECONDARY ASN RRE A Z T B2251-88
SSCH START SUBCHANNEL S C P A SPOP GS BB23314-14
SSKE SET STORAGE KEY EXTENDED RRE P A B22B1-91

SSM SET SYSTEM MASK S P A SPSO B8 1-91


ST STORE (32) RX A ST B5 7-137
STAM STORE ACCESS MULTIPLE RS A SP ST UB9B 7-137
STAP STORE CPU ADDRESS S P A SP ST BB2121-94
STC STORE CHARACTER RX A ST B42 7-137

STCK STORE CLOCK S C A $ ST BB257-138


STCKCSTORE CLOCK COMPARATOR S P A SP ST BB271-93
STCKESTORE CLOCK EXTENDED S C A $ ST BB2787-139
STCM STORE CHARACTERS UNDER MASK (low) RS A ST BBE 7-138
STCMHSTORE CHARACTERS UNDER MASK (high) RSE N A ST BEB2C7-138

STCPSSTORE CHANNEL PATH STATUS S P A SP ST BB23A14-15


STCRWSTORE CHANNEL REPORT WORD S C P A SP ST BB23914-16
STCTGSTORE CONTROL (64) RSE N P A SP ST BEB251-93
STCTLSTORE CONTROL (32) RS P A SP ST BB6 1-93
STD STORE (long) RX A Da ST B6 9-13

Figure B-2 (Part 11 of 13). Instructions Arranged by Mnemonic

B-26 z/Architecture Principles of Operation



Mne- Op Page
monic Name Characteristics Code No.

STE STORE (short) RX A Da ST B7 9-13


STFL STORE FACILITY LIST S N3P B2B11-95
STFPCSTORE FPC S A Db ST BB29C19-45
STG STORE (64) RXE N A ST BE3247-137
STH STORE HALFWORD RX A ST B4 7-141

STIDPSTORE CPU ID S P A SP ST BB221-94


STM STORE MULTIPLE (32) RS A ST B9 7-141
STMG STORE MULTIPLE (64) RSE N A ST BEB247-141
STMH STORE MULTIPLE HIGH RSE N A ST BEB267-142
STNSMSTORE THEN AND SYSTEM MASK SI P A STB AC 1-17

STOSMSTORE THEN OR SYSTEM MASK SI P A SP STB AD 1-17


STPQ STORE PAIR TO QUADWORD RXE N A SP ST BE38E7-142
STPT STORE CPU TIMER S P A SP ST BB291-95
STPX STORE PREFIX S P A SP ST BB2111-95
STRAGSTORE REAL ADDRESS SSE N P A B BPE521-96

STRV STORE REVERSED (32) RXE N3 A ST BE33E7-142


STRVGSTORE REVERSED (64) RXE N A ST BE32F7-142
STRVHSTORE REVERSED (16) RXE N3 A ST BE33F7-142
STSCHSTORE SUBCHANNEL S C P A SPOP GS ST BB23414-17
STSI STORE SYSTEM INFORMATION S C P A SP GM ST BB27D1-97

STURASTORE USING REAL ADDRESS (32) RRE P A SP SU B2461-17


STURGSTORE USING REAL ADDRESS (64) RRE N P A SP SU B9251-17
SU SUBTRACT UNNORMALIZED (short HFP) RX C A Da EO LS B7F 18-21
SUR SUBTRACT UNNORMALIZED (short HFP) RR C Da EO LS 3F 18-21
SVC SUPERVISOR CALL RR A 7-146

SW SUBTRACT UNNORMALIZED (long HFP) RX C A Da EO LS B6F 18-21


SWR SUBTRACT UNNORMALIZED (long HFP) RR C Da EO LS 2F 18-21
SXBR SUBTRACT (extended BFP) RRE C SPDb Xi Xo Xu Xx B34B19-46
SXR SUBTRACT NORMALIZED (extended HFP) RR C SPDa EU EO LS 37 18-21
TAM TEST ADDRESSING MODE E C N3 1B7-146

TAR TEST ACCESS RRE C A U B24C1-18


TB TEST BLOCK RRE C P A II $ G B22C1-11
TBDR CONVERT HFP TO BFP (long) RRF C SPDa B3519-11
TBEDRCONVERT HFP TO BFP (long to short) RRF C SPDa B359-11
TCDB TEST DATA CLASS (long BFP) RXE C Db ED1119-46

TCEB TEST DATA CLASS (short BFP) RXE C Db ED119-46


TCXB TEST DATA CLASS (extended BFP) RXE C SPDb ED1219-46
THDERCONVERT BFP TO HFP (short to long) RRE C Da B3589-1
THDR CONVERT BFP TO HFP (long) RRE C Da B3599-1
TM TEST UNDER MASK SI C A B 91 7-147

TMH TEST UNDER MASK HIGH RI C A7 7-147


TMHH TEST UNDER MASK (high high) RI C N A72 7-147
TMHL TEST UNDER MASK (high low) RI C N A73 7-147
TML TEST UNDER MASK LOW RI C A71 7-147
TMLH TEST UNDER MASK (low high) RI C A7 7-147

Figure B-2 (Part 12 of 13). Instructions Arranged by Mnemonic

Appendix B. Lists of Instructions B-27



Mne- Op Page
monic Name Characteristics Code No.

TMLL TEST UNDER MASK (low low) RI C A71 7-147


TP TEST DECIMAL RSL C E2 A B EBC8-13
TPI TEST PENDING INTERRUPTION S C P A SP ST BB23614-17
TPROTTEST PROTECTION SSE C P A B E511-113
TR TRANSLATE SS A STB BDC 7-148

TRACETRACE (32) RS P A SP T B99 1-115


TRACGTRACE (64) RSE N P A SP T BEBF1-115
TRAP2TRAP E A SO T B ST 1FF1-116
TRAP4TRAP S A SO T B ST B2FF1-116
TRE TRANSLATE EXTENDED RRE C A SP STR RB2A57-15

TROO TRANSLATE ONE TO ONE RRE C E2 A SP GM STRM RB9937-152


TROT TRANSLATE ONE TO TWO RRE C E2 A SP GM STRM RB9927-152
TRT TRANSLATE AND TEST SS C A GM B BDD 7-149
TRTO TRANSLATE TWO TO ONE RRE C E2 A SP GM STRM RB9917-152
TRTT TRANSLATE TWO TO TWO RRE C E2 A SP GM STRM RB997-153

TS TEST AND SET S C A $ ST B93 7-146


TSCH TEST SUBCHANNEL S C P A SPOP GS ST BB23514-19
UNPK UNPACK SS A STB BF3 7-157
UNPKAUNPACK ASCII SS C E2 A SP STB BEA 7-158
UNPKUUNPACK UNICODE SS C E2 A SP STB BE2 7-159

UPT UPDATE TREE E C A SPII GM STI4 127-16


X EXCLUSIVE OR (32) RX C A B57 7-79
XC EXCLUSIVE OR (character) SS C A STB BD7 7-79
XG EXCLUSIVE OR (64) RXE C N A BE3827-79
XGR EXCLUSIVE OR (64) RRE C N B9827-79

XI EXCLUSIVE OR (immediate) SI C A STB 97 7-79


XR EXCLUSIVE OR (32) RR C 17 7-79
XSCH CANCEL SUBCHANNEL S C P OP GS B27614-4
ZAP ZERO AND ADD SS C A Dd DF STB BF8 8-13

Figure B-2 (Part 13 of 13). Instructions Arranged by Mnemonic

B-28 z/Architecture Principles of Operation



Op Mne- Page
Code Name monic Characteristics No.

11PROGRAM RETURN PR E L A SPZ T B ST 1-7


12UPDATE TREE UPT E C A SPII GM STI4 7-16
17SET CLOCK PROGRAMMABLE FIELD SCKPFE P SP G 1-86
1BTEST ADDRESSING MODE TAM E C N3 7-146
1CSET ADDRESSING MODE (24) SAM24E N3 SP T 7-131

1DSET ADDRESSING MODE (31) SAM31E N3 SP T 7-131


1ESET ADDRESSING MODE (64) SAM64E N T 7-131
1FFTRAP TRAP2E A SO T B ST 1-116
4 SET PROGRAM MASK SPM RR L 7-132
5 BRANCH AND LINK BALR RR T B 7-19

6 BRANCH ON COUNT (32) BCTR RR B 7-24


7 BRANCH ON CONDITION BCR RR B 7-23
A SUPERVISOR CALL SVC RR 7-146
B BRANCH AND SET MODE BSM RR T B 7-22
C BRANCH AND SAVE AND SET MODE BASSMRR T B 7-21

D BRANCH AND SAVE BASR RR T B 7-2


E MOVE LONG MVCL RR C A SPII STR R7-94
F COMPARE LOGICAL LONG CLCL RR C A SPII R R7-44
1 LOAD POSITIVE (32) LPR RR C IF 7-9
11 LOAD NEGATIVE (32) LNR RR C 7-9

12 LOAD AND TEST (32) LTR RR C 7-86


13 LOAD COMPLEMENT (32) LCR RR C IF 7-86
14 AND (32) NR RR C 7-18
15 COMPARE LOGICAL (32) CLR RR C 7-42
16 OR (32) OR RR C 7-11

17 EXCLUSIVE OR (32) XR RR C 7-79


18 LOAD (32) LR RR 7-83
19 COMPARE (32) CR RR C 7-33
1A ADD (32) AR RR C IF 7-16
1B SUBTRACT (32) SR RR C IF 7-143

1C MULTIPLY (64<32) MR RR SP 7-17


1D DIVIDE (32<64) DR RR SP IK 7-77
1E ADD LOGICAL (32) ALR RR C 7-17
1F SUBTRACT LOGICAL (32) SLR RR C 7-144
2 LOAD POSITIVE (long HFP) LPDR RR C Da 18-16

21 LOAD NEGATIVE (long HFP) LNDR RR C Da 18-16


22 LOAD AND TEST (long HFP) LTDR RR C Da 18-14
23 LOAD COMPLEMENT (long HFP) LCDR RR C Da 18-14
24 HALVE (long HFP) HDR RR Da EU 18-13
25 LOAD ROUNDED (extended to long HFP) LDXR RR SPDa EO 18-17

25 LOAD ROUNDED (extended to long HFP) LRDR RR Da EO 18-17


26 MULTIPLY (extended HFP) MXR RR SPDa EU EO 18-18
27 MULTIPLY (long to extended HFP) MXDR RR SPDa EU EO 18-18
28 LOAD (long) LDR RR Da 9-12
29 COMPARE (long HFP) CDR RR C Da 18-1

Figure B-3 (Part 1 of 13). Instructions Arranged by Operation Code

Appendix B. Lists of Instructions B-29



Op Mne- Page
Code Name monic Characteristics No.

2A ADD NORMALIZED (long HFP) ADR RR C Da EU EO LS 18-8


2B SUBTRACT NORMALIZED (long HFP) SDR RR C Da EU EO LS 18-21
2C MULTIPLY (long HFP) MDR RR Da EU EO 18-18
2D DIVIDE (long HFP) DDR RR Da EU EO FK 18-12
2E ADD UNNORMALIZED (long HFP) AWR RR C Da EO LS 18-9

2F SUBTRACT UNNORMALIZED (long HFP) SWR RR C Da EO LS 18-21


3 LOAD POSITIVE (short HFP) LPER RR C Da 18-16
31 LOAD NEGATIVE (short HFP) LNER RR C Da 18-16
32 LOAD AND TEST (short HFP) LTER RR C Da 18-14
33 LOAD COMPLEMENT (short HFP) LCER RR C Da 18-14

34 HALVE (short HFP) HER RR Da EU 18-13


35 LOAD ROUNDED (long to short HFP) LEDR RR Da EO 18-17
35 LOAD ROUNDED (long to short HFP) LRER RR Da EO 18-17
36 ADD NORMALIZED (extended HFP) AXR RR C SPDa EU EO LS 18-8
37 SUBTRACT NORMALIZED (extended HFP) SXR RR C SPDa EU EO LS 18-21

38 LOAD (short) LER RR Da 9-12


39 COMPARE (short HFP) CER RR C Da 18-1
3A ADD NORMALIZED (short HFP) AER RR C Da EU EO LS 18-8
3B SUBTRACT NORMALIZED (short HFP) SER RR C Da EU EO LS 18-21
3C MULTIPLY (short to long HFP) MDER RR Da EU EO 18-18

3C MULTIPLY (short to long HFP) MER RR Da EU EO 18-18


3D DIVIDE (short HFP) DER RR Da EU EO FK 18-12
3E ADD UNNORMALIZED (short HFP) AUR RR C Da EO LS 18-9
3F SUBTRACT UNNORMALIZED (short HFP) SUR RR C Da EO LS 18-21
4 STORE HALFWORD STH RX A ST B7-141

41 LOAD ADDRESS LA RX 7-84


42 STORE CHARACTER STC RX A ST B7-137
43 INSERT CHARACTER IC RX A B7-81
44 EXECUTE EX RX AI SP EX 7-8
45 BRANCH AND LINK BAL RX B 7-19

46 BRANCH ON COUNT (32) BCT RX B 7-24


47 BRANCH ON CONDITION BC RX B 7-23
48 LOAD HALFWORD (32) LH RX A B7-87
49 COMPARE HALFWORD CH RX C A B7-42
4A ADD HALFWORD AH RX C A IF B7-16

4B SUBTRACT HALFWORD SH RX C A IF B7-144


4C MULTIPLY HALFWORD (32) MH RX A B7-17
4D BRANCH AND SAVE BAS RX B 7-2
4E CONVERT TO DECIMAL (32) CVD RX A ST B7-7
4F CONVERT TO BINARY (32) CVB RX A Dd IK B7-7

5 STORE (32) ST RX A ST B7-137


51 LOAD ADDRESS EXTENDED LAE RX U BP7-84
54 AND (32) N RX C A B7-18
55 COMPARE LOGICAL (32) CL RX C A B7-43
56 OR (32) O RX C A B7-11

Figure B-3 (Part 2 of 13). Instructions Arranged by Operation Code

B-30 z/Architecture Principles of Operation



Op Mne- Page
Code Name monic Characteristics No.

57 EXCLUSIVE OR (32) X RX C A B7-79


58 LOAD (32) L RX A B7-83
59 COMPARE (32) C RX C A B7-33
5A ADD (32) A RX C A IF B7-16
5B SUBTRACT (32) S RX C A IF B7-143

5C MULTIPLY (64<32) M RX A SP B7-17


5D DIVIDE (32<64) D RX A SP IK B7-77
5E ADD LOGICAL (32) AL RX C A B7-17
5F SUBTRACT LOGICAL (32) SL RX C A B7-144
6 STORE (long) STD RX A Da ST B9-13

67 MULTIPLY (long to extended HFP) MXD RX A SPDa EU EO B18-18


68 LOAD (long) LD RX A Da B9-12
69 COMPARE (long HFP) CD RX C A Da B18-1
6A ADD NORMALIZED (long HFP) AD RX C A Da EU EO LS B18-8
6B SUBTRACT NORMALIZED (long HFP) SD RX C A Da EU EO LS B18-21

6C MULTIPLY (long HFP) MD RX A Da EU EO B18-18


6D DIVIDE (long HFP) DD RX A Da EU EO FK B18-12
6E ADD UNNORMALIZED (long HFP) AW RX C A Da EO LS B18-9
6F SUBTRACT UNNORMALIZED (long HFP) SW RX C A Da EO LS B18-21
7 STORE (short) STE RX A Da ST B9-13

71 MULTIPLY SINGLE (32) MS RX A B7-19


78 LOAD (short) LE RX A Da B9-12
79 COMPARE (short HFP) CE RX C A Da B18-1
7A ADD NORMALIZED (short HFP) AE RX C A Da EU EO LS B18-8
7B SUBTRACT NORMALIZED (short HFP) SE RX C A Da EU EO LS B18-21

7C MULTIPLY (short to long HFP) MDE RX A Da EU EO B18-18


7C MULTIPLY (short to long HFP) ME RX A Da EU EO B18-18
7D DIVIDE (short HFP) DE RX A Da EU EO FK B18-12
7E ADD UNNORMALIZED (short HFP) AU RX C A Da EO LS B18-9
7F SUBTRACT UNNORMALIZED (short HFP) SU RX C A Da EO LS B18-21

8 SET SYSTEM MASK SSM S P A SPSO B1-91


82 LOAD PSW LPSW S L P A SP B1-39
83 DIAGNOSE DM P DM MD1-2
84 BRANCH RELATIVE ON INDEX HIGH (32) BRXH RSI B 7-28
85 BRANCH RELATIVE ON INDEX L OR E (32)BRXLERSI B 7-28

86 BRANCH ON INDEX HIGH (32) BXH RS B 7-24


87 BRANCH ON INDEX LOW OR EQUAL (32) BXLE RS B 7-25
88 SHIFT RIGHT SINGLE LOGICAL (32) SRL RS 7-136
89 SHIFT LEFT SINGLE LOGICAL (32) SLL RS 7-134
8A SHIFT RIGHT SINGLE (32) SRA RS C 7-136

8B SHIFT LEFT SINGLE (32) SLA RS C IF 7-134


8C SHIFT RIGHT DOUBLE LOGICAL SRDL RS SP 7-135
8D SHIFT LEFT DOUBLE LOGICAL SLDL RS SP 7-133
8E SHIFT RIGHT DOUBLE SRDA RS C SP 7-135
8F SHIFT LEFT DOUBLE SLDA RS C SP IF 7-132

Figure B-3 (Part 3 of 13). Instructions Arranged by Operation Code

Appendix B. Lists of Instructions B-31



Op Mne- Page
Code Name monic Characteristics No.

9 STORE MULTIPLE (32) STM RS A ST B7-141


91 TEST UNDER MASK TM SI C A B 7-147
92 MOVE (immediate) MVI SI A STB 7-93
93 TEST AND SET TS S C A $ ST B7-146
94 AND (immediate) NI SI C A STB 7-18

95 COMPARE LOGICAL (immediate) CLI SI C A B 7-43


96 OR (immediate) OI SI C A STB 7-11
97 EXCLUSIVE OR (immediate) XI SI C A STB 7-79
98 LOAD MULTIPLE (32) LM RS A B7-88
99 TRACE (32) TRACERS P A SP T B1-115

9A LOAD ACCESS MULTIPLE LAM RS A SP UB7-84


9B STORE ACCESS MULTIPLE STAM RS A SP ST UB7-137
A5 INSERT IMMEDIATE (high high) IIHH RI N 7-82
A51 INSERT IMMEDIATE (high low) IIHL RI N 7-82
A52 INSERT IMMEDIATE (low high) IILH RI N 7-82

A53 INSERT IMMEDIATE (low low) IILL RI N 7-82


A54 AND IMMEDIATE (high high) NIHH RI C N 7-19
A55 AND IMMEDIATE (high low) NIHL RI C N 7-19
A56 AND IMMEDIATE (low high) NILH RI C N 7-19
A57 AND IMMEDIATE (low low) NILL RI C N 7-19

A58 OR IMMEDIATE (high high) OIHH RI C N 7-111


A59 OR IMMEDIATE (high low) OIHL RI C N 7-111
A5A OR IMMEDIATE (low high) OILH RI C N 7-111
A5B OR IMMEDIATE (low low) OILL RI C N 7-111
A5C LOAD LOGICAL IMMEDIATE (high high) LLIHHRI N 7-88

A5D LOAD LOGICAL IMMEDIATE (high low) LLIHLRI N 7-88


A5E LOAD LOGICAL IMMEDIATE (low high) LLILHRI N 7-88
A5F LOAD LOGICAL IMMEDIATE (low low) LLILLRI N 7-88
A7 TEST UNDER MASK (low high) TMLH RI C 7-147
A7 TEST UNDER MASK HIGH TMH RI C 7-147

A71 TEST UNDER MASK (low low) TMLL RI C 7-147


A71 TEST UNDER MASK LOW TML RI C 7-147
A72 TEST UNDER MASK (high high) TMHH RI C N 7-147
A73 TEST UNDER MASK (high low) TMHL RI C N 7-147
A74 BRANCH RELATIVE ON CONDITION BRC RI B 7-26

A75 BRANCH RELATIVE AND SAVE BRAS RI B 7-26


A76 BRANCH RELATIVE ON COUNT (32) BRCT RI B 7-27
A77 BRANCH RELATIVE ON COUNT (64) BRCTGRI N B 7-27
A78 LOAD HALFWORD IMMEDIATE (32) LHI RI 7-87
A79 LOAD HALFWORD IMMEDIATE (64) LGHI RI N 7-87

A7A ADD HALFWORD IMMEDIATE (32) AHI RI C IF 7-16


A7B ADD HALFWORD IMMEDIATE (64) AGHI RI C N IF 7-16
A7C MULTIPLY HALFWORD IMMEDIATE (32) MHI RI 7-18
A7D MULTIPLY HALFWORD IMMEDIATE (64) MGHI RI N 7-18
A7E COMPARE HALFWORD IMMEDIATE (32) CHI RI C 7-42

Figure B-3 (Part 4 of 13). Instructions Arranged by Operation Code

B-32 z/Architecture Principles of Operation



Op Mne- Page
Code Name monic Characteristics No.

A7F COMPARE HALFWORD IMMEDIATE (64) CGHI RI C N 7-42


A8 MOVE LONG EXTENDED MVCLERS C A SP STR R7-97
A9 COMPARE LOGICAL LONG EXTENDED CLCLERS C A SP R R7-46
AC STORE THEN AND SYSTEM MASK STNSMSI P A STB 1-17
AD STORE THEN OR SYSTEM MASK STOSMSI P A SP STB 1-17

AE SIGNAL PROCESSOR SIGP RS C P $ 1-91


AF MONITOR CALL MC SI SP MO 7-92
B1 LOAD REAL ADDRESS (32) LRA RX C P A SO BP1-41
B22STORE CPU ID STIDPS P A SP ST B1-94
B24SET CLOCK SCK S C P A SP B1-85

B25STORE CLOCK STCK S C A $ ST B7-138


B26SET CLOCK COMPARATOR SCKC S P A SP B1-86
B27STORE CLOCK COMPARATOR STCKCS P A SP ST B1-93
B28SET CPU TIMER SPT S P A SP B1-86
B29STORE CPU TIMER STPT S P A SP ST B1-95

B2ASET PSW KEY FROM ADDRESS SPKA S Q 1-87


B2BINSERT PSW KEY IPK S Q G2 1-27
B2DPURGE TLB PTLB S P $ 1-8
B21SET PREFIX SPX S P A SP $ B1-87
B211STORE PREFIX STPX S P A SP ST B1-95

B212STORE CPU ADDRESS STAP S P A SP ST B1-94


B218PROGRAM CALL PC S Q A Z T GM B ST 1-57
B219SET ADDRESS SPACE CONTROL SAC S Q SPSW 1-83
B21ACOMPARE AND FORM CODEWORD CFC S C A SPII GM I1 7-33
B221INVALIDATE PAGE TABLE ENTRY IPTE RRE P A $ 1-29

B222INSERT PROGRAM MASK IPM RRE 7-83


B223INSERT VIRTUAL STORAGE KEY IVSK RRE Q A SO R1-28
B224INSERT ADDRESS SPACE CONTROL IAC RRE C Q SO 1-26
B225SET SECONDARY ASN SSAR RRE A Z T 1-88
B226EXTRACT PRIMARY ASN EPAR RRE Q SO 1-2

B227EXTRACT SECONDARY ASN ESAR RRE Q SO 1-21


B228PROGRAM TRANSFER PT RRE Q A SPZ T B 1-74
B229INSERT STORAGE KEY EXTENDED ISKE RRE P A 1-27
B22ARESET REFERENCE BIT EXTENDED RRBE RRE C P A 1-8
B22BSET STORAGE KEY EXTENDED SSKE RRE P A 1-91

B22CTEST BLOCK TB RRE C P A II $ G 1-11


B22DDIVIDE (extended HFP) DXR RRE SPDa EU EO FK 18-12
B22EPAGE IN PGIN RRE C ESP A 1-55
B22FPAGE OUT PGOUTRRE C ESP A 1-56
B23CLEAR SUBCHANNEL CSCH S C P OP GS 14-4

B231HALT SUBCHANNEL HSCH S C P OP GS 14-5


B232MODIFY SUBCHANNEL MSCH S C P A SPOP GS B14-7
B233START SUBCHANNEL SSCH S C P A SPOP GS B14-14
B234STORE SUBCHANNEL STSCHS C P A SPOP GS ST B14-17
B235TEST SUBCHANNEL TSCH S C P A SPOP GS ST B14-19

Figure B-3 (Part 5 of 13). Instructions Arranged by Operation Code

Appendix B. Lists of Instructions B-33



Op Mne- Page
Code Name monic Characteristics No.

B236TEST PENDING INTERRUPTION TPI S C P A SP ST B14-17


B237SET ADDRESS LIMIT SAL S P OP G1 14-11
B238RESUME SUBCHANNEL RSCH S C P OP GS 14-9
B239STORE CHANNEL REPORT WORD STCRWS C P A SP ST B14-16
B23ASTORE CHANNEL PATH STATUS STCPSS P A SP ST B14-15

B23BRESET CHANNEL PATH RCHP S C P OP G1 14-8


B23CSET CHANNEL MONITOR SCHM S P OP GM 14-12
B24BRANCH AND STACK BAKR RRE A Z T B ST 1-1
B241CHECKSUM CKSM RRE C A SP R7-29
B244SQUARE ROOT (long HFP) SQDR RRE Da SQ 18-19

B245SQUARE ROOT (short HFP) SQER RRE Da SQ 18-19


B246STORE USING REAL ADDRESS (32) STURARRE P A SP SU 1-17
B247MODIFY STACKED STATE MSTA RRE A SPSE ST 1-46
B248PURGE ALB PALB RRE P $ 1-8
B249EXTRACT STACKED REGISTERS (32) EREG RRE A SE U U1-21

B24AEXTRACT STACKED STATE ESTA RRE C A SPSE 1-23


B24BLOAD USING REAL ADDRESS (32) LURA RRE P A SP 1-46
B24CTEST ACCESS TAR RRE C A U 1-18
B24DCOPY ACCESS CPYA RRE U U7-77
B24ESET ACCESS SAR RRE U 7-131

You might also like