X-Git-Url: http://cloudbase.mooo.com/gitweb/ddt180.git/blobdiff_plain/3f9577cdb9cd98760758b6318cfea767da850974..cab0d80a35d1c7871f2f8af22c52f6ff1b77fa3d:/ddt180.z80?ds=sidebyside diff --git a/ddt180.z80 b/ddt180.z80 index 85e3705..5b531f6 100644 --- a/ddt180.z80 +++ b/ddt180.z80 @@ -9,7 +9,6 @@ ;------------------------------------------------------------------------------- ; Relocation loader ; - TPA equ 0100h cseg .phase TPA @@ -80,8 +79,11 @@ ddtz_bdos: 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,'$' @@ -235,83 +237,18 @@ 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 ret -get_line: - push hl - ld de,conbuf - 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 - pop hl - ret - -toupper: - cp 'a' - ret c - cp 'z'+1 - ret nc - and 05fh - ret - out.hl.@: call out_hl push de @@ -321,8 +258,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 @@ -331,26 +268,9 @@ l01bfh: pop de ret -out.bin.w: - ld a,h - call out.bin.b - ld a,l -out.bin.b: - ld b,8 -l01c9h: - add a,a - push af - ld a,00 - adc a,a - call out_dgt - pop af - djnz l01c9h - ld a,'"' - jp outchar - sub_01d9h: - ld a,'-' - call outchar + call pstr_inl + dc '-' dec hl jp cpl.hl @@ -363,12 +283,13 @@ out.hl.dec: 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 @@ -410,34 +331,59 @@ out_dgt: l0229h: add a,'0' jr outchar -l022dh: - ld a,'-' - call outchar - ld a,040h -out.ascii: - ex af,af' - call outquote - ex af,af' + +out.bin.w: + ld a,h + call out.bin.b + ld a,l +out.bin.b: + ld b,8 +l01c9h: + add a,a push af + ld a,00 + adc a,a + call out_dgt + pop af + djnz l01c9h + ld a,'"' + jr outchar + +out.ascii: + push bc + ld c,a res 7,a cp ' ' + push af + call nc,outbl + call outquote + pop af jr nc,l0242h sub 0c0h + ld b,a + call pstr_inl + dc '^' + ld a,b l0242h: call outchar - push af cp '''' call z,outchar - pop af - ex af,af' call outquote - pop af - or a + sla c + pop bc + ret nc ld a,'.' - call m,outchar - ex af,af' - jr c,l022dh - ret + jr outchar + +outbl6: + call outbl2 +outbl4: + call outbl2 +outbl2: + call outbl +outbl: + ld a,' ' + jr outchar p_char_lparen: ld a,'(' @@ -462,6 +408,29 @@ outchar: pop hl ret +pstr: + ld a,(hl) + inc hl + and a + ret z + call outchar + and a + ret m + jr pstr + +pstr_inl: + ex (sp),hl + call pstr + ex (sp),hl + ret + +p_fill_space: + call outbl + ld a,(con_col) + cp c + jr c,p_fill_space + ret + inchar: push hl push de @@ -479,49 +448,74 @@ l0284h: pop hl ret -pstr: +get_line: + push hl + ld de,conbuf + ld c,BDOS_CBUF + call ddtz_bdos + call crlf + ld de,conbuf+1 + ld a,(de) + ld b,a ld c,0 -l028ah: - ld a,(hl) - inc hl - and a - ret z - call outchar + 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 - and a - ret m - jr l028ah - -pstr_inl: - ex (sp),hl - call pstr - ex (sp),hl +l0191h: + pop de + jr l0162h +l0194h: + xor a + ld (de),a + ld de,conbuf+2 + pop hl ret -outbl6: - call outbl2 -outbl4: - call outbl2 -outbl2: - call outbl -outbl: - ld a,' ' - jr outchar - -add_hl_a: - add a,l - ld l,a +toupper: + cp 'a' + ret c + cp 'z'+1 ret nc - inc h + and 05fh ret skipbl0: inc de skipbl: ld a,(de) - cp ' ' - jr z,skipbl0 - cp TAB + call test_whitespace jr z,skipbl0 or a ret @@ -553,12 +547,126 @@ chk_sp: jr c,to_error ret +add_hl_a: + add a,l + ld l,a + ret nc + inc h + ret + cp_hl_de: and a 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_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: @@ -1030,17 +1138,20 @@ do_factor: cp '(' jr z,fact_mem cp '[' - jp z,expr_brckt + jr z,expr_brckt cp '''' jr z,fact_factstring + cp '.' + jr z,fact_symbol dec de scf ret fact_reg.Y: call get.decdigit - jp c,ERROR + jr c,error1 inc de +get_y_val: add a,a ld hl,reg_Y call add_hl_a @@ -1078,7 +1189,7 @@ l0557h: fact_reg.CPU: call sub_0caeh - jr nc,error4 + jr nc,error1 ld a,(hl) inc hl ld h,(hl) @@ -1107,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 @@ -1127,14 +1238,54 @@ 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 ;symtbl start + +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_2: + ld a,(de) + djnz fs_3 + call test_sym_char + jr z,fs_cont + pop hl ;inpsym ptr (discard) + 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 + cp (hl) + jr z,fs_2 +fs_cont: ;start over + pop de ;inpsym ptr + pop hl ;symtbl ptr + ld a,(hl) + add a,3 + call sub_hl_a + jr fs_nxtsym + get.number: call get.hexdigit ret c @@ -1254,24 +1405,21 @@ 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' + pop af + pop hl and a - jr z,l066bh - call outbl6 - call p_offset -l066bh: + call nz,outbl6 + call nz,p_offset jp crlf p_f: @@ -1286,6 +1434,7 @@ p_f2: ld a,(reg.f2) call p_flags jp outbl + p_flags: ld b,a ld a,'S' @@ -1307,11 +1456,10 @@ sub_06aah: jp outbl p_regs: - push bc push de call pstr - ld a,'=' - call outchar + call pstr_inl + dc '=' ex (sp),hl ld e,(hl) inc hl @@ -1322,13 +1470,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.@ @@ -1344,7 +1490,6 @@ l06e2h: call outbl pop de pop hl - pop bc ret b_06e9_start: @@ -1424,24 +1569,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 @@ -1465,12 +1610,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 @@ -1481,9 +1626,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 @@ -1493,16 +1639,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 @@ -1514,10 +1659,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 @@ -1547,7 +1692,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 @@ -1555,7 +1700,7 @@ l085ah: ld bc,BP_SIZE add ix,bc pop bc - djnz l085ah + djnz bp_gf_l jp ERROR bp_get_count: @@ -1897,7 +2042,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 @@ -1947,15 +2096,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 @@ -1963,19 +2111,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.@ @@ -1993,12 +2140,15 @@ l0c5fh: call sub_0c6ah ld (reg.f2),a ret + sub_0c6ah: - ex af,af' + push af ld b,000h call outbl call assert_eol call get_line + pop af + ex af,af' l0c76h: call skipbl ld a,b @@ -2319,100 +2469,57 @@ l0e5eh: call out_hl_dec_neg call outbl4 call out.bin.w - call outbl2 + call outbl ld a,l call out.ascii + 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 - cp 10h - ret nc + ld a,(hl) + cp 0c3h + jr z,psym_e 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 - -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 + ex de,hl 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 - - 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 a,c + add b ld c,a - ld b,0 + ld a,80 ;screen width + sub b + cp c + jr c,psym_nxtline + call p_fill_space + jr psym_nxtsym + +psym_nxtline: + ld c,0 + call crlf + jr psym_nxtsym + +psym_e: + ld a,c or a - sbc hl,bc - pop bc - ret + ret z + jp crlf + cmd_Q: ld a,(de) @@ -2577,7 +2684,7 @@ sub_0f58h: push bc push de push hl - ex af,af' + push af l0f5ch: call out.hl.@ call z,outbl2 @@ -2609,15 +2716,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 @@ -2793,6 +2901,7 @@ read_byte: cp 080h jr nz,l1111h call read_sector + ld a,01ah ret z sub a l1111h: @@ -2814,9 +2923,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 @@ -2828,10 +2937,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 @@ -2876,11 +2985,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: @@ -2919,12 +3028,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: @@ -2933,29 +3045,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 @@ -2964,10 +3075,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 @@ -2979,88 +3090,144 @@ 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 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 ld (hl),a ; - inc e ; symlen++ - ld a,e ; + inc b ; symlen++ + ld a,b ; cp 10h+1 ; jr c,rs_5 ; -error9: +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 af ; symlen + ld (hl),a ; inc hl ; pop de ; symval ld (hl),e ; inc hl ; ld (hl),d ; + ld hl,symlen_max ; + 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'+1 + ccf + ret c + cp 'a' + ret nc + cp 'Z'+1 + ccf + ret c + cp '?' + ret nc +test_numeral: + cp '9'+1 + 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 @@ -3073,6 +3240,10 @@ p_max_high: DC ' Max = ' ld hl,(max_load) call out_hl + call pstr_inl + DC ' Top = ' + ld hl,(BDOS+1) + call out_hl jp crlf cmd_W: @@ -3089,7 +3260,7 @@ l11adh: push bc ld a,(dfcb1+1) cp ' ' - jr z,error5 + jr z,error4 ld de,dfcb1 call setup_fcb push de @@ -3099,7 +3270,7 @@ l11adh: ld c,BDOS_CREATE call ddtz_bdos inc a - jr z,error5 + jr z,error4 pop bc pop hl l11cch: @@ -3128,7 +3299,7 @@ write_sector: and a ret z call close_file -error5: +error4: jp ERROR close_file: @@ -3152,18 +3323,15 @@ l1211h: push hl call p_disas_line pop iy - ld c,b ld de,(var.@) ld a,d or e - ld b,011h + ld c,17 jr z,l122dh - ld b,019h + ld c,25 l122dh: - call outbl - ld a,(con_col) - cp b - jr c,l122dh + call p_fill_space + ld c,b push bc call get_line pop bc @@ -3384,9 +3552,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 @@ -3400,9 +3568,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 @@ -3419,12 +3587,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: @@ -3923,7 +4091,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 @@ -3941,14 +4109,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: @@ -3958,9 +4126,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 @@ -3979,7 +4147,7 @@ l170fh: call sub_171bh l1715h: jp c,gen.opc.ED2 -error2: +error7: jp ERROR sub_171bh: @@ -3991,9 +4159,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 @@ -4004,7 +4172,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 @@ -4087,7 +4255,7 @@ arg.bit: call arg.imm_8bit ld a,l cp 008h - jr nc,error3 + jr nc,error8 ret arg.j_displ: @@ -4104,7 +4272,7 @@ arg.j_displ: ld a,h xor l bit 7,a - jr nz,error3 + jr nz,error8 ret arg.addr_8bit: @@ -4123,14 +4291,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: @@ -4348,23 +4516,23 @@ p_disas_line: and a ret z -l193fh: - call outbl - ld a,(con_col) - cp 16 - jr c,l193fh + ld c,16 + call p_fill_space + call p_offset + ld a,80h + jp p_sym_space 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: @@ -4557,14 +4725,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) @@ -4590,6 +4755,7 @@ lookup_opc: and a jr nz,lookup_opc ret + l1aa8h: inc hl ld c,(hl) @@ -4597,8 +4763,9 @@ 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 @@ -4622,7 +4789,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: @@ -4680,7 +4847,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 @@ -4712,7 +4879,7 @@ b_1b54_start: 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 @@ -5135,13 +5302,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: @@ -5191,14 +5358,11 @@ p_arg: jp pstr p_mnemonic: - call pstr -l1ebch: - call outbl - inc c - ld a,c - cp 5 - jr c,l1ebch - ret + ld a,(con_col) + add a,5 + ld c,a + call pstr + jp p_fill_space t_MNEMONICS: DC 'ADC' @@ -5522,7 +5686,7 @@ l2115h: ret cmd_C: ld hl,cmd_C - ld a,001h + ld a,1 jr l2122h cmd_T: xor a @@ -5806,6 +5970,8 @@ l1ffbh: l1ffdh: db 0 +symlen_max: ;max length of symbols read so far + db 0 cur_fcb: dw 0 fcbsym: