.TITLE PRSFMT ; This subroutine is used to parse the extended format control ; commands which are used to enhance the performance of the ; system subroutine "$EDMSG". ; It interprets a format command of the form: ; ; %(xxxxx) ; ; where: ; ; the values between the parenthesis can by any combination of the ; following: ; ; B Blank Fill; Default = No Blank Fill ; Z Leading Zero Suppression; Default = Print leading zeroes. ; Rnn Radix nn (2-16); Default = 10 ; Wnn Field Width = nn; Default = 6 ; Note: If Z is specified without B, this field is ignored. ; ; ; Inputs: R4 Address of string to parse ; ; Outputs:R3 Options word for the $CBTA routine ; R4 Next address in string ; .MCALL ISTAT$,STATE$,TRAN$ ZFLAG = 1000 ; Zero include flag BFLAG = 2000 ; Blank fill flag DEFWID = 6 ; Default field width DEFRAD = 10. ; Default radix OPTION: .WORD 0 ; Options bits FWIDTH: .WORD 0 ; Width of field RADIX: .WORD 0 ; Radix PRSFMT:: MOV R0,-(SP) MOV R1,-(SP) MOV R2,-(SP) MOV R5,-(SP) ; Save registers we will be using ; Set up default values CLR OPTION MOV #DEFWID,FWIDTH MOV #DEFRAD,RADIX CLR R1 ; Clear the options word MOV #FMTKTB,R2 ; Move address of keyword table MOV #100.,R3 ; Move an arbitrary length to R3 MOV #FMTSTB,R5 ; Address of start in state table CALL .TPARS ; Call the parsing routine BCS RET ; Convert the parsed information into options words MOV OPTION,R3 ; Move the options bits to R5 ; Move the width into position MOV FWIDTH,R5 BIC #177740,R5 ; Mask out all but low 5 bits ASH #11.,R5 ; Shift into position BIS R5,R3 ; Or into the result ; Move the radix into position BIC #177400,RADIX ; Mask out all but low 8 bits BIS RADIX,R3 ; Or into the result RET: MOV (SP)+,R5 MOV (SP)+,R2 MOV (SP)+,R1 MOV (SP)+,R0 ; Restore registers we used RETURN .GLOBL FMTSTB ISTAT$ FMTSTB,FMTKTB ; Beginning of the format command state table STATE$ FMTSTB TRAN$ '% STATE$ TRAN$ '( STATE$ NXTCMD ; Get the next command TRAN$ '),$EXIT ; Close parens is end of command TRAN$ 'B,NXTCMD,,BFLAG,OPTION TRAN$ 'Z,NXTCMD,,ZFLAG,OPTION TRAN$ 'R,GETRDX TRAN$ 'W,GETWID STATE$ GETRDX TRAN$ $DNUMB,NXTCMD,STRRDX STATE$ GETWID TRAN$ $DNUMB,NXTCMD,STRWID STATE$ ; Action routines STRRDX: CMP .PNUMB,#2 ; Check radix for correct range BLT ACTERR CMP .PNUMB,#16. BGT ACTERR MOV .PNUMB,RADIX ; It's good; store it RETURN STRWID: CMP .PNUMB,#1 ; Check radix for correct range BLT ACTERR CMP .PNUMB,#32. BGT ACTERR MOV .PNUMB,FWIDTH ; It's good; store it RETURN ACTERR: ADD #2,(SP) ; Signal error RETURN .END