X-Git-Url: http://cloudbase.mooo.com/gitweb/ddt180.git/blobdiff_plain/ca1c9c55bf9f5453368770a8ae137bcb732f96aa..3628b07486563949246f6e30ef479e3db86b5c4b:/ddt180.z80 diff --git a/ddt180.z80 b/ddt180.z80 index dbcebc8..2763329 100644 --- a/ddt180.z80 +++ b/ddt180.z80 @@ -62,8 +62,7 @@ STACK_SIZE equ 80 ;ddtz internal stack CONBUF_SIZE equ 80 ;Size of console input buffer EXPR_BUF_SIZE equ 128 ;expressen buffer for conditional breakpoints BP_CNT equ 12 ;Number of breakpoints -BP_SIZE equ 8 ;Size of a breakpoint record -YREG_CNT equ 10 ;Number of Y registers (0..9) +BP_SIZE equ 6 ;Size of a breakpoint record ;------------------------------------------------------------------------------- @@ -121,9 +120,7 @@ reg.iff: db 0c3h reg.pc: dw TPA var.$: dw 0000h -var.@: dw 0 -error_func:dw p_msg_error cmd_rpt:dw mainloop ;------------------------------------------------------------------------------- @@ -134,9 +131,7 @@ conbuf: ld sp,stack exx ld de,ddtz_base - or a - sbc hl,de - add hl,de + call cp_hl_de jr c,l0079h ex de,hl l0079h: @@ -173,10 +168,10 @@ l0093h: ;------------------------------------------------------------------------------- CMDTAB: - dw cmd_@ ;examine/substitute the displacement register @ + dw ERROR ;cmd_@ ;examine/substitute the displacement register @ dw ERROR ;cmd_A ;Assemble dw cmd_B ;Breakpoints display/set/clear - dw cmd_C ;trace over Calls + dw ERROR ;cmd_C ;trace over Calls dw cmd_D ;Display memory in hex and ascii dw ERROR ; dw cmd_F ;specify Filename and command line @@ -198,18 +193,22 @@ CMDTAB: dw cmd_V ;Verify (compare) two memory areas dw cmd_W ;Write a file to disk dw cmd_X ;eXamine [and substitute] registers - dw cmd_Y ;examine [and substitute] Y variables + dw ERROR ;cmd_Y ;examine [and substitute] Y variables dw cmd_Z ;Zap (fill) memory with a byte string +ERROR: +p_msg_error: + call pstr_inl + dc '?',CR,LF + ;fall thru mainloop: ld sp,stack - ld hl,p_msg_error - ld (error_func),hl ld hl,(reg.pc) ld (var.$),hl call bp_clr_temporary ld hl,(cmd_rpt) ld de,mainloop + push de call cp_hl_de ld a,'>' call outchar @@ -218,7 +217,8 @@ mainloop: call get_line call skipbl jr z,exe_hl - ld hl,mainloop + pop hl + push hl ld (cmd_rpt),hl inc de sub '@' @@ -232,48 +232,20 @@ mainloop: inc hl ld h,(hl) ld l,a - jr exe_hl - -ERROR: - ld hl,(error_func) exe_hl: - call CALL_HL - jr mainloop + jp (hl) ;------------------------------------------------------------------------------- -p_msg_error: - call pstr_inl - dc '?' - ;fall thru crlf: call pstr_inl - db CR,LF+80h + dc CR,LF call inchar ld a,0 ld (con_col),a jr c,mainloop ret -out.hl.@: - call out_hl - push de - push hl - ld de,(var.@) - ld a,d - or e - jr z,l01bfh - call outbl - call pstr_inl - dc '@' - and a - sbc hl,de - call out_hl -l01bfh: - pop hl - pop de - ret - sub_01d9h: call pstr_inl dc '-' @@ -563,10 +535,6 @@ l0300h: sub_0303h: ld hl,t_reg_names ld b,07fh - jr l030ch - -sub_030ah: - ld b,0ffh l030ch: inc b ld a,(hl) @@ -577,10 +545,6 @@ l030ch: res 7,b ret -sub_0318h: - push bc - res 7,b - defb 03eh ;ld a,nn sub_031ch: push bc push de @@ -994,9 +958,6 @@ do_factor: ld hl,TPA cp 'L' ret z - ld hl,(var.@) - cp '@' - ret z ld hl,(var.$) cp '$' ret z @@ -1011,8 +972,6 @@ do_factor: jr z,fact_factor cp '^' jr z,fact_reg.CPU - cp 'Y' - jr z,fact_reg.Y cp '(' jr z,fact_mem cp '[' @@ -1025,21 +984,6 @@ do_factor: ;------------------------------------------------------------------------------- -fact_reg.Y: - call get.decdigit - jr c,error1 - inc de -get_y_val: - add a,a - ld hl,reg_Y - call add_hl_a - ld a,(hl) - inc hl - ld h,(hl) - ld l,a - and a - ret - fact_factstring: ld hl,0 l054bh: @@ -1245,6 +1189,7 @@ p_cpustat: l063eh: call p_regs djnz l063eh + call outbl6 push hl push de ld iy,(reg.pc) @@ -1261,8 +1206,6 @@ l065bh: djnz l065bh pop af pop hl - call nz,outbl6 - call nz,p_offset jp crlf p_f: @@ -1319,12 +1262,6 @@ p_regs: inc hl ld d,(hl) ex de,hl - dec a - jr z,l06d9h - call out.hl.@ - call z,outbl6 - jr l06e2h -l06d9h: call out_hl jr l06e2h l06deh: @@ -1387,7 +1324,6 @@ b_0709_start: cmd_G: sub a - ld (trace_call_flag),a ld (bp_p_cpu_flag),a call expr jr c,l0740h @@ -1432,7 +1368,6 @@ bp_clr_temporary: ld a,(ix+000h) and 0f1h ld (ix+000h),a - call bp_clr_condition call bpl_next ret @@ -1448,7 +1383,7 @@ bp_clr_temporary: ; clear breakpoints ; ; where breakp is: -; [R] expression [I condition] +; expression cmd_B: call skipbl @@ -1485,45 +1420,27 @@ bp_clr: jr nz,l07aeh l07a7h: ld (ix+000h),000h - call bp_clr_condition l07aeh: pop af call bpl_next ret bp_print: + ld c,0 call bpl_init bit 0,(ix+000h) jr z,bp_pr_cont - ld a,'R' - bit 4,(ix+000h) - jr nz,l07cdh - ld a,' ' -l07cdh: - call outchar - call outbl ld l,(ix+002h) ld h,(ix+003h) - call out.hl.@ - call pstr_inl - dc ' :' - ld l,(ix+004h) - ld h,(ix+005h) call out_hl - ld l,(ix+006h) - ld h,(ix+007h) - ld a,h - or l - jr z,l0805h - call outbl4 - call pstr_inl - dc 'I ' - call pstr -l0805h: - call crlf + call outbl2 + inc c bp_pr_cont: call bpl_next + ld a,c + or a + call nz,crlf ret ;------------------------------------------------------------------------------- @@ -1535,11 +1452,7 @@ bp_enter: ld b,a call skipbl ret z - cp 'R' - jr nz,bp_e_1 - inc de - set 4,b -bp_e_1: + push bc call expr jr c,error12 @@ -1557,9 +1470,6 @@ bp_e_1: call bp_get_count ld (ix+004h),l ld (ix+005h),h - call bp_get_condition - ld (ix+006h),l - ld (ix+007h),h call next_arg pop af ld (ix+000h),a @@ -1587,39 +1497,6 @@ bp_get_count: jr c,error12 ret -bp_get_condition: - call skipbl - cp 'I' - ld hl,0 - ret nz - inc de - call skipbl - push de - call expr - jr c,error12 - ex de,hl - pop de - push de - sbc hl,de - ld b,h - ld c,l - ld hl,(expr_p1) - push hl - add hl,bc - ld de,expr_bufe - call cp_hl_de - jr nc,error12 - pop de - pop hl - push de - ldir - ex de,hl - ld (hl),c ; trailing 0 - inc hl - ld (expr_p1),hl - pop hl - ret - ;------------------------------------------------------------------------------- ; Breakpoint handling routine. @@ -1699,15 +1576,6 @@ sub_0942h: ex af,af' res 7,a ex af,af' - ld e,(ix+006h) - ld d,(ix+007h) - ld a,d - or e - ld hl,0ffffh - call nz,expr - ld a,h - or l - jr z,l0969h ld e,(ix+004h) ld d,(ix+005h) dec de @@ -1716,11 +1584,6 @@ sub_0942h: jr z,l0974h ld (ix+004h),e ld (ix+005h),d -l0969h: - bit 4,(ix+000h) - ret z - ld a,001h - ld (bp_p_cpu_flag),a ret l0974h: ex af,af' @@ -1770,8 +1633,6 @@ bp_trace_enter: ld (ix+005h),000h ld (ix+002h),l ld (ix+003h),h - ld (ix+006h),000h - ld (ix+007h),000h ld a,(b_21e2_start) and a ld a,008h @@ -1843,105 +1704,12 @@ l0a41h: ld sp,(reg_sp) jp reg.iff -;------------------------------------------------------------------------------- - -bp_clr_condition: - ld a,(ix+000h) - and 003h - ret nz - ld e,(ix+006h) - ld d,(ix+007h) - ld a,d - or e - ret z - push bc - ld h,d - ld l,e - sub a - ld (ix+006h),a - ld (ix+007h),a - ld bc,0ffffh - cpir -l0a7dh: - push de - ld de,(expr_p1) - call cp_hl_de - pop de - jr nc,l0a93h - call sub_0a99h -l0a8bh: - ld a,(hl) - ldi - and a - jr nz,l0a8bh - jr l0a7dh -l0a93h: - ld (expr_p1),de - pop bc - ret - -sub_0a99h: - ld iy,bp_tab - push de -l0a9eh: - ld e,(iy+006h) - ld d,(iy+007h) - call cp_hl_de - jr z,l0ab0h - ld de,BP_SIZE - add iy,de - jr l0a9eh -l0ab0h: - pop de - ld (iy+006h),e - ld (iy+007h),d - ret - ;------------------------------------------------------------------------------- ; > Y ; examine all Y variables ; > Y[0..9] ; examine (and substitute) an Y variable -cmd_Y: - call get.decdigit - jr c,l0bc3h - inc de - push af - call assert_eol - pop af - call sub_0bdch - jp l0c15h -l0bc3h: - call assert_eol - xor a -l0bc7h: - push af - call sub_0bdch - call outbl4 - pop af - inc a - bit 0,a - push af - call z,crlf - pop af - cp YREG_CNT - jr c,l0bc7h - ret - -sub_0bdch: - ld c,a - ld b,0 - add a,'0'+080h - ld de,msg_Y+1 - ld (de),a - dec de - ld hl,reg_Y - add hl,bc - add hl,bc - ex de,hl - ld c,003h - jp l0c33h ;------------------------------------------------------------------------------- ; > X @@ -1966,9 +1734,8 @@ cmd_X: ex de,hl ld hl,t_reg_names call sel_dc_string -l0c12h: call l0c33h -l0c15h: + call outbl push de push bc @@ -2002,9 +1769,7 @@ l0c33h: ld a,(de) dec de ld h,a - bit 1,c - jp z,out_hl - jp out.hl.@ + jp out_hl l0c4fh: call p_f @@ -2187,7 +1952,7 @@ cmd_S: call get_lastarg_def l0d60h: ld (last_S),hl - call out.hl.@ + call out_hl call outbl ld a,(hl) call out_hex @@ -2222,22 +1987,13 @@ l0d8ah: ; > @ ; examine (substitute) displacement register @ -cmd_@: - call assert_eol - ld hl,msg_@ - ld de,var.@ - ld c,001h - jp l0c12h - -msg_@: - dc '@' +;cmd_@: ;------------------------------------------------------------------------------- ; >>I [port] ; Input a byte from port cmd_I: - ld hl,cmd_I ld (cmd_rpt),hl ld hl,(last_I) call get_lastarg_def @@ -2257,7 +2013,6 @@ cmd_I: ; Output a byte to a port cmd_O: - ld hl,cmd_O ld (cmd_rpt),hl ld hl,(last_O_val) call get_arg_def @@ -2287,7 +2042,7 @@ l0dedh: cp b jr z,l0e10h ld c,a - call out.hl.@ + call out_hl call outbl ld a,b call out_hex @@ -2296,7 +2051,7 @@ l0dedh: call out_hex call outbl ex de,hl - call out.hl.@ + call out_hl ex de,hl call crlf l0e10h: @@ -2349,30 +2104,11 @@ cmdm_up: ; off all loaded files, and Top address of available memory ; > H expression ; evaluate expression and display result in hex, decimal and other formats -; > H expression expression -; display sum und difference of expressions cmd_H: call expr jp c,p_max_high0 - call next_arg - push hl - call expr - push af call assert_eol - pop af - ex de,hl - pop hl - jr c,l0e5eh - push hl - push de - add hl,de - call l0e5eh - pop de - pop hl - and a - sbc hl,de -l0e5eh: call out_hl call outbl2 call out_hl_neg @@ -2552,7 +2288,6 @@ l0f42h: ; Display memory in hex and ASCII cmd_D: - ld hl,cmd_D ld (cmd_rpt),hl ld hl,(last_D) ld bc,128 @@ -2564,7 +2299,7 @@ sub_0f58h: push hl push af l0f5ch: - call out.hl.@ + call out_hl call z,outbl2 call outbl ld de,0 @@ -2947,15 +2682,6 @@ rdhex_done: pop hl jp p_max_high - -test_numeral: - cp '9' - ret z - ccf - ret c - cp '0' - ret - test_whitespace: cp ' ' ret z @@ -3075,7 +2801,6 @@ l1773h: ; List disassembled code cmd_L: - ld hl,cmd_L ld (cmd_rpt),hl call expr jr nc,l18dbh @@ -3122,7 +2847,7 @@ cmdl_p_line: p_disas_line: call outbl2 - call out.hl.@ + call out_hl call z,outbl call outbl sub a @@ -3136,19 +2861,7 @@ p_disas_line: call p_goto_col ; fall thru ;------------------------------------------------------------------------------- - -p_offset: - ld de,(var.@) - ld a,d - or e - ret z - call pstr_inl - dc '(@' - and a - sbc hl,de - call out_hl - add hl,de - jp out_rparen + ret ;------------------------------------------------------------------------------- @@ -4200,12 +3913,6 @@ b_2048_start: ;------------------------------------------------------------------------------- ; call mn call cc,mn l2080h: - ld a,(b_21e2_start) - and a - jr nz,l208bh - ld a,(trace_call_flag) - and a - ret nz ; jp mn jp cc,mn l208bh: @@ -4275,15 +3982,6 @@ l20d7h: jp (hl) l20dch: - ld a,(b_21e2_start) - and a - jr nz,l20edh - ld a,(trace_call_flag) - and a - jr z,l20edh - call l20edh - pop hl - ret l20edh: ld hl,(reg_sp) ld e,(hl) @@ -4305,11 +4003,8 @@ l20f9h: ld h,000h ld a,(b_21e2_start) and a - jr nz,l2113h - ld a,(trace_call_flag) - and a - ret nz -l2113h: + ret z + scf ret @@ -4319,10 +4014,6 @@ l2113h: ; >>C[N][J] U expression ; trace over Calls [No list] [Jumps only] /.While./.Until. -cmd_C: - ld hl,cmd_C - ld a,1 - jr cmd_tc ;------------------------------------------------------------------------------- ; >>T[N][J] [steps] @@ -4331,119 +4022,31 @@ cmd_C: ; Trace [no List] [Jumps only] / .While. / .Until. cmd_T: - xor a - ld hl,cmd_T -cmd_tc: ld (cmd_rpt),hl - ld (trace_call_flag),a - call get_char_upper - sub 'N' - jr nz,tc_non - inc de -tc_non: - ld (trace_N_flag),a - call get_char_upper - sub 'J' - jr nz,tc_noj - inc de -tc_noj: - ld (trace_J_flag),a - call tc_chk_u_or_w - jr z,tc_save_uw_expr_ptr ld hl,1 ;default: 1 step call get_lastarg_def -tc_save_uw_expr_ptr: ld (trace_cnt_or_ptr),hl sub a ld (bp_p_cpu_flag),a -l214ch: call tc_set_bp jr user_go1 l2151h: call bp_clr_temporary - ld a,(trace_J_flag) - and a - jr nz,l216bh - ld iy,(reg.pc) - call sub_21c8h - jr z,l216bh - ld hl,b_2048_start - call lookup_opc - jr nc,l214ch -l216bh: - ld a,(trace_UW_flag) ;0 or 'U' or 'W' - and a - jr z,tc_cnt ;flag is 0, check for step count. - ld de,(trace_cnt_or_ptr) - call expr - ld a,h - or l - add a,0ffh - sbc a,a - ld hl,trace_UW_flag ;'U' or 'W' - xor (hl) - bit 1,a ;'U' = 55H, 'W' = 57H - jr z,l2193h -do_break0: ;print registers and go to main loop - jp do_break - -tc_cnt: ld hl,(trace_cnt_or_ptr) dec hl ld (trace_cnt_or_ptr),hl ld a,h or l - jr z,do_break0 -l2193h: + jp z,do_break + call tc_set_bp - jr nc,do_break0 - ld a,(trace_N_flag) - ld b,a - ld a,(bp_p_cpu_flag) - or b + jp nc,do_break + sbc a,a ld (bp_p_cpu_flag),a user_go1: jp user_go -tc_chk_u_or_w: - call skipbl - xor a - ld (trace_UW_flag),a - call get_char_upper - cp 'U' - jr z,l21b5h - cp 'W' - ret nz -l21b5h: - inc de - push af - push de - call expr - jp c,ERROR - call assert_eol - pop hl - pop af - ld (trace_UW_flag),a - sub a - ret - -sub_21c8h: - ld a,(iy+000h) - cp 0edh - jr z,l21dah - and 0dfh - cp 0ddh - ret nz - ld a,(iy+001h) - cp 0e9h - ret -l21dah: - ld a,(iy+001h) - and 0f7h - cp 045h - ret - ;------------------------------------------------------------------------------- con_col: @@ -4453,16 +4056,8 @@ con_col: b_21e2_start: db 0 -trace_call_flag: - db 0 ;1=call, 0=trace -trace_UW_flag: - db 0 ;0 or 'U' or 'W' trace_cnt_or_ptr: dw 0 -trace_N_flag: - db 0 ;0 if 'N' -trace_J_flag: - db 0 ;0 if 'J' bp_p_cpu_flag: db 0 @@ -4474,9 +4069,6 @@ bp_tab: endm endm -expr_p1: - dw expr_buf - expr_buf: current_cseg defl $ - current_cseg .phase current_phase + current_cseg @@ -4564,13 +4156,6 @@ expr_bufe: ;------------------------------------------------------------------------------- -msg_Y: - dc 'Yn' -reg_Y: - rept YREG_CNT - dw 0 - endm - last_S: dw TPA