;--------------------------------------------------------- "Loading DEBUG" $PRINT CRLF CREATE DEBUG * * "DEBUG" - enables debug mode * Version II * Converted to CREATE 9/22/02 * Version II- * Removed E function 12/30/03 * * ZP vars used but not defined by create... DBGVE EQU 352 IR EQU 306 W2AIN EQU 363 STOP EQU 437 RTOP EQU 441 W2OUA EQU 404 ZW2A EQU 335 W2LEN EQU 407 ANBYA EQU 360 ANVAL EQU 361 ZA2W EQU 336 * LDA ZNXT,I * get instruction at insert point CPA DBGJS * compare to debug instruction JMP ZNXT,I * if equal do nothing, already hooked LDA ZNXT,I * get instruction to replace STA DBGSI * store in debugger flow LDA DBGVV * get debugger subroutine location STA DBGVE * save at debugger vector LDA DBGJS * get debugger call to insert STA ZNXT,I * replace original instruction JMP ZNXT,I DBGJS JSB DBGVE,I * instruction that calls debug DBGVV DEF MYDBG * what to put in debug vector MYDBG NOP * implemented as subroutine DBGSI NOP * saved instruction goes here STA DBGSA * save A register STB DBGSB * entry.. save B too JMP DBGST * display registers then command loop * command loop... DBGLP JSB ZCRLF,I * print crlf LDA DBGA1 * load message len LDB DBGA2 * load message adr JSB ZPBFL,I * print "BUG>" prompt DBG10 JSB ZCHIN,I * get character CPA DBGKC * is it C? JMP DBGPC * yes - process Continue CPA DBGKS * is it S? JMP DBGPS * yes - process Step CPA DBGKR * is it R? JMP DBGPR * yes - process Registers CPA DBGKD * is it D? JMP DBGPD * yes - process stack Dump CPA DBGKT * is it T? JMP DBGPT * yes - process reTurn stack dump CPA DBGKH * is it help? JMP DBGPH * yes - print command list JMP DBG10 * unrecognised, get another character * continue... DBGPC LDA DBGSI * get saved instruction STA ZNXT,I * replace debug hook JSB with original * step... DBGPS LDA DBGSS * get space JSB ZCOUT,I * output to console LDA DBGSA * restore LDB DBGSB * registers JMP MYDBG,I * return from sub * display registers... DBGPR LDA DBGSS * display space JSB ZCOUT,I * to match with Step output DBGST LDA DBGA5 * entry point LDB DBGA6 JSB ZPBFL,I * print " IR:" LDA IR * get value of IR JSB DBGPN * print number LDB IR,I * get contents of IR ADB CMIN3 * subtract 3 STB DBGTE * save LDA 1,I * get potential header JSB DBSAN * sanitize for printing JSB ZPTWD,I * print it LDB DBGTE INB LDA 1,I JSB DBSAN JSB ZPTWD,I * print the next 2 chars LDA DBGAD LDB DBGAE JSB ZPBFL,I * print " SP:" LDA SP JSB DBGPN * print value of SP LDA DBGAF LDB DBGAG JSB ZPBFL,I * print " RP:" LDA RP JSB DBGPN * print value of RP LDA DBGA7 LDB DBGA8 JSB ZPBFL,I * print " XP:" LDA XP JSB DBGPN * print value of XP LDA DBGA9 LDB DBGAA JSB ZPBFL,I * print " YP:" LDA YP JSB DBGPN * print value of YP LDA DBGAB LDB DBGAC JSB ZPBFL,I * print " ZP:" LDA ZP JSB DBGPN * print value of ZP * JMP DBGLP * goto prompt DBSAN NOP * sanitize sub.. make printable AND DBSAM * make each byte 0-127 STA DBSAT * save in temp ALF,ALF * put high byte in low to check AND DBSLM * isolate just low byte ADA DBS40 * add -32 SSA,RSS * skip if <0 JMP DBSA2 * ok, continue with checking low DBSA1 LDA DBSDO * not ok, dot it out JMP DBSAN,I * return DBSA2 LDA DBSAT * get back double AND DBSLM * isolate low ADA DBS40 * add -32 SSA * skip if >=0 JMP DBSA1 * not ok, dot out and return LDA DBSAT * restore A JMP DBSAN,I * and return DBSAM OCT 77577 * clear bits 7 and 15 DBSAT OCT 0 * temp for sanitize sub DBSLM OCT 377 * for clearing high byte DBS40 OCT 177740 * -32 in octal DBSDO OCT 27056 * ".." DBGDS OCT 20040 * " " * dump system stack... past to current DBGPD LDB STOP * get base of system stack STB DBGV1 * save in pointer variable DBG2D LDB DBGV1 * get pointer CPB SP * compare to stack pointer JMP DBGLP * jump to prompt when equal JSB ZCRLF,I * print crlf LDB DBGV1 * get address LDA 1,I * get data INB * increment pointer STB DBGV1 * save pointer JSB DBGPN * convert and print JMP DBG2D * loop until emptied DBGV1 OCT 0 * dump return stack... DBGPT LDB RTOP * get base of return stack STB DBGV1 * save in pointer variable DBG2T LDB DBGV1 * get pointer CPB RP * compare to return stack pointer JMP DBGLP * jump to prompt when equal JSB ZCRLF,I * print crlf LDB DBGV1 * get address LDA 1,I * get data INB * increment pointer STB DBGV1 * save pointer JSB DBGPN * convert and print JMP DBG2T * loop until emptied * print help... DBGPH LDA DBGA3 * len of help text LDB DBGA4 * adr of help text JSB ZPBFL,I * print help JMP DBGLP * goto prompt * print number in A sub... DBGPN NOP STA W2AIN * save in W2ASC's input location JSB ZW2A,I * convert to ascii LDB W2OUA * get address of W2ASC's output DBG2N STB DBGV2 * save in pointer LDA 1,I * get ascii character JSB ZCOUT,I * output it to console LDB DBGV2 * get pointer INB * increment pointer LDA W2LEN * get (remaining) length ADA CON1 * decrement STA W2LEN * save back SZA * skip if A=0 JMP DBG2N * otherwise keep printing characters LDA DBGSS * get space char JSB ZCOUT,I * print space JMP DBGPN,I * return from sub DBGV2 OCT 0 * DBGSA OCT 0 * save for A,B DBGSB OCT 0 DBGSS OCT 40 * space char * debug prompt... DBGA1 DEC 2 DBGA2 DEF *+1 ASC 2,BUG> * help text... DBGA3 DEC 29 DBGA4 DEF *+1 OCT 6412 ASC 15,C-CONTINUE S-STEP R-REGISTERS OCT 6412 ASC 12,D-DUMP STACK T-RET.STACK * register labels... DBGA5 DEC 2 DBGA6 DEF *+1 ASC 2, IR: DBGA7 DEC 2 DBGA8 DEF *+1 ASC 2, XP: DBGA9 DEC 2 DBGAA DEF *+1 ASC 2, YP: DBGAB DEC 2 DBGAC DEF *+1 ASC 2, ZP: DBGAD DEC 2 DBGAE DEF *+1 ASC 2, SP: DBGAF DEC 2 DBGAG DEF *+1 ASC 2, RP: * key codes... DBGKC DEC 67 DBGKS DEC 83 DBGKR DEC 82 DBGKD DEC 68 DBGKT DEC 84 DBGKH DEC 63 * ? character * CMIN3 OCT 177775 * -3 DBGTE OCT 0 * temp * * end debug code * END ;--------------------------------------------------------- "Done" $PRINT CONSOLE