Learn You a COBOL for Great Good

The title is a reference to one of my favorite programming language instruction texts: Learn You a Haskell for Great Good. Funny, well-written and instructive. If you want to learn a functional language, Haskell is a fine choice. I still like writing in Scheme – another functional language that’s almost as old as Cobol.

But today’s topic is Cobol, which has been in the news lately, and which has a few programmers dusting off their old textbooks and manuals.  If you want to learn Cobol or brush up on your old Cobol skills, I might be able to help. I developed an online class a few years ago to use for corporate training. Now I’ve decided to publish it for general use.

You can find it here: IBM Enterprise Cobol and as a link at the top of the home page. It was built with the idea of taking a beginner and turning them into a corporate programmer. If you have some mainframe skills already, you can skip some of the beginning lessons.

The course is divided into 5 units, and if you push hard, it’s possible to get through a unit each day – a week of corporate training.  The course comes with an extensive collection of slides – 299 in all.  There are 15 programming problems that you will need to tackle and complete if you are really wanting to learn something.

You can help me by reporting any problems you have with the site or with the material.

So, … I hope this will help you learn a Cobol for great good!

4 Comments

Filed under IBM Enterprise Cobol, IBM Mainframe Assembler

Introduction to Macros and Conditional Assembly

In the Video Course for IBM Assembler section, I’ve added an introductory lesson on Conditional Assembly and Macro Processing. If you haven’t written macros or want to learn something about conditional assembly instructions, this guide will get you started. There’s also a link to the Powerpoint that goes along with the video.

Leave a comment

Filed under IBM Mainframe Assembler

What you can learn from the Cobol compiler about Assembly language

It can be fun to take a look at the assembly language listing of a Cobol program. Geeky, admittedly, but still fun. If you have never given the listings much thought, take a look at this video. You might be surprised what the Cobol compiler gets up to, and what you can learn about Cobol and assembler. In this video I examine whether to COMPUTE or not to COMPUTE, whether to PERFORM or to PERFORM THRU, and what happens when you tell the optimizer to give it the old college try.

1 Comment

Filed under IBM Mainframe Assembler

It’s worse than he thought

Cobol has been in the news lately since the NJ governor asked for help with some legacy systems.  Perhaps someone should tell him it’s worse than he thought – he’s going to need some assembler programmers, too. 🙂

Some of the recent discussion of Cobol by people who should know better is amusing if it weren’t also disappointing.  You would think that Cobol died in the 1970s.  The fact is, IBM’s Cobol compiler is quite sophisticated, as is the language.  This isn’t your father’s or mother’s Cobol. It is a truly modern language, even object-oriented if you want it to be. On the other hand, writing business systems in Java, C, Python, Ruby, etc.  represents a challenge I would not like to tackle (even though I love those languages).  In many ways those languages are ill-suited to the task – for example, just doing business arithmetic in Java requires some really ugly code.

But what do I know? I still think assembler is fun to write.

One thing’s for sure: It will be fun to hear the forensics of what happened with the governor’s legacy systems. I’m guessing it has little to do with any shortcomings in Cobol.

3 Comments

Filed under IBM Mainframe Assembler

Channeling John Ehrman

In the last post I suggested we take the challenge that John Ehrman posed in problem 41.7.1 of his well-known and used assembler book:

Programming Problem 41.3.(3)+ Write a program with a program interruption exit that generates each of the 15 possible interruption types in turn. For each interruption, generate a message describing the interruption type and the address of the interrupted instruction. Then, return to the mainline program to generate the next interruption.

David Staudacher contributed a number of interesting ways to abend, but I especially liked BCTR R15,R15 for a protection exception. Melvyn Maltz had some interesting comments about the whole issue and suggested he gets S0C5s whenever he uses a bad index into a branch table. You can see all their contributions in the comments on the last article.

I was surprised (after posting) to discover that John himself had already weighed in on this challenge in the Solutions part of his book. Here is what he published (page 1275 of his book):

41.7.1. Some possible but unverified instruction sequences are:

(01)  DC H’0′ Invalid operation

(02)   LPSW 0,8(0,0) Privileged operation

(03)  EX 0,* Execute

(04)  MVI 0,0 Protection

(05)  LGHI 1,-1

IC 1,0(,1) Addressing

(06)   DC X’1D11′ DR 1,1: Specification

(07)  AP *,* Decimal Data

(08)  LA 1,1

SLA 1,33 Fixed-point overflow

(09)   SRDL 0,63

DR 0,0 Fixed-point divide

(0A)   AP A,A Decimal Overflow

A DC P’6′

