Programming Assembler Language
on the IBM Mainframes:
An Introduction

Edward L. Bosworth, Ph.D.
TSYS Department of Computer Science

Columbus State University
4225 University Avenue
Columbus, GA
Copyright © 2009 by Edward L. Bosworth, Ph.D.


NOTE:                        The illustration above and many others in this text were taken from
                                   the IBM on–line archives, and is used by permission of IBM.


Table of Contents.


1.      Why Study Assembler Language?     PDF Version   HTML Version   MS-Word Version
         a)   Historic reasons by decade.
         b)   Relationship of high–level languages to assembler.
         c)   The idea of virtual machines and levels of interpretation.
         d)   Assembler language as the functional specification for the architecture.

2.      Structure of an IBM Mainframe Assembler Language Program
PDF Version   HTML Version   MS-Word Version
         Here, the idea is to get the students an early start in programming the mainframe.
         a)   Fixed formatting as a remnant of the card–based days.
               Emphasize the importance of no extra spaces in the instruction.
         b)   Organization of data into fixed–length records (card images) and fields.
               The importance of columns in defining input.  Free-formatted input is not usable.
         c)   Description of a standard two–pass assembler.
         d)   Loaders and link editors.
         e)   Types of Assembler Statements,
         f)   The standard coding format; putting things into columns.
         g)   Accessing the IBM Mainframe: editing and submitting a program.
         h)   A standard boilerplate program and its sections. (Pages 58)
               Macros for program initialization and definition of I/O files.
         i)    I/O macros: GET and PUT.  Present Lab 1.

3.      The IBM S/360 Heritage.         PDF Version   HTML Version   MS-Word Version
         a)   IBM 704, IBM 1401, IBM 7090, etc.
         b)   Card punches and line printers.
         c)   Card codes and their impact on the design of EBCDIC.
         d)   Early operating systems and OS/360.  Job control language (JCL).
         e)   Batch mode and time–sharing mode.  Discuss CICS.
         f)   Card image input.  The 132–column line printer for output.  Carriage control.
         g)   Growth into the z/Series: motivation for zero down time.

4.      Representation of Data            PDF Version   HTML Version   MS-Word Version
         a)   Number bases: binary, octal, decimal, and hexadecimal.
         b)   Arithmetic in various bases: binary, decimal, and hexadecimal.
         c)   Conversion between various number systems.
         d)   Two’s–complement integers; 8–bit, 16–bit, 32–bit, and 64–bit.
         e)   Floating point data: IEEE standard format and IBM Mainframe format.
         f)   Packed decimal representation.
         g)   The EBCDIC scheme and its origins in IBM punch card codes.
         h)   IBM notation for bit numbering.

5.      Top–Level Discussion of Computer Architecture and Organization
PDF Version   HTML Version   MS-Word Version
         a)   The origin of the idea “architecture” in the development of the S/360.
         b)   Basic components of the computer: CPU, Memory, and Input/Output.
         c)   Basic components of the CPU: ALU, register file, and control unit.
         d)   General purpose registers and (even, odd) register pairs.
               Restrictions on general–purpose registers.
         e)   Organization of memory, and methods to address memory (byte addressability, etc.)
         f)   Byte addressability of multi–byte items: Big Endean vs. Little Endean.
         g)   Addressing modes: direct, indirect, indexed, and register/offset.
         h)   The PSW (Program Status Word).
         i)    I/O Design: Program Controlled I/O, Interrupt Driven I/O, Direct Memory Access<
               and I/O Channels.

6.      The Assembly Process             PDF Version   HTML Version   MS-Word Version
         a)   A sample program fragment.
         b)   The functioning of a two–pass assembler.
         c)   Loading and executing the program.
         d)   Some preliminary remarks comparing a compiler and an assembler.

7.      Assembler Directives and Data Definitions  
PDF Version   HTML Version   MS-Word Version
         a)   EQU
         b)   START
         c)   CSECT
         d)   END
         e)   PRINT

         f)   Formatting the input and output records.
         g)   The DC and DS declaratives
         h)   Some basic data types: A, B, C, F, H, P, Q, V, and X.
         i)    Hexadecimal constants and the use of hexadecimal in defining other types.
         j)    Literals and the literal pool.

