Search390.com
Developer Tip
May 23, 2001

========================================================
Get free offers from reputable merchants for products that you are
interested in. Pick from over 50 categories of interest, modify your
profile at any time to suit your needs, and receive only the email
that interests you when you subscribe today. Just click on the link
below and get your account up and running: 
http://search390.techtarget.com/postmasterDirect/
========================================================

========================================================
ENTER TO WIN A PALM Vx!
========================================================
Got a great tip?  Share it with us, and you could win a cool prize. 
Search390 is offering a prize to the user-submitted tip that receives
the highest rating each month.  The winner of this month's tip
contest will receive a Palm Vx ultra slim handheld. Weighing in at
just 4 ounces, the Palm Vx has the same anodized aluminum exterior
and LCD screen as the Palm V handheld, yet it has four times the
memory of its predecessor, giving you more speed and more storage.  
To submit a tip, contact us at mailto:[EMAIL PROTECTED].  For more
information and contest rules, click on
http://search390.techtarget.com/tipsContest/0,289488,sid10_prz550161_cts550144,00.html
========================================================

TODAY'S DEVELOPER TIP:

S/390's new RELATIVE and IMMEDIATE instructions
By Jim Keohane

Years ago, I had the pleasure of working with a very talented
development staff at Computer Associates. We worked on the
CA-Optimizer series of IBM COBOL Compiler add-ons that further
improved cpu performance of the resultant object code.

The "register optimization" logic was the most amazing portion of the
product. If the object code could be tweaked to need fewer base
registers to branch around, then the unneeded registers could be used
to hold interim values and calculations. That would have the result
of reducing the number of register loads and stores which would have
the effect of reducing code size and which would ... You get the
picture.

One neat method of reducing the number of base registers was the use
of 2 index registers preset to 4K and 8K. Normally, you might need 6
base registers to branch around about 24K of code. Those 6 registers
were set to point to TOP, TOP+4K, TOP+8K, TOP+12K, TOP+16K and
TOP+20K.

CA-Optimizer would set just 2 base registers (BASE0K & BASE12K) to
point to TOP and TOP+12K. CA-Optimizer also had 2 index registers
(INDEX4K and INDEX8K) set to 4K and 8K. You could now branch to
anywhere within that 24K needing 2 fewer registers. Branches to TOP,
TOP+10K and TOP+19K would look like:

         BRC   2,0(0,BASE0K)
         BRC   8,2048(INDEX8K,BASE0K)
         BRC   7,3072(INDEX4K,BASE12K)

The speedup was sometimes very impressive. Unfortunately, this kind
of branching could only be done by a sophisticated compiler and not
by hand. Sigh.

That has changed. You can now do even better by hand through use of
newer S/390 instructions. The new BRANCH RELATIVE instructions allow
you to branch anywhere within about 64K, up or down, of the branch
instruction without any base registers needed! The new IMMEDIATE
instructions can reduce code size and also reduce the number of base
registers needed for data. I'm sure compiler writers will make the
most of these new instructions but they can also be of significant
use to those who handcraft their own assembler programs.

Following code snippet shows the various IMMEDIATE and RELATIVE
instructions and how they assemble without the use of base registers
or USING statements. Note the large DS gaps that serve to increase
CSECT size to over 64K. This is to illustrate the range of the
relative branch instructions.

000000 00000 1037C         1 START    START 0 
000000                     2          DS    0100D 
000320                     3 LABEL1   DS    0H 
000320 A75A 7FFF 07FFF     4          AHI   5,32767   
000324 A75A 8000 FF8000    5          AHI   5,-32768 
000328 A75E 7FFF 07FFF     6          CHI   5,32767 
00032C A75E 8000 FF8000    7          CHI   5,-32768 
000330 A758 7FFF 07FFF     8          LHI   5,32767 
000334 A758 8000 FF8000    9          LHI   5,-32768 
000338 A75C 7FFF 07FFF    10          MHI   5,32767 
00033C A75C 8000 FF8000   11          MHI   5,-32768 
000340 A750 F0F0 0F0F0    12          TMH   5,X'F0F0' 
000344 A751 0F0F 00F0F    13          TML   5,X'0F0F' 
000348 B252 0045          14          MSR   4,5 
00034C A784 FFEA 00320    15          BRC   8,LABEL1 
000350 A784 7E9C 10088    16          BRC   8,LABEL2 
000354 8545 FFE6 00320    17          BRXLE 4,5,LABEL1 
000358 8445 7E98 10088    18          BRXH  4,5,LABEL2 
00035C A755 7E96 10088    19          BRAS  5,SUBRTN 
000360 A756 FFE0 00320    20          BRCT  5,LABEL1 
000364 A756 7E92 10088    21          BRCT  5,LABEL2 
000368                    22          DS    8100D 
010088                    23 LABEL2   DS    0H 
010088 07F5               24 SUBRTN   BR    5 
010090                    25          DS    0092D 
010370                    26          USING *,15 
010370 7150 F008 10378    27          MS    5,=F'-100' 
                          28          END 