(0B)   DP A,=P’0′ Decimal Divide

(0C)   LE 0,=E’1E72′ Exponent overflow

MER 0,0

(0D)  LE 0,=E’1E-72′ Exponent underflow

MER 0,0

(0E) LE 0,=X’41000001′ Significance

SU 0,=X’41000001′

(0F)  LE 0,=E’1′ Floating-pointdivide

D 0,=E’0′

I tried running the code above and found an assembly error on (02). John said the code suggestions were unverified! Still he was on the right track. LPSW is a type S instruction and expects a simple base/displacement address, so LPSW 0(8) will generate the error he intended.

You can also get away with SLA 1,32 on (08), but that’s nit-picking.

The only problem in the list was his suggestion for (05) which generated an S0C6 for me instead of the S0C5 we require.

So how do we get a S0C5 exception to occur? I’ve tried a number of bad branches – protection errors every one. After reading the Principles of Operation, I’m wondering if a garden-variety programmer can easily get a S0C5? I hope one of you will prove me wrong. Send me the code that generates a S0C5!

2 Comments

Filed under IBM Mainframe Assembler

Help Me Write The Worst Program Ever

I never got to meet John Erhman but we corresponded a little.  He was kind enough to get me included on the program at a Share conference in Anaheim.  John wrote an excellent Assembler reference titled  Assembler Language Programming for IBM z System Servers . Even a seasoned assembler programmer can learn a lot from this book – it’s packed with many interesting assembler goodies. I keep a link to it nearby and you should, too. I was browsing through it today and came across a suggestion he had for a program to write:

Programming Problem 41.3.(3)+ Write a program with a program interruption exit that generates each of the 15 possible interruption types in turn. For each interruption, generate a message describing the interruption type and the address of the interrupted instruction. Then, return to the mainline program to generate the next interruption.

 

The program suggestion comes after a section of the book that covers how to handle program interruptions using ESPIE. It wasn’t too hard to get a basic version of the program going. You do have to write some “bad” code to generate the 15 possible program interruptions. As I began to write this code, it struck me as funny that this would be the worst program ever. That’s when I thought it would be fun to enlist your help. Many of the interruptions are easy to generate – we’ve all sinned. But I did scratch my head on how to generate a S0C5. I can’t remember ever getting that interruption, but then my memory isn’t as good as it used to be.

Here’s how you can help: If you have a favorite way to generate one of the 15 possible program interrupts in just a few lines (the fewer the better) send it in. I’ll pick the ones I like best and include them in my program and give you credit. The program will appear in a future post or article on recovering from program interrupts. The program I’m writing does have an input file (FILEIN) and an output file (FILEOUT). That might help you with some of the interrupts. Be sure to include the definitions of any fields you need. As a small tribute to John, we’ll commit every possible error. Help me write the worst program ever!

19 Comments

Filed under IBM Mainframe Assembler

Study Assembler On-line with Me at Marist University – Starting Fall

If you would like to pursue on-line assembler training with me starting Fall, 2019, check out the Marist University IDCP program here:  http://idcp.marist.edu/enterprisesystemseducation/zosprogramoverview.html

You can explore their main website here: http://idcp.marist.edu/

 

2 Comments

Filed under IBM Mainframe Assembler

Marist Assembler and z/OS Fall Training

I have been away from the website for quite a while, but I’m trying to get back to it again.  Over the past year, I’ve been busy writing a novel (mystery), and I also added a second grandson this year. And of course, there’s golf to play.

If you are looking for online assembler training or other z/OS training, you might consider the Marist College Institute for Data Center Professionals (IDCP) program.  The program starts in late August and there will be an online assembler course starting in December. I have taught the assembler course over the last few years.  They have also added a security certificate. Here is a link to the Marist site:  Marist IDCP

I cut the following graphic from their latest blurb which describes the programs they offer.

marist

 

Leave a comment

Filed under IBM Mainframe Assembler

Instruction of the Day: SPM

Are you catching all the overflows that occur when you perform packed decimal arithmetic? Not sure? Read about the Set Program Mask instruction (SPM) that controls how decimal overflows (as well as a few others) are handled inside your program. Learn all about it here.

1 Comment

Filed under IBM Mainframe Assembler

Instruction of the Day: CRB

Learn one new instruction today – Compare and Branch – CRB.  You can tighten your code just a bit with CRB, an instruction that combines a comparison operation on two registers with a branch operation – all in one line.  It comes with some extended mnemonics that make it easy to use.  Learn all about it here in the time it takes to finish a cup of coffee.

2 Comments

Filed under IBM Mainframe Assembler