Category: IBM Mainframe Assembler

Videos and word documents that cover how to program in IBM mainframe assembler language.

Two Great Assembler TextsTwo Great Assembler Texts

My all-time favorite IBM mainframe assembler text is Peter Abel’s Programming Assembler Language:  IBM 370 series architecture and assembly language.

I first taught assembler using a an early version of this book in 1980.  Our department faithfully used this book for twenty plus years, even after it went out of print.  (Perhaps a record for a continuously used college text.)  It has good descriptions, few mistakes and lots of good examples.  You can still buy used copies on the Web for a few dollars (a bargain), but if you decide to buy one, be sure you get the mainframe version – Professor Abel also wrote a PC assembler book.

  Dr. Edward Bosworth, a colleague in my department, wrote his own assembler textbook, partly based on Abel’s material.  It’s well written, very complete, and includes some terrific historical material.   An attractive feature of his book is that it’s available free on the web:  http://www.edwardbosworth.com/My3121Textbook/MyText3121_AFrontMatter_V03.htm

Give it a try, it’s a good read.

And, in case you haven’t already stumbled over it, you can also find my own material here:  http://csc.columbusstate.edu/woolbright/WOOLBRIG.htm 

The Best of All Possible WorldsThe Best of All Possible Worlds

In the best of all possible worlds, each assembler program we write would require only a single base register. Alas, programs grow larger over time, record sizes are huge, and data areas expand. Our programs sometimes require two or more base registers. I’ve added a video lesson that highlights my way of declaring and loading extra base registers. You can watch it here.

Instruction of the Day: LAInstruction of the Day: LA

You’ll need to master this instruction if you want to be an expert assembler programmer.  LA can be used to create an address (think pointer if you’re a C programmer) and place it in a register for further processing, or used to address other items in memory directly.  It is often used to load multiple base registers for larger programs.  Here’s the video that discusses it.

Instruction of the Day: EDInstruction of the Day: ED

If you learn one instruction a day, you will know a workable subset of instructions in two months – not bad for a technologically challenging language like assembler.  Here is a short video that will help you master the ED instruction.  Learn to convert data from packed decimal to a printable character format.  Discover the two common mistakes that beginners usually make.  Watch the results in VisibleZ.

Instruction of the Day: PACKInstruction of the Day: PACK

I just posted the first of many short instructional videos that cover specific mainframe instructions here. The link to it is on my assembler resources page here. The first video covers the PACK instruction. I’ll try to post one video each day, five days a week, so join in and learn assembly language one instruction at a time. Each video will cover instruction semantics, examples of using the instruction, and demo executions of the instruction in VisibleZ. The notes for each instruction are included in a Powerpoint document. You can already find some introductory assembler videos on the resources page. If you have an instruction you would like to hear about soon, drop me a line and let me know. I’ll try to build a video for it as soon as possible.

Making PlansMaking Plans

I’ll be teaching an assembler class again in spring semester at Columbus State University, so lately I’ve been thinking about what I want to do with the class.  I’ll be teaching IBM mainframe assembler again, and I’m planning to record Camtasia lectures for the entire class.  I’ll make them available on the VisibleZ website as they become available.  Most of the lectures will appear in December during the winter break.  The rest will appear as the semester progresses.  I have a few lectures already recorded and available.  My plans are to make the lectures shorter, perhaps 15 minutes or less, to promote their use. I’ll also be using VisibleZ, which has completely changed my approach to teaching assembler.  Seeing is believing, so if you haven’t tried it, now is the time.  I can’t think of a better way to get up to speed on IBM assembler concepts than to load an object program into VisibleZ and watch it execute one instruction at a time.  

A Little Assembler MagicA Little Assembler Magic

In most languages, if you need to swap the contents of two variables, say X and Y, it normally requires a third temporary location:

 Temp = X;

 X = Y;

Y = Temp;

But in assembly language, if the two variables are stored in registers (or even in memory), you can swap them without using a third register (or variable).  Here’s the code that uses an exclusive or to swap the values:

XR    R5,R3

XR    R3,R5

XR    R5,R3

Try it yourself with some real values and you can almost see the bits exchanging places.  Presto, Changeo!  A little assembler magic. 

The Secret of PUTs and GETsThe Secret of PUTs and GETs

PUTs and GETs are easy, right? PUT FILEOUT,RECOUT adds the contents of RECOUT as a new record in FILEOUT. GET FILEIN,RECIN reads a record off FILEIN and stores it in RECIN. Simple, yes? But there is a little known fact about the PUT and GET macros that you might find interesting. It really doesn’t matter which macro you choose to code (PUT or GET) because both macros generate identical code. Hard to believe, but these macros are interchangeable. You can see this in the example below. Lines 90-94 were generated by a PUT macro and lines 97-01 were generated by a GET macro. See for yourself: Both macros generate the same code.
87 PRINT ON,NODATA,GEN
88 PUT FILEIN,RECORDIN
90+ LA 1,FILEIN
91+ LA 0,RECORDIN
92+ SLR 15,15
93+ ICM 15,7,49(1)
94+ BALR 14,15
95 GET FILEIN,RECORDIN
97+ LA 1,FILEIN
98+ LA 0,RECORDIN
99+ SLR 15,15
00+ ICM 15,7,49(1)
01+ BALR 14,15
02 PRINT ON,NODATA,NOGEN
So how does the machine distinguish when you want to read a record, and when you want to write a record if PUT and GET are equivalent? The answer lies in the OPEN macro which does all the heavy lifting. It’s in the OPEN macro that you indicate the type of operation you intend to invoke on the file: OPEN (PRINTER,(OUTPUT)) or OPEN (FILEIN,(INPUT)).
A little knowledge is sometimes a dangerous thing, so while PUT and GET may generate the same code, I don’t recommend coding PUT when you want to read a file, or GET when you want to write to one. That would be unnecessarily confusing to the programmers coming behind you. After all, one of those programmers is likely to be you.