COBOLSTACK.COM
//CS170  EXEC PGM=COURSE,PARM='CS170'

Developer track · Elective · self-paced ~28h (5–7 weeks at 5h/week) · prerequisite: CS105 or CS110, and CS120

HLASM: Assembler for Programmers Who Know a Little COBOL

The layer underneath COBOL, taught as craft rather than trivia. You already know that a packed field is 12 34 5C — here you write the AP that adds it, in a module you assemble, link and run yourself. Sixteen registers, one base register, a save area, and a listing that prints every byte of object code next to the statement that produced it. Twelve sessions, every one ending at a machine-checked lab, until you can read an exit, a listing and a dump without flinching.

Self-paced available Cohort

//SYLLABUS DD DISP=SHR

Syllabus

Every session ends in a lab on your own environment. Labs are machine-checked against expected outputs — you and your L&D team always know exactly where you stand.

Why assembler still exists

What the machine actually executes, and why a language this old is still in every estate: vendor exits the product gave you no other way to write, the last mile COBOL cannot express, and — the reason most developers meet it — because one day you must read it. A real module, a real listing and a real dump shown in the first ten minutes so you know exactly what this course is buying you. The honest scope: you will not write an operating system. You will write modules that genuinely assemble and run, and you will stop being blind at the byte level.

LAB Read three real assembler modules from the estate cold and answer the harness: which one writes a file, which one is entered with a parameter list, where does each one return. From reading alone — you write no code this session.

The machine model

The whole computer on one screen. Sixteen 32-bit general registers, and the fact that nothing is typed — a register holds whatever you last put in it, and only the instruction you choose decides whether that is a number, a character or an address. Main storage as one flat byte-addressed array. The PSW, and the instruction address living inside it. The condition code: two bits, set by the last interesting instruction, read by every branch. Then the idea that explains assembler’s whole shape — base + displacement addressing, why a storage operand is written D(B) and not an address, and the 4096-byte reach of a single base register.

LAB Hand-trace a supplied eight-instruction sequence: register contents after each instruction and the condition code at the end. Then run it and diff your table against the machine’s. Your trace must match before the session closes.

Bytes, hex, and the number formats you have already met

Binary, hex, and two’s complement — why −1 is FFFFFFFF, and what that does to a compare. EBCDIC as a table you can finally read: C1 is A, F1 is 1, 40 is a blank. Then the three numeric formats from COBOL, re-met as storage you control rather than storage the compiler picked: zoned decimal (F1F2F3 — the same bytes CS105 showed you), packed decimal with its sign nibble, and the fullword binary you know as COMP. Alignment, and why a fullword wants to sit on a multiple of four.

LAB Decode eight hex dumps by hand — character, zoned, packed and signed binary — then define the same values with DC and prove every reading byte-for-byte in the hex view. Wrong sign nibble, wrong answer: the harness checks all eight.

Your first module, and the assemble–link–run deck

The statement format — label, operation, operands, comment — and the columns that still matter, including the continuation rules that bite everyone once. Your first working instruction set: L, ST, LR, LA, A, S, SR. The RR and RX instruction formats, and the object bytes each one produces. Then the pipeline for real: ASMA90 takes your SYSIN and writes a load module to SYSLMOD, a second job step runs it with STEPLIB, and the value you leave in R15 becomes the step’s return code. Where the listing lands, and how to read an ASMA diagnostic.

LAB Assemble, link and run a module that loads two fullwords, adds them, stores the result and returns RC 0. Then break it three ways — a typo’d mnemonic, an undefined symbol, a bad operand — and fix each from the diagnostic alone. The harness checks the stored result and the step RC.

Base registers, USING, and addressability

The session that makes assembler click. Why a module cannot simply name a storage location; how BALR 12,0 followed by USING *,12 hands the assembler a register it can measure displacements from; and what DROP withdraws. Reading your own object code to see the base and displacement the assembler chose on your behalf. The classic beginner failure — an address that is not addressable — provoked on purpose, and then the second failure nobody warns you about: a CSECT that grows past 4096 bytes and needs a second base register.

LAB Fix two supplied modules: one whose USING is missing, one whose CSECT has outgrown a single base register. Both must assemble clean and run. The harness reads the resolved displacements out of your listing, not just your return code.

Comparing, branching, and loops

There is no IF here, and no PERFORM — there is a condition code and a four-bit mask. C, CR, CLC and CLI, and precisely what each one sets. BC with its mask, and the extended mnemonics (BE, BNE, BH, BL, B) that are the very same instruction wearing a readable name. Then building, out of compares and branches, the three structures you already think in: the decision, the counted loop with BCT, and the walk along a table with LA stepping an address. Signed versus logical comparison — and the bug that lives in the difference.

LAB Write a loop that walks a table of fullwords, accumulates a total, and counts the entries above a threshold — BCT for the count, the correct compare for signed data. Totals checked; the harness also feeds your table a negative value to prove you chose a signed compare.

Moving and testing storage

The SS-format instructions that do the work of a COBOL MOVE: MVC and MVI, with the length built into the instruction — and why that length is fixed at assembly time, the single fact behind most assembler surprises. CLC and CLI for comparing storage against storage and against a constant. The overlapping MVC and its propagation trick, which fills a whole field from one byte: shown deliberately, because you will meet it in real code and you would otherwise misread it. Then building a print line field by field.

