X-Git-Url: http://cloudbase.mooo.com/gitweb/ddt180.git/blobdiff_plain/3a4deef923e7cdf53a61035bb58575f8da8045b0..85b57f2af28ed5ff67bed5f8a8f3959c7a3fb675:/ddt180.z80?ds=sidebyside diff --git a/ddt180.z80 b/ddt180.z80 index 862dbc2..4f12b0a 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,15 +237,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 +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 @@ -269,8 +269,8 @@ l01bfh: ret sub_01d9h: - ld a,'-' - call outchar + call pstr_inl + dc '-' dec hl jp cpl.hl @@ -283,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 @@ -349,7 +350,8 @@ l01c9h: jr outchar out.ascii: - push af + push bc + ld c,a res 7,a cp ' ' push af @@ -358,22 +360,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 @@ -392,6 +392,8 @@ p_char_lparen: outquote: ld a,'''' outchar: + push ix + push iy push hl push de push bc @@ -406,20 +408,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,6 +428,13 @@ pstr_inl: 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 @@ -511,9 +519,7 @@ skipbl0: inc de skipbl: ld a,(de) - cp ' ' - jr z,skipbl0 - cp TAB + call test_whitespace jr z,skipbl0 or a ret @@ -533,7 +539,7 @@ assert_eol: to_error: jp ERROR -chk_sp: +chk_stack: push hl push de ld hl,0 @@ -558,6 +564,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: @@ -715,14 +828,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,7 +849,7 @@ l03b6h: l03b8h: pop af pop hl - jr z,error0 + jr z,error0 ;'S', but no expression following scf ret @@ -994,7 +1107,7 @@ fact_factor: jp ERROR do_factor: - call chk_sp + call chk_stack call get.number ret nc inc de @@ -1040,8 +1153,9 @@ do_factor: 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 +1193,7 @@ l0557h: fact_reg.CPU: call sub_0caeh - jr nc,error4 + jr nc,error1 ld a,(hl) inc hl ld h,(hl) @@ -1108,10 +1222,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,74 +1242,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 + ld hl,ddtz_base ;symtbl start 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 + push hl ;symtbl ptr + push de ;inpsym ptr fs_2: 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) + 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: - pop de - pop hl +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 -fs_endstr: - dec b - jr nz,fs_cont - pop hl - pop hl - inc hl - ld a,(hl) - inc hl - ld h,(hl) - ld l,a - or a - 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 - - - get.number: call get.hexdigit ret c @@ -1315,24 +1409,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: @@ -1347,6 +1438,7 @@ p_f2: ld a,(reg.f2) call p_flags jp outbl + p_flags: ld b,a ld a,'S' @@ -1368,11 +1460,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 @@ -1383,13 +1474,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 +1494,6 @@ l06e2h: call outbl pop de pop hl - pop bc ret b_06e9_start: @@ -1485,24 +1573,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 +1614,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 +1630,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 +1643,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 +1663,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 +1696,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 +1704,7 @@ l085ah: ld bc,BP_SIZE add ix,bc pop bc - djnz l085ah + djnz bp_gf_l jp ERROR bp_get_count: @@ -1958,7 +2046,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 @@ -2008,15 +2100,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 +2115,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,12 +2144,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 @@ -2228,6 +2321,12 @@ l0d60h: dec hl inc de cp '.' + jr nz,cmds_dash + ld a,(de) + or a + jr nz,l0d8ah + ret +cmds_dash: jp z,assert_eol cp '-' jr nz,l0d8ah @@ -2383,109 +2482,54 @@ 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 - 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 + ld a,c + add b + ld c,a + 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 -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 + jp crlf -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 c,a - ld b,0 - or a - sbc hl,bc - pop bc - ret cmd_Q: ld a,(de) @@ -2650,7 +2694,7 @@ sub_0f58h: push bc push de push hl - ex af,af' + push af l0f5ch: call out.hl.@ call z,outbl2 @@ -2682,15 +2726,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 @@ -2866,6 +2911,7 @@ read_byte: cp 080h jr nz,l1111h call read_sector + ld a,01ah ret z sub a l1111h: @@ -2887,9 +2933,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 +2947,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 +2995,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: @@ -2992,12 +3038,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 +3055,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 +3085,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 +3100,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 @@ -3166,7 +3270,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 +3280,7 @@ l11adh: ld c,BDOS_CREATE call ddtz_bdos inc a - jr z,error5 + jr z,error4 pop bc pop hl l11cch: @@ -3205,7 +3309,7 @@ write_sector: and a ret z call close_file -error5: +error4: jp ERROR close_file: @@ -3216,55 +3320,56 @@ close_file: 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,b ld de,(var.@) ld a,d or e - ld b,011h + ld c,19 jr z,l122dh - ld b,019h + ld c,19+7 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 + 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: +cmda_restart: call l0146h ld sp,(l1262h) - jr l1211h + jr cmda_loop -sub_1268h: +asemble_line: call skipbl ld hl,t_MNEMONICS call sub_030ah @@ -3461,9 +3566,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 +3582,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 +3601,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: @@ -4000,7 +4105,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 +4123,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 +4140,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 +4161,7 @@ l170fh: call sub_171bh l1715h: jp c,gen.opc.ED2 -error2: +error7: jp ERROR sub_171bh: @@ -4068,9 +4173,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 +4186,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 @@ -4164,7 +4269,7 @@ arg.bit: call arg.imm_8bit ld a,l cp 008h - jr nc,error3 + jr nc,error8 ret arg.j_displ: @@ -4181,7 +4286,7 @@ arg.j_displ: ld a,h xor l bit 7,a - jr nz,error3 + jr nz,error8 ret arg.addr_8bit: @@ -4200,14 +4305,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: @@ -4364,8 +4469,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 +4476,35 @@ 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,27 +4514,29 @@ 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,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: @@ -4449,20 +4544,24 @@ p_disas_instr: ld (l1ffdh),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_fill_space ex de,hl call call_hl pop bc ld a,(l1ffdh) - ld hl,(l1ffbh) + ld hl,(disas_arg_16) scf ret l197fh: call pstr_inl DC '???' - ld b,001h + ld b,1 sub a ret @@ -4634,14 +4733,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 +4763,7 @@ lookup_opc: and a jr nz,lookup_opc ret + l1aa8h: inc hl ld c,(hl) @@ -4674,8 +4771,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 @@ -4699,7 +4797,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 +4855,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 @@ -4789,7 +4887,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 @@ -5050,9 +5148,9 @@ l1d4eh: ld a,002h sub_1d50h: ld (l1ffdh),a - ld (l1ffbh),hl - call out_hl - ret + ld (disas_arg_16),hl + jp out_hl + p_arg_ww_mn: call p_arg_ww call p_char_comma @@ -5062,6 +5160,7 @@ p_arg_addr_hl: call sub_1e13h call p_char_comma jp p_arg_hlixiy + p_arg_hl_addr: call p_arg_hlixiy call p_char_comma @@ -5212,13 +5311,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: @@ -5267,16 +5366,6 @@ 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' DC 'ADD' @@ -5442,7 +5531,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 @@ -5599,7 +5688,7 @@ l2115h: ret cmd_C: ld hl,cmd_C - ld a,001h + ld a,1 jr l2122h cmd_T: xor a @@ -5878,11 +5967,13 @@ isprefix_ixiy: db 0 last_L: dw TPA -l1ffbh: +disas_arg_16: dw 0 l1ffdh: db 0 +symlen_max: ;max length of symbols read so far + db 0 cur_fcb: dw 0 fcbsym: