.TITLE GETCMD .IDENT /hah013/ ; ; VERSION 01 ; ; TOM GETZINGER 19-SEP-80 ; ; Modified: 02-Aug-85 HAH011 ; Support for RT11 libraries. Also allow user ; to specify that the entry point table should ; also be checked if the name is not found in ; the module name table. ; 11-Aug-85 hah012 ; Add additional error messages. Allow all error ; messages from this routine only to be non-fatal. ; 11-Aug-85 hah013 ; Add support for /ID switch to print version #. ; ; THIS MODULE GETS THE NEXT COMMAND. IT EXITS IF THERE IS NONE. ; ; LOCAL DATA ; .PSECT RWDATA,RW,D MNTBAS: .BLKW 1 ; BASE BLOCK # OF MNT FOR LIBRARY FILES endtbl: .blkw 1 ;End block # of mnt for RT11 lib. files ;hah011 savsp: .blkw 1 ;SP at entry for restart purposes. ;hah012 .PSECT CODE,RO .MCALL CSI$1 CSI$2 EXIT$S GET$S GCML$ .MCALL OPEN$ OPNT$D .mcall close$ ;hah012 GETCMD:: mov sp,savsp ;In case we have to restart. ;hah012 restar: ;restart point ;hah012 mov savsp,sp ;Restore stack pointer ;hah012 ; ;hah012 ; Close any open files in case restarting from error in this module only;hah012 ; Any errors in any other module currently continue to abort program. ;hah012 ; ;hah012 close$ #fdbout ;hah012 close$ #fdbtmp ;hah012 close$ #fdbin ;hah012 MOV #S.LABL,SWITCH ; SET DEFAULT SWITCH VALUES GCML$ #GCLBLK ; GET THE COMMAND LINE BCC 2$ JMP 200$ ; ERROR 2$: CSI$1 #CSIBLK,GCLBLK+G.CMLD+2,GCLBLK+G.CMLD bcc 3$ ;Continue ;hah012 trap syntax ;Syntax error ;hah012 br restar ;Restart ;hah012 3$: ;hah012 CSI$2 ,OUTPUT,#SWTOUT ; GET THE OUTPUT FILE NAME bcc 5$ ;Continue ;hah012 trap syntax ;Syntax error ;hah012 br restar ;hah012 5$: ;hah012 bit #s.iden,switch ;/ID? ;hah013 beq 6$ ;No ;hah013 bic #s.iden,switch ;Dont identify twice ;hah013 trap id ;hah013 6$: ;hah013 bitb #cs.equ,c.stat(r0) ;have an output file spec? ;hah013 beq restar ;No ;hah013 OPEN$ #FDBOUT ; OPEN THE OUTPUT FILE bcc 7$ ;Continue ;hah012 trap noout ;Error opening output file ;hah012 br restar ;hah012 7$: BIT #S.LABL,SWITCH ; DO THEY WANT LABELS? BEQ 10$ ; NO CLR CSIBLK+34 ; YES, MAKE SURE CSI DOESN'T USE DEFAULTS CLR CSIBLK+36 ; FROM THE OUTPUT FILE-SPEC CLR CSIBLK+44 CLR CSIBLK+46 CSI$2 #CSIBLK,OUTPUT,#0 ; YES, SO GET THE TEMP FILE NAME bcc 9$ ;Continue ;hah012 trap syntax ;Error ;hah012 jmp restar ;hah012 9$: ;hah012 OPNT$D #FDBTMP ; OPEN THE TEMPORARY FILE bcc 10$ ;Continue ;hah012 trap notemp ;Cant open .TMP file ;hah012 jmp restar ;hah012 10$: CSI$2 #CSIBLK,INPUT,#SWTIN ; GET THE INPUT FILE NAME bcc 12$ ;Continue ;hah012 11$: ;hah013 trap syntax ;Error ;hah012 jmp restar ;hah012 12$: ;hah012 bit #s.iden,switch ;Identify ourselves? ;hah013 beq 121$ ;No, continue ;hah013 trap id ;Do identity prompt and continue ;hah013 121$: ;hah013 MOV #DFNOBJ,R1 ; ASSUME WE WANT TO OPEN A .OBJ FILE BIT #S.LIBR,SWITCH ; IS THAT TRUE? BEQ 13$ ; YES bit #s.rt11,switch ; Is this an RT11 library? ;hah011 bne 13$ ; Yes, do not change file type ;hah011 MOV #DFNOLB,R1 ; NO, SO WE WANT TO OPEN A .OLB FILE 13$: OPEN$ #FDBIN,,,,R1 ; OPEN THE INPUT FILE 15$: bcc 151$ ;No error ;hah011 trap nofile ;Cant find the file ;hah012 jmp restar ;hah012 151$: ;hah011 BIT #S.LIBR,SWITCH ; IS THIS A LIBRARY FILE? bne 152$ ;Yes, continue ;hah012 jmp 100$ ;Branch wont reach ;hah012 152$: ;hah012 CLR R1 ; YES, SETUP FOR READING THE FIRST BLOCK MOV #1,R2 bit #s.rt11,switch ; Is this an RT11 library? ;hah011 bne 16$ ; Yes ;hah011 CLR R3 CALL .POINT ; READ THE LIBRARY HEADER bcc 153$ ;Point worked ;hah012 trap lbrior ;Library read error ;hah012 jmp restar ;hah012 153$: ;hah012 MOV F.NREC(R0),R1 ; GET BUFFER ADDRESS MOV 34(R1),MNTBAS ; GET MNT BASE BLOCK NUMBER MOV 36(R1),R5 ; GET # OF MNT ENTRIES ALLOCATED SUB 40(R1),R5 ; - FREE = # OF MNT ENTRIES IN USE br 17$ ; Continue ;hah011 16$: ;hah011 mov r2,mntbas ; Module name table starts at block 1 ;hah011 mov #40,r3 ; where first module name starts ;hah011 call .point ; Point to it ;hah011 bcc 17$ ;hah012 trap lbrior ;Library read error ;hah012 jmp restar ;hah012 17$: ;hah011 MOV #MODNAM,R0 ; CONVERT THE MODULE NAME TO RAD50 MOV R0,R4 CALL $CAT5 MOV R1,(R4) BCC 18$ CLR 2(R4) BR 20$ 18$: CALL $CAT5 MOV R1,2(R4) 20$: clr -(sp) ; Looking for modules flag ;hah011 call fndnam ; Made this into a subroutine ;hah011 bcc 50$ ;hah011 ; ;hah011 ; Now check entry point table if requested. ;hah011 ; ;hah011 bit #s.entr,switch ; Check entry point table? ;hah011 bne 23$ ;Yes ;hah012 trap notfnd ;Module not found ;hah012 jmp restar ;hah012 23$: ;hah012 clr r1 ; yes, setup for reading the first block;hah011 mov #1,r2 ; ;hah011 bit #s.rt11,switch ; is this an rt11 library? ;hah011 bne 30$ ; yes ;hah011 clr r3 ;hah011 call .point ; read the library header ;hah011 bcc 25$ ;Continue ;hah012 trap lbrior ;Library read error ;hah012 jmp restar ;hah012 25$: ;hah012 mov f.nrec(r0),r1 ; get buffer address ;hah011 mov 24(r1),mntbas ; get ept base block number ;hah011 mov 26(r1),r5 ; get # of ept entries allocated ;hah011 sub 30(r1),r5 ; - free = # of ept entries in use ;hah011 br 40$ ; Continue ;hah011 30$: ;hah011 mov r2,mntbas ; entry point table starts at block 1 ;hah011 mov #40,r3 ; Where first module name starts ;hah011 call .point ; Point to it ;hah011 bcc 40$ ;Continue ;hah012 trap lbrior ;Library read error ;hah012 jmp restar ;hah012 40$: inc @sp ; Looking for entry points flag ;hah011 call fndnam bcc 50$ ;Continue ;hah012 trap notfnd ;Cant find it in either table ;hah012 jmp restar ;hah012 50$: tst (sp)+ ;Clean stack ;hah011 CLR R1 ; POINT TO THE MODULE HEADER MOV 4(R3),R2 MOV 6(R3),R3 bit #s.rt11,switch ;RT11? ;hah011 beq 55$ ;No ;hah011 bic #100000,r2 ;Clear module flag ;hah011 inc r2 ;Count from 1 instead of 0 ;hah011 55$: ;hah011 CALL .POINT bcc 57$ ;Point worked ;hah012 trap lbrior ;Library file read error ;hah012 jmp restar ;hah012 57$: ;hah012 bit #s.rt11,switch ;RT11? ;hah011 bne 60$ ;Yes ;hah011 MOVB #R.VAR,F.RTYP(R0) ; SET VARIABLE LENGTH RECORD FLAG GET$S ; SKIP OVER THE MODULE HEADER bcc 60$ ;Read was Ok ;hah012 trap lbrior ;Library file read error ;hah012 jmp restar ;hah012 60$: ;hah011 100$: CALL .MARK ; MARK THE INPUT FILE MOV R1,VBN ; SAVE VIRTUAL BLOCK NUMBER MOV R2,VBN+2 MOV R3,BYTNUM ; SAVE STARTING BYTE NUMBER RETURN ; AND RETURN 200$: CMPB #GE.EOF,G.ERR(R0) ; EOF ON COMMAND FILE? BEQ 210$ ; YES, SO EXIT CMPB #GE.IOR,G.ERR(R0) ; I/O ERROR ON COMMAND FILE? BNE 220$ ; NO TRAP CMDIOR ; YES, SO OUTPUT ERROR MESSAGE jmp restar ;hah012 210$: EXIT$S ; AND EXIT 220$: TRAP SYNTAX ; COMMAND SYNTAX ERROR jmp restar ;Try again ;hah012 ; ; FNDNAM - Find the requested name in the module name table or the entry ; point table. ; Entry: ; 2(sp) = 0 if searching for module name (for RT11 searches only) ; 2(sp) <> 0 if searching for entry point (for RT11 searches only) ; r4 -> Requested module name ; First block of correct table read in. ; Exit: ; 'C' set if error ; 'C' clear if found ; fndnam: MOV #FDBIN,R0 25$: CLR R1 ; READ IN THE NEXT BLOCK OF MNT ENTRIES MOV MNTBAS,R2 CLR R3 CALL .POINT BCS 220$ ; ERROR MOV F.NREC(R0),R3 ; GET BUFFER ADDRESS MOV #64.,R2 ; COUNT OF MNT ENTRIES IN THE BLOCK bit #s.rt11,switch ;RT11? ;hah011 beq 30$ ;No ;hah011 cmp #1,mntbas ;Is this the first block? ;hah011 bne 30$ ;No, there are a full set in this block ;hah011 add #40,r3 ;Skip RT11 library header. ;hah011 sub #4,r2 ;Header length = 4 module entries ;hah011 30$: bit #s.rt11,switch ;RT11? ;hah011 beq 35$ ;No ;hah011 tst endtbl ;Have the end of the table yet? ;hah011 bne 35$ ;Yes ;hah011 mov 4(r3),endtbl ;Set end of table ;hah011 bic #100000,endtbl ;Clear module name flag ;hah011 35$: ;hah011 CMP (R3),(R4) ; DO THE MODULE NAMES MATCH? BNE 40$ ; NO CMP 2(R3),2(R4) ; MAYBE BEQ 50$ ; YES 40$: bit #s.rt11,switch ;RT11? ;hah011 bne 45$ ;Yes ;hah011 DEC R5 ; NO, ARE THERE ANY MORE TO CHECK? BEQ 220$ ; NO 45$: ADD #10,R3 ; YES, SKIP TO THE NEXT ONE SOB R2,30$ ; IF THERE ARE MORE IN THE BLOCK, CHECK THEM INC MNTBAS ; THERE AREN'T ANY MORE bit #s.rt11,switch ;RT11? ;hah011 beq 25$ ;No, continue ;hah011 cmp mntbas,endtbl ;End of table yet? ;hah011 bne 25$ ;No, continue ;hah011 br 220$ ;End of table, sorry ;hah011 50$: bit #s.rt11,switch ;RT11? ;hah011 beq 100$ ;No, done ;hah011 bit #100000,4(r3) ;RT11 module name? ;hah011 beq 60$ ;No ;hah011 tst 2(sp) ;Searching for modules? ;hah011 bne 40$ ;No, skip it ;hah011 bic #100000,4(r3) ;Yes, clear flag and exit ;hah011 br 100$ ;hah011 60$: ;hah011 tst 2(sp) ;Searching for entry points? ;hah011 beq 40$ ;No, skip it ;hah011 100$: ;hah011 clc ;Found module ;hah011 bit #s.entr,switch ;Match on entry points? ;hah011 return ;hah011 220$: ;hah011 sec ;Module not found ;hah011 return ;hah011 .END