LAB Build an 80-byte print line from separate fields — blank it, place the pieces, insert the separators — and match the expected image byte-for-byte, every trailing blank included. One required exercise can only be solved with the MVC propagation idiom.

Packed decimal arithmetic and ED

Money, in a language whose hardware does decimal arithmetic directly. PACK and UNPK to cross between zoned and packed; ZAP, AP, SP, MP, DP and CP, each with the field-length rules that decide whether it works or faults; CVB and CVD to cross between packed and binary. Then ED, the instruction that repays the whole session: an edit pattern is a tiny program written in data — digit selectors, fill character, significance start, the floating sign — and it is exactly what a COBOL edited PICTURE compiles down to. Finally the S0C7 you met in CS105, caused here on purpose with an invalid sign nibble and then read out of storage, byte by byte, until the bad nibble is on screen.

LAB Compute a fee with packed arithmetic and format it with an ED pattern until it reads as money. Then provoke an S0C7 and report which field and which instruction faulted. Cents checked exactly; your diagnosis matched against the seeded fault.

Linkage: save areas, entry and exit

The convention that lets your module be called by anything and call anything in turn. R1 points at the parameter list, R13 at a save area, R14 holds the return address, R15 carries the entry point in and the return code out. STM 14,12,12(13) and its matching LM, read register by register rather than copied from a book. Chaining your own save area forward and back — and what a broken chain does to a dump, which is the reason anyone cares. Then calling a second module and receiving a parameter by address.

LAB Split your program: the fee calculation moves into a separately assembled module entered with a parameter list. Both assemble, link and run, and the output must not change by a single byte. The harness verifies the save-area chain is intact at entry to the callee.

DSECTs, records, and real file I/O

The DSECT is assembler’s copybook: a map that occupies no storage, based on a register with USING, so one layout can be laid over a buffer, a parameter list or a record — the same idea as COBOL’s LINKAGE SECTION, which is why it will feel familiar. DC and DS in earnest (C, X, F, H, P, Z, A), and the difference that costs people afternoons: DC defines a value, DS only reserves space — and space you never initialised is not zero, so handing it to packed arithmetic is the S0C7 from Session 8 arriving on schedule. EQU for names instead of magic numbers, and literals collected by LTORG. Then real I/O: a DCB, OPEN, GET, PUT, CLOSE, and the DD statement that binds the whole thing — the session where your module finally writes a dataset an operator can browse.

LAB Map the account record with a DSECT, read its fields through that map, and write formatted records to a real output dataset. Record count, LRECL and the bytes of every record checked against the harness’s own image.

Reading listings and dumps

The two skills that make you useful on your first day in an estate. First the assembler listing, column by column — LOC, OBJECT CODE, STMT, SOURCE — plus the symbol cross-reference and the literal pool, and the thing the LOC column exists for: turning an offset back into the statement that failed. Then diagnosis as a method rather than a hunch: the completion code tells you what kind of failure, the listing tells you where, and a SNAP you placed yourself tells you why — real dump-format hex over the field you suspect, taken on demand instead of waited for. S0C7 and S0C4 worked end to end that way. Closing with the professional habits: a return code that means something, and WTO when a message is what the operator needs at 03:00.

LAB Four broken modules, four different failures: an S0C7, an S0C4, a bad displacement and a broken save-area chain. Diagnose each from the listing and your own SNAP output, state the root cause in one line, and fix it. Three of four required to progress.

Capstone: a complete assembler module

Everything, once, as one module: read the input records, map each with a DSECT, validate, compute with packed arithmetic, format with ED, write the detail records and a total line, set the return code by outcome, and return cleanly through the save-area chain. It runs against data you have never seen — including a record engineered to fault if your validation is careless. Then the honest map of what lies beyond this course: macros and conditional assembly, CICS assembler programs, the vendor exits — and why the estate will now hand them to you.

LAB Capstone run: output dataset byte-identical to the harness’s expected image, control total correct, return-code contract honoured, listing clean. The certificate is issued from this run.

//SKILLS  DD DSN=AFTER.THIS.COURSE

After this course, you can

//CERT    DD DSN=CS170.CERTIFICATE,DISP=(NEW,CATLG)

How the certificate is earned

CobolStack Certificate — HLASM Assembler (CS170) is issued from the lab harness’s own record of your runs — not from attendance. To earn it you must clear every gate below:

The certificate attests that you can read, write, assemble, link, run and debug a complete assembler module using the standard linkage convention, packed-decimal arithmetic and DSECT-mapped records — the byte-level literacy an estate needs when someone has to open an exit, diagnose a dump, or maintain the assembler nobody else will touch.

The environment

Your seat is a private, full z/OS-compatible environment with a real HLASM assembler (ASMA90), an S/390 instruction interpreter, the assemble–link–run pipeline, hex views, dumps and the graded lab harness in the browser — nothing to install, snapshot and reset per exercise. By the end of the course the lab harness will have verified: one assembler module grown across nine checkpoints into a complete record-processing program — DSECT-mapped input, packed arithmetic, ED-formatted money, records written to a real dataset at RC 0 — plus four abends diagnosed from the listing and your own storage displays.