Starting Assembler

Here’s a daunting thought for anyone starting to learn IBM assembly language:  The latest System/z machine executes over 500 machine instructions.  Where on earth should you start if your goal is to become proficient?   As in many subjects that are complicated (think mathematics, physics, chemistry), taking a historical approach to their study is often helpful, and while there is no royal road to assembly language, going back to the roots of any subject can be illuminating.  

  The roots of IBM System/z assembly language started with the System 360 in 1964.  This historic machine was equipped with an instruction set that was much smaller than current models.  Ignoring privileged instructions (those that require special authority), and floating point operations altogether (business arithmetic occurs in packed decimal), the instruction set that is left over numbers around 100.  Another happy fact of learning assembly language is that by mastering a single instruction, you will learn several others by association.  We are left with a manageable instruction set of fifty or sixty instructions that make up a working subset – a subset that can make you marketable. 

   So where do we begin?  Here’s a plan that will ease you into assembly language:

1)  The Lay of the Land – Start with a general orientation to the machine and the components you will interact with as a programmer here.

2)  Location, Location, Location  – Every variable you create in assembly language is converted to a Base/Displacement address.  In a high-level language, we don’t usually worry about the exact location of variables, but in assembly language it’s critical.  Read about base/displacement addressing here and give it your full attention.  Alternatively, you can listen to the beginning assembler video tutorials on my website.

3)  Ground Zero Every displacement is measured from a specific point in memory called the “base address”.  This address is loaded into a register – the “base register”.  The combination of the base register and the displacement is used to identify where a variable lives in memory.  The instruction which establishes the base address and loads the base register is called BASR (BALR is an older similar instruction).  Look up IBM’s manual called Principles of Operation on the web and read about BASR.  While you are there, check out  MVC, CLC, and BC.

4)  See It Happen – Download the VisibleZ software from this site.  VizibleZ is a java-based object code interpreter that is designed to help you visualize assembly programs and the effects they have on system components.  After reading the article on instruction formats here, load the mvc.obj program that is distributed in the Codes directory.  Single step through each instruction.  Pay close attention to the base displacement addresses in each instruction.   Do they make sense?  The color coding in the product should help you figure it all out.

  At this point, you’re on your way.  It’s a long journey, but an interesting one, particularly if you like to program, you would rather do things yourself, in your own way, and you like laying code down directly on top of the metal.    


5 thoughts on “Starting Assembler”

  1. Thank you very much for producing these articles, lectures, and tools. I recently start to convert reports written in assembly language, these tutorials will really help me to read and understand the logics written by the programmers. I’ve always been interested in learning and writing assembly langages. Now I finally have the materials and a guide to follow through. Thank you so much!

  2. Greatest source of Assembler education we have here!
    Thank you Professor.
    I wonder if with these nice 500 instructions and many Macros could be exist one to do the trim(cut the white spaces in the beginning or at the end) of a variable?
    Thank you

    1. Thanks, Georges!
      You can use TRT (Translate and Test) to get R1 pointing at the first non-whitespace character at the beginning of the field. You’ll have to create a translate table to define what non-whitespace characters are. You can use TRTR (Translate and Test Reverse) to get R2 to contain the address of the first non-whitespace character on the right – you can use the same table for both.

Leave a Reply