ALWAYS 22MAR5 FORMAT ;22MAR5 ;************************************************************************ ;* * ;* Module: FORMAT - Set I/O file format for READ and WRITE * ;* * ;* Author: Chris Doran * ;* * ;* Date: 14-Nov-83 * ;* * ;* Input Parameters: * ;* * ;* R0 Points to the command line in process * ;* * ;* Output parameters: * ;* * ;* R0 points just beyond the last character of the line * ;* * ;* RWFORMAT contains format code no:- * ;* Micro- INTEL = 0 (default) * ;* processors: MOTOROLA = 2 * ;* ROCKWELL = 4 * ;* RCA = 6 * ;* TEKHEX = 10 * ;* EXTENDED = 12 Extended Tekhex * ;* TEXAS = 14 (TI99xx) * ;* MOSTEK = 16 * ;* WHITESMITHS = 20 (XEQ.) * ;* RIM = 22 PDP-8 Read-In-Mode * ;* BIN = 24 PDP-8 Binary mode * ;* HEX = 26 (hex space etc.) * ;* OCTAL = 30 (octal space etc.) * ;* TCI = 32 * ;* FAIRCHILD = 34 * ;* SIRA = 36 (Sira binary) * ;* PDP-11: OBJECT = 40 (MACRO-11 .ENABL ABS) * ;* ABSOLUTE = 42 (paper-tape abs loader) * ;* TASK = 44 (TKB .SYS file) * ;* * ;* (actual codes are defined in main module HEX.) * ;* * ;* For HEX and OCTAL formats: * ;* SEPTOR contains number terminator (default space, * ;* other common ones are %, ', and comma). Always * ;* ' for SMS format. * ;* BEGFLG contains beginning of data flag: SOM=DC2=ctrl/R * ;* for SMS format, else STX (ctrl/B) * ;* ENDFLG contains end of data flag: EOM=DC4=ctrl/T for * ;* SMS, else ETX (ctrl/C). * ;* * ;* If no argument is given, the current format is shown. * ;* * ;* Destroys: %1, %2, %4, %5 * ;* * ;* MODIFICATIONS RECORD: * ;* ===================== * ;* CJD Jan 84 * ;* Add new formats. * ;* Always confirm format selected. * ;* CJD 29-Feb-84 * ;* Support SMS option for HEX and OCTAL formats, and correct bug * ;* that HEX didn't confirm. * ;* Add FAIRCHILD format. * ;* * ;* 27MAR4 Scott Smith, Telex Computer Products, Raleigh, NC. * ;27MAR4 ;* Changed to accept both 'EXTENDED' and 'EXTENDED TEKHEX'.* ;27MAR4 ;* This change was necessary in order to preserve * ;27MAR4 ;* compatibility with the format command in Kevin Angley's * ;27MAR4 ;* original version of HEX. * ;27MAR4 ;* * ;27MAR4 ;* CJD 22-Mar-85 * ;22MAR5 ;* Merge 27MAR4 with 29FEB4. * ;22MAR5 ;* * ;************************************************************************ .MCALL DIR$,CALLR FORMAT:: MOV #FORMTS,%4 ; Address list of formats TSTB (R0) ; Format specified? BEQ 100$ ; No, just display 10$: CLR %5 ; Clear format code 20$: MOV %4,%1 ; Copy format name pointer CALL MATCH ; See if we have a match BEQ 40$ ; Yes, found entry, branch TST (%5)+ ; No, advance format code 30$: TSTB (%4)+ ; No, look for next name BNE 30$ ; By advancing to null terminator TSTB @%4 ; Look at following character BNE 20$ ; Retry if that's not a null too OUTPUT UFS ; Not found = "Unsupported format" SEC ; Set error flag BR 250$ ; Exit 40$: MOV %5,RWFORMAT ; Found, store new format CALL HEXOCT ; HEX or OCTAL? BNE 60$ ; No, done MOV #SEPTOR,%5 ; Address SEPTOR/BEGFLG/ENDFLG MOVB #SPACE,@%5 ; Default to space separator TSTB @%0 ; If nothing given BEQ 55$ ; GETKEY SMS ; Check for SMS BNE 50$ ; No, must be HEX char MOVB #'',(%5)+ ; SMS, separator is apostrophe MOVB #'R&37,(%5)+ ; ^R begins data MOVB #'T&37,(%5)+ ; and ^T ends it BR 60$ 50$: MOVB (%0)+,@%5 ; Non-SMS. Copy separator 55$: INC %5 ; Point to BEGFLG MOVB #'B&37,(%5)+ ; ^B begins data MOVB #'C&37,(%5)+ ; and ^C ends it 60$: TST QUIET ; Echo suppressed? BEQ 250$ ; Yes, don't confirm ; Show current format 100$: MOV #FORMTS,%4 ; Address list of formats MOV RWFORMAT,%1 ; Get format code to %1 MOV %1,%5 ; and to %5 for HEXOCT BEQ 120$ ; %4 already addresses format if 0 = Intel CMP %1,#F.EXTENDED ; Is this EXTENDED TEKHEX format? ;27MAR4 BNE 101$ ; NE: No - continue ;27MAR4 GETKEY TEKHEX ; YES - clean up command line ;27MAR4 MOV #EXTEK,%4 ; Move alternate format address to %4 ;27MAR4 BR 120$ ; and continue ;27MAR4 101$: ;27MAR4 ASR %1 ; Halve for count 110$: TSTB (%4)+ ; Look for nulls BNE 110$ SOB %1,110$ ; Found one, count it 120$: MOV #RECORD,%1 ; Build up a buffer in I/O record MOV #FMT,%2 ; Starting "Format: " 125$: MOVB (%2)+,(%1)+ BNE 125$ 130$: MOVB (%4)+,(%1)+ ; Copy format name BNE 130$ ; Until terminator CALL HEXOCT ; HEX or OCTAL? BNE 150$ ; No, done DEC %1 ; Yes, lose null terminator CMPB BEGFLG,#'B&37 ; If data begins ^B, this is HEX-char format BEQ 133$ MOV #KSMS-1,%2 ; Else HEX SMS BR 135$ ; Go append " SMS" 133$: MOVB (%2)+,(%1)+ ; HEX-char needs hyphen MOVB SEPTOR,@%1 ; and data terminator CMPB (%1)+,#SPACE ; If terminator is space BNE 150$ DEC %1 135$: MOVB (%2)+,(%1)+ ; Make it visible as "space" BNE 135$ 150$: SUB #RECORD,%1 ; Compute record length OUTPUT RCD,%1 ; Display it, should be cc from QIO 250$: CALLR EXTRA ; Purge command line of superfluous junk ; and return from there ; Return z set if type is HEX or OCTAL. HEXOCT: CMP %5,#F.HEX ; HEX? BEQ 10$ CMP %5,#F.OCTAL ; or OCTAL? 10$: RETURN ; Return with z flag set appropriately .PSECT PURE RO,D ; ** N.B.B. Update following table in parallel with those in HEX, READ, & WRITE. FORMTS: .ASCIZ "INTEL" ; 0 .ASCIZ "MOTOROLA" ; 2 .ASCIZ "ROCKWELL" ; 4 .ASCIZ "RCA" ; 6 .ASCIZ "TEKHEX" ; 10 .ASCIZ "EXTENDED" ; 12 .ASCIZ "TEXAS" ; 14 .ASCIZ "MOSTEK" ; 16 .ASCIZ "WHITESMITHS" ; 20 .ASCIZ "RIM" ; 22 .ASCIZ "BIN" ; 24 .ASCIZ "HEX" ; 26 .ASCIZ "OCTAL" ; 30 .IF DF TCI .ASCIZ "TCI" ; 32 .IFF .BYTE 377,0 ; 34 Dummy never-match for unsupported TCI format .ENDC .ASCIZ "FAIRCHILD" ; 36 .ASCIZ "SIRA" ; 40 .ASCIZ "OBJECT" ; 42 .ASCIZ "ABSOLUTE" ; 44 .ASCIZ "TASK" ; 46 .BYTE 0 ; End of table EXTEK: .ASCIZ "EXTENDED TEKHEX" ;27MAR4 FMT: .ASCIZ <15>"Format: " ; Format introducer, followed immediately by: .ASCIZ "-space" ; "-" and "space" for "HEX/OCTAL-{space}" KEY TEKHEX ;27MAR4 .BYTE SPACE ; " " prefix to "SMS" KEY SMS ; SMS option to HEX/OCTAL .EVEN .END