.MCALL .MODULE .MODULE DBGSYM,02,COMMENT=,AUDIT=YES ; Copyright (c) 1998 by Mentec, Inc., Nashua, NH. ; All rights reserved ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the ; inclusion of the above copyright notice. This software, or ; any other copies thereof, may not be provided or otherwise ; made available to any other person except for use on such ; system and to one who agrees to these license terms. Title ; to and ownership of the software shall at all times remain ; in Mentec, Inc. ; ; The information in this document is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation, or Mentec, Inc. ; ; Digital and Mentec assume no responsibility for the use or ; reliability of its software on equipment which is not supplied ; by Digital or Mentec, and listed in the Software Product ; Description. ;++ ; Facility: DBGSYM - .STB file manipulation utility ; ; Author: Joe Worrall ; ; Created: 09-Feb-83 ; ; Abstract: DBGSYM - Main routine ; ; Externals Description ; --------- ----------- ; ; See STDRV.MAC and STBSUB.MAC ; ; Edit Who Date Description of modification ; ---- --- ---- --------------------------- ; ; 0.1(V5.5) I.B. Sokari 19-Apr-88 Change version number from 5.4 to 5.5 ; ;-- .SBTTL Macro calls and definitions .MCALL .CLOSE, .EXIT, .PRINT, .RCTRLO,.READW .MCALL .REOPEN,.SAVEST,.SRESET,.WRITW, .ENTER .MCALL .GTIM, .CSIGEN,.WAIT, ...CMV .MCALL .DEBUG, .DPRINT,SOB ; ASECT addresses and values JSW =: 44 ;Job status word OVLY$ =: 1000 ;Overlaid program (channel 17 stays open) ERRBYT =: 52 ;Return error byte USERRB =: 53 ;Error status byte on exit SUCCS$ =: 1 ;Success WARN$ =: 2 ;Warning ERROR$ =: 4 ;Error FATAL$ =: 10 ;Fatal SYSPTR =: 54 ;Pointer to rmon in syscom region SYSVER =: 276 ;-> System version as .BYTE major,.BYTE minor SYSGEN =: 372 ;-> SYSGEN options word SUFFIX =: 412 ;RAD50 handler suffix for running monitor ; Define symbols for current RT11 version ...CMV PART=ALL,TYPE=V .enabl LSB .DEBUG ON,Value=YES .dsabl LSB ; Channel definitions CH.OVR =: 17 ;Channel for DBGSYM.SAV ; Force overlay bit on .ASECT . = JSW .WORD OVLY$ .PSECT LIMITS: .LIMIT ;Get program low and high limits PGMEND = .-2 ;Second word is high linked limit AREA: .BLKW 6 ;general purpose emt area CHANNL: .BLKW 5 ;savestatus area BLKSAV: .BLKW 1 ;Additive factor for reading BLKADD: .BLKW 1 ;" Modified at run time " BLKWRI: .WORD 0 ; Output file block DEFBLK: .RAD50 /SY / ;Default handler name for output DEFNAM: .RAD50 /ST / ;Default output filename (filled in) .RAD50 / / .RAD50 /SYS/ DEXT: .RAD50 /STB/ ;Default extentions for .CSIGEN .RAD50 /SYS/ .RAD50 /SYS/ .RAD50 /SYS/ TT$BUF: .BLKB 132. ;Terminal printing buffer $STBBF::.BLKB 200. ;.STB record buffer $SPSAV: .BLKW 1 ;Saved stack pointer for re-starts NSYMS: .BLKW 1 ;# Symbols in .STB file NBYTES: .BLKW 1 ;# bytes needed to hold symbols ;+ ;ERROR ; Messages .NLIST BEX NOMON: .ASCIZ /?DBGSYM-U-Wrong version of RT-11/ NOTAG: .ASCIZ /?DBGSYM-U-Unable to locate proto blocks/ REDERR: .ASCIZ /?DBGSYM-U-Error reading proto blocks/ NOROOM: .ASCIZ /?DBGSYM-F-Output Device full/ PROTOU: .ASCII /?DBGSYM-F-Protected output file already exists /<200> PROTCL: .ASCII /?DBGSYM-W-File created; Protected output file already exists /<200> WRTERR: .ASCIZ /?DBGSYM-F-Error writing .SYS file/ NOIN: .ASCIZ /?DBGSYM-E-No input .STB file specified/ NOSYMS: .ASCIZ /?DBGSYM-E-No symbols in .STB file/ REINST: .ASCIZ /?DBGSYM-W-Remove and reinstall ST handler/ DEFMSG: .ASCII /?DBGSYM-I-Default output filename is /<200> FILNAM: .ASCIZ /SY:???.SYS/ IDSTR: .NLCSI ;- .EVEN .LIST BEX ; Start of DBGSYM DBGSYM::.RCTRLO ;Speak to me! ; Get RMON pointer, check major and minor version numbers MOV @#SYSPTR,R0 ; R0 -> $RMON ; Make sure we're installing with the matching monitor CMPB SYSVER(R0),#RT$REL ; Monitor major version match ? BNE 25$ ; Branch if not, error. CMPB SYSVER+1(R0),#RT$VER ; Monitor minor version match ? BNE 25$ ; Branch if not, also an error. ; Set up overlay channel ADD SUFFIX(R0),DEFNAM ; Set default ST driver name suffix MOV #FILNAM+3,R0 ; R0 -> Output string area MOV DEFNAM,R1 ; R1 = .RAD50 /STx/ CALL $C5TA ; Convert to .ASCII .GTIM #AREA,#AREA ; Check for possible date rollover MOV SP,$SPSAV ; Save SP MOV #3,ICHAN ; Use first input channel for STBSUB.MAC .SAVEST #AREA,#CH.OVR,#CHANNL ; Save the overlay channel BCS 20$ ; Not overlaid, error ; Ensure we have ST.SYS file MOV PGMEND,R0 ; Get high limit of program ROR R0 ; Shift it CLRB R0 ; Round it down SWAB R0 ; Make it blocks INC R0 ; and round upward CMP R0,CHANNL+4 ; Is program shorter than sav file? BHIS 20$ ; Yes, ST.SYS not appended, error! MOV R0,BLKSAV ; Set additive factor to find .SYS file .REOPEN #AREA,#CH.OVR,#CHANNL ; Open save image as data BCC RESTART ;+ ;ERROR 20$: MOV #NOTAG,R0 ; BR 30$ 25$: MOV #NOMON,R0 ; 30$: .PRINT R0 ; Display the message ;- .SRESET ; Clear out channels, handlers .EXIT ; Get input .STB file and any switches from user RESTART:: .SRESET ; Clear out channels, handlers .CSIGEN LIMITS+2,#DEXT,,#BINBUF BCS RESTART ; Try again... MOV BLKSAV,BLKADD ;Refresh dynamic additive factor MOV $SPSAV,SP ;Reset the stack pointer (No switches) .WAIT #3 ;Make sure we have input channel #3 BCS 200$ ; Don't have it...... ; Open the output file .WAIT #0 ; Did user specify an output file ? BCC 20$ ; Yes, use specified file ;+ ;ERROR .PRINT #DEFMSG ; Print .PRINT #FILNAM ; .....and the filename ;- .ENTER #AREA,#0,#DEFBLK,#-1 ; Open it for output BCS 210$ ; Error, can't open it ; Run through the symbol table file to count the total number of symbols 20$: CALL REWIND ; Rewind STB file to beginning CLR NSYMS ; Clear # symbols 25$: CALL GETGSD ; Get a symbol BCS 30$ ; Branch if no more. INC NSYMS ; Count another symbol BR 25$ ; Next ... ; Convert number of symbols to bytes; 3 bytes/symbol + trailer word 30$: MOV NSYMS,R1 ;R1 = # Symbols BEQ 220$ ; No symbols, try again MOV R1,R2 ;Save value for add ASL R1 ;* 2 ADD R2,R1 ; * 3 INC R1 ;Add one for trailer word ASL R1 ;Make it bytes MOV R1,NBYTES ;Save symbol table size (in bytes) ; Read proto block, customize, Write the first block of output .SYS file CALL STBINP ; Get proto block for STB BCS 230$ ; Bad read, error MOV @#SYSPTR,R0 ; R0 -> Base of RMON MOV SYSGEN(R0),R0 ; R0 = Sysgen configuration word BIC #^C<377>,R0 ; Only want low byte for handlers MOV R0,BINBUF+60 ; Save it for write-back onto disk. ADD NBYTES,BINBUF+50 ; Correct size of handler ADD NBYTES,BINBUF+52 CLR BLKWRI ; Start output with block zero CALL STBOUT ; Write the buffer out BCS 240$ ; Get the second block of the proto to start filling at. INC BLKADD ; Increment block we are on CALL STBINP ; Get proto block for STB BCS 230$ ; Bad READ, error ADD NBYTES,BINBUF+2 ; Adjust size of handler MOV #BINBUF-1000,R0 ADD #$SYMS,R0 ;R0 -> Buffer location to start fill at. MOV #1,BLKWRI ;Set block number to write next on output CALL REWIND ;Rewind STB file to beginning ; Read symbols, move to output buffer, writing when buffer is full 60$: CALL GETGSD ; Get a entry BCS 70$ ; Branch if done. CALL PUTSYM ; Move to output buffer, write if full BCS 240$ ; Error, ... BR 60$ ; Next ... ; Insert a -1 terminating record 70$: MOV #MONE,R1 ; Last one is a -1 for DBG CALL FILL ; Insert -1 BCS 240$ ; Error, ... ; Zero fill rest of this block, write it out 80$: CMP R0,#BINE ; Done? BHIS 90$ ; Branch if so. CLR (R0)+ ; Else zero fill BR 80$ 90$: CALL STBOUT ; Write the buffer out BCS 240$ ; Bad WRITE, error INC BLKWRI ; Increment block # we are on ; Write out an empty block for later use, then close files MOV #BINBUF,R0 ; Get start of buffer MOV #256.,R1 ; Get size of buffer 100$: CLR (R0)+ ; Clear a word SOB R1,100$ ; Repeat to end of buffer CALL STBOUT ; Write the buffer out BCS 240$ ; Bad WRITE, error .CLOSE #0 ; Close output file. BCS 250$ .CLOSE #1 ; Close input file ; Tell user what we've done CALL STBRPT ; Report on symbol table JMP RESTART ; Back to beginning ;+ ;ERROR ; Bad filename entry from keyboard 200$: TSTB BINBUF ; Anything typed? BNE 201$ ; Branch if so, ok. MOV #IDSTR,R0 ; Nothing typed, reprompt BR 280$ ; ....and try again 201$: MOV #NOIN,R0 ; Bad entry, print error message. BR 280$ ; ....and try again ; Unable to open the disk file 210$: CMPB @#ERRBYT,#3 ; Disk full ? BNE 245$ ; Yes, tell user .PRINT #PROTOU ; No, must be a protected file BR 260$ ; Print file name ; No symbols in the symbol table file 220$: MOV #NOSYMS,R0 ; Symbol table file is empty BR 280$ ; ....and try again ; Unable to READ the file 230$: MOV #REDERR,R0 ; READ error BR 280$ ; ....and try again ; Unable to WRITE to disk 240$: TSTB @#ERRBYT ; Write past EOF? BEQ 245$ ; Yes, no room on disk MOV #WRTERR,R0 ; No, this is a real error BR 280$ 245$: MOV #NOROOM,R0 ; No disk space available BR 280$ ; Error CLOSING output file 250$: .PRINT #PROTCL ; Output "protected" error ; Fall through to display file name ; Print the file name 260$: MOV #FILNAM,R0 ; Print file name ; Fall through to Re-start 280$: .PRINT R0 ; Print selected message ;- 300$: JMP RESTART ; SUBR PUTSYM - Move symbol record to output, write if buffer full .ENABL LSB PUTSYM: CALL FILL BCS 9$ ; Error, ... CALL FILL BCS 9$ ; Error, ... TST (R1)+ ; Skip flags/entry type in .STB file CALL FILL ; and insert VALUE 9$: RETURN ; Insert value into buffer, when full, output it. FILL: CMP R0,#BINE ; At the end? BLO 20$ ; Branch if not at the end yet. CALL STBOUT ; Write the buffer out BCS 25$ INC BLKWRI ; Bump us to next block MOV #BINBUF,R0 ; Re-set to beginning 20$: MOV (R1)+,(R0)+ ; Stuff word CLC 25$: RETURN ; Return to caller ; READ a buffer from the input file STBINP: .READW #AREA,#CH.OVR,#BINBUF,#256.,BLKADD RETURN ; Write a buffer to the output file STBOUT: .WRITW #AREA,#0,#BINBUF,#256.,BLKWRI RETURN ; Report symbol table numbers to console STBRPT: MOV NSYMS,R1 ;R1 = Number to convert CLRB @R0 ;Make it .ASCIZ ;+ ;ERROR .PRINT #TT$BUF ;Print it. .DPrint ,R1,TYPE=DEC .PRINT #REINST ; Display 'RE-INSTALL HANDLER' msg ;- RETURN .Dsabl LSB ; General data MONE: .WORD -1 BINBUF: .BLKW 256. BINE: .END DBGSYM