Mainframe Path Start learning free
Applied11 min readLesson 3 of 3

Storage definitions, dumps and program checks

Assembler programs define their data with DC and DS, map other programs' storage with DSECTs and are packaged in CSECTs. When something goes wrong the processor raises a program check, and the PSW and registers in the dump tell you which instruction failed and why.

Defining storage: DC and DS

DC (define constant) reserves storage and gives it an initial value. DS (define storage) reserves storage without a value. Both take a type that sets the format, alignment and default length.

Common storage definitionsWhat it means
NAME DS CL20
20 bytes of character storage, no initial value
TITLE DC C'MONTHLY'
Character constant, length taken from the value
COUNT DC F'0'
Fullword binary zero, aligned on a 4-byte boundary
HALF DS H
Halfword (2 bytes), aligned on a 2-byte boundary
TOTAL DC PL6'0'
6-byte packed decimal zero (like COBOL COMP-3)
DWORK DS D
Doubleword (8 bytes), the work area CVB and CVD need
MASK DC X'0F'
Hexadecimal constant
ADDR DC A(TABLE)
Address constant, resolved at link or load time

Types map directly onto COBOL: C is PIC X, F and H are binary COMP fields, P is COMP-3. Reading a copybook and its assembler equivalent side by side is a good way to learn both.

CSECT, DSECT and USING

These are assembler instructions: directions to the assembler rather than machine instructions. A CSECT (control section) is a block of code and data that becomes part of an object module; the binder combines CSECTs into a load module or program object. A DSECT (dummy section) describes a layout without allocating any storage: it is a template laid over storage that belongs to someone else, such as a parameter area or a control block.

Mapping a parameter with a DSECT (illustrative)
PARMMAP  DSECT
PCUSTNO  DS    CL10
PAMOUNT  DS    PL6
PSTATUS  DS    CL1
DATECHK  CSECT
*        ... entry logic ...
         L     2,0(,1)          R2 = address of first parameter
         USING PARMMAP,2        lay the map over it
         CLI   PSTATUS,C'A'
         BNE   NOTACTV
         DROP  2

Once USING PARMMAP,2 is in effect, the assembler turns PSTATUS into displacement 16 from R2. The DSECT is the assembler equivalent of a COBOL LINKAGE SECTION item.

Macros are different again: named pieces of source that expand into instructions. IBM supplies system macros such as SAVE, RETURN, WTO (write to operator) and STORAGE (obtain or release storage), and many sites keep their own macro libraries. The listing shows the expanded instructions, which is what actually runs.

The PSW

The Program Status Word (PSW) is the processor's record of its current state. In z/Architecture it is 128 bits. It holds, among other things, the address of the next instruction, the condition code, the addressing mode, the storage protection key and whether the program is in problem (application) or supervisor state.

Program checks

When an instruction cannot complete, the hardware raises a program interruption with an interruption code. z/OS turns an unhandled one into a system abend of the form 0Cx.

AbendInterruptionCommon cause
S0C1Operation exceptionBranched into data or a bad address, so the bytes are not a valid instruction
S0C4Protection exception (or a segment or page translation exception)Bad pointer, uninitialised base register, wrong AMODE, storage key mismatch
S0C7Data exceptionInvalid packed decimal data in AP, ZAP, CVB and similar
S0C9Fixed-point divide exceptionBinary divide by zero or quotient too large
S0CBDecimal divide exceptionPacked divide by zero or quotient too large

Reading assembler in a dump

  1. Find the PSW at the time of the error and the instruction length code (ILC), 2, 4 or 6.
  2. In most cases the PSW points to the instruction after the failing one. Subtract the ILC to find the failing instruction.
  3. Find the module's entry point address (the dump or Language Environment report usually names it). Failing address minus entry point gives the offset.
  4. Look up that offset in the assembler listing (or the COBOL listing with an offset map) to find the source statement.
  5. Decode the operands and check the registers they use. A base register containing zero or rubbish explains most S0C4s.
Abend summary (illustrative)
COMPLETION CODE  SYSTEM = 0C4  REASON = 00000004
PSW AT ENTRY TO ABEND  078D1000 8002A1B6  ILC 6  INTC 0004
MODULE DATECHK  ENTRY POINT 0002A000
GR 0-3   00000000 0002A3F0 00000000 0002B110

Here the PSW address is X'2A1B6' (the leading 8 is the 31-bit mode bit). The ILC is 6, so the failing instruction is at X'2A1B0', offset X'1B0' in DATECHK: an SS instruction such as MVC. R2 is zero, and the listing shows that instruction addresses a parameter through R2. The calling program passed no parameter.

Interactive dump analysis on z/OS is done with IPCS for SVC and SYSMDUMP dumps, while SYSUDUMP and Language Environment CEEDUMP output is formatted text. Vendor tools such as IBM Fault Analyzer, BMC AMI and Broadcom products automate much of this, but they assume you understand the steps above.

Common mistakes

Taking the PSW address as the failing instruction

For most program checks the PSW already points past the failing instruction. Subtract the instruction length code first.

Thinking a DSECT allocates storage

A DSECT is only a map. Without a USING and a register loaded with a real address, references to its fields point at nothing useful.

Restarting a program-check abend unchanged

S0C4 and S0C7 are usually caused by code or data, not by the system. Find the cause first, or the rerun will fail the same way and may waste the batch window.

What you will see at work

Key terms

Check your understanding.
Take this lesson's quiz and save your progress. Free.

Take the lesson quiz
← Common instructions and linkage conventionsBack to Assembler (HLASM) fundamentals