; DEBUGS.a ; ISUAL Debug functions - for Debug Pod ; This is set up to call code starting at 0C000h ; which was copied from EEPROM. ; The EEPROM was generated from "DEBH.A" ; The debug code is copied in "BGLOOP.a". ; The EEPROM bank is checksummed first. ; If it fails, a call to DEBUG_DISABLE disables ; the debug code (no debug output at all) ; Entry points of debug code ; This code was copied into high RAM from EEPROM ; It was uploaded from a binary assembled from "DEBH.A" ; 10 C000: C3 0000 ccsds_send: jmp 0 ; 11 C003: C3 0000 task: jmp 0 ; 12 C006: C3 0000 task_new: jmp 0 INIT equ 0C214h PUTBYTE equ 0C01Ch SHOW equ 0C310h DUMP equ 0C3D4h SHOWUT equ 0C40Ah SHOWA equ 0C0A8h REGSET equ 0C3A5h HEXOUT equ 0C359h DECOUT equ 0C37Fh include debug.i include ioports.i include gbl.i DEBUG_DISABLE: lda RET_INSTRUCTION sta DEBUG_INIT sta DEBUG_PUTBYTE sta DEBUG_SHOW sta DEBUG_DUMP sta DEBUG_SHOWUT sta DEBUG_SHOWA sta DEBUG_REGSET sta ch0 sta ch1 sta ch2 sta ch3 RET_INSTRUCTION: ret debug_trap: out 0 ; force a reset jmp debug_trap ; =================== ; Initialization DEBUG_INIT: ; stuff all the interrupt vectors ; ; this will make jumps to 0000 do a Trap mvi a,JMP_OPCODE sta RST_0 ; 0 lxi h,DEBUG_TRAP shld RST_0+1 ; wild RST 7 is also a trap sta RST_7 shld RST_7+1 ; sta RST_0+4 ; 0.5 shld RST_0+5 ; sta RST_1 ; 1 shld RST_1+1 ; sta RST_1+4 ; 1.5 shld RST_1+5 ; sta RST_2 ; 2 shld RST_2+1 ; sta RST_2+4 ; 2.5 shld RST_2+5 ; sta RST_3 ; 3 shld RST_3+1 ; sta RST_3+4 ; 3.5 shld RST_3+5 ; sta RST_4 ; 4 shld RST_4+1 ; sta RST_4+4 shld RST_4+5 ; sta RST_5 ; 5 shld RST_5+1 ; sta RST_6 shld RST_6+1 ; sta RST_55 shld RST_55+1 ; sta RST_65 shld RST_65+1 ; sta RST_75 shld RST_75+1 ; ; set TRAP vector mvi a,JMP_OPCODE ; JMP opcode sta TRAP lxi h,DEBUG_TRAP ; address of Trap handler shld TRAP+1 ; set as JMP address ch0: nop call INIT ret ; DEBUG_PUTBYTE: nop ; ***ret ; *** needs to be NOP'd to activate debugging jmp PUTBYTE DEBUG_SHOW: nop jmp SHOW DEBUG_DUMP: nop jmp DUMP DEBUG_SHOWUT: nop jmp SHOWUT DEBUG_SHOWA: nop JMP SHOWA DEBUG_REGSET: nop jmp REGSET DEBUG_ASC: ; text follows call: look for '$' or '~' in following string ; (don't show '~' or '$') xthl ; exchange top of stack (TOS) with HL push psw a1: mov a,M ; get string byte cpi '$' ; end of string? jz a2 ; yes cpi '~' ; end with no newline? jz a2nl call DEBUG_PUTBYTE ; no send out byte inx h ; keep looking jmp a1 a2: mvi a,10 ; send Newline call DEBUG_PUTBYTE a2nl: inx h pop psw xthl ; set new return-address as TOS ret ; DEBUG_ASC_HL: ; HL - data value to display in Hex ; text follows call: look for '=' in following string xthl ; exchange top of stack (TOS) with HL push psw stl1: mov a,M ; get string byte ch3: call DEBUG_PUTBYTE ; send it out cpi '=' ; end of string? jz found_eq ; yes inx h ; no; keep looking jmp stl1 found_eq: inx h pop psw xthl ; set new return-address as TOS ch1: nop call HEXOUT ; tell monitor to display (original) HL as hex ret ; DEBUG_ASC_DEC: ; HL - data value to display in decimal ; text follows call: look for '=' in following string xthl ; exchange top of stack (TOS) with HL push psw ttl1: mov a,M ; get string byte call DEBUG_PUTBYTE ; send it out cpi '=' ; end of string? jz fnd_eq ; yes inx h ; no; keep looking jmp ttl1 fnd_eq: inx h pop psw xthl ; set new return-address as TOS ch2: nop call DECOUT ; tell monitor to display (original) HL as decimal ret