Fun With Chaotic Code

High Level Assembler(HLASM) for MVS & VM & VSE

Fun With Chaotic Code

Postby RISCCISCInstSet » Wed Dec 12, 2012 8:12 am

related to

I was working on my stuff and I put something together. The main point of what is below is I have something to work with right now. I would like you to not point out how much this code sucks and show how much it doesn't work, as I already know that. What I'm trying to do is understand how to look at individual characters in given input text, to respond accordingly in my given algorithm.




notEOF EQU *
    LA 0,INPUT1 
    LA  1,L’INPUT1   
    LA  14,COMMA   
    LA  15,L’COMMA   
    ICM  15,B’1000’,=X’40
    CLCL    0,14
    BZ    OUT
    B     ANYCHAR    EQU  *
OUT    EQU   *
    B  notEOF  EQU   *
EOF      DS    0H
         CLOSE (INFILE)
         CLOSE (OUTFILE)
         WTO   'PROG4 ENDED OK'
INFILE   DCB   DDNAME=INPUT,                                           X
               DSORG=PS,                                               X
               EODAD=EOF,                                              X
               LRECL=80,                                               X
               RECFM=FB,                                               X
OUTFILE  DCB   DDNAME=OUTPUT,                                          X
               LRECL=80,                                               X
               DSORG=PS,                                               X
               RECFM=FB,                                               X
               MACRF=(PM),                                             X

         END   COPY
User avatar
Posts: 121
Joined: Mon Oct 17, 2011 1:46 pm
Has thanked: 146 times
Been thanked: 0 time

Re: Fun With Chaotic Code


Re: Fun With Chaotic Code

Postby steve-myers » Wed Dec 12, 2012 10:39 am


is not Assembler!

You've been told this before: use QSAM "locate" mode for input data sets; the GET macro returns the address of a record, and you do not have to provide a record buffer of your own. I use "move" mode at least once every 10 years, so there are times when it is appropriate, but they are rare indeed.

I do not see any code to find a comma. There are two common approaches. Beginners do a loop that tests each byte. More advanced programmers will use the TRT instruction to test the entire record, or at least groups of 256 bytes. A TRT solution is noticeably faster, but is harder for a beginner to understand.
         GET   INFILE
         LR    3,1
         LR    14,1
         LR    15,0
FIND     CLI   0(14),C','
         BE    FOUND
         AH    14,=H'1'
         BCT   0,FIND
FOUND    AR    15,3
         SR    15,14
         BNP   NOFILL
         SR    1,1
         ICM   1,B'1000',=C' '
         MVCL  14,0
NOFILL   ---

The GET macro is for QSAM "locate" mode I/O.

(DCBLRECL-IHADCB)+INFILE is the address of DCBLRECL in the INFILE DCB. Doing it this way is simpler than setting up addressability for the DCB data area, though the coding for the one instruction certainly look complicated!

The program will get to FOUND for two reasons. What are they?

What are the contents of register 14 for each reason the program got to FOUND?

What are the contents of register 15 after the AR instruction at FOUND executes?

What are the contents of register 15 after the SR instruction after FOUND executes? What is the purpose of the BNP instruction after the SR instruction executes?

There are three sources for the contents of DCBRECFM, DCBLRECL and DCBBLKSI in a DCB:
  • Values specified in the DCB macro itself or placed there before the OPEN macro for the DCB macro executes.
  • Values specified in the DD statement.
  • The data set label.
It is usually a good idea to not specify values for an input data set. If you must specify something, specify just RECFM. That way, the OPEN will usually fail if the DD statement or the data set label specify something that does not agree with the RECFM.

In your next post for this topic I expect answers for the 5 questions in this post.

These users thanked the author steve-myers for the post:
RISCCISCInstSet (Wed Dec 12, 2012 12:14 pm)
Global moderator
Posts: 1773
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 168 times

Return to Assembler


  • Related topics
    Last post