ALWAYS 27MAR4 FORMAT ;27MAR4 ;************************************************************************ ;**-1 ;* * ;* 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 * ;* SIRA = 34 (Sira binary) * ;* PDP-11: OBJECT = 36 (MACRO-11 .ENABL ABS) * ;* ABSOLUTE = 40 (paper-tape abs loader) * ;* TASK = 42 (TKB .SYS file) * ;* * ;* (actual codes are defined in main module HEX.) * ;* * ;* SEPTOR contains HEX/OCTAL number terminator (default * ;* space, other common ones are %, ', and comma) * ;* * ;* 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. * ;* * ;* 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 ;************************************************************************ .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 50$ ; NE -- No, done MOVB (%0)+,SEPTOR ; Yes, may be a separator byte, copy it BNE 250$ ; If given (no validity check) MOVB #SPACE,SEPTOR ; Default to space DEC %0 ; Resetting pointer 50$: 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,#12 ; 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$ MOVB (%2)+,-1(%1) ; 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 "SIRA" ; 36 .ASCIZ "OBJECT" ; 40 .ASCIZ "ABSOLUTE" ; 42 .ASCIZ "TASK" ; 44 .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 .EVEN .END