The Complete Guide to IBM High Level Assembler on z/OS
Learn IBM High Level Assembler on z/OS end to end: source format, registers, linkage, data, I/O, macros, DSECTs, dumps and modern instructions.

Assembler is the language that z/OS itself is written in. The dispatcher that picks the next task, the routines that open your data sets, the exits that let sites bend the system to their rules: most of that is High Level Assembler, and every compiled program on the platform, COBOL, PL/I, C and the rest, turns into the same machine instructions you write by hand in assembler. Learning it does not make you faster at business logic. It makes you the person in the room who can read a dump, explain why a program failed at offset X'3C', write the exit nobody else can, and call a system service that has no COBOL interface.
HLASM does not hide the machine from you. Every statement is an instruction or a request to the assembler, every address is a base register plus a displacement, and every failure points to a PSW and a set of registers that you can read.
This guide takes you from the source format to a working batch program that reads a file, does decimal arithmetic, formats a result and writes it to the console, and then through the topics that decide whether the program survives in production: linkage, macros, DSECTs, reading the listing, reading a dump, reentrancy, recovery and the modern instruction set. It is written for programmers who know another language and want the whole picture first. The focused posts in the cluster go deeper on one subject each, and this is the map. The product is IBM High Level Assembler for z/OS, Release 6, on z/OS 3.1, documented in the HLASM manuals at the High Level Assembler documentation and in the z/OS library on the z/OS documentation site. The instruction definitions come from the z/Architecture Principles of Operation. Code is written against those levels, and every sample that produces output is followed by that output.
What HLASM is, and when to use it
HLASM is a macro assembler. It translates one source statement into one machine instruction, or expands a macro statement into many. It runs as the batch program ASMA90, produces an object module and a listing, and the object module goes through the binder to become a load module. It is the successor to Assembler H, and it accepts the classic System/360 source without change, which is why programs written in the 1970s still assemble today.
You use it in four situations. System programmers write exits and system services in it, because only assembler can use authorized services without restriction and run in the states those services require. Performance-critical routines use it where a compiler's code is not tight enough, though modern compilers have narrowed that gap. Maintenance programmers use it because a program they inherit is already written in it. And anyone who debugs compiled code on z/OS uses it as a reading skill, since a dump shows machine instructions, and a compiler's LIST option prints a pseudo-assembler listing of what it generated. The honest advice for new application work is to write it in COBOL, PL/I, C or Java and drop to assembler only where you must, and that advice is repeated in the boundary section below.
The source format
Assembler source is column-sensitive, a legacy of punched cards that never went away. Each statement has up to four fields, separated by blanks:
| Field | Starts in | Content |
|---|---|---|
| name | column 1 | a label, optional; a blank in column 1 means no label |
| operation | usually column 10 | an instruction, a macro name or an assembler instruction |
| operand | usually column 16 | operands separated by commas, with no blanks inside |
| remarks | after one blank | a comment on the same line |
A line with * in column 1 is a comment. A statement continues on the next line when you put any non-blank character in column 72 and start the next line in column 16. Columns 73 to 80 are ignored and used for sequence numbers. Labels are up to 63 characters, but the convention is eight or fewer so that the listing stays tidy. Names are not case sensitive in the operation field, and the conventional style is uppercase.
* THIS IS A COMMENT LINE
LABEL1 LR R5,R6 COPY R6 INTO R5
AR R5,R7 ADD R7Operand fields are strict: no blanks except inside quoted text, because a blank ends the operand field and everything after it is a remark. L R5,COUNT works only because the blank separates the operation from its operands. Writing L R5, COUNT turns COUNT into a remark and the instruction fails to assemble with a missing operand. This is the single most common typing mistake of new programmers.
Registers and the PSW in two minutes
The processor has sixteen 64-bit general registers, numbered 0 to 15. A 31-bit program uses the low 32 bits. Conventions give them roles: register 1 holds the parameter list address on entry, 13 the save area address, 14 the return address and 15 the entry point on entry and the return code on exit, while 12 is by custom the program's base register. The program status word holds the instruction address, a 2-bit condition code, the addressing mode and the problem state bit. Instructions come in lengths of 2, 4 or 6 bytes, and a storage operand is a base register plus a 12-bit displacement, which is why every program needs a base register and a USING statement. The post on z/Architecture registers, the PSW and instruction formats works through the encoding by hand, and the post on base registers and USING covers the addressing rule. YREGS, a macro, defines the names R0 to R15 so you can write R12 instead of 12.
The skeleton of a program
Every program starts with the same shape. A control section, an entry sequence that saves the caller's registers and sets a base, the work, and an exit sequence that restores them and returns a code:
SKELETON CSECT
SKELETON AMODE 31
SKELETON RMODE ANY
YREGS
STM R14,R12,12(R13)
LR R12,R15
USING SKELETON,R12
WTO 'HELLO FROM SKELETON',ROUTCDE=11
LM R14,R12,12(R13)
SLR R15,R15
BR R14
END SKELETONCSECT begins the control section, the unit the binder places. AMODE 31 and RMODE ANY say the program works with 31-bit addresses and may load above the 16 MB line. STM R14,R12,12(R13) saves registers 14 through 12 in the caller's save area, LR R12,R15 copies the entry point address into the base register, and USING tells the assembler about it. After the work, LM restores, SLR R15,R15 zeroes the return code and BR R14 returns. Note that the return code is set after the LM, since the LM reloads register 15. END names the entry point. When the job runs, the console shows the message and the step ends with condition code 0000. The first-program post walks the same code with its job.
Defining data
Storage is reserved and initialized with DC, define constant, and DS, define storage. Each takes a duplication factor, a type and a length, and the type decides how the value is stored:
| Type | Meaning | Example | Bytes stored |
|---|---|---|---|
C | character | DC C'ABC' | C1C2C3 |
X | hexadecimal | DC X'0FA0' | 0FA0 |
F | fullword binary | DC F'100' | 00000064 |
H | halfword binary | DC H'-2' | FFFE |
FD | doubleword binary | DC FD'1' | 0000000000000001 |
P | packed decimal | DC P'1250' | 01250C |
Z | zoned decimal | DC Z'1250' | F1F2F5C0 |
A | address | DC A(LABEL) | the address of LABEL |
B | binary | DC B'10110000' | B0 |
A length modifier changes the size: DC CL10'HELLO' is ten bytes padded with blanks on the right, and DC PL5'1250' is a five-byte packed field. The assembler aligns F, H, A and FD constants on their natural boundary, inserting padding bytes in the object code, but character and packed data are not aligned. DS 0F forces alignment without storing anything. DS is the same without a value: DS CL80 reserves 80 bytes, and DS 3F reserves three fullwords. A name on a data statement gets the address and, through attributes, the length: L'NAME is its length in bytes, which is the safe way to write a MVC that copies a whole field.
COUNT DC F'0'
MSG DC CL20'PAYROLL EXTRACT'
AMOUNT DS PL5
SWITCH DC X'00'
TABLE DC 10F'0'TABLE is ten fullwords of zero in one statement, using a duplication factor of 10. Literals are constants written in place: =F'100' or =C'ACCT' in an operand makes the assembler create the constant and place it at the next LTORG, or at the end of the program by default. They keep short programs short and cost a base register reach of 4 KB, so long programs place LTORG statements where literals are near their users.
Moving data and doing arithmetic
Five instructions carry most traffic between registers and storage. L loads a fullword from storage into a register and ST stores one. LR copies register to register. LA loads an address, not what is there, and doubles as a small adder that leaves the condition code alone. STM and LM move ranges of registers. The post on register moves traces each of these with its register values. For storage-to-storage work, MVC copies up to 256 bytes, MVI stores one byte, CLC compares and XC clears:
MVC NAME,=CL20'DEFAULT NAME'
MVI SWITCH,X'01'
XC TABLE(40),TABLEBinary arithmetic works on registers. A adds a fullword from storage to a register, S subtracts, M multiplies into a register pair and D divides a register pair. The result of each is in the register, with the condition code set to zero, negative, positive or overflow:
L R2,PRICE
A R2,TAX
ST R2,GROSS
LA R3,1
AR R2,R3For money, binary integers in cents work, but the platform's natural type is packed decimal, which gives exact decimal arithmetic on fields up to 31 digits, PACK, AP, SP, MP, DP, CP and UNPK. The post on decimal arithmetic with PACK, AP, ZAP and UNPK explains the formats and the two abends you will see, the data exception 0C7 for an invalid digit or sign nibble and the decimal overflow 0CA for a result that does not fit.
Comparing and branching
Assembler has no IF. A compare sets the condition code, and a conditional branch tests it. CLC and CLI compare characters, C and CR compare fullwords, and the branch mnemonics read the result: BE for equal, BNE, BL for low, BH for high. The relative forms JE, JNE, JL and JH need no base register. A loop uses BCT, which subtracts one from a register and branches while the result is nonzero:
LA R3,5
SLR R4,R4
NEXT AHI R4,10
BCT R3,NEXT
ST R4,RESULTThe loop runs five times and adds 10 each time, so RESULT ends at 50. The branch condition code values are the key to reading decisions: after a compare, code 0 is equal, 1 is low and 2 is high, and each branch mnemonic is a mask over those values. The post on CLC, CLI and BRC builds a record classifier from them.
A complete program: totals from a file
Put the pieces together. The program reads a customer file, adds up the balances of one department in packed decimal, edits the total with commas and a floating dollar sign and writes it to the job log. The record layout is a DSECT, the I/O is QSAM, the sum is PACK and AP, and the editing is EDMK:
TOTALS CSECT
TOTALS AMODE 31
TOTALS RMODE ANY
YREGS
STM R14,R12,12(R13)
LR R12,R15
USING TOTALS,R12
LA R2,SAVE
ST R13,4(,R2)
ST R2,8(,R13)
LR R13,R2
OPEN (INDCB,INPUT)
LTR R15,R15
BNZ BADOPEN
ZAP TOTAL,=P'0'
LA R5,REC
USING CUSTREC,R5
LOOP GET INDCB,REC
CLC CUSTDEPT,=C'ACCT'
BNE LOOP
PACK PKBAL,CUSTBAL
AP TOTAL,PKBAL
B LOOP
EOF CLOSE (INDCB)
MVC OUT,PATTERN
LA R1,OUT+1
EDMK OUT,TOTAL
BCTR R1,0
MVI 0(R1),C'$'
MVC MSGLIST+4+11(L'OUT),OUT
WTO MF=(E,MSGLIST)
SLR R2,R2
B EXIT
BADOPEN WTO 'TOTALS: INPUT FILE WILL NOT OPEN',ROUTCDE=11
LA R2,12
EXIT ST R2,RCODE
L R13,4(,R13)
LM R14,R12,12(R13)
L R15,RCODE
BR R14
SAVE DC 18F'0'
RCODE DS F
REC DS CL80
TOTAL DS PL5
PKBAL DS PL5
PATTERN DC X'40206B2020206B2020214B2020'
OUT DS CL13
MSGLIST WTO 'ACCT TOTAL .............',ROUTCDE=11,MF=L
INDCB DCB DDNAME=INDD,DSORG=PS,MACRF=GM,EODAD=EOF,RECFM=FB,LRECL=80
LTORG
CUSTREC DSECT
CUSTNO DS CL6
CUSTNAME DS CL20
CUSTDEPT DS CL4
CUSTBAL DS ZL8
END TOTALSWalk it from the top. The entry sequence saves the caller's registers and chains a static save area, which the GET and OPEN macros need because they call the access method. OPEN returns zero in register 15 if the file opened. ZAP TOTAL,=P'0' initializes the packed total correctly, since zero bytes would have an invalid sign. LA R5,REC and USING CUSTREC,R5 map the DSECT over the input buffer, so CUSTDEPT and CUSTBAL are real field names. In the loop, GET copies the next record into REC, and at end of file the access method branches to EOF. Records whose department is not ACCT loop back. For the others, PACK converts the zoned balance to packed and AP adds it.
At EOF the program closes the file and formats the answer. PATTERN is the edit pattern of the editing post: a fill blank, one digit, a comma, three digits, a comma, three digits with a significance starter, a point and two digits. EDMK edits the total into OUT and leaves the address of the first significant digit in register 1, which BCTR backs up by one and MVI fills with a dollar sign. MVC MSGLIST+4+11(L'OUT),OUT copies the 13 bytes into the message list at offset 4, past the list header, plus 11 characters of fixed text, and WTO MF=(E,MSGLIST) issues it. The return code is built in register 2 and parked in storage, because LM reloads the registers. LTORG places the literals, and the DSECT goes last, after the code and data.
The job assembles, link-edits and runs it in one go:
//TOTALS JOB (ACCT),'ASM LINK GO',CLASS=A,MSGCLASS=X
//ASM EXEC PGM=ASMA90,PARM='OBJECT,NODECK,LIST(133)',REGION=0M
//SYSLIB DD DISP=SHR,DSN=SYS1.MACLIB
// DD DISP=SHR,DSN=SYS1.MODGEN
//SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(5,5))
//SYSPRINT DD SYSOUT=*
//SYSLIN DD DSN=&&OBJ,DISP=(NEW,PASS),UNIT=SYSDA,
// SPACE=(TRK,(5,5)),DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)
//SYSIN DD DISP=SHR,DSN=USERID.ASM.SRC(TOTALS)
//LKED EXEC PGM=IEWL,PARM='LIST,MAP,XREF',COND=(8,LT,ASM)
//SYSLIN DD DSN=&&OBJ,DISP=(OLD,DELETE)
//SYSLMOD DD DSN=&&LOADSET(TOTALS),DISP=(NEW,PASS),UNIT=SYSDA,
// SPACE=(CYL,(1,1,1)),DCB=(RECFM=U,BLKSIZE=32760)
//SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(2,2))
//SYSPRINT DD SYSOUT=*
//GO EXEC PGM=*.LKED.SYSLMOD,COND=((8,LT,ASM),(8,LT,LKED))
//INDD DD DISP=SHR,DSN=USERID.DEMO.CUSTOMER
//SYSUDUMP DD SYSOUT=*With a customer file of four records, three in department ACCT with balances of 250000, 480015 and 5000 cents, and one in SALE, the job log shows:
ACCT TOTAL $7,350.15
IEF142I USERID GO - STEP WAS EXECUTED - COND CODE 0000The sum of the three balances is 735,015 cents, which the pattern prints as 7,350.15 with the dollar sign floating up against the first digit. This one program uses most of what the guide covers, and each piece has its own post if the explanation above moved too fast.
Linkage: how programs call each other
A program that calls others, or is called, must follow the standard linkage. On entry register 1 points to a list of parameter addresses, register 13 to a save area the caller owns, register 14 holds the return address and register 15 the entry point. The callee saves the caller's registers in that save area, builds its own save area and chains the two with pointers at offsets 4 and 8, so a dump can walk the chain from the current program back to its callers. On exit it restores the registers and puts the return code in register 15. The CALL macro builds the parameter list and does the branch:
CALL ADDTWO,(NUM1,NUM2),VL
LTR R15,R15
BNZ FAILEDVL marks the last parameter address, so the callee can tell where the list ends. The post on standard linkage and save areas develops a main program and a subroutine in full. The same conventions let assembler programs call and be called by COBOL, PL/I and C, with COBOL parameters arriving by reference. In COBOL, CALL 'ADDNUM' USING A B C hands the assembler routine a list of three addresses, and PIC S9(9) COMP is a fullword F. Calling the other way, from assembler into COBOL, needs the Language Environment, which is initialized on the first call, and that is expensive if repeated. The post on calling COBOL from HLASM and the reverse shows both directions with Enterprise COBOL 6.4.
Macros, system and your own
A macro is a statement that expands into many. System macros are the interface to z/OS services: WTO writes a console message, OPEN, GET, PUT and CLOSE do I/O, STORAGE obtains memory, LOAD and DELETE bring programs in and out, ESTAEX sets up recovery. They expand into parameter lists and supervisor calls, and change registers 0, 1, 14 and 15, so values you need across them belong in registers 2 to 12 or in storage. With PRINT GEN in effect, the listing shows each expansion with a plus sign, which is the quickest way to learn what a macro does.
You can write your own with MACRO, a prototype statement, model statements and MEND. A prototype lists symbolic parameters, which start with an ampersand and are either positional or keyword operands with defaults:
MACRO
&LABEL MSGOUT &TEXT,&RC=0
&LABEL WTO '&TEXT',ROUTCDE=11
LA R15,&RC
MENDInside a macro, a conditional assembly language gives you variables with SETA, SETB and SETC, branching with AIF and AGO, and sequence symbols that begin with a period. That is enough to generate tables, check arguments and report mistakes with MNOTE at assembly time. The post on writing your own macros builds a table generator and a self-checking macro. One rule keeps macros readable: use them to hide conventions, such as an entry sequence or a message format, and not to hide logic. A macro that expands to thirty statements at every call is usually a subroutine in disguise.
Structuring storage with DSECTs
A record or a control block is a layout of fields at fixed offsets. A DSECT names that layout without allocating storage: each DS defines a name whose value is an offset, and USING applies the layout to whatever a register points at. The program above used it for the customer record. System control blocks work the same way through mapping macros, for example CVT DSECT=YES for the communications vector table, which you reach through the pointer at absolute address 16, and IHAPSA, IHAASCB and IKJTCB for other blocks. Use the macro and the field names, never an offset from a book, because the field names survive a release that moves things. The post on mapping storage layouts with DSECTs covers overlays with ORG, labeled USING for two views of one layout, and the length attribute L' that keeps copies and compares in step with the definition.
When a program outgrows one base register, which covers 4,096 bytes, you list several on one USING, load each with the next window, and let the assembler choose the register that gives a valid displacement. The post on multiple base registers and labeled USING shows the setup, and the one on baseless code shows how relative instructions remove the problem.
Assembling, link-editing and reading the listing
The assembler's options go on the PARM of the ASMA90 step. OBJECT writes the object module, LIST(133) produces the listing in the usual line width, XREF(SHORT) adds a cross-reference of symbols, USING(MAP) shows which base register each reference used and RENT checks for violations of reentrancy. The listing has sections in a fixed order, and learning to read them is half of debugging.
The external symbol dictionary lists control sections and external references. The main body shows, for each statement, the location counter, the object code in hexadecimal and the source. Below it come the cross-reference of symbols, with the statements that define and use each one, the USING map, and the diagnostics with their ASMA message numbers and severities. A return code of 0 means no flags, 4 a warning, 8 an error that stops a clean object, 12 a severe error and 16 a terminating one.
Loc Object Code Addr1 Addr2 Stmt Source Statement
000000 5 TOTALS CSECT
000000 90EC D00C 0000C 10 STM R14,R12,12(R13)
000004 18CF 11 LR R12,R15
R:C 000000 USING TOTALS,R12
000006 41200 C0A8 000A8 13 LA R2,SAVEThe columns are the location counter, the object code, the resolved operand addresses and the statement number, with the source on the right. The line R:C 000000 is a USING taking effect, naming register 12 as the base. The object code of LR R12,R15 is 18CF, which matches the hand decoding in the post on instruction formats. When an instruction fails at run time, the offset in the dump is a location counter value in this listing, and the object code beside it tells you which instruction it was. Keep the listing with the load module, because the dump is unreadable without it.
Link-editing is done by the binder, PGM=IEWL, with the object module on SYSLIN and the load library member on SYSLMOD. The options LIST, MAP and XREF give the link-edit map, and RENT marks the module reentrant. Run the result with PGM=name and a STEPLIB, or with PGM=*.LKED.SYSLMOD in the same job. The post on assembling your first program walks the whole path.
Reading a dump
A program that fails does so with a completion code, and the system prints a symptom summary in the job log before it writes the dump:
IEA995I SYMPTOM DUMP OUTPUT
SYSTEM COMPLETION CODE=0C7 REASON CODE=00000007
PSW AT TIME OF ERROR 078D1000 80006A3C ILC 4 INTC 07
ACTIVE LOAD MODULE ADDRESS=00006A00 OFFSET=0000003C
NAME=TOTALSThe numbers are an example. Read it like this: the completion code 0C7 is a data exception, which means a packed or decimal operand was invalid. The PSW's second word is the address of the next instruction, 6A3C, and the instruction length code, ILC 4, says the failing instruction was four bytes long, so it started at 6A38, offset 38 in the module, since the module loaded at 6A00. Find offset 000038 in the listing, and the source line is the AP that added a bad field. Then compare the registers in the dump with what the instruction used.
The common completion codes are worth memorizing:
| Code | Name | Typical cause |
|---|---|---|
0C1 | operation exception | branching into data or an unassembled area, often a bad return address |
0C4 | protection or addressing exception | a bad base register, a wrong address, a store into protected storage |
0C5 | addressing exception | referencing storage that does not exist |
0C6 | specification exception | an instruction operand on a wrong boundary, such as a register pair |
0C7 | data exception | invalid packed or zoned data, an uninitialized COMP-3 field |
0CA | decimal overflow | a packed result too big for its field |
0CB | decimal divide | a quotient that does not fit |
806 | program not found | LOAD or PGM= named a module that is not in the libraries |
878 | storage not available | a STORAGE OBTAIN larger than the region allows |
B37, D37, E37 | out of space | a data set ran out of space on a write |
Many 0C4 and 0C1 failures trace back to the same cause, a program that overwrote a register it should have preserved, usually register 13 or 14, and then returned to a wrong place. Check the save area chain first: the dump shows each program's saved registers, and a break in the chain, a back pointer that does not point to a plausible save area, marks the culprit.
Working storage that belongs to the call
A static save area and static counters make a program work once. Real programs obtain their working storage at run time so each call has its own, and so the code can be shared. STORAGE OBTAIN,LENGTH=n,LOC=ANY,ADDR=(R10) returns the address of n bytes in register 10 and STORAGE RELEASE gives them back. Clear the area yourself, with MVCL when it is longer than 256 bytes, since it is not guaranteed to be zero. COND=YES returns a nonzero code in register 15 instead of the 878 abend when storage runs out. The post on STORAGE OBTAIN and RELEASE covers location, subpools and failure.
That obtained area is where the save area, counters and lists live in a reentrant program. Reentrant means the program's own storage never changes after load, so one copy can serve many tasks at once. Every variable moves into a DSECT that maps the obtained area, and macros that build parameter lists use the list form, MF=L, as a read-only model, with a copy in the work area executed with MF=(E,...). The assembler's RENT option and the binder's RENT attribute help find and enforce the rule. The post on writing reentrant programs shows a full example.
Recovering from a failure
A program that holds resources needs a last chance to tidy up when it fails. ESTAEX establishes a task-level recovery routine. When the program abends, the system passes control to it with the address of the system diagnostic work area in register 1, mapped by IHASDWA, and the completion code in SDWACMPC. The routine can percolate, passing the failure along after its cleanup, or retry, resuming the program at an address it names with SETRP RC=4,RETADDR=...,FRESDWA=YES,RETREGS=YES,WKAREA=...:
ESTAEX RECOVER,CT,PARAM=ESTPARM
LTR R15,R15
BNZ NOESTAEXRetries need a guard, such as a count in the parameter area, because a retry that fails the same way loops. A recovery routine is for the failures you did not predict, since predictable ones, a bad packed field for example, are better caught before the arithmetic with a TRT against a table that marks non-digits. The post on ESTAEX recovery routines goes through the entry registers, the retry and the rules for keeping the routine small.
Fast scans and conversions with TR and TRT
Two instructions replace many loops. TR translates every byte of a field through a 256-byte table, which converts case or code pages in one instruction, and TRT scans for the first byte whose table entry is nonzero, returning its address in register 1 and its table entry in register 2. Build the tables with DC 256X'00' and ORG:
DELIMS DC 256X'00'
ORG DELIMS+C','
DC X'04'
ORG
TRT LINE,DELIMSThe same trick validates that a field holds only digits before it reaches PACK. The post on TR and TRT has the identity-table construction and the register results in detail.
Modern instructions and addressing
z/Architecture added instructions that make older habits optional. The relative branches J, BRC, BRAS and BRASL and the address load LARL find their targets from their own address, so a program can run with no base register and no 4 KB window. The relative load and store LRL, STRL, LGRL and STGRL reach static data the same way, with alignment rules. The long-displacement forms such as LY and STY carry a 20-bit signed displacement that reaches half a megabyte from a base. The post on baseless code works through a program with no USING, and the post on BALR, BASR and BRAS explains which branch-and-link instruction to choose.
The registers themselves are 64 bits wide, and the grande instructions use all of it. LG, STG, AG, AGR, STMG and LMG handle 64-bit values and addresses, LGF and LLGF widen a fullword by sign or zero extension, and SAM64 switches to 64-bit addressing for storage above the bar. A routine that changes the upper halves of registers must preserve them for its caller, which STMG and LMG do automatically and STM and LM do not. Add SYSSTATE ARCHLVL=2 so that macro expansions use instructions that are safe for the level you target. The post on the 64-bit instructions has an example with register values traced by hand.
Writing assembler that others can maintain
Assembler has no compiler to enforce structure, so the structure is up to you. Put a comment block at the top of every program that says what it does, its registers on entry and exit, its return codes and its storage use. Keep a register map in comments for any program over a screen long, listing which register is the base, the work area, the current record and so on. Use EQU for every constant that has a meaning, a record length or a code, and let the assembler compute lengths with L' and *-label rather than counting by hand. Prefer the relative branches, since they need no base and read like jumps. Name labels for what they mean, NEXTREC and BADOPEN, not L1 and L2. Keep each routine to one job and give it the standard linkage if anything else might call it. And keep the listing with the load module, because six months from now the only way to read that dump is to have it.
Test the way you would test a compiled program, with one addition. Assemble with a clean listing, with return code zero and no warnings you cannot explain. Run it first against small inputs and read the output against a hand calculation, since there is no type checker to help. Then run the failure paths, an empty input, a record that is too short and a field with bad data, and confirm that the program fails cleanly. If it must run in a shared environment, test the reentrant form with the RENT option on and the module link-edited reentrant.
Learning path
Learn in the order the ladder lays out. Start with writing and assembling a first program, so you have the build and run loop. Learn the registers, PSW and instruction formats, then base registers and USING, because every later error message assumes them. Move to linkage and save areas, and then to the data instructions: register moves, compares and branches, packed decimal and editing. Then do I/O with DCB, GET and PUT, and map records with DSECTs. After that come the topics that make programs production ready: dynamic storage, reentrancy, recovery and calling COBOL. Macros, relative addressing and the 64-bit instructions come last, because you can work for years without them and they make more sense once the rest is routine.
Use real tasks to anchor each step. Write a program that counts records in a file. Extend it to total a field with packed decimal. Print the total with ED. Make it reentrant. Wrap a recovery routine around the arithmetic and drive it with bad data. Each step uses what the earlier one built, and the failures you meet on the way are the best teachers.
Debugging habits that save hours
Most assembler bugs fall into five families, and knowing them turns a dump into a short search. The first is a register that held the wrong value: a base register overwritten by a macro, a pointer never loaded, a counter that was cleared by a called routine. The second is a displacement or length that is off by one, which copies a byte too many or too few and corrupts the field that follows. The third is a condition code tested after an instruction that did not set it, or after one that set it differently from what the branch expects. The fourth is data that is not what the instruction assumes, most often a packed field with an invalid sign or digit. The fifth is the linkage itself: a missing save area chain, a return code set before the registers are restored, or a parameter list in the wrong order.
Work from the evidence in the dump, in order. Read the completion code and the PSW, find the failing instruction through the listing, and decode its operands. Read the registers it used and compare each with what the code assumed. If a base register is wrong, find the last instruction that changed it by searching the listing for stores into that register. If the data is wrong, find where the field was last written. Do not guess and patch: a change you cannot explain is a second bug waiting for its turn. When the problem is hard to see, add WTO messages at the key points, with the values converted to printable form, and run the program on a small input. Remove them when you are done, or make them conditional on a switch, so production output stays quiet.
Two tools help beyond the listing. The assembler's cross-reference shows every statement that touches a symbol, which finds the stray store into a field. And the instruction trace and storage display functions of your debugger, such as IBM Z Open Debugger or the interactive facilities your installation provides, let you step through the program and watch registers change, which is the fastest way to learn what a new instruction does.
Who this does not fit
Assembler is the wrong choice for most application programming. A COBOL program that does the same work is easier to write, easier to read and easier to hand to the next person, and the compiler's code is competitive for almost all business workloads. If the reason is speed, measure first: a profile usually points at I/O, a database call or an algorithm, and none of those is fixed by assembler. If you need portability, assembler is the least portable choice there is, since it is tied to the instruction set and to z/OS services. If the team has no one else who reads it, a routine only you understand is a liability, and a short, well-commented one that calls a documented service is better than a clever one. If the work needs access to services with no higher-level interface, such as an authorized system call, a cross-memory service or a system exit, then assembler is the right tool, with C as the main alternative for some of it. And if your goal is only to read dumps or compiler listings, you do not need to write much assembler at all. Reading the instruction formats, the registers and the PSW, and following the save area chain, is the skill, and the first half of this guide covers it.


