YREGS * Define register names ... * The first code sample below shows the 2 most common uses of EX. * The first packs a numeric field after determining how many digits there are. * The second moves a variable number of characters. * The examples use TRT which scans a field, looking for specified characters. * When it finds something, it puts the address of the found character in * register 1, and the byte from the search table in register 2. * For a description of TRT, see that instructions description. * * In the first TRT, we ignore ##s and look for anything else, * in order to find the length of the numeric field. * We then use EX to pack the exact number of digits found. * * In the second TRT, we ignore everything else, and look for a period, * in order to find the text length. * We then move the exact number of characters in the string. * SR R2,R2 * TRT does not clear the high 3 bytes. TRT CARD(16),TESTNUM * Scan to find end of ### field. BZ TOOLONG * More than 15 digits, error BCTR R2,NOTNUM * Not ending in blank, error. S R1,=A(CARD+1) * Calc length of ### -1 EX R1,PACK * and pack ### into packed field ... TRT CARD,FINDPER * Find end of text S R1,=A(CARD+1) * Calc length we want to move EX R1,MOVECHAR * move to output field ... * PACK PACK DW,CARD(0) MOVECHAR MVC LINE(0),CARD * CARD DC C'124356 IS THE NUMBER TO CONVERT TO PACKED DECIMAL.' DW DC D'0' LINE DC CL133' ' * * TRT table: Numbers are X'F0'through X'F9' TESTNUM DC CL64' ',X'01',CL175' ',XL10'00',CL6' ' * TRT table: Period is X'75' FINDPER DC XL75'00',C'.',XL180'00' * =================================== TESTNUM1 DC CL240' ',XL10'00',CL6' ' ORG TESTNUM+C' ' DC X'01' ORG FINDPER1 DC XL256'00' ORG FINDPER+C'.' DC C'.' ORG * * There are 2 ways to define the TRT tables shown above. * Both are shown above and both produce the same result. * ...
YREGS * Define register names ... * This is a rather long example, that shows the use of EX twice. * The first use is to pack a variable number of numeric digits. * The second use is to move a string of variable length. * Note that because EX OR's the low byte of the specified register, * there may already be some non-zero bits in the target instruction. * * The example shows reading a text file, and narrowing the text to * fit into a column width that is specified in the first record of * the text read. * OPEN (INPUTDCB,INPUT,COLUMOUT,OUTPUT) GET INPUTDCB,LINE * Read the control record. TRT LINE,TESTNUM * Test for numeric field. BZ TOOLONG * If too long, error. S R1,=A(LINE+1) * Calc length-1 of ### BM NOTNUM * If length=0, error. EX R1,PACKLEN * Pack the digits read CVB R8,DW * And make it binary. = col width. * FIRSTREA LA R3,LINE * Point to input record area LR R4,R3 * Point to first available loc to read * READ GET INPUTDCB,(R4) * Read into first blank area CLC SPACES(12),0(R4) * Q. spaces? BNE SETSCAN * no, go parse. PUT COLUMDCB,(R3) * yes, write remnants of prior text PUT COLUMDCB,(SPACES) * and a blank line. MVC LINE,SPACES * init line to blanks B FIRSTREA * and start all over * * In this routine, we'll find the end of the read text, so we know where to * put the next line read. * SETSCAN LA R4,133(R4) * Point to last possible loc SETSCANB BCTR R4,0 * Backup until we find some text CLI 0(R4),C' ' * Q. text yet? BE SETSCANB * no, backup more LA R4,2(R4) * yes, point 1 byte past end of text. * * In the scan routine, we'll see if there is enough text to fill a column. * If not, we go read and get some more. * SCAN LA R5,1(R3,R8) * Set end of col width. CR R5,R4 * Q. is there enough text to fill col line? BNH BACKUP * yes, go find work break. CLC SPACES(12),0(R3) * Q. is there more text? BE FIRSTREA * no, go start anew. MVC LINE,0(R3) * yes, move remaining text to beg of line S R3,=A(LINE) * calc how far to backup end-of-text SR R4,R3 * calc place to put next input line LA R3,LINE * point to start of text B READ * and go add to end of text * * Here, we back up until we find a word break. * BACKUP BCTR R5,0 * Back up 1 byte CLI 0(R5),C' ' * Q. are we still in the middle of word? BNE BACKUP * yes, back up 1 more byte to find text. LR R2,R5 * no, calc length of text to move SR R2,R3 * to the column buffer. EX R2,MVCCOL * move text to column buffer PUT COLUMOUT,column * write column buffer LA R3,2(R3,R2) * point to next word MVC COLUMN,SPACES * space out column buffer CLC SPACES(12),0(R3) * Q. end of text? BE FIRSTREA * yes, start with new text line. B SCAN * no, continue with next text word. * ENDOFILE MVC 0(133,R4),SPACES * Insure spaces PUT COLUMOUT,(R3) * Write last column record CLOSE (INPUTDCB,,COLUMOUT) * Close files. ... * MVCCOL MVC COLUMN,0(R3) * Move variable length of text PACKLEN PACK DW,LINE(1) * Pack variable # of digits to 8 byte field. * DW DC D'0' SPACES DS 0CL133 * we use the numeric test tbl for blanks. TESTNUM DC CL240' ',10X'00',CL6' ' * this is used to test for #s. * INPUTDCB DCB DDNAME=CHARTEXT,DSORG=PS,DEVD=DA,MACRF=GM,EODAD=ENDOFILE COLUMOUT DCB DDNAME=COLUMN,DSORG=PS,DEVD=DA,MACRF=PM * LINE DC 2CL133' ' * input text line (long to accomodate 2 lines) COLUMN DC CL133' ' * output column ...
To the Opcodes Overview.
To the English Homepage for Hlasm.com.
To the General Homepage for Bixoft and Hlasm.com.
This site is a member of WebRing.
You are invited to browse the list of mainframe-loving sites.
|Dinos are not dead. They are alive and well and living in data centers all around you. They speak in tongues and work strange magics with computers. Beware the dino! And just in case you're waiting for the final demise of these dino's: remember that dinos ruled the world for 155-million years!|
[ Join Now | Ring Hub | Random | | ]
Below you find the logo of our sponsor and logos of the web-standards that this page adheres to.