Parsing and Outputting Text



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

Parsing and Outputting Text

Postby RISCCISCInstSet » Tue Oct 18, 2011 12:38 am

I'm trying to understand how to look at my code and output a modified version of it.

There's more I need to do, but what types of things do I need to do to edit this code to have it make it take input text files; then output text files with line numbers?

          AVG        SUBENTRY
          OPEN  (DATAIN,INPUT,SUMMARY,OUTPUT)
          READLOOP    DS    0H
          GET    DATAIN,INREC
          ZAP    TOTAL,=P’0’
          PACK  WORK8,NUM1
          AP    TOTAL,WORK8
          PACK  WORK8,NUM2
          AP    TOTAL,WORK8
          PACK  WORK8,NUM3
          AP    TOTAL,WORK8
          MP    TOTAL,=P’100’
          DP    TOTAL,=P’3’
          MVC   OUTID,INID
          UNPK  AVERAGE,TOTAL(5)
          PUT   SUMMARY,OUTREC
          B    READLOOP

          WORK8      DS    D
          TOTAL      DS    PL6
          INREC      DS    CL80
          INID       EQU   INREC,5
          NUM1      EQU   INREC+6,5
          NUM2      EQU   INREC+12,5
          NUM3      0E QU   INREC+18,5
          OUTREC      DS    CL13
          OUTID      EQU   OUTREC,5
          AVERAGE     EQU   OUTREC+6,7
        END   AVG 
RISCCISCInstSet
User avatar
RISCCISCInstSet
 
Posts: 121
Joined: Mon Oct 17, 2011 1:46 pm
Has thanked: 146 times
Been thanked: 0 time

Re: Parsing and Outputting Text

Postby Maxime B » Tue Oct 18, 2011 12:54 am

Since it seems you're new to assembler, to understand your code, you can check z/Architecture Reference Summary : http://publibz.boulder.ibm.com/epubs/pdf/dz9zs005.pdf" onclick="window.open(this.href);return false;

For a more detailed description of the operations, check z/Architecture Principles of Operations :
http://publibz.boulder.ibm.com/epubs/pdf/dz9zr007.pdf" onclick="window.open(this.href);return false;

It's been a while since I've done some assembler but by looking rapidly at your code, you open the DDNAME "DATAIN", loop on each record and write in DDNAME "SUMMARY". It shouldn't be too hard to modify to do what you need.

If you really don't understand a thing, you should get a look at that topic :
assembler/topic3082.html

These users thanked the author Maxime B for the post:
RISCCISCInstSet (Mon Nov 12, 2012 4:57 am)
Maxime B
 
Posts: 21
Joined: Thu Oct 13, 2011 12:40 am
Has thanked: 0 time
Been thanked: 1 time

Re: Parsing and Outputting Text

Postby dick scherrer » Tue Oct 18, 2011 1:19 am

Hello and welcome to the forum,

Suggest you copy the code you have to a new source module. Then remove everything except the OPEN, read (GET), and write (PUT).

Assemble and get the simple copy running.

Then add the code to define a line number to increment, increment the line number, and write the new output record instead of the original.

Any organization that permits using assembler insists that code follow the "standard linkage conventions" for that organization. Ask someone who works on your system to show you where these are located. They may be macros, copy-members, or in-line code, but should be used in whatever way is standard there.

For your initial testing, you might not include these, but if this is to be something long-term, you surely want to use standard practices.
Hope this helps,
d.sch.

These users thanked the author dick scherrer for the post:
RISCCISCInstSet (Mon Nov 12, 2012 4:58 am)
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Parsing and Outputting Text

Postby RISCCISCInstSet » Tue Oct 18, 2011 2:16 am

How do you displace text? As in, how do you place a character such that the others are pushed to the right are put in the next line?

Code that went with what I put out:

ENDDATA     DS    0H 
          CLOSE  (DATAIN,,SUMMARY) 
          SUBEXIT 
DATAIN      DCB    DDNAME=INPUT,                                              X 
              DSORG=PS,                                              X 
              EODAD=ENDDATA,                                              X 
              LRECL=80,                                               X 
              RECFM=FT,                                              X 
              MACRF=GM 
SUMMARY    DCB    DDNAME=OUTPUT,                                              X 
              BLKSIZE=130,                                              X 
              LRECL=13,                                              X 
              DSORG=PS,                                              X 
              RECFM=FT,                                              X 
              MACRF=PM 
RISCCISCInstSet
User avatar
RISCCISCInstSet
 
Posts: 121
Joined: Mon Oct 17, 2011 1:46 pm
Has thanked: 146 times
Been thanked: 0 time

Re: Parsing and Outputting Text

Postby steve-myers » Tue Oct 18, 2011 9:57 am