010378 FFFFFF9C           29          =F'-100' 
Ordinary Symbol and Literal Cross Reference 
Symbol Length Value Id R Type   Defn References 
LABEL1      2 00000320 00000001 H  3 15B 17B 20B 
LABEL2      2 00010088 00000001 H 23 16B 18B 21B 
SUBRTN      2 00010088 00000001 I 24 19B 
=F'-100'    4 00010378 00000001 F 29 27 

Note also the MULTIPLY SINGLE instructions (MS and MSR), which use
one less register (no register pair for product) than older MULTIPLY
instructions and are safe to use as long as product can be contained
in 32-bit signed register. The MS instruction is the only instruction
in this example requiring a base register and a USING statement.

The "BRAS 5,SUBRTN" instruction shows a subroutine call which returns
via "BR 5".

You must have the necessary RELATIVE and IMMEDIATE support facility
on your S/390. Last, but not least, make sure your disaster recovery
site or backup site also has the hardware support.


About the author: Jim Keohane ([EMAIL PROTECTED]) is
president of New York consulting company Multi-Platforms, Inc. His
company specializes in commercial software development/consulting
with emphasis on cross-platform and performance issues. 

=======================================================================
DID YOU LIKE THIS TIP? 

Why not let us know? Email your comments to
mailto:[EMAIL PROTECTED], or you can rate this tip by scrolling to
the bottom of
http://www.search390.com/tip/1,289483,sid10_gci553886,00.html
=======================================================================

===============================
JIM KEOHANE DAY!
===============================
Tomorrow (May 24) we've arranged for Jim Keohane, search390's
Troubleshooting S/390 and Web Integration Expert to patrol the
discussion forums and respond to your Developer and
E-Business-related posts instantly. Jim will be available from 12:00
PM to 2:00 PM EDT (16:00-18:00 GMT) to answer your questions and
share some of his most valuable tips and advice! 

Tomorrow at 12:00 PM EDT (16:00 GMT) go to either the Ebusiness
Forum: 
http://search390.discussions.techtarget.com/WebX?50@@.ee83ff8

Or the Developer Forum:
http://search390.discussions.techtarget.com/WebX?50@@.ee83ff7

And find Jim waiting with answers to any of your toughest S/390
questions. 

=======================================================================
ADDITIONAL RESOURCES:

*  Do you have programming-related questions? If so, ask an expert.
Search390 has two programming experts available to answer your
questions, so ask away!  Go to
http://search390.techtarget.com/ateQuestion/0,289624,sid10_tax285034,00.html

*  For a list of the latest tips on Search390.com, go to
http://search390.techtarget.com/tipsIndex/0,289482,sid10_tax286020,00.html
 
*  And don't forget to check out our discussion forums at
http://search390.discussions.techtarget.com/WebX?[EMAIL PROTECTED]^0@/search390
========================================================

========================================================
The Learning Zone Featured Book
========================================================
An Introduction to Object COBOL
Author: E. Reed Doke, Bill C. Hardgrave
Summary: With its use of straightforward language and real-world
examples, An Introduction to Object COBOL is a concise and accessible
introduction to using Object COBOL. You'll discover how object
technology is applied and how the resulting Object COBOL code is
constructed. All of the programs included in the text can be
downloaded from the Wiley web site (http://www.wiley.com/college/).
You are encouraged to execute and experiment with them. As you work
with these programs and follow the related case study, you will gain
important experience in using Object COBOL in a business environment.
http://www.digitalguru.com/dgstore/product.asp?isbn=0471183466&ac_id=54

========================================================
Disclaimer: Our tips exchange is a forum for you to share technical
advice and expertise with your peers and to learn from other IT
professionals. Techtarget.com provides the infrastructure to
facilitate this sharing of information. However, we can't guarantee
the accuracy and validity of the material submitted. You agree that
your use of the ask the expert services and your reliance on any
questions, answers, information or other materials received through
the web site will be at your own risk.
========================================================
If you no longer wish to receive this newsletter simply reply to 
this message with "REMOVE" in the subject line.  Or, visit 
http://search390.techtarget.com/register 
and adjust your subscriptions accordingly. 

If you choose to unsubscribe using our automated processing, you 
must send the "REMOVE" request from the email account to which 
this newsletter was delivered.  Please allow 24 hours for your 
"REMOVE" request to be processed.

Reply via email to