X-Git-Url: http://cloudbase.mooo.com/gitweb/ddt180.git/blobdiff_plain/786e99f6a0938ee6e1bce05b3b83e0cbf447f160..d0ff7c76b85c1d1f7e76672462c0ba85861ab9b3:/ddt180.z80 diff --git a/ddt180.z80 b/ddt180.z80 index 2baacd9..da5cfe6 100644 --- a/ddt180.z80 +++ b/ddt180.z80 @@ -63,11 +63,6 @@ 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) - -SYMCASE_SENS equ 0 ;Symbols are case sensitive -SYMCASE_CONV equ 1 ;Convert case when symbols are loaded -SYMCASE_LOWER equ 2 ;Convert to lower case if set, else to upper case ;------------------------------------------------------------------------------- @@ -80,19 +75,11 @@ di_or_ei: ret ddtz_bdos: jp 0 -screen_width: - db 80 -symlen_max: - db 16 - -symattrib: - db 0 - current_cseg defl $ - current_cseg .phase current_phase + current_cseg signon: - db 'Symbolic DDTZ/180' + db 'DDTZ/180' db ' - Version ' maclib version.inc defvers @@ -133,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 ;------------------------------------------------------------------------------- @@ -146,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: @@ -174,7 +157,6 @@ l0093h: ld hl,ddtz_base ld l,000h ld (reg_sp),hl - call cpy_fcb2 ld a,(dfcb1+1) cp ' ' ld hl,0 @@ -186,7 +168,7 @@ 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 @@ -204,25 +186,29 @@ CMDTAB: dw cmd_O ;Output a byte to port dw ERROR ; dw cmd_Q ;Qery memory for byte string - dw cmd_R ;Read binary or hex file and/or symbol file + dw cmd_R ;Read binary or hex file dw cmd_S ;Substitute memory dw cmd_T ;Trace dw ERROR ; 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 @@ -231,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 '@' @@ -245,48 +232,21 @@ 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 '-' @@ -441,17 +401,6 @@ pstr_inl: ex (sp),hl ret -p_align_@_sym: - push de - ld de,(var.@) - ld a,d - or e - pop de - ld a,(symlen_cur) - jr z,$+4 - add a,6 - add a,c - ld c,a p_goto_col: ld a,(con_col) cp c @@ -511,15 +460,6 @@ toupper: and 05fh ret -tolower: - cp 'A' - ret c - cp 'Z'+1 - ccf - ret c - or 020h - ret - ;------------------------------------------------------------------------------- skipbl0: @@ -574,86 +514,6 @@ cp_hl_de: sbc hl,de add hl,de ret - -sub_hl_a1: - dec hl -sub_hl_a: - push bc - ld c,a - ld b,0 - or a - sbc hl,bc - pop bc - ret - -;------------------------------------------------------------------------------- - -sym_getname: - push de - push hl - ld hl,ddtz_base+2 -sgn_l: - ld d,(hl) - dec hl - ld e,(hl) - dec hl - ld a,(hl) - cp 0c3h - jr z,sgn_e - - ex (sp),hl - call cp_hl_de - jr z,sgn_e - ex (sp),hl - call sub_hl_a1 - jr sgn_l -sgn_e: - sub 0c3h - pop hl - pop de - ret - -p_symstr: - push bc - ld b,(hl) -pss_l: - dec hl - ld a,(hl) - call outchar - djnz pss_l - dec hl - pop bc - ret - -p_symbol: - if 0 - ld a,(dash_flag) - or a - ret nz - endif - push hl - call sym_getname - call nz,p_symstr - pop hl - ret - -p_label: - if 0 - ld a,(dash_flag) - or a - ret nz - endif - push hl - call sym_getname - jr z,pl_e - call p_symstr - call pstr_inl - dc ':' - call crlf -pl_e: - pop hl - ret - ;------------------------------------------------------------------------------- lookupch: @@ -676,10 +536,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) @@ -690,10 +546,6 @@ l030ch: res 7,b ret -sub_0318h: - push bc - res 7,b - defb 03eh ;ld a,nn sub_031ch: push bc push de @@ -1107,9 +959,6 @@ do_factor: ld hl,TPA cp 'L' ret z - ld hl,(var.@) - cp '@' - ret z ld hl,(var.$) cp '$' ret z @@ -1124,37 +973,18 @@ 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 '[' jr z,expr_brckt cp '''' jr z,fact_factstring - cp '.' - jr z,fact_symbol dec de scf ret ;------------------------------------------------------------------------------- -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: @@ -1239,59 +1069,6 @@ expr_brckt: error1: jp ERROR -fact_symbol: - push bc - ld hl,ddtz_base ;symtbl start - ld a,(symattrib) - ld c,07fh - rra - jr c,fs_nxtsym - res 5,c - -fs_nxtsym: - ld a,(hl) ;symlen - cp 0c3h - jr z,error1 - ld b,a ;symlen - inc b - push hl ;symtbl ptr - push de ;inpsym ptr -fs_nxtchar: - ld a,(de) - djnz fs_3 - call test_sym_char - jr z,fs_cont - pop hl ;inpsym ptr (discard) - inc de - cp a,':' - jr z,fs_cont_1 - dec de - - pop hl ;symtbl ptr - inc hl - ld a,(hl) ;symval h - inc hl - ld h,(hl) ;symval l - ld l,a - or a ;clear carry - pop bc - ret - -fs_3: - inc de - dec hl - xor (hl) - and c - jr z,fs_nxtchar -fs_cont: ;start over - pop de ;inpsym ptr -fs_cont_1: - pop hl ;symtbl ptr - ld a,(hl) - add a,3 - call sub_hl_a - jr fs_nxtsym - ;------------------------------------------------------------------------------- get.number: @@ -1413,6 +1190,7 @@ p_cpustat: l063eh: call p_regs djnz l063eh + call outbl6 push hl push de ld iy,(reg.pc) @@ -1429,8 +1207,6 @@ l065bh: djnz l065bh pop af pop hl - call nz,outbl6 - call nz,p_offset jp crlf p_f: @@ -1487,12 +1263,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: @@ -1673,13 +1443,9 @@ l07cdh: call outbl ld l,(ix+002h) ld h,(ix+003h) - call out.hl.@ - call outbl - call p_symbol - ld c,9 - call p_align_@_sym + call out_hl call pstr_inl - dc ':' + dc ' :' ld l,(ix+004h) ld h,(ix+005h) call out_hl @@ -2075,53 +1841,6 @@ l0ab0h: ; > 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 outbl - pop af - push af - call get_y_val - call p_symbol - pop af - inc a - push af - rra - push af - ld c,11 - call c,p_align_@_sym - pop af - call nc,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 @@ -2148,7 +1867,7 @@ cmd_X: call sel_dc_string l0c12h: call l0c33h -l0c15h: + call outbl push de push bc @@ -2182,9 +1901,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 @@ -2367,7 +2084,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 @@ -2402,22 +2119,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 @@ -2437,7 +2145,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 @@ -2467,7 +2174,7 @@ l0dedh: cp b jr z,l0e10h ld c,a - call out.hl.@ + call out_hl call outbl ld a,b call out_hex @@ -2476,7 +2183,7 @@ l0dedh: call out_hex call outbl ex de,hl - call out.hl.@ + call out_hl ex de,hl call crlf l0e10h: @@ -2527,38 +2234,13 @@ cmdm_up: ; > H ; display Highest load address of last filed loaded, Maximum "High" ; off all loaded files, and Top address of available memory -; > HS -; display symbol list ; > 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 get_char_upper - cp 'S' - jr z,p_sym_list - 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 @@ -2568,56 +2250,11 @@ l0e5eh: call out_hl_dec_neg call outbl4 call out.bin.w - call outbl + call outbl2 ld a,l call out.ascii - call outbl2 - call p_symbol jp crlf -p_sym_list: - inc de - call assert_eol - ld a,(symlen_cur) - add a,7 - ld b,a - ld c,0 - ld hl,ddtz_base+2 -psym_nxtsym: - ld d,(hl) - dec hl - ld e,(hl) - dec hl - ld a,(hl) - cp 0c3h - jr z,psym_e - - call p_goto_col - ex de,hl - call out_hl - call outbl - ex de,hl - call p_symstr - - ld a,c - add b - ld c,a - ld a,(screen_width) - sub b - cp c - jr nc,psym_nxtsym - - call crlf - ld c,0 - jr psym_nxtsym - -psym_e: - ld a,c - or a - ret z - jp crlf - - ;------------------------------------------------------------------------------- ; > Q[J] startaddr endaddr bytes ; Query memory for a byte string [Justified] @@ -2783,7 +2420,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 @@ -2795,7 +2431,7 @@ sub_0f58h: push hl push af l0f5ch: - call out.hl.@ + call out_hl call z,outbl2 call outbl ld de,0 @@ -2873,16 +2509,8 @@ l0fb6h: ld de,dfcb1 call parse_filename ld de,dfcb2 - call parse_filename ;fall thru -cpy_fcb2: - ld hl,dfcb2 - ld de,fcbsym - ld bc,16 - ldir - ret - parse_filename: call sub_102ch push de @@ -3110,35 +2738,15 @@ hex_digit_v: error2: jp ERROR -read_hexbyte: - call read_byte -read_hexbyte0: - push bc - call hex_digit_v - rlca - rlca - rlca - rlca - ld c,a - call read_byte - call hex_digit_v - or c - pop bc - ret - ;------------------------------------------------------------------------------- ; > R [displacement] -; Read a binary or hex file and or symbol file [add displacement] +; Read a binary or hex file [add displacement] cmd_R: ld hl,0 call get_lastarg_def read_file: - ld de,dfcb1+1 - ld a,(de) - cp '?' - jr z,read_symfile - dec de + ld de,dfcb1 push hl ld hl,0 ld (high_load),hl @@ -3156,7 +2764,7 @@ l108eh: call read_sector jr nz,read_file_nxt pop hl - jr read_symfile + jp p_max_high read_file_nxt: ld de,DMA_BUF @@ -3200,163 +2808,12 @@ l10cch: call read_hexchar ; CHKSUM ld a,c and a - jr nz,error3 + jp nz,ERROR jr l10aeh rdhex_done: pop hl - jr read_symfile + jp p_max_high -read_symfile: - ld de,fcbsym+1 - ld a,(de) - cp ' ' - jp z,p_max_high - - push hl ; offset - call pstr_inl - db 'SYMBOLS',CR,LF+80h - - dec de - call file_open - ld a,(symattrib) - ld c,a -rs_1: - call read_byte -rs_2: - pop de ; offset - cp 1ah - jp z,p_max_high - push de ; offset - cp '!' - jr c,rs_1 - call read_hexbyte0 ; symval H - ld h,a - call read_hexbyte ; symval L - ld l,a - add hl,de - call read_byte - cp ' ' - jr z,rs_4 -rs_3: call read_byte - cp ' ' - jr nc,rs_3 - jr rs_2 - -rs_4: - push hl ; symval - ld hl,(BDOS+1) ; - ld b,0 ; setup symlen -rs_5: - dec hl ; - call read_byte ; next char of symbol name - call test_sym_char ; valid char? - jr nz,rs_6 - bit SYMCASE_CONV,c - jr z,rs_51 - call toupper - bit SYMCASE_LOWER,c - call nz,tolower -rs_51: - ld (hl),a ; - inc b ; symlen++ - ld a,(symlen_max) ; - cp b ; - jr nc,rs_5 ; -error3: - jp ERROR ; - -rs_6: - call test_symterm_ch - jr nz,error3 - - push bc ; symlen - ex de,hl ; - ld hl,(BDOS+1) ; - inc hl ; - ld c,(hl) ; - inc hl ; - ld b,(hl) ; - ex de,hl - ld (hl),b ; - dec hl ; - ld (hl),c ; - dec hl ; - ld (hl),0c3h ; - - ld de,(max_load) ; - call cp_hl_de ; - jr c,error3 ; - ld de,(reg_sp) ; - call cp_hl_de ; - jr nc,rs_61 ; - ld (reg_sp),hl ; -rs_61: - ld de,(BDOS+1) ; - ld (BDOS+1),hl ; - ex de,hl ; - pop bc ; symlen - ld (hl),b ; - inc hl ; - pop de ; symval - ld (hl),e ; - inc hl ; - ld (hl),d ; - ld a,b ; - ld hl,symlen_cur ; - cp (hl) ; new max? - jr c,$+3 ; - ld (hl),a ; - jp rs_1 ; - - -; test for valid character for symbols -; return z if valid - -test_sym_char: - cp '$' - ret z - cp '%' - ret z - cp '.' - ret z - cp '_' - ret z - call test_alphanum - ret c ; cy == 1 --> z == 0 - cp a ; return z - ret - - -; check if char is in [0..9,?,@,A..Z,a..z] -; return cy if invalid -; return nc if valid alfanumeric char - -test_alphanum: - cp 'z' - ret z - ccf - ret c - cp 'a' - ret nc - cp 'Z' - ret z - ccf - ret c - cp '?' - ret nc -test_numeral: - cp '9' - ret z - ccf - ret c - cp '0' - ret - -test_symterm_ch: - cp CR - ret z - cp LF - ret z test_whitespace: cp ' ' ret z @@ -3476,7 +2933,6 @@ l1773h: ; List disassembled code cmd_L: - ld hl,cmd_L ld (cmd_rpt),hl call expr jr nc,l18dbh @@ -3522,9 +2978,8 @@ cmdl_p_line: ret p_disas_line: - call p_label call outbl2 - call out.hl.@ + call out_hl call z,outbl call outbl sub a @@ -3536,24 +2991,9 @@ p_disas_line: ld c,15 call p_goto_col - call p_offset - call outbl - jp p_symbol - + ; 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 ;------------------------------------------------------------------------------- @@ -4725,7 +4165,6 @@ l2113h: ; trace over Calls [No list] [Jumps only] /.While./.Until. cmd_C: - ld hl,cmd_C ld a,1 jr cmd_tc @@ -4737,7 +4176,6 @@ cmd_C: cmd_T: xor a - ld hl,cmd_T cmd_tc: ld (cmd_rpt),hl ld (trace_call_flag),a @@ -4969,13 +4407,6 @@ expr_bufe: ;------------------------------------------------------------------------------- -msg_Y: - dc 'Yn' -reg_Y: - rept YREG_CNT - dw 0 - endm - last_S: dw TPA @@ -5013,12 +4444,8 @@ disas_argtype: pbl_loop_adr: dw 0 -symlen_cur: ;max length of symbols read so far - db 0 cur_fcb: dw 0 -fcbsym: - ds 33 ddtz_size equ $-ddtz_base ddtz_end: