16 October 2012

Little bitty z/Architecture assembler tips and tricks not worthy of their own blog entry

This blog entry will be updated continually and reposted when I come up with little tips and techniques not worthy of their own blog entry.


High half register check

Can't use those bitchin' new high-half register instructions because you have customers not on the latest z196/z114? Need to check the upper half of a register for non-zero so your AMODE 64 doesn't run amok? Use the following:
CLG   R0,=X'00000000FFFFFFFF'
JH    THERE_IS_SOMETHING_IN_THE_HIGH_HALF_OF_THE_REGISTER
And you also have an example of a label longer than 8 characters.


Make sure your base register is clean in AR mode

LAE is a nice instruction for setting a base register if you aren't sure your code will be called in primary or AR mode. If the B2 field is 0, when you are in AR mode, 00000000 is placed into the corresponding R1 access register, so you can code 

LAE   R12,0(R15)

and get your entry point without the possibility of getting messed up by a stray ALET in AR12.


WAIT LONG=YES and baseless programming (z/OS, 1.12 and earlier)

If you've tried this combination before, you've gotten bit because the macro generates a BCR GPR8,0 instruction followed by an ICM of the second byte via an "*-1" operand. If you're baseless, this fails because you are baseless. However, there is no need to fret. The following code works and gets around this issue.

         IILH  GPR0,X'8000'
         IILL  GPR0,1
         WAIT  (0),ECB=MYECB

The macro generates an unnecessary LR GPR0,GPR0 followed by the appropriate code. If you are using an ECBLIST, just put the number of this-many-POSTed ECBs in GPR0; in this case, it might be easier to load GPR0 first, then use an OILH GPR0,X'8000' instruction.

As noted in the comments below, starting with 1.13, if you are SYSSTATE ARCHLVL=2, WAIT will generate appropriate code for baseless situations.

More to come as I think of them...


4 comments:

  1. If you have done SYSSTATE ARCHLVL=2
    then the z/OS 1.13 version of the WAIT macro will generate code which does not require a base register.

    Jim Mulder

    ReplyDelete
    Replies
    1. What took so long? :D

      As you can surmise, I'm working in an environment that is < 1.13. We have 1.13 in house but on our sandbox system. I've taken a look at the macro source and I like what I see.

      Jim, I really appreciate that you look at this little ol' blog here and take the time to comment on it.

      Delete
  2. The second operand of the CLG (for content checking in high half) is easier to decipher with =F'0,-1' or use CLG R0,=A(1,0) and JNL.

    ReplyDelete

Feel free to leave a comment or ask questions.