Paul Gilmartin wrote:
Consider:

/* I do this all the time... */

do phonyblock = 1 for 1
    ...
    if Bailout then leave phonyblock
    ...
end phonyblock

o I put a "name = 1 for 1" on all my large blocks, and use a
  matching "end name"
  - the interpreter checks that my "end"s match my "do"s.
  - but it's a kludge because I can't name the "end" nor the
    "leave" without introducing a phony control variable.

Structured HLASM provides a "simple" DO for this need. For example:

|  ************************************
|  * Program Main Line                *
|  ************************************
|    DO ,
|      JAS   R14,Routine1
|      DOEXIT LTR,R15,R15,NZ
|      JAS   R14,Routine2
|      DOEXIT LTR,R15,R15,NZ
|      .
|      . (more routine calls)
|      .
|    ENDDO ,

These can, of course, be named and nested -- no dummy control variable required:

|    DO LABEL=ThisIsTheNameOfMyOuterDo
|      DO LABEL=ThisIsTheNameOfMyInnerDo
|        .
|        .
|        LEAVE   ThisIsTheNameOfMyOuterDo
|        .
|        .
|      ENDDO , ThisIsTheNameOfMyInnerDo
|      .
|      . More logic here
|      .
|    ENDDO , ThisIsTheNameOfMyOuterDo

One nice feature is that any "labels" you choose are actually exposed -- as coded -- within the HLASM name space. This means you can use them to produce the most efficient code possible for frequently-executed routines. Consider this example, using TRE, I posted in another thread:

|    LM   R14,R15,0(R1)            Load string ptr and its length
|    LA   R1,TRTSCRUB              Ptr to translation table
|    XR   R0,R0                    Set stop char = x'00'
|    DO INF                        Do for translate
|      TRE   R14,R1                  Translate the string
|      DOEXIT Z                      Exit if no more data
|      IF O                          If iterate needed
|        ITERATE ,                     Process more data
|      ENDIF ,                       EndIf
|      MVC   0(1,R14),0(R1)          Translate x'00' to whatever
|      LA    R14,1(,R14)             Advance past stop character
|      AHI   R15,-1                  Decrement length remaining
|      DOEXIT NP                     Exit if no more data
|    ENDDO ,                       EndDo for translate

It should run slightly faster if I expose a DO label and code instead:

|    LM   R14,R15,0(R1)            Load string ptr and its length
|    LA   R1,TRTSCRUB              Ptr to translation table
|    XR   R0,R0                    Set stop char = x'00'
|    DO INF,LABEL=TreLoop          Do for translate
|      TRE   R14,R1                  Translate the string
|      DOEXIT Z                      Exit if no more data
|      JO    TreLoop                 Branch if another segment
|      MVC   0(1,R14),0(R1)          Translate x'00' to whatever
|      LA    R14,1(,R14)             Advance past stop character
|      AHI   R15,-1                  Decrement length remaining
|      DOEXIT NP                     Exit if no more data
|    ENDDO ,                       EndDo for translate

--
Edward E Jaffe
Phoenix Software International, Inc
5200 W Century Blvd, Suite 800
Los Angeles, CA 90045
310-338-0400 x318
[EMAIL PROTECTED]
http://www.phoenixsoftware.com/

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to