Top Xread Card, 80 Read Rec

Top Xread Card, 80 Read Rec

<p> XDECO/XDECI</p><p>MAIN CSECT USING MAIN,R15 * TOP XREAD CARD, 80 READ REC BC B’0100',EXIT CHECK EOF XDECI R2,CARD GET FIRST NUM XDECI R3,0(R1) GET NEXT NUM AR R3,R2 ADD NUMBERS XDECO R3,SUM BACK TO CHARACTER XPRNT PLINE,33 PRINT PLINE B TOP GO TO TOP OF LOOP * EXIT BR R14 LEAVE PROGRAM ****************************************************** CARD DC 20CL4'CARD’ 80 BYTE CARD PLINE DC CL1' ‘ CARRIAGE CONTROL DC CL20'HERE IS MY SUM’ MESSAGE SUM DC CL12'HI’ MUST BE 12 BYTES! END /* //FT05F001 DD * 5 7 6 10 (these are in stream data records 2 3 you type in for data) /*</p><p>(this is the printed output you would see in your job output)</p><p>HERE IS MY SUM 12 HERE IS MY SUM 16 HERE IS MY SUM 5</p><p>DO WHILE CONSTRUCT </p><p>WE WANT TO DO A LOOP 5 TIMES</p><p>PSEUDOCODE:</p><p>SET UP COUNTERS DO WHILE (COUNT <> 5) DO WORK IN LOOP ENDDO</p><p>CODE:</p><p>SR R2,R2 SET R2 TO O L R5,FIVE SET R5 TO 5 * DO1 CR R2,R5 ARE THEY = BC B’1000’,ENDDO1 BRANCH ON CC OF 0 TO DONE BE ENDO1  ***MNEMONIC ALTERNATIVE</p><p>(DO WORK IN LOOP HERE)</p><p>A R2,ONE ADD 1 TO R2 B DO1 GO TO TOP UNCONDITIONALLY * ENDDO1 go on with other code</p><p>++++++++++++++++++++++++++++++++++++++++++++++++++++ FIVE DC F’5’ ONE DC F’1’ IF - THEN CONSTRUCT</p><p>IF (NUM1 > NUM2) THEN ANSWER = NUM1 + NUM2 END IF</p><p>REGISTER 2 - > NUM1 REGISTER 3 - > NUM2 REGISTER 4 - > ANSWER</p><p>IF CR R2,R3 BC B'1101',ENDIF OR BNH ENDIF (fall through if higher,skip if not higher) LR R4,R3 AR R4,R2 ENDIF DS 0H ______</p><p>IF - THEN - ELSE CONSTRUCT</p><p>IF (NUM1 > NUM2) THEN ANSWER = NUM1 + NUM2 ELSE ANSWER = NUM1 ENDIF</p><p>REGISTER 2 - > NUM1 REGISTER 3 - > NUM2 REGISTER 4 - > ANSWER</p><p>IF CR R2,R3 BC B'1101',ELSE OR BNH ELSE LR R4,R3 COPY NUM2 TO ANSWER AR R4,R2 ADD NUM1 TO ANSWER BC B'1111',ENDIF OR B ENDIF ELSE DS 0H LR R4,R2 SET ANSWER=NUM1 ENDIF DS 0H</p><p> note DS 0H is used as a dummy label so we have a label to branch to, this is a common coding technique BUILDING A TABLE</p><p>BUILD DS 0H BUILD STARTS HERE LA R5,TABLE POINT TO TABLE * TOP XREAD CARD, 80 READ REC BC B’0100',EXIT CHECK EOF XDECI R2,CARD GET FIRST NUM ST R2,0(R5) PUT ENTRY IN TABLE LA R5,4(R5) GO TO NEXT ENTRY B TOP GO TO TOP OF LOOP * EXIT ST R5,EOT SAVE EOT BR R9 GO BACK TO MAIN ***************************************************** CARD DC 20CL4'CARD’ 80 BYTE CARD TABLE DC 10F’-15’ TABLE EOT DC F’-5’ EOT SAVED HERE INTERNAL SUBROUTINES</p><p>MAIN: BAL R9, BUILD CALL INTERNAL SUB BUILD . . . BUILD DS 0H BUILD STARTS HERE LA R5,TABLE POINT TO TABLE * TOP XREAD CARD, 80 READ REC BC B’0100',EXIT CHECK EOF XDECI R2,CARD GET FIRST NUM ST R2,0(R5) PUT ENTRY IN TABLE LA R5,4(R5) GO TO NEXT ENTRY B TOP GO TO TOP OF LOOP * EXIT ST R5,EOT SAVE EOT BR R9 GO BACK TO MAIN ***************************************************** CARD DC 20CL4'CARD’ 80 BYTE CARD TABLE DC 10F’-15’ TABLE EOT DC F’-5’ EOT SAVED HERE MVC/CLC SS INSTRUCTIONS</p><p>MVC IMPLIED MVC F1,F2 MVC F1(4),F2 ALWAYS USE LENGTHS MVC F1(4),F3 MVC F1(4),=CL4’MIKE’</p><p>MVC EXPLICIT LA R1,F1 LA R2,F2 MVC 0(4,R1),0(R2) SAME AS LINE 1 up top</p><p>CLC CLC F2(4),F3 LOGICAL COMPARE CLC F4(4),F5 WHICH IS GREATER?</p><p>F1 DC CL4’bbbb’ F2 DC CL4’BILL’ F3 DC CL4’BIFF‘ F4 DC XL4’FFFFFFFF’ F5 DC XL4’00000001’ CLI/MVI SI INSTRUCTIONS</p><p>MVI PLINE,C’b’ MVI PLINE,C’1’</p><p>CLI BYTE,’A’ CLI BYTE,X’C2’ CLI PLINE,C’-’ </p><p>BYTE DC CL1’b’ PLINE DC CL133‘THIS IS MY PLINE’</p><p>Clear a PLINE with blanks:</p><p>MVI PLINE,C’b’ MVC PLINE+1(122),PLINE</p><p>PLINE DC CL123’THIS IS MY PLINE’</p><p>EDIT used to convert from packed decimal to character for printing p 172 niu text are these examples</p><p>1. MVC PLINE+1(4),=XL4'40202020' Move pattern to pline ED PLINE+1(4),F2 —> 12 3C Edit packed num with pattern</p><p>40 20 20 20 40 F1 F2 F3 <---- Result after edit</p><p>Say F2 HAS 00 0C</p><p>40 40 40 40 <---- Result after edit</p><p>2. 40 20 21 20 21 in the pattern is significance starter</p><p>Edit 00 0C</p><p>40 40 40 FO IS RESULT AFTER EDIT</p><p>5. 40 20 6B 20 20 20 6B 20 20 21 4B 20 20 Edit 00 12 34 56 7C </p><p>40 40 40 40 F1 F2 6B F3 F4 F5 4B F6 F7 12,345.67 <-- after we print Edit 00 00 00 02 3C 40 40 40 40 40 40 40 40 40 40 4B F2 F3 .23 STANDARD LINKAGE</p><p>MAIN CSECT </p><p>LA R13,MSAVE POINT 13 AT MAIN SAVE (***This statement is for a teaching purposes)</p><p>LA R1,PLIST POINT R1 AT LIST OF ADDRESS. L R15,=V(BUILD) 15 POINTS TO SUBROUTINE BALR R14,R15 GO TO SUB, R14 IS RETURN</p><p>CARD DC CL80'CARD’ CARD TO READ INTO PLIST DC A(CARD,TABLE,EOT) LIST OF ADDRESSES TABLE DC 50F’-1' TABLE EOT DC F’-1' BUILD FILLS THIS IN MSAVE DC 18F’-1' MAIN SAVE AREA</p><p>______BUILD CSECT STM R14,R12,12(R13) SAVE CALLERS REGS LR R12,R15 POINT 12 AT START OF BUILD USING BUILD,R12 R12 IS BASE REG LA R14,BSAVE POINT AT BUILD SAVE AREA ST R14,8(R13) SET FORWARD POINTER ST R13,4(R14) SET BACK POINTER LR R13,R14 R13 IS NOW AT BUILD SAVE</p><p>LM R2,R4,0(R1) BRING IN PARMS, AT 0(R1) IS A LIST OF POINTERS XREAD 0(R2),80 WE READ CARD LIKE THIS</p><p>L R13,4(R13) GET OUT BACK POINTER LM R14,R12,12(R13) RESTORE REGS BR R14 GO BACK TO MAIN</p><p>BSAVE DC 18F’-1' BUILD SAVE PACKED DECIMAL</p><p>XREAD CARD,80 READ A CARD WITH 00032 IN CHAR ON IT</p><p>PACK NUM1(3),CARD(5) CONVERT FROM CHAR TO PACKED</p><p>AP NUM1(3),NUM2(2) ADD 5 TO NUM1 SP NUM1(3),NUM2(2) SUBTRACT 5 FROM NUM1 CP NUM1(3),=PL2'4' SEE IF NUM1 IS 4</p><p>ZAP BNUM(6),NUM1(3) MOVE TO BIGGER NUM MP BNUM(6),NUM3(2) NEED 2 BYTES LEADING ZEROS</p><p>DP NUM5(5),NUM4(2) ANSWER ON LEFT, REM ON RIGHT LENGTH OF REM. IS LENGTH 2 NUM5 NUM4 before 00 00 00 03 2C 00 3C after: ans rem 00 01 0C 00 2C </p><p>ZAP NUMOUT(5),NUM5(5) CAN YOU DO THIS? ______NUM1 DC PL3'1' NUM2 DC PL2'5' NUM3 DC PL2'3' BNUM DC PL6'0' NUM5 DC PL5'32' NUM4 DC PL2'3' NUMOUT DC PL5'0' SELECTION SORT ALGORITHM</p><p>BEGIN initially is a pointer to the first entry END is a pointer to the last entry I and LOW are also pointers 1 is the length of one entry</p><p>Do While (BEGIN < END) LOW = BEGIN I = BEGIN + 1 Do While (I not > END) If Key (LOW) > Key (I) LOW <- I Endif I = I + 1 Enddo Swap ENTRY (BEGIN) with ENTRY (LOW) BEGIN = BEGIN + 1 Enddo</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    12 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us