identification division. program-id. ASMXREF. select input-file assign to "c:\temp\romj.asm" organization is line sequential. select sort-file assign to "SORTWORK.FIL". select giving-file assign to "c:\temp\romjxref.txt" organization is line sequential. data division. file section. fd input-file. 01 input-record. 03 in-LINE pic x(120). 03 IN-CHARS REDEFINES IN-LINE PIC X OCCURS 120. * the sort file must have an 'sd' paragraph sd sort-file. 01 sort-record. 03 IN-SYMBOL pic x(16). 03 IN-NUM PIC 9999. 03 TYPE-FLAG PIC X. * giving-file is the output file fd giving-file. 01 giving-record. 02 p-line pic x(80). 02 sym-line redefines p-line. 03 filler pic x(16). 03 symbol-in pic x(16). 03 sym-ref pic x(6) occurs 8. 03 filler pic x(10). working-storage section. 01 upper-len pic 9999 comp-5 value 120. 01 u-ptr pic 999 comp. 01 u-ptr-save pic 999 comp. 01 wrk-rec. 03 in-sym pic x(16). 03 in-sym-chars redefines in-sym pic x occurs 16. 03 filler pic x(6) value "delim=". 03 in-del pic x. procedure division. main-section section. move 0 to in-num. * Example of INPUT PROCEDURE & OUTPUT PROCEDURE sort sort-file on ascending key in-symbol input procedure is pre-sort output procedure is out-sort close input-file giving-file stop run. * sort input procedure section: pre-sort section. open input input-file. read-input-routine. move spaces to in-line. read input-file record, at end go to END-PRE-SORT end-read call "cbl_toupper" using in-line by value upper-len. add 1 to in-num. chk-labels. if in-chars(1) = "$" go to read-input-routine. if in-chars(1) = ";" go to read-input-routine. IF IN-LINE = SPACES GO TO READ-INPUT-ROUTINE. move 1 to u-ptr, u-ptr-save. finish-label. unstring in-line delimited by all " " or ":" into in-sym delimiter in in-del pointer u-ptr. if in-sym-chars(1) = " " go to scan-operator. if in-sym = "IF" go to read-input-routine. move "D" to type-flag. move in-sym to in-symbol. release sort-record. if in-del = ":" go to finish-label. if u-ptr > 80 go to read-input-routine. scan-operator. unstring in-line delimited by all " " or ";" into in-sym delimiter in in-del pointer u-ptr. if in-del = ";" go to read-input-routine. if in-sym = "EQU" or in-sym = "BIT" go to read-input-routine. if in-sym = "MACRO" or in-sym = "DB" go to read-input-routine. * brute force method of stripping directives and other * stuff not wanted in the xref! Just add new if. if in-sym = "DW" or in-sym = "DATA" go to read-input-routine. if in-sym = "CODE" or in-sym = "RET" go to read-input-routine. if in-sym = "NOP" or in-sym = "RETI" go to read-input-routine. scan-operand. move u-ptr to u-ptr-save. move "R" to type-flag. unstring in-line delimited by all " " or "," or ";" or "-" or "+" or "#" or "'" into in-sym delimiter in in-del pointer u-ptr. if in-del = "'" go to read-input-routine. move in-sym to in-symbol. if in-sym = "LOW" or in-sym = "HIGH" GO TO chk-lin-done. IF in-sym = "ACC" or in-sym = "A" or in-sym = "$" go to chk-lin-done. if in-sym-chars(1) = "'" go to read-input-routine. if in-symbol not = space release sort-record. if in-del = "-" or in-del = "+" OR IN-DEL =";" go to read-input-routine. chk-lin-done. if u-ptr < 80 go to scan-operand. go to read-input-routine. end-pre-sort. exit. * sort output procedure section: out-sort section. open output giving-file. move 0 to u-ptr. move " " to p-line. out-sort-routine. return sort-file at end go to END-OUT-SORT end-return. * upd-loop. add +1 to u-ptr. if in-symbol not = symbol-in write giving-record move spaces to p-line move 0 to u-ptr move in-symbol to symbol-in go to upd-loop. if in-symbol = symbol-in and u-ptr = 9 write giving-record move spaces to p-line move 0 to u-ptr move in-symbol to symbol-in go to upd-loop. upd-ref. if type-flag = "D" string in-num "*" delimited by size into sym-ref(u-ptr) else move in-num to sym-ref(u-ptr). go to out-sort-routine. end-out-sort. write giving-record. exit. END PROGRAM asmxref.