.TITLE DOHLIB ; MACRO version of DOHLIB - library of support routines for DOHAND, ; the diagnostic overlay handler. ; ; Robert Walraven ; Multiware, Inc. .MCALL .PRINT .EXIT .PSECT DOHDAT,D ; Allocate variables for calling tree information storage SIZE = 10. ; Max calling chain entries allowed ; Increase SIZE for larger tree MAXLEV = SIZE*2 - 2 ; Max size of array pointer LEVEL: -2 ; Current array pointer ; (-2 means no entires) SEGMENT:.BLKW SIZE ; Array to hold segment numbers ENDSEG = . ; End of segment array + 2 ADDRESS:.BLKW SIZE ; Array to hold addresses ENDADDR = . ; End of address array + 2 ; Text buffers MSG1: .ASCII 'DOH: Illegal call of segment ' MSG1A: .ASCII ' at ' MSG1B: .ASCII ' ' .BYTE 15,12 .ASCIZ 'DOH: calling chain:' MSG2: .ASCII 'DOH: segment ' MSG2A: .ASCII ' at ' MSG2B: .ASCIZ ' ' EMSG1: .ASCIZ 'DOH: too many branches'; NOTE: increase SIZE if this error EMSG2: .ASCIZ 'STOP -- DOH' .EVEN .PSECT DOHCOD,I OHANDE::SUB #2,LEVEL ; Back pointer up 1 on subr. return OHANDI::RETURN OHANDC::CMP LEVEL,#MAXLEV ; Are we out of storage room? BGE 10$ ; Branch if we are ADD #2,LEVEL ; Point to next entry MOV LEVEL,R1 ; R1 = LEVEL MOV @2(R5),SEGMENT(R1) ; Next SEGMENT = ISEG MOV @4(R5),ADDRESS(R1) ; Next ADDRESS = IADDR RETURN 10$: .PRINT #EMSG1 .EXIT OHANDR::CLR R0 ; R0 will be array pointer 10$: CMP R0,LEVEL ; Are we done? BGT 100$ ; Branch if we are CMP @6(R5),ADDRESS(R0) ; Is this an illegal entry? BNE 90$ ; Branch if not MOV #3,R1 ; Convert ISEG to O3 MOV @2(R5),R2 ; and store in MSG1A MOV #MSG1A,R3 ; CALL ASCOUT ; MOV #6,R1 ; Convert ISTART+2 to O6 MOV @6(R5),R2 ; and store in MSG1B ADD #2,R2 ; MOV #MSG1B,R3 ; CALL ASCOUT ; .PRINT #MSG1 ; Print the header message CLR R5 ; Use R4 as an array pointer 20$: CMP R5,LEVEL ; Are we done? BGT 80$ ; Branch if we are MOV #3,R1 ; Convert SEGMENT(R0) to O4 MOV SEGMENT(R5),R2 ; and store in MSG2A MOV #MSG2A,R3 ; CALL ASCOUT ; MOV #6,R1 ; Convert ADDRESS(R0)+2 to O6 MOV ADDRESS(R5),R2 ; and store in MSG2B ADD #2,R2 ; MOV #MSG2B,R3 ; CALL ASCOUT ; .PRINT #MSG2 ; Print traceback message ADD #2,R5 ; Update array pointer BR 20$ 80$: .PRINT #EMSG2 ; Print stop message .EXIT 90$: ADD #2,R0 ; Point to next entry BR 10$ ; And try it 100$: RETURN ; Internal subroutine to convert a number to an equivalent ASCII string. ; On entry, ; R1 contains the field width for output. ; R2 contains the number to be converted. ; R3 contains the address where ASCII equivalent is to be stored. ASCOUT: ADD R1,R3 ; Point to end of string 10$: MOV R2,R4 ; Make copy of number BIC #177770,R2 ; Clear out high bits ADD #60,R2 ; Convert number to ASCII MOVB R2,-(R3) ; Move character to string MOV R4,R2 ; Get number back CLC ; Clear C bit ROR R2 ; Shift to next digit ROR R2 ; ROR R2 ; SOB R1,10$ ; Loop until done RETURN .END