.TITLE FMTHDR - Format Header Record .IDENT /1.0/ .ENABL LC ;+ ; ; Free software BY ; Project Software & Development, Inc. ; ; This software is furnished for free and may be used and copied as ; desired. This software or any other copies thereof may be provided or ; otherwise made available to any other person. No title to and ; ownership of the software is hereby transferred or allowed. ; ; The information in this software is subject to change without notice ; and should not be construed as a commitment by PROJECT SOFTWARE ; AND DEVELOPMENT, INC. ; ; PROJECT SOFTWARE assumes no responsibility for the use or reliability ; of this software on any equipment whatsoever. ; ; Project Software & Development, Inc. ; 14 Story St. ; Cambridge, Ma. 02138 ; 617-661-1444 ; ; ; Title: FMTHDR.MAC ; Author: Robin Miller ; Date: November 19, 1982 ; ; Description: ; ; Format the header record from MISHed files. ; ; Modification History: ; ;- .ENABL AMA .NLIST BEX .MCALL FCSBT$, FDOFF$, FHDOF$, NBOFF$ FCSBT$ ; Define the FCS bits. FDOFF$ DEF$L ; Define the FDB offsets. FHDOF$ DEF$L ; Define the file header offsets. NBOFF$ DEF$L ; Define the FNB offsets. ; Messages: MHDRM: .ASCIZ "MISH FILE HEADER" FILEM: .ASCIZ "File name: " OWNERM: .ASCIZ "Owner UIC: " PROTM: .ASCIZ "Protection: " SYSM: .ASCIZ " System: " OWNM: .ASCIZ ", Owner: " GRPM: .ASCIZ ", Group: " WRLDM: .ASCIZ ", World: " DATEM: .ASCIZ "Mished Date: " COPTM: .ASCIZ "Contiguity Options: " CNONM: .ASCIZ "none" CONTM: .ASCIZ "contiguous" CBTRYM: .ASCIZ "contiguous-best-try" FHDRM: .ASCIZ "FCS/RMS FILE ATTRIBUTES:" FORGM: .ASCIZ "File Organization: " RFORM: .ASCIZ "Record Format: " RATTM: .ASCIZ "Record Attributes: " MRSM: .ASCIZ "Maximum Record Size: " RSIZM: .ASCIZ "Longest Record: " BKSZM: .ASCIZ "Bucket size: " HDSZM: .ASCIZ "Fixed Control Size: " HIBKM: .ASCIZ "Blocks To Allocate: " DEQM: .ASCIZ ", Default Extend Size: " EFBKM: .ASCIZ "End-of-file VBN: " FFBYM: .ASCIZ ", Offset: " .EVEN ; More messages: ; File organizations: ORGTBL: .WORD SEQM ; (0) Sequential. .WORD RELM ; (1) Relative. .WORD IDXM ; (2) Indexed. .WORD HSHM ; (3) Hashed. MAXORG = <<.-ORGTBL>/2> ; Maximum file organization. SEQM: .ASCIZ "sequential" RELM: .ASCIZ "relative" IDXM: .ASCIZ "indexed" HSHM: .ASCIZ "hashed" .EVEN ; Record format table: RTYPE: .WORD UNDM ; (0) Undefined record format. .WORD FIXM ; (1) Fixed length records. .WORD VARM ; (2) Variable length record. .WORD VFCM ; (3) Variable with fixed control. .WORD STMM ; (4) ASCII Stream records. MAXTYP = <<.-RTYPE>/2> ; Maximum record type. UNDM: .ASCIZ "undefined" FIXM: .ASCIZ "fixed" VARM: .ASCIZ "variable" VFCM: .ASCIZ "variable-with-fixed-control" STMM: .ASCIZ "stream" .EVEN ; Record attributes messages. RATBL: .WORD NOM ; (0) No record attributes. .WORD FTNM ; (1) Fortran carriage control. .WORD CRM ; (2) Implied carriage control. .WORD UNKM ; (3) Unknown record attributes. .WORD PRNM ; (4) Print carriage control. MAXRAT = <<.-RATBL>/2> ; Maximum record attribute. NOM: .ASCIZ "" UNKM: .ASCIZ "unknown" FTNM: .ASCIZ "fortran" CRM: .ASCIZ "carriage-return" PRNM: .ASCIZ "print" BLKM: .ASCIZ "no-span" .EVEN .SBTTL FMTHDR - Format The Header Record ;+ ; ; FMTHDR - Format the header record. ; ; This routine is used to read and format the header record. ; ; Inputs: ; R0 = address of the input FDB. ; ; Outputs: ; C bit clear/set = success/failure. ; ; All registers are preserved. ; ;- FMTHDR::CALL $SAVAL ; Save all registers. ;03 MOV F.NRBD+2(R0),R2 ; Copy the record address. MOV R0,R2 ; Copy the record address. CALL WRTSEP ; Start off with a separator. BCC 10$ ; If CC, success. JMP 100$ ; Else, use common return. 10$: CALL WRTBLA ; Now write a blank line. ; MISH FILE HEADER: MOV #FMTBUF,R0 ; The output buffer address. MOV #MHDRM,R1 ; Address of the header message. CALL MOVEC ; Copy it. CALL WRTFMT ; Write it to the output file. CALL WRTBLA ; Now write a blank line. ; Format and write the original file name. MOV #FILEM,R1 ; Address of the file name message. CALL MOVEC ; Copy it. MOV R2,R1 ; Copy the header record address. ; ADD #O.FILE,R1 ; Point to the ASCII file name. CALL MOVEC ; And copy it. CALL WRTFMT ; Write it to the output file. ; Format and write the file owner UIC. MOV #OWNERM,R1 ; Address of the owner message. CALL MOVEC ; Copy it. MOV R2,-(SP) ; Save R2. MOV O.UIC(R2),R3 ; Copy the binary owner UIC. MOV R0,R2 ; Copy the output buffer address. MOV #1,R4 ; Setup the control code. CALL .PPASC ; Convert the UIC to [ggg,mmm]. MOV R2,R0 ; Copy the output buffer address. MOV (SP)+,R2 ; Restore R2. CALL WRTFMT ; Write it to the output file. ; Format and write the protection. MOV #PROTM,R1 ; Address of the protection message. CALL MOVEC ; Copy it. CALL ADDPRO ; Add the protection fields. CALL WRTFMT ; Write it to the output file. ; Format and write the mished date. MOV #DATEM,R1 ; Address of the date message. CALL MOVEC ; Copy it. MOV R2,R1 ; Copy the header record address. ADD #O.DATE,R1 ; Point to the ASCII date. CALL MOVEC ; And copy it. CALL WRTFMT ; Write it to the output file. ; Format and write the contiguity options. MOV #COPTM,R1 ; Address of the contiguity message. CALL MOVEC ; Copy it. MOV #CNONM,R1 ; Presume no options. BITB #UC.CON,O.UCHA(R2) ; Is the file contiguous ? BEQ 20$ ; If EQ, no MOV #CONTM,R1 ; Address of the contiguous message. BR 30$ ; And continue ... 20$: BITB #UC.CNB,O.UCHA(R2) ; Is this contiguous-best-try ? BEQ 30$ ; If EQ, no MOV #CBTRYM,R1 ; Address of best-try message. 30$: CALL MOVEC ; Copy it. CALL WRTFMT ; Write it to the output file. CALL WRTBLA ; Write a blank record. ; FCS/RMS FILE ATTRIBUTES: MOV #FHDRM,R1 ; Address of the header message. CALL MOVEC ; Copy it. CALL WRTFMT ; Write it to the output file. CALL WRTBLA ; Now write a blank line. ; Format and write the file organization (bits 4-7 of O.RTYP). MOV #FORGM,R1 ; Address of file organization message. CALL MOVEC ; Copy it. MOVB O.FORG(R2),R1 ; Copy the file organization byte. ASH #-4,R1 ; Shift into bits 0-4. BIC #^C17,R1 ; Clear unwanted bits. CALL ADDORG ; Add the file organization. CALL WRTFMT ; Write it to the output file. ; Format and write the record format (bits 0-3 of O.RTYP). MOV #RFORM,R1 ; Address of record format message. CALL MOVEC ; Copy it. MOVB O.RTYP(R2),R1 ; Copy the binary file type. BIC #^C17,R1 ; Clear unwanted bits. CALL ADDTYP ; Add the record format message. CALL WRTFMT ; Write it to the output file. ; Format and write the record attributes. MOV #RATTM,R1 ; Address of record attributes message. CALL MOVEC ; Copy it. MOVB O.RATT(R2),R1 ; Copy the binary file attributes. BIC #^C17,R1 ; Clear unwanted bits. CALL ADDRAT ; Add the record attributes message. CALL WRTFMT ; Write it to the output file. ; Format and write the maximum record size. MOV #MRSM,R1 ; Address of maximum size message. CALL MOVEC ; Copy it. MOV O.MRS(R2),R1 ; Copy the maximum record size. CALL CVTDEC ; Convert it to decimal ASCII. CALL WRTFMT ; Write it to the output file. ; Format and write the longest record size. MOV #RSIZM,R1 ; Address of longest size message. CALL MOVEC ; Copy it. MOV O.RSIZ(R2),R1 ; Copy the longest record size. CALL CVTDEC ; Convert it to decimal ASCII. CALL WRTFMT ; Write it to the output file. ; Format and output the bucket size (if there is one). TSTB O.BKSZ(R2) ; Is there a bucket size ? BEQ 40$ ; If EQ, no (skip this then). MOV #BKSZM,R1 ; Address of bucket size message. CALL MOVEC ; Copy it. MOVB O.BKSZ(R2),R1 ; Copy the bucket size. CALL CVTDEC ; Convert it to decimal ASCII. CALL WRTFMT ; Write it to the output file. ; Format and output the fixed control size (if there is one). 40$: TSTB O.HDSZ(R2) ; Is there a fixed control size ? BEQ 50$ ; If EQ, no (skip it then). MOV #HDSZM,R1 ; Address of fixed control message. CALL MOVEC ; Copy it. MOVB O.HDSZ(R2),R1 ; Copy the fixed control size. CALL CVTDEC ; Convert it to decimal ASCII. CALL WRTFMT ; Write it to the output file. ; Format the number of blocks to allocate. 50$: MOV #HIBKM,R1 ; Address of the blocks message. CALL MOVEC ; Copy it. MOV R2,R1 ; Copy the header record address. ADD #O.HIBK,R1 ; Point to the high block number. CALL CVTDTD ; Convert double to decimal ASCII. ; Format and write the default extend size. MOV #DEQM,R1 ; Address of default extend message. CALL MOVEC ; Copy it. MOV O.DEQ(R2),R1 ; Copy the default extend size. CALL CVTDEC ; Convert it to decimal ASCII. CALL WRTFMT ; Write it to the output file. ; Format the end-of-file block number. MOV #EFBKM,R1 ; Address of end-of-file message. CALL MOVEC ; Copy it. MOV R2,R1 ; Copy the header record address. ADD #O.EFBK,R1 ; Point to the end-of-file address. CALL CVTDTD ; Convert double to decimal ASCII. ; Format and write the first free byte in the last block. MOV #FFBYM,R1 ; Address of the free message. CALL MOVEC ; Copy it. MOV O.FFBY(R2),R1 ; Copy the first free byte. CALL CVTDEC ; Convert it to decimal ASCII. CALL WRTFMT ; Write it to the output file. ; Finish up the file header report. CALL WRTBLA ; Write a blank record. CALL WRTSEP ; And a record separator. 100$: RETURN .SBTTL ADDPRO - Add The Protection Message ;+ ; ; ADDPRO - Add the file protection message. ; ; Inputs: ; R0 = the output buffer address. ; R2 = address of the header record. ; ; Outputs: ; R0 = the updated buffer address. ; ; All other registers are preserved. ; ;- ADDPRO::JSR R5,.SAVR1 ; Save R1 - R5 MOV O.PROT(R2),R3 ; Copy the protection code. ; Setup the system protection. MOV #SYSM,R1 ; Address of system message. CALL MOVEC ; Copy it. CALL SETPRO ; Move in the protection. ; Setup the owner protection. MOV #OWNM,R1 ; Address of owner message. CALL MOVEC ; Copy it. ASH #-4,R3 ; Shift bits into place. CALL SETPRO ; Move in the protection. ; Setup the group protection. MOV #GRPM,R1 ; Address of group message. CALL MOVEC ; Copy it. ASH #-4,R3 ; Shift bits into place. CALL SETPRO ; Move in the protection. ; Setup the world protection. MOV #WRLDM,R1 ; Address of world message. CALL MOVEC ; Copy it. ASH #-4,R3 ; Shift bits into place. CALL SETPRO ; Move in the protection. RETURN ; Move in the protection codes: RWED SETPRO::BIT #FP.RDV,R3 ; Allowed read access ? BNE 10$ ; If NE, no. MOVB #'R,(R0)+ ; Yes, show it. 10$: BIT #FP.WRV,R3 ; Allowed write access ? BNE 20$ ; If NE, no. MOVB #'W,(R0)+ ; Yes, show it. 20$: BIT #FP.EXT,R3 ; Allowed execute access ? BNE 30$ ; If NE, no. MOVB #'E,(R0)+ ; Yes, show it. 30$: BIT #FP.DEL,R3 ; Allowed delete access ? BNE 40$ ; If NE, no. MOVB #'D,(R0)+ ; Yes, show it. 40$: RETURN .SBTTL ADDRAT - Add The Record Attributes Message ;+ ; ; ADDRAT - Add the record attributes message. ; ; Inputs: ; R0 = the output buffer address. ; R1 = the binary record attributes byte. ; ; Outputs: ; R0 = the updated buffer address. ; ; All other registers are preserved. ; ;- ADDRAT::JSR R5,.SAVR1 ; Save R1 - R5 CMP R1,#MAXRAT ; Is the attribute too large ? BLO 10$ ; If LO, no. MOV #BLKM,R1 ; Address of no-span message ? BITB #FD.BLK,R1 ; Is the attributes no-span ? BNE 20$ ; If NE, yes. MOV #UNKM,R1 ; Nope, tellem "unknown" BR 20$ ; And continue ... 10$: ASL R1 ; Make a word offset. MOV RATBL(R1),R1 ; Get the message address. 20$: CALL MOVEC ; And copy it. RETURN .SBTTL ADDORG - Add The File Organization ;+ ; ; ADDORG - Add the file organization. ; ; Inputs: ; R0 = the output buffer address. ; R1 = the binary organization value. ; ; Outputs: ; R0 = the updated buffer address. ; ; All other registers are preserved. ; ;- ADDORG::JSR R5,.SAVR1 ; Save R1 - R5 CMP R1,#MAXORG ; Is it too large ? BLO 10$ ; If LO, no. MOV #UNDM,R1 ; Tellem "undefined". BR 20$ ; And copy it. 10$: ASL R1 ; Make a word offset. MOV ORGTBL(R1),R1 ; Get the message address. 20$: CALL MOVEC ; And copy it. RETURN .SBTTL ADDTYP - Add The Record Type Message ;+ ; ; ADDTYP - Add the record type message. ; ; Inputs: ; R0 = the output buffer address. ; R1 = the binary record type. ; ; Outputs: ; R0 = the updated buffer address. ; ; All other registers are preserved. ; ;- ADDTYP::JSR R5,.SAVR1 ; Save R1 - R5 CMP R1,#MAXTYP ; Is the type too large ? BLO 10$ ; If LO, no. CLR R1 ; Yes, force "undefined". 10$: ASL R1 ; Make a word offset. MOV RTYPE(R1),R1 ; Get the message address. CALL MOVEC ; And copy it. RETURN .END