8.      Addressing in the IBM S/370  PDF Version   HTML Version   MS-Word Version
         The general idea here is that in a HLL, the compiler determines the access to a location
         in memory (how many bytes are retrieved); in Assembler it is the instruction itself.
         a)   Labels as opposed to variables, which are HLL constructs.
               The idea of an address as opposed to the contents of that address.
         b)   The dependence of the contents of an address on the type of instruction accessing it.
               L gets a 32–bit (4 byte) word, LH a 16–bit (2 byte) half–word, IC gets one byte.
         c)   Relative addressing
         d)   Base register addressing.

9.      Instruction Formats    
PDF Version   HTML Version   MS-Word Version
         Here mention IBM’s study on memory-to-memory instructions as an alternate
         to the register-to-register operations found in a RISC design.
         a)   The basic formats: RR, RX, RS, SI, and SS.
         b)   The general purpose registers and limits on their usage.
         c)   Type RR instructions: AR, CR, DR, LR, MR, and SR.
         d)   Type RX instructions (Register Load and Store):
               IC, LA, L, LH, LM, ST, STC, STH, and STM.
         e)   Type RS instructions: SLA, SLDA, SRA, etc.
         f)   Type SS instructions: AD, CD, MVC, and ZAP.
         g)   Type SI instructions: CLI, MVI, etc..


10.    Handling Character Data        PDF Version   HTML Version   MS-Word Version
         a)   Structure of character data: zone and numeric (recall card punch codes).
         b)   Review of DS and DC character declaratives.
         c)   The MVC instruction.
         d)   Review of CLC and BC instructions.
         e)   The immediate instructions: CLI and MVI.
         f)   Explicit base addressing for character instructions.

11.    Handling Decimal Data           PDF Version   HTML Version   MS-Word Version
         a)   Zoned decimal data and packed decimal data.
         b)   The MVN and MVZ instructions.
         c)   Data conversions.
         d)   Moving packed data.
         e)   The PACK instruction.
         f)   The UNPK instruction and its limitations.
         g)   Unpacking to correct EBCDIC form.
         h)   Packed decimal arithmetic: AP, CP, DP, MP, SP, and ZAP.
               Discuss the difference between CLC and CP for handling packed data.
         i)    Explicit base addressing for packed data instructions.

12.    Handling Binary Integer Data            PDF Version   HTML Version   MS-Word Version
         a)   Review of the standard integer types: half–word, full–word, and double–word.
         b)   Review of DS and DC integer declaratives.
         c)   Data conversions.
         d)   Addresses and address constants.
         e)   Review of register operations.
         f)   Register shift operations: SLA, SRA, SLDA, and SRDA.
               Possible equivalence to multiplication and division by powers of two.
         g)   Register multiplication and division.

13.    Handling Floating Point Data             PDF Version   HTML Version   MS-Word Version
Review of the IBM floating–point formats.
         Declaring floating–point data.
         The floating–point registers.
         Load and storing floating–point data.
         Arithmetic on floating–point data.
         Comparison operations on floating–point data.
         A few comments on conversion to and from other data formats.

14.    Data Comparison and Branching      PDF Version   HTML Version   MS-Word Version
         a)   Distinct instructions for compare and branching.
         b)   Variants on the BC (Branch on Condition) instruction.
         c)   Use of C, CH, and CR for integer comparison.
         d)   Use of CP for comparison of packed integers.
         e)   Use of CLC for comparison of character data.
         f)   Misuse of the comparison operators.

15.    Arrays and Tables       PDF Version   HTML Version   MS-Word Version
         a)   Use of index registers to access data structures
         b)   Individual characters from a card image
         c)   Homogeneous arrays: definition and access.
         d)   Tables and table searching.
         e)   IBM terminology and standard terminology.
         f)   Direct table addressing and arrays.

16.    Direct Conversion between EBCDIC and 32–bit integer
PDF Version   HTML Version   MS-Word Version
         a)   Review of 16–bit and 32–bit integers; their storage and print representations,
         b)   Standard and older ways to represent negative numbers.  Where is the “–”?
         c)   Use of index registers to scan an input: left–to–right and right–to–left.
         d)   Two routines:           NUMIN          direct EBCDIC to integer conversion
                                                NUMOUT      direct binary to EBCDIC conversion.

