.TITLE DASM3 .IDENT /hah001/ .psect rodata,ro,d ;hah001 emtmsg: .asciz /EMT / ;hah001 trpmsg: .asciz /TRAP / ;hah001 .even ;hah001 .PSECT CODE,RO ; ; VERSION 01 ; ; TOM GETZINGER 21-SEP-80 ; ; Modified: 04-Nov-83 hah001 ; Add code to handle TRAP global and EMT global ; ; THIS ROUTINE DISASSEMBLES AS MUCH TEXT AS IT CAN, WRITING IT ; TO THE OUTPUT FILE. ; DASM3:: JSR R5,$SAVRG ; SAVE R3-R5 5$: MOV FRSTXT,R4 ; R4 -> FIRST TEXT ENTRY BEQ 60$ ; THERE IS NO TEXT MOV #OUTBUF+8.,R5 ; POINT TO THE OUTPUT BUFFER BIT #TF.LMT,T.FLAG(R4) ; IS THIS A .LIMIT? BEQ 10$ ; NO MOV #LIMIT,R0 ; YES, SO OUTPUT = ".LIMIT" CALL APPEND MOV #4,INSTLN ; THE INSTRUCTION IS TWO WORDS LONG (4 BYTES) CLR INST ; BOTH WORDS ARE ZERO CLR INST+2 CLR OPSTRT ; THIS INSTRUCTION HAS NO OPERANDS BR 50$ 10$: BIT #TF.BYT,T.FLAG(R4) ; IS THIS A BYTE? BEQ 30$ ; NO call trpemt ;Check for TRAP or EMT instruction ;hah001 bcs 50$ ;Was a TRAP or EMT ;hah001 MOV #BYTE,R0 ; YES, SO OUTPUT = ".BYTE " CALL APPEND MOV R5,OPSTRT ; SAVE OPERAND STARTING ADDRESS MOV #1,INSTLN ; THE INSTRUCTION IS ONE BYTE LONG BIT #TF.REL,T.FLAG(R4) ; IS THE VALUE RELOCATED? BEQ 20$ ; NO MOV T.STR(R4),R0 ; YES, GET STRING POINTER CALL ADDSTR ; ADD IT TO OUTPUT CLR INST ; USE A VALUE OF ZERO BR 50$ 20$: MOV T.VAL(R4),R0 ; GET TEXT VALUE MOV R0,INST ; PUT IN INSTRUCTION VALUE TABLE CALL ADDOCT ; OUTPUT THE INSTRUCTION IN OCTAL BR 50$ 30$: BIT #TF.REL,T.FLAG(R4) ; IS THE WORD RELOCATED? BEQ 40$ ; NO MOV #WORD,R0 ; YES, OUTPUT = ".WORD " CALL APPEND MOV R5,OPSTRT ; SAVE OPERAND STARTING ADDRESS MOV #2,INSTLN ; THE INSTRUCTION IS TWO BYTES LONG CLR INST ; USE A VALUE OF ZERO MOV T.STR(R4),R0 ; GET STRING POINTER CALL ADDSTR ; ADD IT TO OUTPUT BR 50$ 40$: CALL DINS3 ; DISASSEMBLE THE INSTRUCTION BCS 60$ ; IT ISN'T AN INSTRUCTION 50$: CALL TXTOUT ; OUTPUT THE TEXT BR 5$ ; GO DO THE NEXT TEXT ENTRY 60$: RETURN ; AND WE'RE DONE ; ; All the following code is new code to properly handle TRAPs and EMTs ;hah001 ; that have their lower bytes relocated. ;hah001 ; ; Check to see if this byte is a possible TRAP or EMT prefix. If it is and ; the following text entry is a relocated byte, output it as: ; TRAP global ; or ; EMT global ; instead of two .BYTES ; ; ENTRY: ; r5 -> Output text line ; r4 -> Current instruction packet ; trpemt:: mov @r4,r3 ;Point to the high byte bit #tf.byt,t.flag(r3) ;Is this a byte? beq 50$ ;No, cant process here bit #tf.rel,t.flag(r3) ;Is this byte relocated? bne 50$ ;Yes, cant process here cmpb #emt/400,t.val(r3) ;Is this an EMT? beq 100$ ;Yes cmpb #trap/400,t.val(r3) ;Is this a TRAP? beq 200$ ;Yes 50$: clc ;Not a TRAP or EMT so process normally return ;Bye ; ; Have a possible EMT, see if next byte was relocated ; 100$: call chkbyt ;See if OK bcs 400$ ;No mov #emtmsg,r0 ;Say this is an EMT br 300$ ;Finish in common code ; ; Have a possible TRAP, see if next byte was relocated ; 200$: call chkbyt ;See if OK bcs 400$ ;No mov #trpmsg,r0 ;Say this is a TRAP ; ; Have appropriate message for EMT or TRAP, finish processing ; 300$: call append ;Move it mov r5,opstrt ;Save operand starting address mov #2,instln ;The instruction is two bytes long mov t.str(r4),r0 ;Get the symbol to print call addstr ;Move it mov @r4,r4 ;Done with both bytes sec ;Say this was already handled return ; ; Not an eligible TRAP or EMT, so return ; 400$: clc ;Handle normally return ;Bye ; ; See if the argument record is a relocated byte ; chkbyt:: bit #tf.rel!tf.lib,t.flag(r4) ;Is the value relocated? beq 10$ ;Not relocated, so process normally bit #tf.byt,t.flag(r4) ;Is it a byte? beq 10$ ;No mov t.addr(r4),r2 ;Get the address of the low byte inc r2 ;See if same as next record cmp r2,t.addr(r3) ;Same? bne 10$ ;No, must be something else clc ;Handle as EMT or TRAP return ;Done 10$: sec ;Dont handle as EMT or TRAP return ;Done .END