diff --git a/source/MON.UTIL.SOURCE b/source/MON.UTIL.SOURCE new file mode 100644 index 0000000..4891005 --- /dev/null +++ b/source/MON.UTIL.SOURCE @@ -0,0 +1,312 @@ + LST ON,NOASYM + SBTL +David G. Sparks, Waterloo, Iowa+ + REP 32 +* * +* Hex/ASCII Dump and * +* Disassembler Utility by * +* Val J Golding, David Sparks, * +* Dave Lingwood, Wm. Steinberg * +* * +* with some subroutines * +* Stolen from Apple's monitor * +* * +* Updated and with a search * +* routine by Greg Kielian * +* * +* Disassembler module modified * +* to run under ProDOS 1-2-84 * +* by David Sparks. * +* * +* Original first appeared in: * +* Call -A.P.P.L.E. : Oct. 1982 * +* Re-published 2020 KFEST * +* * + REP 32 + SKP 3 +STADR EQU $1A +NDADR EQU $1C +CSWL EQU $36 +PCL EQU $3A +LINNUM EQU $50 +FRETOP EQU $6F +VARPNT EQU $83 +VECTOUT EQU $BE30 +GETBUFR EQU $BEF5 +PTRGET EQU $DFE3 +CHKSTR EQU $DD6C +SYNCHR EQU $DEC0 +GETSPA EQU $E452 +MOVSTR EQU $E5E2 +INSTDSP EQU $F8D0 +PRNTYX EQU $F940 +PCADJ EQU $F953 +PRBYTE EQU $FDDA +COUT EQU $FDED +* +* +* + ORG $9700 +* +* +* +NEWLINE LDY STADR+1 ;Get start + LDX STADR ;address + LDA #$8D ;and c/r + JSR COUT ;Print c/r + JSR PRNTYX ;Print address + LDY #0 ;Initialize + STY FLAG ;Flag + LDX #$07 ;and counter + LDA #$BA ;":" CHAR + JSR COUT ;Print colon +DATAOUT LDA #$A0 + JSR COUT ;Print space + LDA (STADR),Y ;Get byte + STA BUF,X ;Park in buffer + DEX ;Keep count + JSR PRBYTE ;Output byte + LDA STADR ;Check to + CMP NDADR ;see if + LDA STADR+1 ;start < end + SBC NDADR+1 + BLT NXTBYTE ;Only continue if less than + INC FLAG ;Flag >= result + BNE SPACEOUT ;Halt output of bytes +NXTBYTE INC STADR ;Bump start + BNE MOD8CHK + INC STADR+1 +MOD8CHK LDA STADR + AND #$07 + BNE DATAOUT ;Not done with line yet +SPACEOUT TXA ;Check counter + BMI ASCIDUMP ;Skip if 8 bytes outputted + LDA #$A0 +PUTSPA JSR COUT ;Print + JSR COUT ;three + JSR COUT ;spaces + STA BUF,X ;and pad buffer + DEX ;Repeat + BPL PUTSPA ;until x is negative +* +ASCIDUMP LDA #$A0 ;Output a space + JSR COUT + LDX #$07 ;Counter + LDA ASCFLAG + BNE NOASC +ASC LDA BUF,X ;Get byte + ORA #$80 ;Make it legal + CMP #$A0 + BGE NOTCTRL + CMP #$80 + BEQ NULL + AND #$7F + BIT $C01E + BPL NOTCTRL + ORA #$40 + BNE NOTCTRL +NULL LDA #$AE ;Replace @ with . +NOTCTRL JSR COUT ;Print legal byte + DEX ;Repeat 8 times + BPL ASC +NOASC LDA FLAG ;Check flag + BNE DONE ;Repeat if clear + JMP NEWLINE +DONE RTS ;else all done + RTS ;else all done +* +* The disassembler module calls a monitor +* routine which uses PCL ($3A). The disk +* driver routines of the ProDOS Machine +* Language Interface also use that address +* and do not restore it. +* +* To deal with the conflict, the disassembly +* line is now output to a memory buffer, +* an Applesoft string variable descriptor +* is "pointed" to the buffer, and the +* Applesoft program then writes the string +* to disk. This way the disk driver routines +* are never called during output of a +* line of disassembly. +* +* Thanks to Ken Kashmarek for the idea. +* +* +* CHECK SYNTAX AND LOCATE STRING POINTER +* +DISSAM LDA #$E4 + JSR SYNCHR ;IS IT STR$ TOKEN? + JSR PTRGET ;FIND VARIABLE + JSR CHKSTR ;BE SURE IT'S A STRING + STA STRPTR + STY STRPTR+1 ;SAVE POINTER TO STRING DESCRIPTOR +* +* SAVE MONITOR AND SYSTEM OUTPUT ADDRESSES +* + LDA CSWL + STA CSAVE ;SAVE ZERO PAGE OUTPUT POINTER + LDA CSWL+1 + STA CSAVE+1 + LDA VECTOUT + STA VSAVE ;SAVE SYSTEM OUTPUT POINTER + LDA VECTOUT+1 + STA VSAVE+1 +* +* POINT SYSTEM OUTPUT TO OUR ROUTINE +* + LDA #>OUTSTRNG + STA VECTOUT + LDA #BUF + STA (VARPNT),Y + INY + LDA #