17.    Conversions for Floating Point Formats       
PDF Version   HTML Version   MS-Word Version
         a)   Converting 32–bit (fullword) integers to floating point.
         b)   Converting floating point to 32–bit (fullword) integers.
         c)   Converting packed decimal format to floating point.
         d)   Converting floating point to packed decimal format.

18.    Writing Macros            PDF Version   HTML Version   MS-Word Version
         a)   Basic structure of a macro.
         b)   The Stack as an example: PUSH, POP, and TOP.
         c)   Restrictions on macros, conditional branching in macros, and branching to macros.
         d)   Macros compared to subprograms (subroutines and functions).
         e)   Keyword macros.
         f)   The macro implementation of a stack and its issues.
               Handling “stack empty” and “stack overflow”.

19.    Strings and Heterogeneous Arrays     PDF Version   HTML Version   MS-Word Version
         a)   Strings as a data type.  Creating a string type from an array of characters.
         b)   Self–describing arrays; storing the size of the array.
         c)   Heterogeneous arrays; storing the size of each data entry.
         d)   Use of tables to implement linked lists.

20.    Subroutine Linkage     PDF Version   HTML Version   MS-Word Version
         a)   Basic structure.
         b)   Nesting subroutine calls, two level structure, and lack of support for recursion.
         c)   Passing data by value and by reference.
         d)   The use of dummy sections (DSECT) for passing by reference.

21.    Input/Output Macros   PDF Version   HTML Version   MS-Word Version
         a)   File Definition Macros: the DCB (Data Control Block) and its structure
         b)   Imperative macros: OPEN, CLOSE, GET, and PUT.

22.    Job Control Language             PDF Version   HTML Version   MS-Word Version
         a)   The JOB Card
         b)   The EXEC Card
         c)   Describing data sets (DD)

23.    Some Issues from Systems Programming
PDF Version   HTML Version   MS-Word Version
         a)   Recursive programming with an explicit stack.
         b)   Writing reentrant code and using it in systems programs.
         c)   String space and handling variable–length strings.
         d)   Double–indirect addressing and Dynamic Link Libraries.
         e)   Examples of system routines: SIN(X), etc.
               This will involve the use of some Assembler instructions on real formats.

24.    Some Compilation Examples              PDF Version   HTML Version   MS-Word Version
         a)   The variable as a construct in high-level languages only.
         b)   What can be learned by examination of simplistic compilers
         c)   What can be learned from reading compilation listings.
                (This will be added later.  ELB  January 5, 2010)

Introduction to Part 2 of the Textbook (Material copied from Peter Abel’s Textbook)
PDF Version   HTML Version   MS-Word Version

Here is a link to a PDF Copy (Created by scanning an original text) of
Peter Abel's Original Version of the Following Chapters.     Index

25.    External Storage          PDF Version   HTML Version   MS-Word Version
         a)   File Organization Methods
         b)   Access Methods
         c)   Processing of External Storage Devices
         d)   Buffers: Input and Output
         e)   Magnetic Tape Storage
         f)   Disk Storage

26.    Sequential File Organization   PDF Version   HTML Version   MS-Word Version
         a)   Creating a Tape File
         b)   Creating a Sequential Disk File
         c)   Variable Length Records

27.    Indexed Sequential Access Method (ISAM) 
PDF Version   HTML Version   MS-Word Version
          a)   Characteristics of Indexed Sequential Files
         b)   Processing an Indexed File

28.    Virtual Storage Access Method (VSAM)      
PDF Version   HTML Version   MS-Word Version
         a)   Control Intervals
         b)   Access Method Services (AMS)
         c)   Accessing and Processing
         d)   Key–Sequenced Data Sets
         e)   Entry–Sequenced Data Sets
         f)   Relative-Record Data Sets
         g)   VSAM Macro Instructions
         h)   Keyed Direct Retrieval

29.    Operating Systems 
        PDF Version    HTML Version    MS-Word Version
          a)   Overview and Organization
         b)   The Control Program
         c)   System Service Programs
         d)   Fixed Storage Locations
         e)   Multiprogramming
         f)   The PSW (Program Status Word)
         g)   Interrupts
         h)   Channels
         i)    Physical IOCS

Appendix:      PDF Version   HTML Version   MS-Word Version
         Alphabetical Listing of Useful Instructions
                        The EBCDIC character set.

References     PDF Version   HTML Version   MS-Word Version