X-Git-Url: http://cloudbase.mooo.com/gitweb/ddt180.git/blobdiff_plain/c9705ee41ef7084154b4cf8bffe9fb3b6a054143..e128c8d94b2dcd029077ecaa2854ce7864f62a3c:/ddt180.z80 diff --git a/ddt180.z80 b/ddt180.z80 index 2f43399..d042c76 100644 --- a/ddt180.z80 +++ b/ddt180.z80 @@ -58,7 +58,7 @@ BDOS_SETDMA equ 26 ;Set DMA Address ; ddtz specific definitions -STACK_SIZE equ 64 ;ddtz internal stack +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 @@ -135,9 +135,11 @@ reg.pc: dw TPA var.$: dw 0000h var.@: dw 0 -error_func:dw l0146h +error_func:dw p_msg_error cmd_rpt:dw mainloop +;------------------------------------------------------------------------------- + conbuf: db CONBUF_SIZE @@ -181,6 +183,8 @@ l0093h: ds CONBUF_SIZE + 3 - ($ - conbuf) +;------------------------------------------------------------------------------- + CMDTAB: dw cmd_@ ;examine/substitute the displacement register @ dw cmd_A ;Assemble @@ -212,7 +216,7 @@ CMDTAB: mainloop: ld sp,stack - ld hl,l0146h + ld hl,p_msg_error ld (error_func),hl ld hl,(reg.pc) ld (var.$),hl @@ -249,7 +253,9 @@ exe_hl: call CALL_HL jr mainloop -l0146h: +;------------------------------------------------------------------------------- + +p_msg_error: call pstr_inl dc '?' ;fall thru @@ -290,7 +296,7 @@ sub_01d9h: out_hl_dec_neg: push hl call sub_01d9h - defb 03eh + defb 03eh ;ld a,.. swallow push hl out.hl.dec: push hl ld b,006h @@ -337,12 +343,10 @@ out_hex: pop af out_dgt: - and 0fh - cp 10 - jr c,l0229h - add a,007h -l0229h: - add a,'0' + or 0f0h + daa + add a,0a0h + adc a,040h jr outchar out.bin.w: @@ -352,11 +356,11 @@ out.bin.w: out.bin.b: ld b,8 l01c9h: - add a,a - push af - ld a,00 - adc a,a - call out_dgt + rlca + push af + ld a,'0'/2 + adc a,a + call outchar pop af djnz l01c9h ld a,'"' @@ -398,10 +402,6 @@ outbl: ld a,' ' jr outchar -p_char_lparen: - ld a,'(' - jr outchar - outquote: ld a,'''' outchar: @@ -460,7 +460,7 @@ p_goto_col: call outbl jr p_goto_col - +;------------------------------------------------------------------------------- inchar: push ix @@ -498,6 +498,8 @@ get_line: pop hl ret +;------------------------------------------------------------------------------- + get_char_upper: ld a,(de) toupper: @@ -518,6 +520,8 @@ tolower: or 020h ret +;------------------------------------------------------------------------------- + skipbl0: inc de skipbl: @@ -542,18 +546,22 @@ assert_eol: to_error: jp ERROR +;------------------------------------------------------------------------------- + chk_stack: push hl push de ld hl,0 add hl,sp - ld de,stack-40 + ld de,stack-(STACK_SIZE-28) call cp_hl_de pop de pop hl jr c,to_error ret +;------------------------------------------------------------------------------- + add_hl_a: add a,l ld l,a @@ -578,6 +586,8 @@ sub_hl_a: pop bc ret +;------------------------------------------------------------------------------- + sym_getname: push de push hl @@ -644,6 +654,8 @@ pl_e: pop hl ret +;------------------------------------------------------------------------------- + lookupch: ld b,0 l02f5h: @@ -662,7 +674,7 @@ l0300h: ret sub_0303h: - ld hl,b_0cc3_start + ld hl,t_reg_names ld b,07fh jr l030ch @@ -768,7 +780,7 @@ sub_0377h: jr l0366h b_037c_start: - defb 0e6h + defb 0e6h ;and a,.. clear carry get_arg_range: scf ex af,af' @@ -780,7 +792,7 @@ get_arg_range: jr c,error0 ex af,af' pop hl - defb 03eh + defb 03eh ;ld a,.. swallow pop af l038ch: pop af call get_range @@ -826,6 +838,8 @@ l03b8h: scf ret +;------------------------------------------------------------------------------- + expr: call skipbl expr1: @@ -845,6 +859,8 @@ expr1: pop de ret +;------------------------------------------------------------------------------- + do_op_eq: jr z,l03edh jr l03ech @@ -1074,6 +1090,8 @@ tblf_opa: dw doop_xor dw 0 +;------------------------------------------------------------------------------- + fact_factor: call do_factor ret nc @@ -1127,6 +1145,8 @@ do_factor: scf ret +;------------------------------------------------------------------------------- + fact_reg.Y: call get.decdigit jr c,error1 @@ -1243,19 +1263,17 @@ fs_nxtsym: inc b push hl ;symtbl ptr push de ;inpsym ptr -fs_2: +fs_nxtchar: ld a,(de) djnz fs_3 - cp a,':' - jr nz,fs_21 - inc de - pop hl - jr fs_cont_1 - -fs_21: 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 @@ -1265,12 +1283,13 @@ fs_21: or a ;clear carry pop bc ret + fs_3: inc de dec hl xor (hl) and c - jr z,fs_2 + jr z,fs_nxtchar fs_cont: ;start over pop de ;inpsym ptr fs_cont_1: @@ -1280,6 +1299,8 @@ fs_cont_1: call sub_hl_a jr fs_nxtsym +;------------------------------------------------------------------------------- + get.number: call get.hexdigit ret c @@ -1353,7 +1374,7 @@ error11: sub_060ch: call get_char_upper - cp '[' + cp 'Z'+1 jr l0614h get.hexdigit: @@ -1386,6 +1407,8 @@ l0625h: sub '0' ret +;------------------------------------------------------------------------------- + p_cpustat0: call assert_eol p_cpustat: @@ -1431,24 +1454,25 @@ p_f2: jp outbl p_flags: - ld b,a - ld a,'S' - call sub_06aah - ld a,'Z' - call sub_06aah - rl b - ld a,'H' - call sub_06aah - rl b - ld a,'V' - call sub_06aah - ld a,'N' - call sub_06aah - ld a,'C' -sub_06aah: - rl b - jp c,outchar - jp outbl + push hl + ld hl,t_flag_names+7 + ld c,a + ld b,8 +fl_loop: + ld a,' ' + cp (hl) + ld a,c + rlca + ld c,a + jr z,fl_skip + ld a,(hl) + call c,outchar + call nc,outbl +fl_skip: + dec hl + djnz fl_loop + pop hl + ret p_regs: push de @@ -1532,6 +1556,10 @@ b_0709_start: db 000h db 000h +;------------------------------------------------------------------------------- +; > G [startaddr] [;breakp..] +; Go [to start] [with temporary breakpoints] + cmd_G: sub a ld (trace_call_flag),a @@ -1549,6 +1577,7 @@ l0740h: call bp_enter jp user_go +;------------------------------------------------------------------------------- bpl_init: ld b,BP_CNT @@ -1580,6 +1609,19 @@ bp_clr_temporary: call bpl_next ret +;------------------------------------------------------------------------------- +; > B +; display all breakpoints +; > B breakp [breakp..] +; set breakpoints +; > BX +; clear all breakpoints +; > BX address [address..] +; clear breakpoints +; +; where breakp is: +; [R] expression [I condition] + cmd_B: call skipbl jr z,bp_print @@ -1659,6 +1701,7 @@ bp_pr_cont: call bpl_next ret +;------------------------------------------------------------------------------- ; Add break points to list ; A = 1 Permanent (B command) ; A = 2 Temporary (G command) @@ -1754,6 +1797,8 @@ bp_get_condition: ld hl,(expr_p2) ret +;------------------------------------------------------------------------------- + bpddtz: ld (reg.l),hl pop hl @@ -1940,6 +1985,8 @@ l0a1dh: call bpl_next ret +;------------------------------------------------------------------------------- + user_go: sub a ld (b_21e2_start),a @@ -1973,6 +2020,8 @@ l0a41h: ld sp,(reg_sp) jp reg.iff +;------------------------------------------------------------------------------- + bp_clr_condition: ld a,(ix+000h) and 003h @@ -2025,6 +2074,12 @@ l0ab0h: 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 @@ -2073,6 +2128,14 @@ sub_0bdch: ld c,003h jp l0c33h +;------------------------------------------------------------------------------- +; > X +; eXamine (display) all cpu registers and +; the instruction at the current program counter +; > X register +; eXamine (and substitute) a register + + cmd_X: call skipbl call sub_0caeh @@ -2086,7 +2149,7 @@ cmd_X: cp 01dh jp z,ERROR ex de,hl - ld hl,b_0cc3_start + ld hl,t_reg_names call sel_dc_string l0c12h: call l0c33h @@ -2145,43 +2208,41 @@ l0c5fh: sub_0c6ah: push af - ld b,000h call outbl call assert_eol call get_line pop af ex af,af' + ld b,0 l0c76h: call skipbl ld a,b ret z push bc - ld hl,b_0ca4_start + ld hl,t_flag_names call lookupch jp nc,ERROR - ld a,b - cp 008h - jr z,l0c97h - pop bc - rlca - rlca - rlca - add a,0c0h - ld (l0c94h),a - defb 0cbh -l0c94h: - defb 0c0h + inc b + xor a + scf +nxt_f: + rla + djnz nxt_f + pop bc + jr c,l0c97h + or b + ld b,a jr l0c76h + l0c97h: ex af,af' jp nc,ERROR ex af,af' ld a,0fbh ld (reg.iff),a - pop bc jr l0c76h -b_0ca4_start: +t_flag_names: db 'CNV H ZSE',0 sub_0caeh: @@ -2201,7 +2262,7 @@ sub_0caeh: scf ret -b_0cc3_start: +t_reg_names: DC 'BC''' DC 'DE''' DC 'HL''' @@ -2302,6 +2363,10 @@ b_0cfa_start: db 000h dw reg.f +;------------------------------------------------------------------------------- +; > S [startaddr] +; Substitute memory + cmd_S: ld hl,(last_S) call get_lastarg_def @@ -2338,6 +2403,10 @@ l0d8ah: call sub_0ef8h jr l0d60h +;------------------------------------------------------------------------------- +; > @ +; examine (substitute) displacement register @ + cmd_@: call assert_eol ld hl,msg_@ @@ -2348,6 +2417,10 @@ cmd_@: msg_@: dc '@' +;------------------------------------------------------------------------------- +; >>I [port] +; Input a byte from port + cmd_I: ld hl,cmd_I ld (cmd_rpt),hl @@ -2364,6 +2437,10 @@ cmd_I: call out.bin.b jp crlf +;------------------------------------------------------------------------------- +; >>O [byte] [port] +; Output a byte to a port + cmd_O: ld hl,cmd_O ld (cmd_rpt),hl @@ -2382,6 +2459,10 @@ cmd_O: out (c),a ret +;------------------------------------------------------------------------------- +; > Vstartaddr endaddr targetaddr +; Verify (compare) two memory areas + cmd_V: call sub_034eh l0dedh: @@ -2413,6 +2494,10 @@ l0e10h: jr nz,l0dedh ret +;------------------------------------------------------------------------------- +; > M[V] startaddr endaddr destaddr +; Move memory [and verify] + cmd_M: call get_char_upper cp 'V' @@ -2443,6 +2528,17 @@ cmdm_up: jr z,l0dedh ret +;------------------------------------------------------------------------------- +; > 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' @@ -2527,6 +2623,10 @@ psym_e: jp crlf +;------------------------------------------------------------------------------- +; > Q[J] startaddr endaddr bytes +; Query memory for a byte string [Justified] + cmd_Q: call get_char_upper sub 'J' @@ -2566,6 +2666,10 @@ l0eb0h: pop bc ret +;------------------------------------------------------------------------------- +; > Z startaddr endaddr bytes +; Zap (fill) memory with a byte string + cmd_Z: call get_arg_range push bc @@ -2593,7 +2697,7 @@ sub_0ed7h: push de push bc l0edah: - call get_char_upper + ld a,(de) cp (hl) jr nz,l0ee2h inc de @@ -2679,6 +2783,10 @@ l0f42h: ld (last_S),hl ret +;------------------------------------------------------------------------------- +; >>D [startaddr] [endaddr] +; Display memory in hex and ASCII + cmd_D: ld hl,cmd_D ld (cmd_rpt),hl @@ -2747,6 +2855,10 @@ l0fach: ld a,'.' ret +;------------------------------------------------------------------------------- +; > Fcommandline +; specifiy filenames and command line + cmd_F: push de ld hl,DMA_BUF+1 @@ -2876,6 +2988,8 @@ sub_1043h: cp ',' ret +;------------------------------------------------------------------------------- + setup_fcb: push de ld hl,12 @@ -2892,6 +3006,8 @@ l1052h: pop de ret +;------------------------------------------------------------------------------- + file_open: ld (cur_fcb),de call setup_fcb @@ -3015,6 +3131,10 @@ read_hexbyte0: pop bc ret +;------------------------------------------------------------------------------- +; > R [displacement] +; Read a binary or hex file and or symbol file [add displacement] + cmd_R: ld hl,0 call get_lastarg_def @@ -3217,18 +3337,21 @@ test_sym_char: ; return nc if valid alfanumeric char test_alphanum: - cp 'z'+1 + cp 'z' + ret z ccf ret c cp 'a' ret nc - cp 'Z'+1 + cp 'Z' + ret z ccf ret c cp '?' ret nc test_numeral: - cp '9'+1 + cp '9' + ret z ccf ret c cp '0' @@ -3245,6 +3368,8 @@ test_whitespace: cp TAB ret +;------------------------------------------------------------------------------- + p_max_high0: call assert_eol p_max_high: @@ -3262,6 +3387,10 @@ p_max_high: call out_hl jp crlf +;------------------------------------------------------------------------------- +; > Wstartaddr endaddr +; Write a file to disk + cmd_W: call get_arg_range call assert_eol @@ -3323,6 +3452,10 @@ close_file: ld c,BDOS_CLOSE jp ddtz_bdos +;------------------------------------------------------------------------------- +; > A [startaddr] +; Assemble Zilog Z180 mnemonics + cmd_A: ld hl,(last_A) call get_lastarg_def @@ -3365,7 +3498,7 @@ cmda_lpend: jr cmda_loop cmda_restart: - call l0146h + call p_msg_error ld sp,(l1262h) jr cmda_loop @@ -3392,6 +3525,8 @@ asemble_line: CALL_HL: jp (hl) +;------------------------------------------------------------------------------- + b_1289_start: dw as.ADC_SBC ;ADC db 088h ; @@ -3549,6 +3684,8 @@ b_1289_start: dw as.TSTIO ;TSTIO db 074h ; +;------------------------------------------------------------------------------- + as.TST: call arg.r_HL_A ; jr nc,as.tst_0 @@ -4482,6 +4619,10 @@ test_paren_close: inc de ret +;------------------------------------------------------------------------------- +; >>L [startaddr] [endaddr] +; List disassembled code + cmd_L: ld hl,cmd_L ld (cmd_rpt),hl @@ -4515,6 +4656,8 @@ l190fh: jr c,l190fh ret +;------------------------------------------------------------------------------- + cmdl_p_line: push hl call p_disas_line @@ -4545,6 +4688,8 @@ p_disas_line: call outbl jp p_symbol +;------------------------------------------------------------------------------- + p_offset: ld de,(var.@) ld a,d @@ -4558,6 +4703,8 @@ p_offset: add hl,de jp out_rparen +;------------------------------------------------------------------------------- + p_disas_instr: sub a ld (disas_argtype),a @@ -4617,6 +4764,8 @@ l19b1h: scf ret +;------------------------------------------------------------------------------- + disas_pfx.DDFD: inc iy ld hl,b_19ef_start @@ -4643,6 +4792,7 @@ l19edh: and a ret +;------------------------------------------------------------------------------- ; DD/FD 3 byte (ix+d)/(iy+d) b_19ef_start: db 034h @@ -4690,6 +4840,8 @@ l1a0ah: db 0f9h db 0 +;------------------------------------------------------------------------------- + disas_pfx.ED: inc iy ld hl,b_1bc9_start @@ -4710,6 +4862,8 @@ disas_pfx.ED: ld b,4 ret +;------------------------------------------------------------------------------- + disas_pfx.CB: push iy inc iy @@ -4724,6 +4878,8 @@ l1a42h: ld b,2 ret +;------------------------------------------------------------------------------- + disas_nopfx: ld hl,b_1b54_start call lookup_opc @@ -4743,6 +4899,8 @@ disas_nopfx: ld b,3 ret +;------------------------------------------------------------------------------- + sub_1a72h: ld a,(hl) cp 0ffh @@ -4798,6 +4956,7 @@ get_mnemonic: scf ret +;------------------------------------------------------------------------------- ; 1 byte opcodes (no parameters) ; Format: db opcode, t_MNEMONICS-index b_1ab6_start: @@ -5051,6 +5210,8 @@ b_1c55_start: dw p_arg_bitop db 0 +;------------------------------------------------------------------------------- + p_arg_r_r: call p_arg_r call p_char_comma @@ -5113,8 +5274,7 @@ l1ce5h: sub_1ce8h: call p_char_lparen call p_arg_ww -out_rparen: - jp p_char_rparen + jr out_rparen l1cf5h: call p_A_comma @@ -5154,7 +5314,11 @@ l1d29h: sub_1d2ch: call p_char_lparen ld a,(iy+001h) - jp l1e6bh +p_arg_nn_rp: + call out_hex +out_rparen: + jr p_char_rparen + l1d37h: call sub_1d2ch jr p_char_comma_A @@ -5191,27 +5355,30 @@ p_arg_addr_a: call p_arg_addr p_char_comma_A: call p_char_comma + jr p_char_A + +p_A_comma: + call p_char_A +p_char_comma: + ld a,',' + db 021h p_char_A: ld a,'A' - jr outchar1 -p_arg_a_addr: - call p_A_comma - jp p_arg_addr + db 021h l1d85h: ld a,'0' - jr outchar1 + db 021h l1d89h: ld a,'1' - jr outchar1 + db 021h l1d8dh: ld a,'2' - jr outchar1 - -p_A_comma: - call p_char_A -p_char_comma: - ld a,',' -outchar1: + db 021h +p_char_rparen: + ld a,')' + db 021h +p_char_lparen: + ld a,'(' jp outchar l1d92h: @@ -5264,6 +5431,16 @@ p_arg_ww_addr: call p_char_comma jr p_arg_addr +p_arg_a_addr: + call p_A_comma +p_arg_addr: + call p_char_lparen + ld l,(iy+001h) + ld h,(iy+002h) + ld a,001h + call sub_1d50h + jr p_char_rparen + p_arg_bitop: ld a,(isprefix_ixiy) and a @@ -5295,17 +5472,6 @@ l1e0eh: l1e11h: jr p_arg_r0 -p_arg_addr: - call p_char_lparen - ld l,(iy+001h) - ld h,(iy+002h) - ld a,001h - call sub_1d50h - -p_char_rparen: - ld a,')' - jp outchar - p_arg_r: ld a,(iy+000h) rra @@ -5330,20 +5496,18 @@ p_arg_r0: l1e4dh: call pstr ld a,(iy+001h) - and a - jp m,l1e61h - call pstr_inl - dc '+' - ld a,(iy+001h) - jr l1e6bh -l1e61h: - call pstr_inl - dc '-' - ld a,(iy+001h) + push af + rlca + ld a,'+' + jr nc,l1e61h + pop af neg -l1e6bh: - call out_hex - jr p_char_rparen + push af + ld a,'-' +l1e61h: + call outchar + pop af + jp p_arg_nn_rp p_arg_r1: ld hl,t_BCDEHL_HL_A @@ -5387,6 +5551,8 @@ p_arg: call sel_dc_string jp pstr +;------------------------------------------------------------------------------- + t_MNEMONICS: DC 'ADC' DC 'ADD' @@ -5538,6 +5704,8 @@ t__C_: DC '(C)' DB 0 +;------------------------------------------------------------------------------- + sub_1ffeh: ld hl,(reg.pc) ld a,h @@ -5569,6 +5737,8 @@ l2037h: scf ret +;------------------------------------------------------------------------------- + b_2039_start: db 0ffh,0ddh,000h ;Prefix DD dw l20a7h @@ -5602,6 +5772,8 @@ b_2048_start: dw l20c5h db 0 +;------------------------------------------------------------------------------- + l2080h: ld a,(b_21e2_start) and a @@ -5707,10 +5879,24 @@ l2113h: l2115h: and a ret + +;------------------------------------------------------------------------------- +; >>C[N][J] [steps] +; >>C[N][J] W expression +; >>C[N][J] U expression +; trace over Calls [No list] [Jumps only] /.While./.Until. + cmd_C: ld hl,cmd_C ld a,1 jr l2122h + +;------------------------------------------------------------------------------- +; >>T[N][J] [steps] +; >>T[N][J] W expression +; >>T[N][J] U expression +; Trace [no List] [Jumps only] / .While. / .Until. + cmd_T: xor a ld hl,cmd_T @@ -5824,6 +6010,8 @@ l21dah: cp 045h ret +;------------------------------------------------------------------------------- + b_21e2_start: db 0 trace_call_flag: @@ -5942,6 +6130,8 @@ current_cseg defl $ ds EXPR_BUF_SIZE - ($ - expr_buf) expr_bufe: +;------------------------------------------------------------------------------- + msg_Y: dc 'Yn' reg_Y: