IBM MTM: Part Three – Challenge #13

Assembler! No, it’s not a language that Ikea has come up with. Assembly, asm, scary numbers language thingy or assembler, it has many names. This is there part where I tell you I haven’t written any asm but state that I’ve written some language that looks like it. Ehh… not this time.

This challenge is about… surprise surprise! Assembler!

IBM Z Mainframe Assembler

IBM Master the Mainframe Part Three – Challenge #13

This challenge sure won’t make me a full fledged Assembler programmer but I’ll at least have some experience with asm. Asm is more difficult to learn than other languages. It requires you to learn Assembler mnemonics, machine instructions, Assembler directives, Assembler macros and you need to know a thing or two about hardware architecture.

Being able to understand Assembler gives one the ability to debug complex system problems by reading system dumps. Higher level languages such as C/C++, Java, Cobol etc. were created to make programming the computer easier by hiding the complexity of the underlying machine instructions, addressable memory and registers.

Compile assembler program

I have to admit that this challenge is a good filter. I suffer from great procrastination. Let’s go ahead and compile the assembler program. Let’s edit Z30163.SOURCE and make a new member name s asmpgm and copy ‘zos.mtm2018.public.source(asmpgm)’ and submit. I’ll jump straight to the output panel while I’m at it.
There’s a full review of what this code does available at I doubt I’ll explain it better than IBM 🙂

Use TSO TEST facility to understand assembler program execution

Let’s test the code that we’ve compiled using test ‘z30163.load(asmpgm)’  this has to be done inside the TSO Ready prompt. I had to remove the LOGOFF command when logging in so I could =x and boot myself to the TSO screen.
Now I can run these commands. Excuse my laziness but please check mybluemix to know more about each command.

Note, I will have to enter go numerous times to proceed with the program execution. It should stop at +42.

This is an important part. We know register 2 holds the value 4. The loop continues until register 2 is zero. So it iterates a total of 4 times. We enter go 8 times because we execute 2 things inside the loop.

Well that sure was something! I did this process twice, help! Once for myself and the second time to get some screenshots. I can’t embarrass myself right?!

Modify and re-compile ASMPGM assembler program

Let’s do this boys, girls, bits and bytes!
  1. Use register 6 for all operations where register 2 was previously used
  2. Use register 7 for all operations where register 3 was previously used
  3. Initialize the register used to sum each add operation in the loop with a zero value
  4. Execute the loop 10 times adding 5 to the register being used to sum each add operation

Help! Can I pay someone to do this for me?

As for the registers 6 and 7, just change all occurrences where register 2 or 3 is used. In IBM’s explanation they state which register is being used at what line inside the code. So it’s a matter of understanding the code or just ctrl+f ‘register 2’ at mybluemix 😉

Initialise the register used to sum each add operation in the loop with a zero value is easy. Think how the two registeres are initialised now, they hold the value Begin. Then a bit further register 6 and 7 are ‘loaded‘ with value 4 and 1. I’ve only edited the one register where we add something. I didn’t touch the other register where we subtract from.

We can find the storage address of label LOOP at +3A, when we’ve entered go it adds 1 to register 3 until register 2 is zero as it subtracts one every loop. So in the end register 3 was 5 and register 2 held the value zero. How many times did we need to enter go in order to get register 2 to 0?

Think fast! IBM now wants us to execute the loop 10 times and add 5 every iteration to the register where we add a number.

I think I’ve got it right, now is a good time to debug again and tso submit ‘zos.public.jcl(p3ch13)’ to copy my code to P3.OUTPUT. Let’s debug first! Don’t make the same mistake I did, we’re debugging new registers now 🙂 not register 2 or 3. But 6 or 7.

Looks like it iterated 10 times all the way down to where register 6 equals zero and register 7 equals 0x32 (hex).

Should be it!

Share this:

IBM MTM: Part Three – Challenge #12

We’re in for a short blogpost. I thought those were long gone. Today I’m taking a look at virtualisation with z/VM. Actually the z/OS we’ve been working on was a virtual machine controlled by a single LPAR (logical partition).

I’ve been wondering, there’s so much you can do with a mainframe, how on earth can a man learn everything? Do you get proficient in mainframes once you’re ready to retire?

IBM Z Mainframe Supports 5 Unique Operating Systems

IBM Master the Mainframe Part Three – Challenge #12

I have fiddled around with virtualisation quite a bit. I’ve worked with Virtualbox, VMWare workstation/player and VSphere. But this is probably a whole other level of virtualisation. I’m really curious.

IBM Z supports 5 unique operating systems:

  1. z/OS – flagship operating system used for this contest
  2. Linux – if you know Linux, you know Linux that runs on IBM Z
  3. z/VM – hypervisor operating system
  4. z/TPF – Transaction Processing Facility
  5. z/VSE – similar to z/OS with less features and functions

IBM Z supports 2 types of hypervisors:

  1. LPAR – Logical Partition, a type 1 hypervisor
  2. z/VM – z/Virtual Machine, a type 2 hypervisor

An IBM Z machine can run just about 85 different LPARS at the same time. Running 8,000+ operating systems within a single IBM Z frame with network delay between the operating systems near zero is industrial strength architecture. Impressive! If you’re interested you can request a trial for a Linux virtual machine at

z/VM query command output in preparation for challenge

Let’s head to the ISPF Command shell using =6. Then enter the primary command q cplevel go get more information about the z/VM Operating system hosting the z/OS contest virtual machine.

Entering q n show the number of virtual machines currently active as guests of z/VM.

Hmm, so there are 56 virtual machines? Or 57 including the VSAM – VTAM one. Let’s check which network interface controller I’m using, by issuing q nic.

This is my information. What’s yours? Let me know in the comments below! I also need to issue q 400-402 to see information about device 400 to 402.

Missing text:
0402 OUT + 04 IOCNT = 01245891  ADP = 000 PROG = 000 UNAVAIL = 128
0402          BYTES = 00000000361094D2

I got the information I needed.

Gather z/OS system definitions used to communicate with z/VM hypervisor

Now I exit the ISPF Command Shell and check the vendor.tcpparms data set using dslist ‘vendor.tcpparms’. I need to select the member S0W1.

I need to delete all lines except the 3 lines with the NIC adapter name. So does that mean that I need to delete all lines that don’t have ‘DEVOSA1′ in it? I just did and only have 3 lines left, good.

To be honest, I have no idea how to work with label so I just copied after .zl. So now I’ve copied 99 lines into p3.output(#12) and I should be done.

So that’s it! P3.output(#12) now has 7 lines of z/OS definitions used to connect to z/VM.

Challenge #13 – What about it?

It’s been a very rough week, and challenge #13 is very long and complex so it’ll take much longer for me to complete this challenge and write a blogpost about it. Just a friendly heads-up 🙂

I’m also sad, I thought I was going to learn about virtualisation but to be fair… I’ve learning pretty much nothing from this challenge. What was the point of this? So I would know which NIC I had? No idea.

It was black friday recently, did you buy anything?

Share this:

IBM MTM: Part Three – Challenge #11

Challenge 11… we’re getting there. From now on all following challenges will be about learning a new programming or scripting language. I’ll be shown how to compile, execute and debug a program/script.

In this challenge I’ll be working with some C code. I’ve never written any C in my life, only C# but I doubt it’s the same. Well, I’ll see when I get to the code.

Run C Fun

IBM Master the Mainframe Part Three – Challenge #11

First I’ll continue to OMVS by using the primary command tso omvs then I’ll copy the C source code to my unix directory using cp “//’zos.mtm2018.public.source(cpgm)'” cpgm.c Now we’re able to compile the code using xlc -o cpgm cpgm.c. If it compiled successfully then I should be able to execture it the same way we execute a shell script inside Linux: ./cpgm

The C program counted from 1 to 10, writing each number to the display and wrote a message in Unix cpgm.output. I’ve checked the message and wrote it to //

Now I need to modify the code. I need to change the text it outputs from My first C program on z/OS to Fail fast to succeed!. I’ll edit the file using the primary command oedit cpgm.c. 

I’ve highlighted the most interesting part of the code. Line 000021 is where the message needs to be changed. Line 000028 is where they display the code to write text to a DD name.

To clarify the code, my first guess is that they open the connection using the fopen function, then pass the DD parameter as DD:DDNAME and the second parameter w probably stands for write (to clarify the action they want to perform).

I know the comments at line 000026 and 000027 say comment/uncomment this to write to a Data Set but I’m not sure if I actually need to do it? I’m just going to assume we don’t need to as they don’t instruct us to do so in the assignment.

Now I’ll save using F3, compile and run using the previous commands. And lastly I’ll read the output and write it to

That’s done! I’ll now copy the C executable module from my Unix file system to my MVS data set using cp cpgm ‘//load(cpgm)’. Now we’re ready to exit omvs. I’m told there are multiple ways to compile code. We can also compile C code using JCL.

  • CPGM is the program to be executed
  • STEPLIB DD tells the system where to search first for CPGM
    You copied CPGM from the Unix directory to your MVS LOAD data set
  • HANDLER DD is coded in the JCL

We’re going to submit the JCL using tso submit ‘zos.public.jcl(cpgmjcl)’ as we need the output to be inside P3.OUTPUT(#11). Is HANDLER here DD:HANDLER inside the C-code? It probably is.

The objective is to change the C program source code to write the text message to JCL HANDLER DD instead of cpgm.output

Oh schnitzel, I’ll go and do that. I kind of gave it away I think? Oh… they give it away too when I read a bit further. No harm done.

  • Locate C statement used to write text to cpgm.output
  • Locate C statement used to write text DD:HANDLER
  • Comment statement used to write text to cpgm.output
  • Uncomment statement used to write text DD:HANDLER
  • F3 to save and return to Unix shell prompt

Done! That’s it for challenge #11 🙂


I know… I try to release periodically but work and free time won’t allow me to. But I already prepared a lot of stuff for the coming two weeks. I want to devote the entirety of december to challenge #15!

Share this: