Bit of help with code
Posted: 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 & < translates to <
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.
ex: & must translate to & < translates to <
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(R4),X'00' BINARY ZERO?
BE BINZERO
CLI 0(R4),C'&&' AMPERSAND
BE AMPERSND
CLI 0(R4),C'<' LESS-THAN SIGN
BE LESSTHAN
*
XMLSWP1A EQU *
MVC 0(4,R6),0(R4) MOVE UNTRANSLATED CHARACTER
*
XMLSWP1B EQU *
LA R4,1(R4) BUMP UP TO NEXT CHAR
LA R6,1(R6)
BCT R5,XMLSWP1 LOOP IF MORE TO MOVE
...
*
BINZERO EQU *
MVI 0(R6),C' ' REPLACE BIN ZERO WITH SPACE
B XMLSWP1B
*
AMPERSND EQU *
MVC 0(5,R6),=C'&&' REPLACE AMPERSAND WITH HTML CODE
LA R6,4(R6)
LA R7,4(R7)
B XMLSWP1B
*
LESSTHAN EQU *
C R5,SAVELEN FIRST CHARACTER IN STREAM?
BE XMLSWP1A ALLOWED
*
CLC 0(2,R6),=C'</' ENDING XML TAG?
BE XMLSWP1A ALLOWED
*
LR R1,R6
SR R1,R14
CLC 0(2,R1),=C'><' PAIR OF XML TAGS?
BE XMLSWP1A ALLOWED
*
MVC 0(4,R6),=C'&<' REPLACE LESS-THAN WITH HTML CODE
LA R6,3(R6)
LA R7,3(R7)
B XMLSWP1B