Bit of help with code

Ask/Clarify the questions on ASSEMBLER language.

Moderator: Moderator Group

Post Reply
MikeL
Member
Posts: 7
Joined: Fri Aug 16, 2013 8:28 pm

Bit of help with code

Post by MikeL » Fri Aug 16, 2013 8:44 pm

I haven't coded assembler, much, since I was a systems programmer back in the 80's, so I'm not familiar with the new z-os instructions. I have a task that I coded to process an XML stream being sent through MQ. One of the segments of the program is to parse the data stream, looking for characters that the target program needs translated into their HTML equivalents.

ex: & must translate to &amp; < translates to &lt;

Now, I have the code working in 370-model assembler. The problem is the size of the data stream (8meg) takes up to 11 seconds to process. I would like to see if any of the newer instructions could speed this up. Admittedly, being old-school, I am not aware of anything beyond that there are new instructions. I've found a few doing searches on IBM's site (CUSE, SRST), but don't know much on how to use them, or if they are really CPU hogs, and what I have is the best I can hope for.

Below is the code I am currently using (MQ-DATA is 8meg in size).

Many thanks in advance.

Code: Select all

         LA    R4,MQDATA             GET STARTING ADDRESS      
         LA    R6,MQWORK             GET ADDRESS OF WORK AREA  
         L     R5,MQLEN              GET XML LENGTH            
         LR    R7,R5                                           
         ST    R5,SAVELEN                                      
         L     R14,=F'1'             SET UP FOR LOOP           
*                                                              
*---------------------------------------------------------*    
*  THIS SECTION WILL REPLACE INVALID CHARACTERS WITH XML  *    
*---------------------------------------------------------*    
XMLSWP1  EQU   *                     REPLACE SPECIAL CHARACTERS
         CLI   0&#40;R4&#41;,X'00'           BINARY ZERO?              
         BE    BINZERO                                         
         CLI   0&#40;R4&#41;,C'&&'           AMPERSAND                 
         BE    AMPERSND                                        
         CLI   0&#40;R4&#41;,C'<'            LESS-THAN SIGN            
         BE    LESSTHAN                                         
*                                                               
XMLSWP1A EQU   *                                                
         MVC   0&#40;4,R6&#41;,0&#40;R4&#41;         MOVE UNTRANSLATED CHARACTER
*                                                               
XMLSWP1B EQU   *                                                
         LA    R4,1&#40;R4&#41;              BUMP UP TO NEXT CHAR       
         LA    R6,1&#40;R6&#41;                                         
         BCT   R5,XMLSWP1            LOOP IF MORE TO MOVE       
...
*                                                                    
BINZERO  EQU   *                                                     
         MVI   0&#40;R6&#41;,C' '            REPLACE BIN ZERO WITH SPACE     
         B     XMLSWP1B                                              
*                                                                    
AMPERSND EQU   *                                                     
         MVC   0&#40;5,R6&#41;,=C'&&amp;'    REPLACE AMPERSAND WITH HTML CODE
         LA    R6,4&#40;R6&#41;                                              
         LA    R7,4&#40;R7&#41;                                              
         B     XMLSWP1B                                              
*                                                                    
LESSTHAN EQU   *                                                     
         C     R5,SAVELEN            FIRST CHARACTER IN STREAM?      
         BE    XMLSWP1A                ALLOWED                       
*                                                                    
         CLC   0&#40;2,R6&#41;,=C'</'        ENDING XML TAG?                 
         BE    XMLSWP1A                ALLOWED                       
*                                                                    
         LR    R1,R6                                                 
         SR    R1,R14                                                
         CLC   0&#40;2,R1&#41;,=C'><'        PAIR OF XML TAGS?               
         BE    XMLSWP1A                ALLOWED                       
*                                                                    
         MVC   0&#40;4,R6&#41;,=C'&&lt;'     REPLACE LESS-THAN WITH HTML CODE
         LA    R6,3&#40;R6&#41;                                              
         LA    R7,3&#40;R7&#41;
         B     XMLSWP1B

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Fri Aug 16, 2013 11:57 pm

If you need to parse 8meg one byte at a time, i suspect it will take a while . . .

Lots of your instructions are register-register and/or "immediate" instructions which perform better than storage-storage instructions.

Have you verified that the 11 seconds is in this bit of code?
Last edited by DikDude on Tue Aug 20, 2013 12:39 am, edited 1 time in total.
Have a good one

MikeL
Member
Posts: 7
Joined: Fri Aug 16, 2013 8:28 pm

Post by MikeL » Sat Aug 17, 2013 1:35 am

Yes and no. There is other processing, even more time consuming that this. I was going to post that snippet next for help. But I wanted to go at it one function at a time. I don't know what portion of the 11 seconds is in this vs the other function, I imagine this is 1/3 of that time.

The second function strips away excess spaces between XML tags to reduce the amount of data being sent through MQ. I am still working on minimizing the execution time in this function.

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Tue Aug 20, 2013 12:45 am

Hello,

I've been known to pull a suspicious bit of code into a separate module and do timing tests with this separately.

Read the data in some other bit of code and make a time stamp in a file each time thru recording start-end and total.

You might do the same with the other routine you believe will take a lot of time as well.

As i mentioined earlier, parsing 8meg byte-by-byte Will take time.
Have a good one

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others