*********************************************************************** ***** ***** ***** This program was originally written by David Bond for ***** ***** SHARE 99-101 session 8158. It has been placed into ***** ***** the public domain and thus may be freely modified and ***** ***** redistributed with no restrictions whatsoever. ***** ***** ***** ***** THERE IS NO WARRANTY FOR THIS PROGRAM, EITHER EXPRESS ***** ***** OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ***** ***** WARRENTIES OF MERCHANTABILITY AND FITNESS FOR A ***** ***** PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY ***** ***** AND PERFORMANCE OF THS PROGRAM IS WITH YOU. SHOULD THE ***** ***** PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL ***** ***** NECESSARY SERVICING, REPAIR OR CORRECTION. ***** ***** ***** *********************************************************************** *********************************************************************** * * * This program demonstrates the use of AMODE 64 and "above the bar" * * storage. It reads a file up to 10 Gigabytes into memory. Each * * record is 1000 bytes long, so the maximum number of records is * * more than 10,000,000. The file is then rewritten with the records * * in reverse order. * * * *********************************************************************** Punch ' MODE RMODE(SPLIT)' Print NoGen SYSSTATE AMODE64=YES,ARCHLVL=2 IHASAVER SAVER=NO,SAVF4SA=YES,SAVF5SA=NO * This OPSYN renames BAS to BRAS to keep OPEN and CLOSE happy BAS Opsyn BRAS Entry Csect Start of RMODE 24 area (data) Entry Amode 64 Entry Rmode 24 Prev Using (SAVF4SA,SAVF4SA+SAVF4SA_LEN),R13 STMG R14,R12,Prev.SAVF4SAG64RS14 Save caller's registers LARL R14,SaveArea Get save area address Using (SaveArea,EntryEnd),R14 Tell the assembler New Using (SAVF4SA,SAVF4SA+SAVF4SA_LEN),SaveArea MVC Prev.SAVF4SAID,=C'F4SA' Set format 4 indicator STG R14,Prev.SAVF4SANEXT Chain to next save area STG R13,New.SAVF4SAPREV Chain to previous save area LGR R13,R14 Get new save area address Drop New,R14,Prev Forget about R14 contents Using (SaveArea,EntryEnd),R13 Tell the assembler Using (SAVF4SA,SAVF4SA+SAVF4SA_LEN),SaveArea MVC SAVF4SAID,=C'F4SA' Set format 4 indicator LLGT R15,=A(Main) Get address of RMODE 31 area BR R15 and go to it SaveArea Dc 18FD'0' Origin Dc AD(0) Starting address of file storage High Dc AD(0) Ending address of file storage DcbIn DCB DDNAME=SYSUT1,DSORG=PS,MACRF=(GL),RECFM=FB,LRECL=1000, + DCBE=DcbeIn DcbeIn DCBE RMODE31=BUFF,EODAD=Eof DcbOut DCB DDNAME=SYSUT1,DSORG=PS,MACRF=(PL),RECFM=FB,LRECL=1000, + DCBE=DcbeOut DcbeOut DCBE RMODE31=BUFF IARV64 MF=(L,Iarv64) IARV64 parameter area Ltorg Dump RMODE 24 literals here EntryEnd ds 0d End of RMODE 24 section YREGS , Register Equates Print Gen Main Rsect Start of RMODE 31 area (program) Main Amode 64 Main Rmode 31 LARL R12,Static Get static data area address Using (Static,MainEnd),R12 Tell the assembler SGR R2,R2 Clear record counter IARV64 REQUEST=GETSTOR, Allocate 1 megabyte, + SEGMENTS==AD(MaxSize), but reserve much more + GUARDLOC=HIGH, in case the file is + GUARDSIZE==A(MaxSize-1), very large + ORIGIN=Origin, + MF=(E,Iarv64,COMPLETE) LG R4,Origin Get starting address LGR R0,R4 Compute ending address AGF R0,=A(1024*1024) Compute ending address STG R0,High * SAM31 Switch to AMODE 31 OPEN (DcbIn,(INPUT)),MODE=31 Open the data set GetLoop ds 0h SAM31 Switch to AMODE 31 LA R1,DcbIn Get DCB address GET (1) Read next record SAM64 Switch to AMODE 64 LAY R0,RecordLength(,R4) Get address of next slot CLG R0,High Room for this record? JNH MoveIt yes: jump LR R3,R1 Save R1 IARV64 REQUEST=CHANGEGUARD, Allocate another Megabyte + CONVERT=FROMGUARD, of storage + CONVERTSIZE==F'1', + MEMOBJSTART=Origin, + MF=(E,Iarv64,COMPLETE) LR R1,R3 Restore R1 LG R0,High Update the high storage address AGF R0,=A(1024*1024) to indicate it is STG R0,High 1 Megabyte larger MoveIt ds 0h LLGTR R0,R1 Convert to 64-bit address LGHI R1,RecordLength Copy record from QSAM buffer LGHI R5,RecordLength * MoveIn MVCLE R4,R0,0 * BRC 1,MoveIn * AGHI R2,1 Increment record count J GetLoop Go read next record Eof ds 0h Go here upon End Of File CLOSE (DcbIn),MODE=31 Close the data set CGHI R2,1 At least 2 records? JNH Done no: jump OPEN (DcbOut,(OUTPUT)),MODE=31 Open data set for output PutLoop ds 0h SAM31 Switch to AMODE 31 LA R1,DcbOut Get DCB address PUT (1) Get location of next record SAM64 Switch to AMODE 64 LLGTR R0,R1 Convert to 64-bit address LAY R4,-RecordLength(,R4) Get address of record LGHI R1,RecordLength Copy record to QSAM buffer LGHI R5,RecordLength * MoveOut MVCLE R0,R4,0 * BRC 1,MoveOut * LAY R4,-RecordLength(,R4) Get address of record BRCTG R2,PutLoop Go write next record SAM31 Switch to AMODE 31 CLOSE (DcbOut),MODE=31 Close the data set Done ds 0h SAM64 Switch to AMODE 64 IARV64 REQUEST=DETACH, Free the file storage + MEMOBJSTART=Origin, + MF=(E,Iarv64,COMPLETE) LGHI R15,0 Set return code zero LG R13,SAVF4SAPREV Restore caller's R13 LG R14,SAVF4SAG64RS14 Restore caller's R14 LMG R0,R12,SAVF4SAG64RS0 Restore caller's R0-R12 BR R14 Return to caller Static Ltorg Dump RMODE 31 literals here MainEnd ds 0d End of RMODE 31 section RecordLength Equ 1000 Record size MaxSize Equ 10*1024 Maximum file size in Megabytes End Entry