Ther is nothing really wrong with the way you have defined your input and output areas, but this is not the way it's usually done. This is how it is usually done.
INREC   DS    0CL80
INID    DS     CL5
        DS     C
NUM1    DS     CL5
        DS     C
NUM2    DS     CL5
        DS     C
NUM3    DS     CL5
        DS     (L'INREC-(*-INREC))C


OUTREC  DS     0CL13
OUTID   DS     CL5
        DS     C
AVERAGE DS     CL7
That complicated DS statement after NUM3 just fills out the data area so it is a full 80 bytes. The way it is written means that if you alter the main part of the input area you do not have to alter the statement. In addition, assuming you have written the statement correctly, and the previous data area is greater than 80 bytes you will get an Assembler error.

When you wrote your EQU statements, I noticed you specified the length attribute. This was the right thing to do; something many programmers fail to do.

Defining an input area as you did and using the move mode to copy input data to your area is perfectly legal, but you'll find it's not usually done. Most programmers define their input area as a DSECT and use locate mode I/O to return the address of the data area after the GET macro terminates. This saves storage in your program, which does not matter here but as you write larger programs you will find that can be very important. Using locate mode I/O also saves a small amount of CPU time.

I also noticed your have a field labeled AVERAGE in your output record. You compute an average by dividing a sum by a count. The Divde Decimal instruction is quite tricky. The output area is divided into rwo packed decimal fields: the result and the remainder.
         ZAP   VALUE,=P'25'
         DP    VALUE,COUNT
         .
         .
         .
COUNT    DC    PL1'3'
RESULT   DC    PL(3-L'COUNT)'8'
REMAINDER DC   PL(L'COUNT)'1'
VALUE    EQU   RESULT,L'RESULT+L'REMAINDER
In my example, the output area is initialized to the ultimate result, and it is replaced by the initial value before the DP instruction.

These users thanked the author steve-myers for the post:
RISCCISCInstSet (Mon Nov 12, 2012 4:58 am)
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Parsing and Outputting Text

Postby RISCCISCInstSet » Tue Oct 18, 2011 11:56 pm

At the moment I'm having trouble getting the code I have to run.

AVG        SUBENTRY 
          OPEN  (DATAIN,INPUT,SUMMARY,OUTPUT) 
READLOOP    DS    0H 
          GET    DATAIN,INREC 
          ZAP    TOTAL,=P’0’ 
          PACK  WORK8,NUM1 
          AP    TOTAL,WORK8 
          PACK  WORK8,NUM2 
          AP    TOTAL,WORK8 
          PACK  WORK8,NUM3 
          AP    TOTAL,WORK8 
          MP    TOTAL,=P’100’ 
          DP    TOTAL,=P’3’ 
          MVC   OUTID,INID 
          UNPK  AVERAGE,TOTAL(5) 
          PUT    SUMMARY,OUTREC 
          B    READLOOP 
WORK8      DS    D 
TOTAL      DS    PL6 
INREC      DS    CL80 
INID       EQU   INREC,5 
NUM1      EQU   INREC+6,5 
NUM2      EQU   INREC+12,5 
NUM3      EQU   INREC+18,5 
OUTREC      DS    CL13 
OUTID      EQU   OUTREC,5 
AVERAGE     EQU   OUTREC+6,7 
       

DATAIN   DCB   DDNAME=INPUT,                                           X
               DSORG=PS,                                               X
               EODAD=ENDDATA,                                          X
               LRECL=80,                                               X
               RECFM=FT,                                               X
               MACRF=GM
SUMMARY  DCB   DDNAME=OUTPUT,                                          X
               BLKSIZE=130,                                            X
               LRECL=13,                                               X
               DSORG=PS,                                               X
               RECFM=FT,                                               X
               MACRF=PM


13:23:23 ToModify  MZ390 START USING z390 V1.5.05 ON J2SE 1.6.0_26 10/18/11
13:23:23 ToModify  MZ390 MZ390E error 138         (1/5)5 invalid ascii source line 5 in c:\Program Files\Automated Software Tools\z390\CS4321\ToModify.MLC
13:23:23 ToModify  MZ390 MZ390E error 138       (1/12)12 invalid ascii source line 12 in c:\Program Files\Automated Software Tools\z390\CS4321\ToModify.MLC
13:23:23 ToModify  MZ390 MZ390E error 138       (1/13)13 invalid ascii source line 13 in c:\Program Files\Automated Software Tools\z390\CS4321\ToModify.MLC
13:23:23 ToModify  MZ390 MNOTE 4,'missing END statement'
13:23:23 ToModify  AZ390 AZ390E error 196         (1/1)1   AVG        SUBENTRY 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196         (1/2)2   Â          OPEN  (DATAIN,INPUT,SUMMARY,OUTPUT) 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196         (1/3)3   READLOOP    DS    0H 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196         (1/4)4   Â          GET    DATAIN,INREC 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196         (1/5)5   Â          ZAP    TOTAL,=P0 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196         (1/6)6   Â          PACK  WORK8,NUM1 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196         (1/7)7   Â          AP    TOTAL,WORK8 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196         (1/8)8   Â          PACK  WORK8,NUM2 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196         (1/9)9   Â          AP    TOTAL,WORK8 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196       (1/10)10   Â          PACK  WORK8,NUM3 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196       (1/11)11   Â          AP    TOTAL,WORK8 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196       (1/12)12   Â          MP    TOTAL,=P100 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196       (1/13)13   Â          DP    TOTAL,=P3 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196       (1/14)14   Â          MVC   OUTID,INID 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196       (1/15)15   Â          UNPK  AVERAGE,TOTAL(5) 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196       (1/16)16   Â          PUT    SUMMARY,OUTREC 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196       (1/17)17   Â          B    READLOOP 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196       (1/18)18   WORK8      DS    D 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196       (1/19)19   TOTAL      DS    PL6 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196       (1/20)20   INREC      DS    CL80 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196       (1/21)21   INID       EQU   INREC,5 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196       (1/22)22   NUM1      EQU   INREC+6,5 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196       (1/23)23   NUM2      EQU   INREC+12,5 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196       (1/24)24   NUM3      EQU   INREC+18,5 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196       (1/25)25   OUTREC      DS    CL13 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196       (1/26)26   OUTID      EQU   OUTREC,5 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196       (1/27)27   AVERAGE     EQU   OUTREC+6,7 
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error 196       (1/28)28   Â Â Â     
13:23:23 ToModify  AZ390 AZ390I invalid character in opcode -  
13:23:23 ToModify  AZ390 AZ390E error  98      (2/113)38            DC    A(ENDDATA) DCBEODAD
13:23:23 ToModify  AZ390 AZ390I symbol not found - ENDDATA
13:23:23 ToModify  AZ390 MNOTE 12,'DCB INVALID LRECL/BLKSIZE'
13:23:23 ToModify  AZ390 AZ390I FID=  1 ERR=  31 c:\Program Files\Automated Software Tools\z390\CS4321\ToModify.MLC
13:23:23 ToModify  AZ390 AZ390I FID=  2 ERR=   2 c:\PROGRA~1\AUTOMA~1\z390\mac\DCB.MAC
13:23:23 ToModify  MZ390 ENDED   RC=12 SEC= 0 MEM(MB)= 44 IO=983


Can you tell me about what's going on?
RISCCISCInstSet
User avatar
RISCCISCInstSet
 
Posts: 121
Joined: Mon Oct 17, 2011 1:46 pm
Has thanked: 146 times
Been thanked: 0 time

Re: Parsing and Outputting Text

Postby enrico-sorichetti » Wed Oct 19, 2011 12:02 am

since You are not using a mainframe version of assembler
the best places to ask for help are the z390 mailing lists
as described here http://www.z390.org/
most probably here http://groups.yahoo.com/group/z390/

the chances of getting help here are pretty slim
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort

These users thanked the author enrico-sorichetti for the post:
RISCCISCInstSet (Mon Nov 12, 2012 4:58 am)
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: Parsing and Outputting Text

Postby RISCCISCInstSet » Wed Oct 19, 2011 12:51 am

Okay, thanks for those links, but how are the emulator and the mainframe different diffent in this regard?
RISCCISCInstSet
User avatar
RISCCISCInstSet
 
Posts: 121
Joined: Mon Oct 17, 2011 1:46 pm
Has thanked: 146 times
Been thanked: 0 time

Re: Parsing and Outputting Text

Postby RISCCISCInstSet » Wed Oct 19, 2011 1:03 am

Another thing: sorry about not noting I was using an emulator. :oops:
RISCCISCInstSet
User avatar
RISCCISCInstSet
 
Posts: 121
Joined: Mon Oct 17, 2011 1:46 pm
Has thanked: 146 times
Been thanked: 0 time

Re: Parsing and Outputting Text

Postby dick scherrer » Wed Oct 19, 2011 2:24 am

Hello,

but how are the emulator and the mainframe different diffent in this regard
I As none of what you are running is the mainframe "version", there will be many, many differences. Some of the instructions will function as the mainframe does, but the assembler process is completely different.

Do you have something specific in mind?
Hope this helps,
d.sch.

These users thanked the author dick scherrer for the post:
RISCCISCInstSet (Mon Nov 12, 2012 4:58 am)
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Next

Return to Assembler

 


  • Related topics
    Replies
    Views
    Last post