X-Git-Url: http://cloudbase.mooo.com/gitweb/ddt180.git/blobdiff_plain/3a4deef923e7cdf53a61035bb58575f8da8045b0..2d914eb7d607546546a41af99ded751e8e416dfb:/ddt180.z80 diff --git a/ddt180.z80 b/ddt180.z80 index 862dbc2..9dae620 100644 --- a/ddt180.z80 +++ b/ddt180.z80 @@ -235,15 +235,13 @@ exe_hl: jr mainloop l0146h: - ld a,'?' - call outchar + 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 +256,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,8 +267,8 @@ l01bfh: ret sub_01d9h: - ld a,'-' - call outchar + call pstr_inl + dc '-' dec hl jp cpl.hl @@ -283,8 +281,8 @@ out.hl.dec: ld b,006h call sub_01f9h pop hl - ld a,'.' - call outchar + call pstr_inl + dc '.' l01f3h: call outbl djnz l01f3h @@ -359,8 +357,8 @@ out.ascii: jr nc,l0242h sub 0c0h ex af,af' - ld a,'^' - call outchar + call pstr_inl + dc '^' ex af,af' l0242h: call outchar @@ -409,17 +407,14 @@ outchar: 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 @@ -558,6 +553,113 @@ 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_sym_space: + if 0 + ld a,(dash_flag) + or a + ret nz + endif + + push hl + push bc + ld c,a + ld a,(con_col) + ld b,a + call sym_getname + jr z,psb_align + bit 7,c + jr z,psb_nd + call pstr_inl + dc ' .' +psb_nd: + call p_symstr + +psb_align: + ld a,(con_col) + sub b + ld b,a + ld a,(symlen_max) + bit 7,c + jr z,$+4 + add a,2 + res 7,c + add c + sub b + ld b,a + jr z,psb_e +psb_a_l: + call outbl + djnz psb_a_l +psb_e: + pop bc + 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: @@ -1042,6 +1144,7 @@ fact_reg.Y: call get.decdigit jr c,error4 inc de +get_y_val: add a,a ld hl,reg_Y call add_hl_a @@ -1371,8 +1474,8 @@ p_regs: push bc push de call pstr - ld a,'=' - call outchar + call pstr_inl + dc '=' ex (sp),hl ld e,(hl) inc hl @@ -1485,24 +1588,24 @@ l075ah: 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 @@ -1526,12 +1629,12 @@ l07aeh: djnz l0799h ret -l07b7h: +bp_print: ld b,BP_CNT ld ix,bp_tab -l07bdh: +bp_pr_l: bit 0,(ix+000h) - jr z,l0808h + jr z,bp_pr_cont ld a,'R' bit 4,(ix+000h) jr nz,l07cdh @@ -1542,9 +1645,10 @@ l07cdh: ld l,(ix+002h) ld h,(ix+003h) call out.hl.@ - call outbl2 - ld a,':' - call outchar + ld a,82h + call p_sym_space + call pstr_inl + dc ':' ld l,(ix+004h) ld h,(ix+005h) call out_hl @@ -1554,16 +1658,15 @@ 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: +bp_pr_cont: ld de,BP_SIZE add ix,de - djnz l07bdh + djnz bp_pr_l ret ; Add break points to list @@ -1575,10 +1678,10 @@ 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 @@ -1608,7 +1711,7 @@ l081ch: bp_get_freeslot: ld b,BP_CNT ld ix,bp_tab -l085ah: +bp_gf_l: ld a,(ix+000h) and 00fh ret z @@ -1616,7 +1719,7 @@ l085ah: ld bc,BP_SIZE add ix,bc pop bc - djnz l085ah + djnz bp_gf_l jp ERROR bp_get_count: @@ -1958,7 +2061,11 @@ l0bc3h: l0bc7h: push af call sub_0bdch - call outbl4 + pop af + push af + call get_y_val + ld a,82h + call p_sym_space pop af inc a bit 0,a @@ -2026,8 +2133,8 @@ l0c30h: l0c33h: ld b,c call pstr - ld a,'=' - call outchar + call pstr_inl + dc '=' ld a,(de) bit 0,b jp z,out_hex @@ -2383,109 +2490,58 @@ l0e5eh: call outbl ld a,l call out.ascii - call outbl - call p_symbol + ld a,80h + call p_sym_space jp crlf p_symbols: inc de call assert_eol + ld a,(symlen_max) + 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 ex de,hl call out_hl + call outbl ex de,hl + call p_symstr + + ld a,c + add b + ld c,a + ld a,80 ;screen width + sub b + cp c + jr c,psym_nxtline +psym_fillcol: call outbl -psymch_l: - ld a,(hl) - dec hl - call outchar - djnz psymch_l - call crlf - jr psym_l + ld a,(con_col) + cp c + jr c,psym_fillcol + jr psym_nxtsym +psym_nxtline: + ld c,0 + call crlf + jr psym_nxtsym -p_symbol: - if 0 - ld a,(dash_flag) +psym_e: + ld a,c 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 - -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 - -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 + 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 cmd_Q: ld a,(de) @@ -2866,6 +2922,7 @@ read_byte: cp 080h jr nz,l1111h call read_sector + ld a,01ah ret z sub a l1111h: @@ -2887,9 +2944,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,error8 l1132h: pop bc pop de @@ -2901,10 +2958,10 @@ cmdR_storebyte: push de ld de,TPA call cp_hl_de - jp c,ERROR + jr c,error8 ld de,(BDOS+1) call cp_hl_de - jp nc,ERROR + jr nc,error8 ld de,(high_load) call cp_hl_de jr c,l1157h @@ -2992,12 +3049,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 +3066,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,7 +3096,7 @@ l10cch: pop hl inc hl djnz l10cch - call read_hexchar + call read_hexchar ; CHKSUM ld a,c and a jr nz,error9 @@ -3052,24 +3111,27 @@ read_symfile: cp ' ' jp z,p_max_high + push hl ; offset call pstr_inl db 'SYMBOLS',CR,LF+80h dec de call file_open -;------------------------------------------------------------------------ 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 + push hl ; symval call read_byte cp ' ' jr z,rs_4 @@ -3078,17 +3140,17 @@ 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 ; + call read_byte ; next char of symbol name + cp TAB ; symbol term? jr z,rs_6 ; cp CR ; jr z,rs_6 ; - cp '!' ; - jr c,error9 ; + cp '!' ; TODO: check for valid symbol char instead + jr c,error9 ; ld (hl),a ; inc e ; symlen++ ld a,e ; @@ -3096,7 +3158,7 @@ rs_5: dec hl ; jr c,rs_5 ; error9: jp ERROR ; -; + rs_6: push de ; symlen push hl ; ex de,hl ; @@ -3127,13 +3189,18 @@ rs_61: ex de,hl ; pop de ; ld (hl),e ; symlen + ld a,e inc hl ; pop de ; symval ld (hl),e ; inc hl ; ld (hl),d ; + ld hl,symlen_max + cp (hl) + jr c,$+3 + ld (hl),a jp rs_1 ; -;------------------------------------------------------------------------ + p_max_high0: call assert_eol @@ -3233,9 +3300,9 @@ l1211h: ld de,(var.@) ld a,d or e - ld b,011h + ld b,17 jr z,l122dh - ld b,019h + ld b,25 l122dh: call outbl ld a,(con_col) @@ -4424,7 +4491,6 @@ p_disas_line: call p_disas_instr and a ret z - l193fh: call outbl ld a,(con_col) @@ -4436,9 +4502,8 @@ p_offset: 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 @@ -5212,13 +5277,13 @@ l1e4dh: ld a,(iy+001h) and a jp m,l1e61h - ld a,'+' - call outchar + call pstr_inl + dc '+' ld a,(iy+001h) jr l1e6bh l1e61h: - ld a,'-' - call outchar + call pstr_inl + dc '-' ld a,(iy+001h) neg l1e6bh: @@ -5268,13 +5333,15 @@ p_arg: jp pstr p_mnemonic: + ld a,(con_col) + ld c,a call pstr l1ebch: - call outbl - inc c - ld a,c - cp 5 - jr c,l1ebch + call outbl + ld a,(con_col) + sub c + cp 5 + jr c,l1ebch ret t_MNEMONICS: @@ -5883,6 +5950,8 @@ l1ffbh: l1ffdh: db 0 +symlen_max: ;max length of symbols read so far + db 0 cur_fcb: dw 0 fcbsym: