X-Git-Url: http://cloudbase.mooo.com/gitweb/ddt180.git/blobdiff_plain/3a4deef923e7cdf53a61035bb58575f8da8045b0..e128c8d94b2dcd029077ecaa2854ce7864f62a3c:/ddt180.z80?ds=sidebyside diff --git a/ddt180.z80 b/ddt180.z80 index 862dbc2..d042c76 100644 --- a/ddt180.z80 +++ b/ddt180.z80 @@ -9,12 +9,12 @@ ;------------------------------------------------------------------------------- ; Relocation loader ; - TPA equ 0100h cseg .phase TPA jp start + ds 3 ldr_end: ldr_size equ $ - TPA @@ -58,13 +58,17 @@ 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 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 + ;------------------------------------------------------------------------------- ddtz_base: @@ -76,12 +80,23 @@ sub_0004h: 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 'DDT/180',TAB - db '[8101] 003',CR,LF,'$' + db 'Symbolic DDTZ/180' + db ' - Version ' + maclib version.inc + defvers + db CR,LF,'$' msgz80: db 'Z80 or better required!',cr,lf,'$' @@ -120,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 @@ -166,6 +183,8 @@ l0093h: ds CONBUF_SIZE + 3 - ($ - conbuf) +;------------------------------------------------------------------------------- + CMDTAB: dw cmd_@ ;examine/substitute the displacement register @ dw cmd_A ;Assemble @@ -197,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 @@ -234,16 +253,16 @@ exe_hl: call CALL_HL jr mainloop -l0146h: - ld a,'?' - call outchar +;------------------------------------------------------------------------------- + +p_msg_error: + call pstr_inl + dc '?' ;fall thru crlf: + call pstr_inl + db CR,LF+80h call inchar - ld a,CR - call outchar - ld a,LF - call outchar ld a,0 ld (con_col),a jr c,mainloop @@ -258,8 +277,8 @@ out.hl.@: or e jr z,l01bfh call outbl - ld a,'@' - call outchar + call pstr_inl + dc '@' and a sbc hl,de call out_hl @@ -269,26 +288,27 @@ l01bfh: ret sub_01d9h: - ld a,'-' - call outchar + call pstr_inl + dc '-' dec hl jp cpl.hl 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 call sub_01f9h pop hl - ld a,'.' - call outchar + call pstr_inl + dc '.' l01f3h: call outbl djnz l01f3h ret + sub_01f9h: dec b push de @@ -323,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: @@ -338,18 +356,19 @@ 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,'"' jr outchar out.ascii: - push af + push bc + ld c,a res 7,a cp ' ' push af @@ -358,22 +377,20 @@ out.ascii: pop af jr nc,l0242h sub 0c0h - ex af,af' - ld a,'^' - call outchar - ex af,af' + ld b,a + call pstr_inl + dc '^' + ld a,b l0242h: call outchar cp '''' call z,outchar - ex af,af' call outquote - pop af - or a + sla c + pop bc + ret nc ld a,'.' - call m,outchar - ex af,af' - ret + jr outchar outbl6: call outbl2 @@ -385,13 +402,11 @@ outbl: ld a,' ' jr outchar -p_char_lparen: - ld a,'(' - jr outchar - outquote: ld a,'''' outchar: + push ix + push iy push hl push de push bc @@ -406,20 +421,19 @@ outchar: pop bc pop de pop hl + pop iy + pop ix ret pstr: - ld c,0 -l028ah: ld a,(hl) inc hl and a ret z call outchar - inc c and a ret m - jr l028ah + jr pstr pstr_inl: ex (sp),hl @@ -427,7 +441,29 @@ 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 + ret nc + ret z + call outbl + jr p_goto_col + +;------------------------------------------------------------------------------- + inchar: + push ix push hl push de push bc @@ -442,6 +478,7 @@ l0284h: pop bc pop de pop hl + pop ix ret get_line: @@ -450,70 +487,46 @@ get_line: ld c,BDOS_CBUF call ddtz_bdos call crlf - ld de,conbuf+1 - ld a,(de) - ld b,a - ld c,0 - inc b -l0162h: - inc de - dec b - jr z,l0194h - ld a,(de) - bit 0,c - call z,toupper - ld (de),a - cp '''' - jr nz,l0162h - push de - dec de - ld a,(de) - cp '''' - jr z,l0190h - dec de - ld a,(de) - cp '^' - jr z,l0184h - dec de - ld a,(de) - cp '^' - jr nz,l0190h -l0184h: - inc de - push bc - call sub_0303h - pop bc - dec de - ld a,(de) - cp '''' - jr z,l0191h -l0190h: - inc c -l0191h: - pop de - jr l0162h -l0194h: - xor a - ld (de),a - ld de,conbuf+2 + ld hl,conbuf+1 + ld e,(hl) + xor a + ld d,a + inc hl + ex de,hl + add hl,de + ld (hl),a pop hl ret +;------------------------------------------------------------------------------- + +get_char_upper: + ld a,(de) toupper: cp 'a' ret c cp 'z'+1 - ret nc + ccf + ret c and 05fh ret +tolower: + cp 'A' + ret c + cp 'Z'+1 + ccf + ret c + or 020h + ret + +;------------------------------------------------------------------------------- + skipbl0: inc de skipbl: - ld a,(de) - cp ' ' - jr z,skipbl0 - cp TAB + call get_char_upper + call test_whitespace jr z,skipbl0 or a ret @@ -533,18 +546,22 @@ assert_eol: to_error: jp ERROR -chk_sp: +;------------------------------------------------------------------------------- + +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 @@ -558,13 +575,94 @@ cp_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: ld b,0 l02f5h: ld a,(hl) and a ret z - ld a,(de) + call get_char_upper cp (hl) jr z,l0300h inc hl @@ -576,7 +674,7 @@ l0300h: ret sub_0303h: - ld hl,b_0cc3_start + ld hl,t_reg_names ld b,07fh jr l030ch @@ -595,12 +693,12 @@ l030ch: sub_0318h: push bc res 7,b - defb 03eh + defb 03eh ;ld a,nn sub_031ch: push bc push de l031eh: - ld a,(de) + call get_char_upper xor (hl) and 07fh jr nz,l0336h @@ -682,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' @@ -694,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 @@ -715,14 +813,14 @@ get_range: inc de l03a2h: push hl - push af + push af ;'S' flag call expr jr c,l03b8h ld b,h ld c,l pop af pop hl - jr z,l03b6h + jr z,l03b6h ;'S'? ld a,c sub l ld c,a @@ -736,10 +834,12 @@ l03b6h: l03b8h: pop af pop hl - jr z,error0 + jr z,error0 ;'S', but no expression following scf ret +;------------------------------------------------------------------------------- + expr: call skipbl expr1: @@ -759,6 +859,8 @@ expr1: pop de ret +;------------------------------------------------------------------------------- + do_op_eq: jr z,l03edh jr l03ech @@ -988,13 +1090,15 @@ tblf_opa: dw doop_xor dw 0 +;------------------------------------------------------------------------------- + fact_factor: call do_factor ret nc jp ERROR do_factor: - call chk_sp + call chk_stack call get.number ret nc inc de @@ -1016,6 +1120,9 @@ do_factor: ld hl,(var.$) cp '$' ret z + ld hl,ddtz_base + cp 'Z' + ret z cp '-' jr z,fact_factneg cp '~' @@ -1038,10 +1145,13 @@ do_factor: scf ret +;------------------------------------------------------------------------------- + fact_reg.Y: call get.decdigit - jr c,error4 + jr c,error1 inc de +get_y_val: add a,a ld hl,reg_Y call add_hl_a @@ -1079,7 +1189,7 @@ l0557h: fact_reg.CPU: call sub_0caeh - jr nc,error4 + jr nc,error1 ld a,(hl) inc hl ld h,(hl) @@ -1108,10 +1218,10 @@ fact_factinv: fact_mem: call expr1 - jr c,error4 + jr c,error1 ld a,(de) cp ')' - jr nz,error4 + jr nz,error1 inc de ld a,(hl) inc hl @@ -1128,73 +1238,68 @@ fact_mem: expr_brckt: call expr1 - jr c,error4 + jr c,error1 ld a,(de) cp ']' inc de ret z -error4: +error1: jp ERROR fact_symbol: push bc - ld hl,ddtz_base + 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,error4 - ld b,a + jr z,error1 + ld b,a ;symlen inc b - push hl - push de -fs_2: + push hl ;symtbl ptr + push de ;inpsym ptr +fs_nxtchar: ld a,(de) - call test_termchar - jr z,fs_endstr - dec b + djnz fs_3 + call test_sym_char jr z,fs_cont + pop hl ;inpsym ptr (discard) inc de - dec hl - cp (hl) - jr z,fs_2 -fs_cont: - pop de - pop hl - ld a,(hl) - add a,3 - call sub_hl_a - jr fs_nxtsym + cp a,':' + jr z,fs_cont_1 + dec de -fs_endstr: - dec b - jr nz,fs_cont - pop hl - pop hl + pop hl ;symtbl ptr inc hl - ld a,(hl) + ld a,(hl) ;symval h inc hl - ld h,(hl) + ld h,(hl) ;symval l ld l,a - or a + or a ;clear carry pop bc ret -t_trmchrs: - db ' !#&()*+,-/:;<=>[\]{|}',0 -t_trmchrs_len equ $ - t_trmchrs - -test_termchar: - push hl - push bc - ld hl,t_trmchrs - ld bc,t_trmchrs_len - cpir - pop bc - pop hl - 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: call get.hexdigit @@ -1239,7 +1344,7 @@ l05dbh: jr next_bindigit l05e4h: cp '"' - jp nz,ERROR + jr nz,error11 call get.bindigit jr nc,l05dbh or a @@ -1264,16 +1369,18 @@ next_decdigit: decnum_done: cp '.' ret z +error11: jp ERROR sub_060ch: - ld a,(de) - cp '[' + call get_char_upper + cp 'Z'+1 jr l0614h get.hexdigit: ld a,(de) hex_digit: + call toupper cp 'F'+1 l0614h: ccf @@ -1284,13 +1391,13 @@ l0614h: ret get.decdigit: - ld a,(de) + call get_char_upper l061eh: cp '9'+1 jr l0625h get.bindigit: - ld a,(de) + call get_char_upper cp '1'+1 l0625h: ccf @@ -1300,6 +1407,8 @@ l0625h: sub '0' ret +;------------------------------------------------------------------------------- + p_cpustat0: call assert_eol p_cpustat: @@ -1315,24 +1424,20 @@ l063eh: push de ld iy,(reg.pc) call p_disas_instr - exx - ex af,af' + pop de + ex (sp),hl + push af call crlf call p_f2 call outbl2 - pop de - pop hl ld b,7 l065bh: call p_regs djnz l065bh - exx - ex af,af' - and a - jr z,l066bh - call outbl6 - call p_offset -l066bh: + pop af + pop hl + call nz,outbl6 + call nz,p_offset jp crlf p_f: @@ -1347,32 +1452,33 @@ p_f2: ld a,(reg.f2) call p_flags 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 bc push de call pstr - ld a,'=' - call outchar + call pstr_inl + dc '=' ex (sp),hl ld e,(hl) inc hl @@ -1383,13 +1489,11 @@ p_regs: push hl and a jr z,l06deh - push af - ld a,(de) - ld l,a - inc de - ld a,(de) - ld h,a - pop af + ex de,hl + ld e,(hl) + inc hl + ld d,(hl) + ex de,hl dec a jr z,l06d9h call out.hl.@ @@ -1405,7 +1509,6 @@ l06e2h: call outbl pop de pop hl - pop bc ret b_06e9_start: @@ -1453,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 @@ -1470,46 +1577,77 @@ l0740h: call bp_enter jp user_go +;------------------------------------------------------------------------------- + +bpl_init: + ld b,BP_CNT + ld ix,bp_tab + ex (sp),hl + ld (pbl_loop_adr),hl + ex (sp),hl + ret + +bpl_next: + ld de,BP_SIZE + add ix,de + dec b + ret z + + ex (sp),hl + ld hl,(pbl_loop_adr) + ex (sp),hl + ret + bp_clr_temporary: - ld b,BP_CNT - ld ix,bp_tab -l075ah: + call bpl_init + ld a,(ix+000h) and 0f1h ld (ix+000h),a call bp_clr_condition - ld de,BP_SIZE - add ix,de - djnz l075ah + + 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,l07b7h + jr z,bp_print inc de cp 'X' - jr z,l077dh + jr z,bp_clr0 dec de ld a,001h jp bp_enter -l077dh: +bp_clr0: call skipbl jr z,bp_clr_all -l0782h: +bp_clr_next: call expr jp c,assert_eol push de call bp_clr pop de call next_arg - jr l0782h + jr bp_clr_next bp_clr_all: scf bp_clr: - ld b,BP_CNT - ld ix,bp_tab -l0799h: + call bpl_init + push af jr c,l07a7h ld e,(ix+002h) @@ -1520,18 +1658,15 @@ l07a7h: ld (ix+000h),000h call bp_clr_condition l07aeh: - ld de,BP_SIZE - add ix,de pop af - djnz l0799h + call bpl_next ret -l07b7h: - ld b,BP_CNT - ld ix,bp_tab -l07bdh: +bp_print: + call bpl_init + bit 0,(ix+000h) - jr z,l0808h + jr z,bp_pr_cont ld a,'R' bit 4,(ix+000h) jr nz,l07cdh @@ -1542,9 +1677,12 @@ l07cdh: ld l,(ix+002h) ld h,(ix+003h) call out.hl.@ - call outbl2 - ld a,':' - call outchar + call outbl + call p_symbol + ld c,9 + call p_align_@_sym + call pstr_inl + dc ':' ld l,(ix+004h) ld h,(ix+005h) call out_hl @@ -1554,18 +1692,16 @@ l07cdh: or l jr z,l0805h call outbl4 - ld a,'I' - call outchar - call outbl2 + call pstr_inl + dc 'I ' call pstr l0805h: call crlf -l0808h: - ld de,BP_SIZE - add ix,de - djnz l07bdh +bp_pr_cont: + call bpl_next ret +;------------------------------------------------------------------------------- ; Add break points to list ; A = 1 Permanent (B command) ; A = 2 Temporary (G command) @@ -1575,13 +1711,13 @@ bp_enter: call skipbl ret z cp 'R' - jr nz,l081ch + jr nz,bp_e_1 inc de set 4,b -l081ch: +bp_e_1: push bc call expr - jp c,ERROR + jr c,error12 pop bc bit 0,b push bc @@ -1606,17 +1742,14 @@ l081ch: jr bp_enter bp_get_freeslot: - ld b,BP_CNT - ld ix,bp_tab -l085ah: + call bpl_init + ld a,(ix+000h) and 00fh ret z - push bc - ld bc,BP_SIZE - add ix,bc - pop bc - djnz l085ah + + call bpl_next +error12 jp ERROR bp_get_count: @@ -1626,7 +1759,7 @@ bp_get_count: ret nz inc de call expr - jp c,ERROR + jr c,error12 ret bp_get_condition: @@ -1638,7 +1771,7 @@ bp_get_condition: call skipbl push de call expr - jp c,ERROR + jr c,error12 ex de,hl pop de push de @@ -1650,7 +1783,7 @@ bp_get_condition: add hl,bc ld de,expr_bufe call cp_hl_de - jp nc,ERROR + jr nc,error12 pop hl ld (expr_p2),hl pop de @@ -1664,6 +1797,8 @@ bp_get_condition: ld hl,(expr_p2) ret +;------------------------------------------------------------------------------- + bpddtz: ld (reg.l),hl pop hl @@ -1718,9 +1853,8 @@ sub_0913h: ex af,af' sub a ld (l0941h),a - ld b,BP_CNT - ld ix,bp_tab -l0920h: + call bpl_init + ld a,(ix+000h) and 007h jr z,l0938h @@ -1732,9 +1866,8 @@ l0920h: call z,sub_0942h pop bc l0938h: - ld de,BP_SIZE - add ix,de - djnz l0920h + + call bpl_next ex af,af' ret @@ -1772,9 +1905,8 @@ l0974h: ret sub_097ah: - ld b,BP_CNT - ld ix,bp_tab -l0980h: + call bpl_init + bit 5,(ix+000h) res 5,(ix+000h) jr z,l099ah @@ -1787,15 +1919,13 @@ l0980h: ld (hl),a l099ah: res 3,(ix+000h) - ld de,BP_SIZE - add ix,de - djnz l0980h + + call bpl_next ret sub_09a6h: - ld b,BP_CNT - ld ix,bp_tab -l09ach: + call bpl_init + ld a,(ix+000h) and 003h jr z,l09c0h @@ -1805,9 +1935,8 @@ l09ach: call cp_hl_de ret z l09c0h: - ld de,BP_SIZE - add ix,de - djnz l09ach + + call bpl_next sub a inc a ret @@ -1824,15 +1953,14 @@ sub_09cah: and a ld a,008h jr nz,l09edh - ld a,004h + rra l09edh: ld (ix+000h),a ret -sub_09f1h: - ld b,BP_CNT - ld ix,bp_tab -l09f7h: +bp_set_to_mem: + call bpl_init + ld a,(ix+000h) and c jr z,l0a1dh @@ -1853,11 +1981,12 @@ l09f7h: inc hl ld (hl),d l0a1dh: - ld de,BP_SIZE - add ix,de - djnz l09f7h + + call bpl_next ret +;------------------------------------------------------------------------------- + user_go: sub a ld (b_21e2_start),a @@ -1872,7 +2001,7 @@ user_go: call sub_1ffeh ld c,008h l0a41h: - call sub_09f1h + call bp_set_to_mem ld sp,reg.l2 pop hl pop de @@ -1891,6 +2020,8 @@ l0a41h: ld sp,(reg_sp) jp reg.iff +;------------------------------------------------------------------------------- + bp_clr_condition: ld a,(ix+000h) and 003h @@ -1943,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 @@ -1958,12 +2095,20 @@ l0bc3h: l0bc7h: push af call sub_0bdch - call outbl4 + call outbl + pop af + push af + call get_y_val + call p_symbol pop af inc a - bit 0,a push af - call z,crlf + rra + push af + ld c,11 + call c,p_align_@_sym + pop af + call nc,crlf pop af cp YREG_CNT jr c,l0bc7h @@ -1983,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 @@ -1996,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 @@ -2008,15 +2161,14 @@ l0c15h: call skipbl jr z,l0c30h call sub_0363h - ld b,h - ld c,l - pop af + ex de,hl + pop bc pop hl - ld (hl),c - bit 0,a + ld (hl),e + bit 0,c ret z inc hl - ld (hl),b + ld (hl),d ret l0c30h: pop af @@ -2024,19 +2176,18 @@ l0c30h: ret l0c33h: - ld b,c call pstr - ld a,'=' - call outchar + call pstr_inl + dc '=' ld a,(de) - bit 0,b + bit 0,c jp z,out_hex ld l,a inc de ld a,(de) dec de ld h,a - bit 1,b + bit 1,c jp z,out_hl jp out.hl.@ @@ -2054,43 +2205,44 @@ l0c5fh: call sub_0c6ah ld (reg.f2),a ret + sub_0c6ah: - ex af,af' - ld b,000h + push af 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: @@ -2110,7 +2262,7 @@ sub_0caeh: scf ret -b_0cc3_start: +t_reg_names: DC 'BC''' DC 'DE''' DC 'HL''' @@ -2211,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 @@ -2228,10 +2384,16 @@ l0d60h: dec hl inc de cp '.' + jr nz,cmds_dash + call get_char_upper + or a + jr nz,l0d8ah + ret +cmds_dash: jp z,assert_eol cp '-' jr nz,l0d8ah - ld a,(de) + call get_char_upper or a dec hl jr z,l0d60h @@ -2241,6 +2403,10 @@ l0d8ah: call sub_0ef8h jr l0d60h +;------------------------------------------------------------------------------- +; > @ +; examine (substitute) displacement register @ + cmd_@: call assert_eol ld hl,msg_@ @@ -2251,6 +2417,10 @@ cmd_@: msg_@: dc '@' +;------------------------------------------------------------------------------- +; >>I [port] +; Input a byte from port + cmd_I: ld hl,cmd_I ld (cmd_rpt),hl @@ -2267,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 @@ -2285,6 +2459,10 @@ cmd_O: out (c),a ret +;------------------------------------------------------------------------------- +; > Vstartaddr endaddr targetaddr +; Verify (compare) two memory areas + cmd_V: call sub_034eh l0dedh: @@ -2316,8 +2494,12 @@ l0e10h: jr nz,l0dedh ret +;------------------------------------------------------------------------------- +; > M[V] startaddr endaddr destaddr +; Move memory [and verify] + cmd_M: - ld a,(de) + call get_char_upper cp 'V' jr nz,l0e1fh inc de @@ -2346,10 +2528,21 @@ 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: - ld a,(de) + call get_char_upper cp 'S' - jr z,p_symbols + jr z,p_sym_list call expr jp c,p_max_high0 @@ -2383,112 +2576,59 @@ l0e5eh: call outbl ld a,l call out.ascii - call outbl + call outbl2 call p_symbol jp crlf -p_symbols: +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_l: +psym_nxtsym: ld d,(hl) dec hl ld e,(hl) dec hl - ld b,(hl) - dec hl - ld a,b + ld a,(hl) cp 0c3h - ret z + jr z,psym_e + call p_goto_col ex de,hl call out_hl - ex de,hl call outbl -psymch_l: - ld a,(hl) - dec hl - call outchar - djnz psymch_l - call crlf - jr psym_l - + ex de,hl + call p_symstr -p_symbol: - if 0 - ld a,(dash_flag) - or a - ret nz - endif - call sym_getname - ret z - ld a,'.' - call outchar -p_symstr: - ld b,(hl) -pss_l: - dec hl - ld a,(hl) - call outchar - djnz pss_l - ret + ld a,c + add b + ld c,a + ld a,(screen_width) + sub b + cp c + jr nc,psym_nxtsym -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 - ld a,':' - call outchar call crlf -pl_e: - pop hl - ret + ld c,0 + jr psym_nxtsym -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 +psym_e: + ld a,c + or a + ret z + jp crlf - 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 -sub_hl_a1: - dec hl -sub_hl_a: - push bc - ld c,a - ld b,0 - or a - sbc hl,bc - pop bc - ret +;------------------------------------------------------------------------------- +; > Q[J] startaddr endaddr bytes +; Query memory for a byte string [Justified] cmd_Q: - ld a,(de) + call get_char_upper sub 'J' ld (cmd_Q_jopt),a jr nz,l0e8dh @@ -2526,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 @@ -2639,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 @@ -2650,7 +2798,7 @@ sub_0f58h: push bc push de push hl - ex af,af' + push af l0f5ch: call out.hl.@ call z,outbl2 @@ -2682,15 +2830,16 @@ l0f86h: inc hl dec e jr nz,l0f86h - ex af,af' + pop af + push af jr nc,l0f97h ld (last_D),hl l0f97h: - ex af,af' call crlf ld a,b or c jr nz,l0f5ch + pop af pop hl pop de pop bc @@ -2706,13 +2855,17 @@ l0fach: ld a,'.' ret +;------------------------------------------------------------------------------- +; > Fcommandline +; specifiy filenames and command line + cmd_F: push de ld hl,DMA_BUF+1 ld (hl),' ' inc hl l0fb6h: - ld a,(de) + call get_char_upper ld (hl),a inc hl inc de @@ -2803,6 +2956,7 @@ sub_1012h: cp '.' ret z ld c,'?' + call toupper cp '*' ret @@ -2834,6 +2988,8 @@ sub_1043h: cp ',' ret +;------------------------------------------------------------------------------- + setup_fcb: push de ld hl,12 @@ -2850,6 +3006,8 @@ l1052h: pop de ret +;------------------------------------------------------------------------------- + file_open: ld (cur_fcb),de call setup_fcb @@ -2866,6 +3024,7 @@ read_byte: cp 080h jr nz,l1111h call read_sector + ld a,01ah ret z sub a l1111h: @@ -2887,9 +3046,9 @@ read_sector: ld de,(cur_fcb) ld c,BDOS_READ call ddtz_bdos - dec a + sub a,1 jr z,l1132h - jp p,ERROR + jr nc,error2 l1132h: pop bc pop de @@ -2901,10 +3060,10 @@ cmdR_storebyte: push de ld de,TPA call cp_hl_de - jp c,ERROR + jr c,error2 ld de,(BDOS+1) call cp_hl_de - jp nc,ERROR + jr nc,error2 ld de,(high_load) call cp_hl_de jr c,l1157h @@ -2949,11 +3108,11 @@ read_hexchar: read_hexdigit: call read_byte - jr z,error8 + jr z,error2 hex_digit_v: call hex_digit ret nc -error8: +error2: jp ERROR read_hexbyte: @@ -2972,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 @@ -2992,12 +3155,15 @@ read_file: pop hl jr z,read_hexfile ld de,TPA - add hl,de push hl + add hl,de l108eh: call read_sector + jr nz,read_file_nxt pop hl - jr z,read_symfile + jr read_symfile + +read_file_nxt: ld de,DMA_BUF ld b,080h l109ah: @@ -3006,29 +3172,28 @@ l109ah: inc de inc hl djnz l109ah - push hl jr l108eh read_hexfile: push hl l10aeh: - call read_byte + call read_byte ; RECORD MARK jr z,rdhex_done cp ':' jr nz,l10aeh ld c,0 - call read_hexchar + call read_hexchar ; RECLEN ld b,a - call read_hexchar + call read_hexchar ; LOAD ADDR H ld h,a - call read_hexchar + call read_hexchar ; LOAD ADDR L ld l,a ld a,b and a jr z,rdhex_done - call read_hexchar + call read_hexchar ; RECTYP l10cch: - call read_hexchar + call read_hexchar ; DATA pop de push de push hl @@ -3037,10 +3202,10 @@ l10cch: pop hl inc hl djnz l10cch - call read_hexchar + call read_hexchar ; CHKSUM ld a,c and a - jr nz,error9 + jr nz,error3 jr l10aeh rdhex_done: pop hl @@ -3052,88 +3217,158 @@ read_symfile: cp ' ' jp z,p_max_high + push hl ; offset call pstr_inl db 'SYMBOLS',CR,LF+80h - dec de - call file_open -;------------------------------------------------------------------------ + dec de + call file_open + ld a,(symattrib) + ld c,a rs_1: call read_byte rs_2: + pop de ; offset cp 1ah - jr z,p_max_high + jp z,p_max_high + push de ; offset cp '!' jr c,rs_1 - call read_hexbyte0 - ld d,a - call read_hexbyte ; symval - ld e,a - push de ; symval + 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 - pop hl ; discard symval rs_3: call read_byte cp ' ' - jr c,rs_2 - jr rs_3 -; -rs_4: ld hl,(BDOS+1) ; - ld e,0 ; setup symlen -rs_5: dec hl ; - call read_byte ; - cp TAB ; - jr z,rs_6 ; - cp CR ; - jr z,rs_6 ; - cp '!' ; - jr c,error9 ; + 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 e ; symlen++ - ld a,e ; - cp 10h+1 ; - jr c,rs_5 ; -error9: + inc b ; symlen++ + ld a,(symlen_max) ; + cp b ; + jr nc,rs_5 ; +error3: jp ERROR ; -; -rs_6: push de ; symlen - push hl ; + +rs_6: + call test_symterm_ch + jr nz,error3 + + push bc ; symlen ex de,hl ; ld hl,(BDOS+1) ; inc hl ; - ld e,(hl) ; + ld c,(hl) ; inc hl ; - ld d,(hl) ; - pop hl ; - ld (hl),d ; + ld b,(hl) ; + ex de,hl + ld (hl),b ; dec hl ; - ld (hl),e ; + ld (hl),c ; dec hl ; ld (hl),0c3h ; ld de,(max_load) ; call cp_hl_de ; - jr c,error9 ; - + 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 de ; - ld (hl),e ; symlen + 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 + cp TAB + ret + +;------------------------------------------------------------------------------- p_max_high0: call assert_eol @@ -3152,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 @@ -3166,7 +3405,7 @@ l11adh: push bc ld a,(dfcb1+1) cp ' ' - jr z,error5 + jr z,error4 ld de,dfcb1 call setup_fcb push de @@ -3176,7 +3415,7 @@ l11adh: ld c,BDOS_CREATE call ddtz_bdos inc a - jr z,error5 + jr z,error4 pop bc pop hl l11cch: @@ -3205,7 +3444,7 @@ write_sector: and a ret z call close_file -error5: +error4: jp ERROR close_file: @@ -3213,62 +3452,61 @@ 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 - push hl - pop iy - ld hl,l1259h + ld (last_A),hl + ld (cmd_A_prev),hl + ld hl,cmda_restart ld (error_func),hl ld (l1262h),sp -l1211h: - push iy - pop hl - ld (last_A),hl +cmda_loop: + ld hl,(last_A) ld (var.$),hl push hl call p_disas_line - pop iy + ld c,19 + call p_align_@_sym ld c,b - ld de,(var.@) - ld a,d - or e - ld b,011h - jr z,l122dh - ld b,019h -l122dh: - call outbl - ld a,(con_col) - cp b - jr c,l122dh push bc call get_line pop bc + pop hl call skipbl cp '.' ret z cp '-' jr nz,l124bh - ld iy,(cmd_A_prev) - jr l1211h + ld hl,(cmd_A_prev) + jr cmda_lpend l124bh: + push hl + pop iy + push hl and a - call nz,sub_1268h - ld (cmd_A_prev),iy + call nz,asemble_line ld b,0 - add iy,bc - jr l1211h + pop hl + ld (cmd_A_prev),hl + add hl,bc +cmda_lpend: + ld (last_A),hl + jr cmda_loop -l1259h: - call l0146h +cmda_restart: + call p_msg_error ld sp,(l1262h) - jr l1211h + jr cmda_loop -sub_1268h: +asemble_line: call skipbl ld hl,t_MNEMONICS call sub_030ah - jp nc,ERROR + jr nc,error4 call skipbl push de ld a,b @@ -3287,6 +3525,8 @@ sub_1268h: CALL_HL: jp (hl) +;------------------------------------------------------------------------------- + b_1289_start: dw as.ADC_SBC ;ADC db 088h ; @@ -3444,6 +3684,8 @@ b_1289_start: dw as.TSTIO ;TSTIO db 074h ; +;------------------------------------------------------------------------------- + as.TST: call arg.r_HL_A ; jr nc,as.tst_0 @@ -3461,9 +3703,9 @@ as.TSTIO: as.IN0: call arg.r_HL_A ; - jr nc,error7 + jr nc,error5 cp 006h - jr z,error7 + jr z,error5 rlca rlca rlca @@ -3477,9 +3719,9 @@ as.OUTO: call arg.addr_8bit ; call assert_comma ; call arg.r_HL_A ; - jr nc,error7 + jr nc,error5 cp 006h - jr z,error7 + jr z,error5 rlca rlca rlca @@ -3496,12 +3738,12 @@ as.store_io0: as.MLT: call arg.ww ; - jr nc,error7 + jr nc,error5 add a,b ld b,a jp gen.opc.ED2 -error7: +error5: jp ERROR as.LD: @@ -3513,13 +3755,13 @@ as.LD: jp c,l149ch call arg.IX_IY jp c,l14f5h - ld a,(de) + call get_char_upper cp 'I' jp z,l1511h cp 'R' jp z,l1519h cp '(' - jp nz,ERROR + jr nz,error5 inc de call arg.ww jp c,l1528h @@ -3541,12 +3783,14 @@ l139bh: ld (iy+003h),h ld c,004h ret + l13aah: - ld a,(de) + call get_char_upper cp 'A' - jp nz,ERROR + jr nz,error5 inc de ld b,032h + as.store_3: call assert_eol ld (iy+000h),b @@ -3554,6 +3798,7 @@ as.store_3: ld (iy+002h),h ld c,003h ret + l13c2h: cp 020h jr z,l13d0h @@ -3566,6 +3811,7 @@ l13c9h: l13d0h: ld b,022h jr as.store_3 + l13d4h: ld b,a call assert_comma @@ -3581,10 +3827,11 @@ l13d4h: add a,b add a,040h cp 076h - jp z,ERROR + jr z,error60 l13ech: ld b,a jp as.opc.noarg + l13f0h: call arg.IDX_displcmnt jr nc,l1413h @@ -3594,7 +3841,7 @@ l13f0h: rlca add a,046h cp 076h - jp z,ERROR + jr z,error60 l1400h: ld b,a @@ -3605,21 +3852,23 @@ l1400h: ld (iy+000h),a ld c,003h ret + l1413h: - ld a,(de) + call get_char_upper cp 'I' jr z,l1426h cp 'R' jr nz,l1432h ld a,b cp 007h - jp nz,ERROR + jr nz,error60 ld b,05fh jr l142eh + l1426h: ld a,b cp 007h - jp nz,ERROR + jr nz,error60 ld b,057h l142eh: inc de @@ -3645,15 +3894,19 @@ l144ch: inc de ld a,b cp 007h - jp nz,ERROR + jr nz,error60 call arg.ww jr nc,l1466h cp 030h - jp nc,ERROR + jr nc,error60 add a,00ah ld b,a call test_paren_close jp as.opc.noarg + +error60: + jp error + l1466h: call test_expr call test_paren_close @@ -3665,7 +3918,7 @@ l1471h: call arg.r_HL_A jr nc,l1483h cp 006h - jp z,ERROR + jr z,error60 add a,070h jp l1400h @@ -3698,14 +3951,16 @@ l14b4h: ld (iy+001h),b ld c,002h ret + l14c3h: ld a,b cp 030h jr nz,error6 ld b,0f9h jr as.opc.noarg ;14ca + l14cch: - ld a,(de) + call get_char_upper cp '(' jr nz,l14e8h inc de @@ -3717,9 +3972,11 @@ l14cch: add a,04bh ld b,a jp l13c9h + l14e3h: ld b,02ah jp as.store_3 + l14e8h: call test_expr call assert_eol @@ -3729,7 +3986,7 @@ l14e8h: jp as.store_3 l14f5h: call assert_comma - ld a,(de) + call get_char_upper cp '(' jr nz,l1509h inc de @@ -3737,21 +3994,24 @@ l14f5h: call test_paren_close ld b,02ah jp l1395h + l1509h: call test_expr ld b,021h jp l1395h + l1511h: inc de call assert_comma ld b,047h jr l151fh + l1519h: inc de call assert_comma ld b,04fh l151fh: - ld a,(de) + call get_char_upper inc de cp 'A' jr z,gen.opc.ED2 @@ -3765,7 +4025,7 @@ l1528h: ld b,a call test_paren_close call assert_comma - ld a,(de) + call get_char_upper cp 'A' jr nz,error6 inc de @@ -3788,7 +4048,7 @@ as.ADC_SBC: jr nc,as.AND_CP_OR_SUB_XOR call assert_comma call arg.ww - jp nc,ERROR + jr nc,error6 push af ld a,b cp 088h @@ -3801,6 +4061,7 @@ l156ch: l156eh: ld b,a jr gen.opc.ED2 + as.ADD: ld hl,t_HL.AF call sub_0318h @@ -3815,7 +4076,7 @@ as.ADD: ld hl,t_BC.DE.IY.SP l158eh: call arg.reg_16bit - jp nc,ERROR + jr nc,error6 add a,009h l1596h: ld b,a @@ -3823,11 +4084,12 @@ l1596h: l159ah: call assert_comma call arg.ww - jp nc,ERROR +error61nc: + jr nc,error6 add a,009h jp l13ech as.AND_CP_OR_SUB_XOR: - ld a,(de) + call get_char_upper cp 'A' jr nz,l15b8h push de @@ -3859,7 +4121,7 @@ as.SHIFTOP: call arg.r_HL_A jr c,l15fah call arg.IDX_displcmnt - jp nc,ERROR + jr nc,error61nc ld a,b add a,006h ld b,a @@ -3889,7 +4151,7 @@ as.BITOP: call arg.r_HL_A jr c,l1624h call arg.IDX_displcmnt - jp nc,ERROR + jr nc,error61nc ld a,l rlca rlca @@ -4000,7 +4262,7 @@ as.IM: call arg.imm_8bit ld a,l cp 003h - jr nc,error2 + jr nc,error7 and a jr z,l16c7h ld b,056h @@ -4018,14 +4280,14 @@ as.RST: ld b,a pop af and 0c7h - jr nz,error2 + jr nz,error7 jp as.opc.noarg as.POP_PUSH: call arg.IX_IY jr c,l16e7h call arg.zz - jr nc,error2 + jr nc,error7 add a,b jp l13ech l16e7h: @@ -4035,9 +4297,9 @@ l16e7h: as.IN: call arg.r_HL_A - jr nc,error2 + jr nc,error7 cp 006h - jr z,error2 + jr z,error7 rlca rlca rlca @@ -4056,7 +4318,7 @@ l170fh: call sub_171bh l1715h: jp c,gen.opc.ED2 -error2: +error7: jp ERROR sub_171bh: @@ -4068,9 +4330,9 @@ as.OUT: jr nc,l1739h call assert_comma call arg.r_HL_A - jr nc,error2 + jr nc,error7 cp 006h - jr z,error2 + jr z,error7 rlca rlca rlca @@ -4081,7 +4343,7 @@ l1739h: call arg.addr_8bit call assert_comma cp 'A' - jr nz,error2 + jr nz,error7 inc de ld b,0d3h jp as.store_2 @@ -4089,7 +4351,7 @@ l1739h: as.EX: ld hl,b_176d_start call sub_030ah - jp nc,ERROR + jr nc,error7 ld c,b call assert_eol ld b,000h @@ -4130,7 +4392,7 @@ as.DEC_INC: call arg.r_HL_A jr c,l17cch call arg.IDX_displcmnt - jp nc,ERROR + jr nc,error8 ld a,b add a,030h jp l1400h @@ -4164,7 +4426,7 @@ arg.bit: call arg.imm_8bit ld a,l cp 008h - jr nc,error3 + jr nc,error8 ret arg.j_displ: @@ -4181,11 +4443,11 @@ arg.j_displ: ld a,h xor l bit 7,a - jr nz,error3 + jr nz,error8 ret arg.addr_8bit: - ld a,(de) + call get_char_upper cp '(' jr nz,arg.imm_8bit inc de @@ -4200,14 +4462,14 @@ sub_1802h: ret z inc a ret z - jr error3 + jr error8 test_expr: push bc call expr pop bc ret nc -error3: +error8: jp ERROR arg.zz: @@ -4269,7 +4531,7 @@ l1852h: arg.IDX_displcmnt: push hl push bc - ld a,(de) + call get_char_upper cp '(' jr nz,l18a1h push de @@ -4284,14 +4546,14 @@ arg.IDX_displcmnt: ld a,0fdh l186eh: ld (prefix_ixiy),a - ld a,(de) + call get_char_upper cp '+' jr z,l1882h cp ')' ld hl,0 jr z,l189ah cp '-' - jp nz,ERROR + jr nz,error9 l1882h: push af inc de @@ -4305,9 +4567,9 @@ l1882h: and a sbc hl,bc l1894h: - ld a,(de) + call get_char_upper cp ')' - jp nz,ERROR + jr nz,error9 l189ah: inc de pop bc @@ -4347,16 +4609,20 @@ l18b1h: assert_comma: call next_arg ret z -l18c2h: +error9: jp ERROR test_paren_close: - ld a,(de) + call get_char_upper cp ')' - jr nz,l18c2h + jr nz,error9 inc de ret +;------------------------------------------------------------------------------- +; >>L [startaddr] [endaddr] +; List disassembled code + cmd_L: ld hl,cmd_L ld (cmd_rpt),hl @@ -4364,8 +4630,6 @@ cmd_L: jr nc,l18dbh ld hl,(last_L) l18dbh: - push hl - pop iy call next_arg call get_range jr nc,l1905h @@ -4373,45 +4637,37 @@ l18dbh: ld b,16 l18ebh: push bc - push iy - pop hl - push hl - call p_disas_line - call crlf - pop iy - ld c,b - ld b,0 - add iy,bc - ld (last_L),iy + call cmdl_p_line pop bc djnz l18ebh ret + l1905h: call assert_eol - ld h,b - ld l,c - ld a,b - or c - jr nz,l190fh - dec hl + ld d,h + ld e,l + add hl,bc + ex de,hl l190fh: - push hl - push iy - pop hl - push hl - call p_disas_line - call crlf - pop iy - ld e,b - ld d,000h - add iy,de - ld (last_L),iy - pop hl - and a - sbc hl,de - ret z - ret c - jr l190fh + push de + call cmdl_p_line + pop de + call cp_hl_de + jr c,l190fh + ret + +;------------------------------------------------------------------------------- + +cmdl_p_line: + push hl + call p_disas_line + call crlf + pop hl + ld c,b + ld b,0 + add hl,bc + ld (last_L),hl + ret p_disas_line: call p_label @@ -4421,48 +4677,58 @@ p_disas_line: call outbl sub a ld (con_col),a + push hl + pop iy call p_disas_instr - and a ret z -l193fh: - call outbl - ld a,(con_col) - cp 16 - jr c,l193fh + ld c,15 + call p_goto_col + call p_offset + call outbl + jp p_symbol + +;------------------------------------------------------------------------------- p_offset: ld de,(var.@) ld a,d or e ret z - call p_char_lparen - ld a,'@' - call outchar + call pstr_inl + dc '(@' and a sbc hl,de call out_hl + add hl,de jp out_rparen +;------------------------------------------------------------------------------- + p_disas_instr: sub a - ld (l1ffdh),a + ld (disas_argtype),a call disas_get_instrlen jr nc,l197fh - push bc - call p_mnemonic + push bc + ld a,(con_col) + add a,5 + ld c,a + call pstr + call p_goto_col ex de,hl call call_hl pop bc - ld a,(l1ffdh) - ld hl,(l1ffbh) + ld a,(disas_argtype) + ld hl,(disas_arg_16) + or a scf ret l197fh: call pstr_inl DC '???' - ld b,001h + ld b,1 sub a ret @@ -4498,6 +4764,8 @@ l19b1h: scf ret +;------------------------------------------------------------------------------- + disas_pfx.DDFD: inc iy ld hl,b_19ef_start @@ -4524,6 +4792,7 @@ l19edh: and a ret +;------------------------------------------------------------------------------- ; DD/FD 3 byte (ix+d)/(iy+d) b_19ef_start: db 034h @@ -4571,6 +4840,8 @@ l1a0ah: db 0f9h db 0 +;------------------------------------------------------------------------------- + disas_pfx.ED: inc iy ld hl,b_1bc9_start @@ -4591,6 +4862,8 @@ disas_pfx.ED: ld b,4 ret +;------------------------------------------------------------------------------- + disas_pfx.CB: push iy inc iy @@ -4605,6 +4878,8 @@ l1a42h: ld b,2 ret +;------------------------------------------------------------------------------- + disas_nopfx: ld hl,b_1b54_start call lookup_opc @@ -4624,6 +4899,8 @@ disas_nopfx: ld b,3 ret +;------------------------------------------------------------------------------- + sub_1a72h: ld a,(hl) cp 0ffh @@ -4634,14 +4911,11 @@ sub_1a72h: inc hl jr sub_1a72h l1a7fh: + ld de,l1c97h inc hl ld c,(hl) - ld hl,t_MNEMONICS - ld b,0 - add hl,bc - ld de,l1c97h - scf - ret + jr get_mnemonic + test_DDFD: ld a,(hl) @@ -4667,6 +4941,7 @@ lookup_opc: and a jr nz,lookup_opc ret + l1aa8h: inc hl ld c,(hl) @@ -4674,12 +4949,14 @@ l1aa8h: ld e,(hl) inc hl ld d,(hl) +get_mnemonic: ld hl,t_MNEMONICS - ld b,000h + ld b,0 add hl,bc scf ret +;------------------------------------------------------------------------------- ; 1 byte opcodes (no parameters) ; Format: db opcode, t_MNEMONICS-index b_1ab6_start: @@ -4699,7 +4976,7 @@ b_1ab6_start: db 0ffh -; 1 byte opcodes +; 1 byte opcodes ; Format: db mask, match, t_MNEMONICS-index ; dw argument formating fuction b_1ad1_start: @@ -4757,7 +5034,7 @@ b_1ad1_start: dw l1ce5h db 0 -; 2 byte opdodes +; 2 byte opdodes b_1b54_start: db 0c7h,006h,056h ;ld r,nn dw l1cfah @@ -4778,18 +5055,18 @@ b_1b54_start: db 0ffh,0feh,013h ;cp a,nn dw l1d09h db 0ffh,010h,02eh ;djnz - dw l1d1ah + dw p_arg_jrel db 0ffh,018h,054h ;jr - dw l1d1ah - db 0e7h,020h,054h ;jr,cc - dw l1d0fh + dw p_arg_jrel + db 0e7h,020h,054h ;jr cc, + dw p_arg_cc_jrel db 0ffh,0d3h,076h ;out (nn),a dw l1d37h db 0ffh,0dbh,03fh ;in a,(nn) dw l1d29h db 0 -; 3 byte opcodes +; 3 byte opcodes b_1b9b_start: db 0c7h,0c2h,052h ;jp cc,mn dw p_arg_cc_mn @@ -4933,6 +5210,8 @@ b_1c55_start: dw p_arg_bitop db 0 +;------------------------------------------------------------------------------- + p_arg_r_r: call p_arg_r call p_char_comma @@ -4995,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 @@ -5013,12 +5291,12 @@ l1d09h: l1d0ch: jp out_hex -l1d0fh: +p_arg_cc_jrel: ld a,(iy+000h) and 018h call p_arg_cc0 call p_char_comma -l1d1ah: +p_arg_jrel: ld c,(iy+001h) ld a,c rla @@ -5030,12 +5308,17 @@ l1d1ah: inc hl inc hl jr l1d4eh + l1d29h: call p_A_comma 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 @@ -5049,49 +5332,53 @@ p_arg_mn: l1d4eh: ld a,002h sub_1d50h: - ld (l1ffdh),a - ld (l1ffbh),hl - call out_hl - ret + ld (disas_argtype),a + ld (disas_arg_16),hl + jp out_hl + p_arg_ww_mn: call p_arg_ww call p_char_comma jr p_arg_mn p_arg_addr_hl: - call sub_1e13h + call p_arg_addr call p_char_comma jp p_arg_hlixiy + p_arg_hl_addr: call p_arg_hlixiy call p_char_comma - jp sub_1e13h + jp p_arg_addr p_arg_addr_a: - call sub_1e13h + 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 sub_1e13h + 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: @@ -5135,14 +5422,24 @@ l1dcah: jp p_arg_ww p_arg_addr_ww: - call sub_1e13h + call p_arg_addr call p_char_comma jp p_arg_ww p_arg_ww_addr: call p_arg_ww call p_char_comma - jr sub_1e13h + 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) @@ -5175,17 +5472,6 @@ l1e0eh: l1e11h: jr p_arg_r0 -sub_1e13h: - 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 @@ -5210,20 +5496,18 @@ p_arg_r0: l1e4dh: call pstr ld a,(iy+001h) - and a - jp m,l1e61h + push af + rlca ld a,'+' - call outchar - ld a,(iy+001h) - jr l1e6bh -l1e61h: + jr nc,l1e61h + pop af + neg + push af ld a,'-' +l1e61h: call outchar - ld a,(iy+001h) - neg -l1e6bh: - call out_hex - jr p_char_rparen + pop af + jp p_arg_nn_rp p_arg_r1: ld hl,t_BCDEHL_HL_A @@ -5267,15 +5551,7 @@ p_arg: call sel_dc_string jp pstr -p_mnemonic: - call pstr -l1ebch: - call outbl - inc c - ld a,c - cp 5 - jr c,l1ebch - ret +;------------------------------------------------------------------------------- t_MNEMONICS: DC 'ADC' @@ -5428,6 +5704,8 @@ t__C_: DC '(C)' DB 0 +;------------------------------------------------------------------------------- + sub_1ffeh: ld hl,(reg.pc) ld a,h @@ -5442,7 +5720,7 @@ sub_1ffeh: call disas_get_instrlen jp nc,ERROR ld c,b - ld b,000h + ld b,0 ld hl,(reg.pc) add hl,bc call sub_09cah @@ -5459,6 +5737,8 @@ l2037h: scf ret +;------------------------------------------------------------------------------- + b_2039_start: db 0ffh,0ddh,000h ;Prefix DD dw l20a7h @@ -5492,6 +5772,8 @@ b_2048_start: dw l20c5h db 0 +;------------------------------------------------------------------------------- + l2080h: ld a,(b_21e2_start) and a @@ -5597,23 +5879,37 @@ 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,001h + 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 l2122h: ld (cmd_rpt),hl ld (trace_call_flag),a - ld a,(de) + call get_char_upper sub 'N' jr nz,l212eh inc de l212eh: ld (trace_N_flag),a - ld a,(de) + call get_char_upper sub 'J' jr nz,l2137h inc de @@ -5680,7 +5976,7 @@ sub_21a6h: call skipbl xor a ld (trace_UW_flag),a - ld a,(de) + call get_char_upper cp 'U' jr z,l21b5h cp 'W' @@ -5714,6 +6010,8 @@ l21dah: cp 045h ret +;------------------------------------------------------------------------------- + b_21e2_start: db 0 trace_call_flag: @@ -5832,6 +6130,8 @@ current_cseg defl $ ds EXPR_BUF_SIZE - ($ - expr_buf) expr_bufe: +;------------------------------------------------------------------------------- + msg_Y: dc 'Yn' reg_Y: @@ -5878,11 +6178,16 @@ isprefix_ixiy: db 0 last_L: dw TPA -l1ffbh: +disas_arg_16: dw 0 -l1ffdh: +disas_argtype: db 0 +pbl_loop_adr: + dw 0 + +symlen_cur: ;max length of symbols read so far + db 0 cur_fcb: dw 0 fcbsym: