; ; ; This program is written in IBM mainframe assembly language (BAL). ; ; The program is designed to read 10 names, each up to 12 ; characters in length, from a file into an array. The array is ; then sorted using a rather crude sorting technique and written to ; another file. This program relies upon a collection of macros ; that converts the IBM instructions into equivalent VAX code to do ; the task. ; ; CSECT OPEN INFILE,INF,12,R ;Open input file; name ;at INFILE; 12-byte records EXPAND ;Show macros expanded L 1,ADD L 2,RECS ;Loop to read records into LOOP: GET INF,HOLD ;HOLD and move to array at MVC 0(12,1),HOLD ;NAMES (address in ADD) A 1,SIZE S 2,=F'1' BH LOOP ;Bottom of input loop CLOSE INF ;Close input file TOP: L 1,ADD ;Simple sort of NAMES L 3,=F'9' ;9 = record count - 1 AGAIN: CLC 0(12,1),12(1) ;Compare adjacent entries BNH HOP MVC SAFE(12),0(1) ;Exchange adjacent entries MVC 0(12,1),12(1) MVC 12(12,1),SAFE B TOP ;Start over after exchange HOP: A 1,SIZE S 3,=F'1' BH AGAIN ;Bottom sort loop OPEN OUTFILE,OUTF,12,W ;Open output file; name at ;OUTFILE; 12-byte records L 1,ADD L 2,RECS UP: MVC HOLD(12),0(1) ;Move a record to HOLD PUT OUTF,HOLD ;Write to output file A 1,SIZE S 2,=F'1' BH UP ;Bottom of output loop BR 14 ;Terminate program RECS: DC F'10' ;Number of records in file SIZE: DC F'12' ;Length of a record INFILE: DC F'13' ;Length of infile name DC C'ORIGINAL.FILE' ;Input file name OUTFILE: DC F'13' ;Length of outfile name DC C'SORTED.RESULT' ;Output file name ADD: DC A'NAMES' ;Address of array SAFE: DS 12C ;Temporary for exchanges HOLD: DS 12C ;Temporary for in/output NAMES: DS 120C ;Array of records END