Dave's z/Architecture Assembler FAQ
- Do you have any assembler programming style
suggestions?
- View an uncredited assembler programming
style discussion that was on the IBM mainframe assembler
mailing list a while back.
- Some old timers don't like labels that are longer than 8
characters. So they hate my code! I heard one person
say recently "You should be able to fit all you need in 8
characters".
This is a personal taste issue. I point to IBM's usage of
longer labels in SYS1.MACLIB.
- Don't code "R0" on "BCTR Rx,0" instruction. In this case,
you are not using register zero.
- Restrict the use of in-line executes:
MVC 0(0,R4),0(R5) ** Executed **
EX R3,*-6 Move string to output line
I use to code like this but now move the executed
statement out of program flow. Even worse are things like
"B *+12"
- Some feel that you should have the assembler do all the work
including counting characters:
MVC 0(12,R5),=C'somedatahere' *** BAD ***
MVC 0(L'DATA,R5),DATA *** GOOD line 1 ***
DATA DC C'somedatahere' *** GOOD line 2 ***
Sometimes I'm lazy and don't always follow this practice.
- Don't overuse USINGs. Consider the following code:
L R4,CVTPTR -> CVT
L R4,CVTJESCT-CVTMAP(R4) -> JESCT
L R4,JESSSCT-JESCT(R4) -> SSCVT
A lot of people would have two extra USING and DROPs for the
CVT and JESCT DSECTS. I feel this obscures the code with
extra statements that get in the way. If you're looking at
a lot of fields in a DSECT, use a USING, if only one or two,
use the FIELD-DSECT(R?) method.
Should I code everything in Assembler?
Assembler is a lot of fun, but consider REXX or some other tool if:
- It's not a system exit
- Performance isn't critical
- It doesn't invoke any API's (or programming interfaces)
only available to assembler
You'll have more time to code things that really should be
done in assembler. Case in point is my
ISPF to 3270 datastream
assembler program that didn't really need to be written
in assembler (but then again, REXX wasn't available back then).
What are the missing opcodes?
You may have seen the list of assembler instructions that IBM hasn't
implemented yet at:
http://kurtz.tcimet.net/humor/f/opcodes.html
Some of my favorites:
- BOB - BRANCH ON BUG
- KCE - KILL CONSULTANT ON ERROR
- SRDR - SHIFT RIGHT DOUBLE RIDICULOUS
A larger assembler opcode list is at (that includes my favorite: BCF -
Branch and Catch Fire):
http://www.umr.edu/~huilman/jokes/assemble
Bruce A. Black points out that both of those lists are missing
his favorite:
- BOH- Branch on Operator High
It was more popular in the 60s.
Here's yet another list:
Secret Assembler Mnemonics
What are some good MVS assembler books?
Going beyond the basics, here are the two most highly recommended
assembler books for MVS Systems Programmers:
In a post on the ASSEMBLER-LIST mailing list dated 2000年06月02日,
John Ehrman of IBM posted the following collection of books
that has been recommended by others:
- "The IBM 370: Computer Organization and Assembly Language" by
Gordon L. Bailes and Robert R. Riser
- "Assembler Language Programming: The IBM System/370 Family" (Third
Edition) by George Struble 1984, 525 pages, Addison-Wesley Publishing
Co. Inc. ISBN 0-201-07815-5
- "Assembler Language with ASSIST and ASSIST/I" by Ross Overbeek and
W.E. Singletary, Macmillan, 1991.
- "IBM 370 Assembly Language with ASSIST, Structured Concepts & Advanced
Topics" by Charles J. Kacmar. Prentice-Hall, 1988. (Superseded by the
previous book, I think?)
- "Assembler Language Programming for the IBM 370" by Frank Carrano.
- "Assembler Language Programming for the IBM 370, ASSIST Edition" by
Frank M. Carrano, The Benjamin/Cummings Publishing Company, 1988
ISBN 0-8053-1810-0
- "Programming Assembler Language; Second Edition" by Peter Abel.
Prentice-Hall: Reston, Virginia, 1984. 581 pages (ISBN 0-13-728924-3)
- "Assembler Language Programming of IBM and IBM Compatible Computers",
by Stern, Sager, and Stern; John Wiley & Sons, Inc.
- "Advanced Assembler Language and MVS Interfaces: for IBM Systems
and Application Programmers" (2nd edition, August 1999) by Carmine
Cannatello. John Wiley & Sons, Inc.
- "MVS Assembler Language" (1987) by Kevin McQuillen and Anne Prince.
Mike Murach & Associates.
You may want to check out the FAQ author's
Assembler books
This might be of interest:
Architecture of the IBM System/360 from 1964.
Are there any Mainframe Assembler courses
available on the Internet?
What Mainframe Assembler education is available?
Here are a few companies that offer courses that are known to the FAQ author:
Are there any LE/370 migration issues?
You can make S/390 Assembler programs
LE/370 enabled by using the IBM-supplied LE housekeeping macros. See
CEE.SCEESAMP(CEEIVP) for a sample Assembler program that
uses LE/370 macros.
Here's a short discourse on
Save Area chaining in a LE/370 environment.
Dave's personal recommendation: If all you need is the
current date and time, don't invoke LE/370 routines, use the IBM
TIME macro. If you need the julian date converted to
gregorian, you could use the
CONVTOD, and STCKCONV macros to do this for you.
How can I subtract 64-bit unsigned integers using 32 bit instructions only?
Here is a post made by Edward E. Jaffe on comp.lang.asm370 in January 1998:
To subtract two TOD clock values (64-bit unsigned integers), I generally
use something like (for A-B):
LM R0,R1,A Load A
SL R1,B+4 Subtract low order part of B
BC 11,*+6 Branch if no borrow
BCTR R0,0 Perform borrow
SL R0,B Complete the subtraction
.
.
A DS 2F
B DS 2F
John Erhman of IBM sent me some sample programs which do
128-bit Math. These are provided without
warranty - "any bugs/disasters are the responsibility of the user."
How do I do conditional assemblies based on a macro
library level?
Often times, you want your S/390 Assembler program to assemble on
any version of a macro library. To do this:
- Put a mapping macro at the top of your program source
- Use the D'field method to determine if a given field is
defined. This will tell you the macro library level.
To make this clearer. Let's say you have a program that you would
like to use the CSVQUERY macro if the MVS macro library is at the level
that has it. Here is some sample code that does conditional assemblies
based on the MVS macro library level:
CVT DSECT=YES,LIST=NO
...
AIF (NOT D'CVTH4430).MVS43X At MVS 4.3 maclib or higher?
CSVQUERY ...
.MVS43X ANOP ,
To see a program that does extensive MVS macro library level checking,
see Gilbert Saint-flour's SHOWMVS which is in File492 of the
CBT tape
What are the top ten ways to
Shoot yourself in the foot using S/390 Assembler?
I have this on a separate page which also has
Ways to avoid
"Shooting yourself in the foot" and
Ways to make debugging easier.
What colleges teach Mainframe assembler?
IBM has a list at
Higher Education and S/390
I NEED A NEW LINK!!!!!!!!!!!!!!!
I see that the college I graduated from,
University of North Texas, still uses the mainframe along with
client/server in their
1999-2000 BCIS (Business Computer Information Systems) Course and Subject Guide.
Hire a UNT BCIS graduate - they already have seen and used JCL!
How does the ED instruction work?
This is from a post on the Assembler mailing list on 2000年01月08日 by
John Murray
EDIT (ED) is one of the most feared instructions of the original S/360
instruction set. Even career (professional) programmers have shied away
from ED, many developing complex macro instructions and/or subroutines to
shield them from this poor instruction's use.
As it turns out, and if you ignore all the BS about "field separators"
(nobody ever uses them, it was perhaps a good idea that went astray or
perhaps temporary insanity on the part of the original hardware engineers),
ED turns out to be a fairly nice and easy to use instruction.
There are no pointers involved. The EDMK (Edit and Mark instruction can
feedback an address that tells you where the first significant digit is,
but not edit).
The edit instruction has target and source fields like many other SS
instructions. The target is the first operand which must contain the edit
pattern (or mask) before the instruction is executed. The edit pattern is
the way you tell the machine how to edit the data. The source field is
usually a packed decimal field, if it isn't watch out for S0C7 problems.
The length of the first operand governs the result of the edit operation.
Special attention must be given to the edit pattern. The first byte of the
pattern is the fill character, usually a blank. Subsequent bytes are
typically "digit select" characters or constants to insert in the result to
pretty it up. There is also some consideration for "significance start"
and signs (eg. +, -, CR, DB, etc.) that can be inserted in the edited
result. I don't have all this on the tip of my brain, so I'll stick with a
simple case to give you the hang of the instruction, the rest can be found
in the POP.
Assume you have a three byte packed field containing the year (YEAR DC
XL3'02000C') and you would like to display this value as "2,000". You can
do this with a simple edit pattern and the ED instruction.
Since there are 5 digits in the year counting the leading zero, you must
allow for this in your edit pattern which will look something like this
"X'4020206B202020'". The first byte (X'40') is the fill character. The
next two bytes (X'20's) are digit select characters and act like filters in
that zeros do not pass through the filter unless there has been a prior
non-zero digit. When there has not been a prior non-zero digit, zero is
replaced by the fill character. The X'6B' is a comma that will be inserted
in the result to pretty it up. The final three X'20's are the rest of the
digit select characters necessary for properly editing the year.
The instructions:
MVC OUT(7),=X'4020206B202020'
ED OUT(7),YEAR
will correctly edit this result and leave the variable OUT =
X'4040F26BF0F0F0'.
That should take some of the mystery out of it and get you on the right
track for using ED productively.
What does BINZER mean?
BINary ZERo
For more, see
http://www.binzer.org
What is the format of the 64-bit Save Area?
This entry was taken from a post by
Peter Relson of IBM on the
IBM-Main newsgroup/mailing-list:
The recommended format is:
Bytes 0-3: reserved
Bytes 4-7: character string 'F4SA' (analogous to 'F1SA' at this
offset when regs are saved in the linkage stack)
Bytes 8-127: 8-byte GPRs in order 14-12
Bytes 128-135: address of previous savearea
Bytes 136-143: address of next savearea
It is z/OS 1.2 that will introduce storage above 2G. But that release does
not support passing control between programs in AMODE 64. Modules are
expected to get control in AMODE 31 and switch when needed to AMODE 64. The
system will not give control to modules in AMODE 64.
When you control your caller, you can have the caller provide a 144-byte
savearea and then you can use the linkage convention described above. When
you cannot control your caller (or your caller is the system) you likely
need to live with the 72-byte savearea that an unchanged caller would
provide, and that means that you need to save registers on the linkage
stack, or need to save the high halves of the GPRs in your own dynamic
storage after you have obtained it. This latter case is the "F5SA" case
which looks just like the "F4SA" case except it has the character string
"F5SA" at bytes 4-7, and has an additional 72 bytes following byte 143, for
saving the high halves of GPRs 0-15 (plus 8 reserved bytes).
The savearea types are as follows:
-- 72-byte standard savearea that we know and love
-- F1SA at bytes 4-7: 72-byte SA, caller's regs saved on
linkage stack
-- F4SA at bytes 4-7: 144-byte SA, caller's regs saved in
caller's 144-byte SA in the F4SA format above
-- F5SA at bytes 4-7: 216-byte SA, low halves of caller's
regs saved in caller's 72-byte save area, high halves
saved in callee's dynamic area as described earlier
-- F6SA at bytes 4-7: 144-byte SA, caller's regs saved on
linkage stack
Please note carefully that just as certain registers are "expected" to
remain unchanged when using standard linkage, a target program should take
care to preserve the high halves of registers 2 through 14 so that they are
unchanged upon return.
Also see this Save Area Definitions page.
What Assembler Debuggers are available?
If you know of other ones, please email me.
Are there any S/390 disassemblers?
There are a few free disassemblers on the
CBT Tape.
There are a few
disassemblers that I know of that are included in commercial products:
- IBM's
HLASM Toolkit has a full function disassembler which processes:
- MVS - An object module, a program object or load module
- CMS - An object deck or CMS module
- VSE - An object module or a phase
- Cole Software's XDC/SE
- Serena's StarTool - Here's
an example of the output for IEFBR14.
- SAS C compiler has a object module disassembler called
omd. Here are some more
instructions.
- Waterloo's C Demonstration and Utility Programs page has a CMS
TEXT file and MVS object code disassembler.
Others? Send me an email... Planet MVS contact page
Warning: Just because you CAN disassemble a module
doesn't mean that you LEGALLY have the right to do so...
Some random things:
- I didn't mention the AMASPZAP utility which does a very primitive
disassembly (just instructions) during a module dump. Here's an example of
"DUMPT IEFBR14 IEFBR14":
**CCHHR- 0343000A0A RECORD LENGTH- 000008 MEMBER NAME IEFBR14
000000 1BFF 07FE
SR BCR
This function is so ancient and
can get "mixed up" easily unlike a full function two-pass disassembler
like the one that is included in the
HLASM Toolkit.
- I like the way Compuware's
ABENDAID does a small disassembly of the code around the PSW
at ABEND time. Here's an example:
The next sequential instruction to be executed in
program GETABEND was at displacement 000000A6.
00000098 18D1 LR R13,R1
0000009A 58101004 L R1,4(,R1)
0000009E 58101018 L R1,24(,R1)
000000A2 50000000 ST R0,0
NSI==> 000000A6 D2130000E008 MVC 0(20,R0),8(R14)
000000AC 58D0D004 L R13,4(,R13)
000000B0 41F00000 LA R15,0
000000B4 58E0D00C L R14,12(,R13)
000000B8 980CD014 LM R0,R12,20(R13)
I have no experience using them but it appears that at least one of their
competitors also has this capability:
CA-SymDump (which mentions having this function) and
Dumpmaster (which doesn't that I could find).
Where is the Dead Zone in z/OS?
New
[2006年01月01日]
The "dead zone" is the single, contiguous area between 2G and 4G. IARV64 simply does not allocate any virtual storage in the 2GB-4GB range. Referencing such an address will result in a 0C4 abend with reason code 38, 39, 3A, or 3B.
This item was created from two posts to the ASSEMBLER-LIST mailing list by
Edward E. Jaffe and
Jim Mulder.
Is it safe to convert lowercase to uppercase by ORing with x'40'?
New
[2006年01月01日]
No. Code pages other than 37 or 1047 have uppercase alphabetic characters that
fall outside the x'C1' to x'F9' range.
This item was created from a post to the ASSEMBLER-LIST mailing list by
Edward E. Jaffe 2004年06月24日.
What instruction gives you the opcode DEAD BEEF CAFE?
New
[2006年01月01日]
ED 3823(174,11),2814(12)
What is an Architectural Level Set?
New
[2006年01月01日]
An architectural level set occurs when the operating system folks draw a
"line in the sand" saying their system will not run on any machine that
does not have features "x, y, and z". The first architectural level set
(now known as ALS1) occurred with OS/390 V2R10. The features it required
can be found in this list:
http://www.ibm.com/servers/s390/os390/plug.html
The second architectural level set (now known as ALS2) was not
established by technical people but rather by edict from the "geniuses"
in marketing. That's why it backfired and angered so many customers. It
occurred with z/OS V1R1. The additional features it required can be
found in this list:
http://www.ibm.com/servers/s390/os390/plug1.html
The next "line in the sand" was the requirement by z/OS V1R6 to run in
z/Architecture mode. Some have called this ALS3. All z/OS releases will
still run on the original "freeway" (z900) machines and there have been
no level sets since.
The next level set probably won't occur for years. When it does
eventually arrive, most of us will probably consider it to be ALS4 --
even if IBM abandons the "level set" terminology in favor of something new.
Again, a new hardware generation with new features is not an
architectural level set. Rather, an architectural level set is a list of
hardware features required by the operating system. Or, put another way,
a program can determine which hardware features are guaranteed to be
available by testing the level of the operating system in the CVT.
This entry was created from a post on the
IBM-Main newsgroup by Ed Jaffe.
S/390 is a
registered trademark of
IBM.
If you find this page useful, you may also want to check out
IBM's HLASM web site
BC 15,
Dave's HLASM web page.
Dave's HLASM web pages
IS PROVIDED "AS IS" AND WITHOUT ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE
IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
PURPOSE.
Last Updated: 2025年07月04日
This web page is © 1997-2025+ by
David Alcock.
All Rights Reserved.