Get Shifty – Shift Factors in Shifts and Rotate Instructions

There’s two distinct approaches you can take when coding shifts and rotate instructions:

1) Hardcoded Shift Factor – Here’s a typical shift and round packed instruction –

SRP SUMPK,3,0

The 3 is a shift factor that represents a 3 digit left shift. It has the advantage of being easy to code, but the shift factor is fixed and can’t be programmatically altered.

2) Computed Shift Factor – This second technique is less commonly coded, so perhaps you haven’t seen an SRP coded like this:

L   R4,=F'3'
SRP SUMPK,0(R4),0

Just how does this second SRP above work? First the shift factor is loaded into register 4. The 0(R4) is in fact a base/displacement address. Like all base/displacement computations, the contents of the base register and the displacement are added to produce an effective address. But instead of using the effective address to reference a memory location, only the rightmost six bits of the address are used as a shift factor. In the case of SRP, the 6 bits are interpreted as a 2’s complement binary integer, and the shift moves left for positive integers and right for negative ones. An advantage to this technique is the shift factor can be programmatically changed, providing a flexibility that the first approach doesn’t offer.

In both cases, the shift factor is expressed as a base/displacement address. In the first case the 3 is simply a displacement and the base register was omitted, so it defaulted to 0.  The effective address was the displacement, 3. Abreviating this to six bits, left 3 as the shift factor.

There are lots of opportunities to use these techniques because there are many shift and rotate instructions (including SRP) that express their shift factors in base displacement format D(B).
These instructions include:

Shifts:
SLL
SLLK
SLLG
SLA
SLAK
SLAG
SLDL
SLDA
SRL
SRA
SRAK
SRAG
SRDL
SRDA
SRLK
SRLG
SRP

Rotates:
RLL
RLLG

For each of these instructions, the base/displacement address in not used as an address at all.  In fact, only the last 6 bits of the “address” is used to represent the shift factor. Some shift factors are in plain binary while others are in 2’s complement. You’ll have to check with the Principles of Operation for the details on each instruction.

Leave a comment

Filed under IBM Mainframe Assembler

Back in Business

You should be able to see all the web pages on my academic site now, including all the relevant assembler videos.

Leave a comment

Filed under IBM Mainframe Assembler

Web Site Down Temporarily

The web site at Columbus State University that hosts my assembler material is temporarily down.  I’m working on moving all of it to a different server.  Sorry for the inconvenience.

Leave a comment

Filed under IBM Mainframe Assembler

Enterprise Training in the new year

Check out the specialized enterprise training that is available through Marist College (credit or non-credit).  I may teach the assembler course in the spring if we have enough students.  Here is the link for more information:  http://idcp.marist.edu/enterprisesystemseducation/enterprisesystemscoursecalendar.html

Leave a comment

Filed under IBM Mainframe Assembler

Institute for Data Center Professionals – Online Training

If you are looking to improve your enterprise System Z computing skills including Networking, Security, COBOL, Assembler, DB2 and IMS, check out the Institute for Data Center Professionals that is sponsored by Marist College in Poughkeepsie, NY. They have an excellent System Z online program that is designed for anyone trying to advance their technical skills. The curriculum is extensive and unique. I taught a couple of assembler courses in the program last year. The program is very hands-on and you receive lots of personal assistance. If you are interested in this year’s program, you will need to hurry, though. Classes start in September. Here’s the link: http://idcp.marist.edu/

Leave a comment

Filed under IBM Mainframe Assembler

Lots of Code On One Base Register

Do your assembler programs look like they were written in 1970?  Are you still using the instruction set your dad learned back in college?  There are lots of new instructions you can master with minimal effort.  Consider branching.  The old-fashioned BC and all the related extended mnemonics (BL,BH, …) all use base/displacement addresses to satisfy your desire to change locations.  But there is a host of newer, relative-branch instructions that determine the target location by adding a signed binary integer to the current PSW instruction address instead.  What’s the difference?  The old BC-based instructions require that you have a base register covering up the target address, so if you have lots of executable code, you’ll need more base registers.  The new relative branch instructions don’t need a base register at all – they jump forward and backward from the current PSW address.

So … if you put all the static storage fields together and keep them separate from your executable code, one base register might be sufficient.  

I’ve put together a sample program at http://csc.columbusstate.edu/woolbright/relative/relative.txt  that demonstrates how this can happen.  There’s also a new video in the video course that walks you through it at  http://csc.columbusstate.edu/woolbright/relative/relative.html .  The program uses a newer linkage technique but its not a requirement for this idea to work for you.

It’s time to show your daddy a thing or two…

1 Comment

Filed under IBM Mainframe Assembler

Labeled Using – A Powerful Tool

Occasionally you need to take a DSECT and apply the structure to multiple areas of storage simultaneously. With a standard DSECT that can be tricky. What you need in these cases is an idea called a “Labeled Using”. You can watch a short video that shows you how to use this powerful idea here.

Here’s the code that goes along with the video:

Leave a comment

Filed under IBM Mainframe Assembler