X-Git-Url: http://cloudbase.mooo.com/gitweb/ddt180.git/blobdiff_plain/d24eec894e877b19b848303a46ba6a81b7ccc5b0..46b2e3c74e2964eb1f53b0dfcda533978caaeffe:/ddt180.z80 diff --git a/ddt180.z80 b/ddt180.z80 index cc5ca41..122748d 100644 --- a/ddt180.z80 +++ b/ddt180.z80 @@ -14,6 +14,7 @@ TPA equ 0100h .phase TPA jp start + ds 3 ldr_end: ldr_size equ $ - TPA @@ -57,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: @@ -75,6 +80,14 @@ 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 @@ -122,7 +135,7 @@ 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: @@ -199,7 +212,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 @@ -236,7 +249,7 @@ exe_hl: call CALL_HL jr mainloop -l0146h: +p_msg_error: call pstr_inl dc '?' ;fall thru @@ -392,6 +405,8 @@ p_char_lparen: outquote: ld a,'''' outchar: + push ix + push iy push hl push de push bc @@ -406,6 +421,8 @@ outchar: pop bc pop de pop hl + pop iy + pop ix ret pstr: @@ -424,14 +441,29 @@ pstr_inl: ex (sp),hl ret -p_fill_space: - call outbl +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 - jr c,p_fill_space - ret + ret nc + ret z + call outbl + jr p_goto_col + + inchar: + push ix push hl push de push bc @@ -446,6 +478,7 @@ l0284h: pop bc pop de pop hl + pop ix ret get_line: @@ -454,67 +487,41 @@ 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) + call get_char_upper call test_whitespace jr z,skipbl0 or a @@ -535,12 +542,12 @@ 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 @@ -608,45 +615,15 @@ pss_l: pop bc ret -p_sym_space: +p_symbol: 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 + call nz,p_symstr pop hl ret @@ -673,7 +650,7 @@ l02f5h: ld a,(hl) and a ret z - ld a,(de) + call get_char_upper cp (hl) jr z,l0300h inc hl @@ -704,12 +681,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 @@ -824,14 +801,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 @@ -845,7 +822,7 @@ l03b6h: l03b8h: pop af pop hl - jr z,error0 + jr z,error0 ;'S', but no expression following scf ret @@ -1103,7 +1080,7 @@ fact_factor: jp ERROR do_factor: - call chk_sp + call chk_stack call get.number ret nc inc de @@ -1125,6 +1102,9 @@ do_factor: ld hl,(var.$) cp '$' ret z + ld hl,ddtz_base + cp 'Z' + ret z cp '-' jr z,fact_factneg cp '~' @@ -1249,6 +1229,11 @@ error1: fact_symbol: push bc 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 @@ -1258,12 +1243,17 @@ fs_nxtsym: inc b push hl ;symtbl ptr push de ;inpsym ptr -fs_2: +fs_nxtchar: ld a,(de) djnz fs_3 call test_sym_char jr z,fs_cont pop hl ;inpsym ptr (discard) + inc de + cp a,':' + jr z,fs_cont_1 + dec de + pop hl ;symtbl ptr inc hl ld a,(hl) ;symval h @@ -1273,13 +1263,16 @@ fs_2: or a ;clear carry pop bc ret + fs_3: inc de dec hl - cp (hl) - jr z,fs_2 + 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 @@ -1329,7 +1322,7 @@ l05dbh: jr next_bindigit l05e4h: cp '"' - jp nz,ERROR + jr nz,error11 call get.bindigit jr nc,l05dbh or a @@ -1354,16 +1347,18 @@ next_decdigit: decnum_done: cp '.' ret z +error11: jp ERROR sub_060ch: - ld a,(de) + call get_char_upper cp '[' jr l0614h get.hexdigit: ld a,(de) hex_digit: + call toupper cp 'F'+1 l0614h: ccf @@ -1374,13 +1369,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 @@ -1417,7 +1412,6 @@ l065bh: djnz l065bh pop af pop hl - and a call nz,outbl6 call nz,p_offset jp crlf @@ -1554,17 +1548,35 @@ 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 cmd_B: @@ -1591,9 +1603,8 @@ 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) @@ -1604,16 +1615,13 @@ 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 bp_print: - ld b,BP_CNT - ld ix,bp_tab -bp_pr_l: + call bpl_init + bit 0,(ix+000h) jr z,bp_pr_cont ld a,'R' @@ -1626,8 +1634,10 @@ l07cdh: ld l,(ix+002h) ld h,(ix+003h) call out.hl.@ - ld a,82h - call p_sym_space + call outbl + call p_symbol + ld c,9 + call p_align_@_sym call pstr_inl dc ':' ld l,(ix+004h) @@ -1645,9 +1655,7 @@ l07cdh: l0805h: call crlf bp_pr_cont: - ld de,BP_SIZE - add ix,de - djnz bp_pr_l + call bpl_next ret ; Add break points to list @@ -1665,7 +1673,7 @@ bp_enter: bp_e_1: push bc call expr - jp c,ERROR + jr c,error12 pop bc bit 0,b push bc @@ -1690,17 +1698,14 @@ bp_e_1: jr bp_enter bp_get_freeslot: - ld b,BP_CNT - ld ix,bp_tab -bp_gf_l: + call bpl_init + ld a,(ix+000h) and 00fh ret z - push bc - ld bc,BP_SIZE - add ix,bc - pop bc - djnz bp_gf_l + + call bpl_next +error12 jp ERROR bp_get_count: @@ -1710,7 +1715,7 @@ bp_get_count: ret nz inc de call expr - jp c,ERROR + jr c,error12 ret bp_get_condition: @@ -1722,7 +1727,7 @@ bp_get_condition: call skipbl push de call expr - jp c,ERROR + jr c,error12 ex de,hl pop de push de @@ -1734,7 +1739,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 @@ -1802,9 +1807,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 @@ -1816,9 +1820,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 @@ -1856,9 +1859,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 @@ -1871,15 +1873,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 @@ -1889,9 +1889,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 @@ -1908,15 +1907,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 @@ -1937,9 +1935,8 @@ l09f7h: inc hl ld (hl),d l0a1dh: - ld de,BP_SIZE - add ix,de - djnz l09f7h + + call bpl_next ret user_go: @@ -1956,7 +1953,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 @@ -2042,16 +2039,20 @@ l0bc3h: l0bc7h: push af call sub_0bdch + call outbl pop af push af call get_y_val - ld a,82h - call p_sym_space + 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 @@ -2096,15 +2097,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 @@ -2112,19 +2112,18 @@ l0c30h: ret l0c33h: - ld b,c call pstr 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.@ @@ -2319,10 +2318,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 @@ -2408,7 +2413,7 @@ l0e10h: ret cmd_M: - ld a,(de) + call get_char_upper cp 'V' jr nz,l0e1fh inc de @@ -2438,9 +2443,9 @@ cmdm_up: ret 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 @@ -2474,14 +2479,14 @@ l0e5eh: call outbl ld a,l call out.ascii - ld a,80h - call p_sym_space + call outbl2 + call p_symbol jp crlf -p_symbols: +p_sym_list: inc de call assert_eol - ld a,(symlen_max) + ld a,(symlen_cur) add a,7 ld b,a ld c,0 @@ -2495,6 +2500,7 @@ psym_nxtsym: cp 0c3h jr z,psym_e + call p_goto_col ex de,hl call out_hl call outbl @@ -2504,16 +2510,13 @@ psym_nxtsym: ld a,c add b ld c,a - ld a,80 ;screen width + ld a,(screen_width) sub b cp c - jr c,psym_nxtline - call p_fill_space - jr psym_nxtsym + jr nc,psym_nxtsym -psym_nxtline: - ld c,0 call crlf + ld c,0 jr psym_nxtsym psym_e: @@ -2524,7 +2527,7 @@ psym_e: cmd_Q: - ld a,(de) + call get_char_upper sub 'J' ld (cmd_Q_jopt),a jr nz,l0e8dh @@ -2749,7 +2752,7 @@ cmd_F: ld (hl),' ' inc hl l0fb6h: - ld a,(de) + call get_char_upper ld (hl),a inc hl inc de @@ -2840,6 +2843,7 @@ sub_1012h: cp '.' ret z ld c,'?' + call toupper cp '*' ret @@ -3096,8 +3100,10 @@ read_symfile: 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: @@ -3129,11 +3135,17 @@ rs_5: 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 b ; symlen++ - ld a,b ; - cp 10h+1 ; - jr c,rs_5 ; + ld a,(symlen_max) ; + cp b ; + jr nc,rs_5 ; error3: jp ERROR ; @@ -3166,14 +3178,15 @@ rs_61: ld de,(BDOS+1) ; ld (BDOS+1),hl ; ex de,hl ; - pop af ; symlen - ld (hl),a ; + pop bc ; symlen + ld (hl),b ; inc hl ; pop de ; symval ld (hl),e ; inc hl ; ld (hl),d ; - ld hl,symlen_max ; + ld a,b ; + ld hl,symlen_cur ; cp (hl) ; new max? jr c,$+3 ; ld (hl),a ; @@ -3203,18 +3216,21 @@ test_sym_char: ; return nc if valid alfanumeric char test_alphanum: - cp 'z'+1 + cp 'z' + ret z ccf ret c cp 'a' ret nc - cp 'Z'+1 + cp 'Z' + ret z ccf ret c cp '?' ret nc test_numeral: - cp '9'+1 + cp '9' + ret z ccf ret c cp '0' @@ -3312,56 +3328,54 @@ 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 de,(var.@) - ld a,d - or e - ld c,17 - jr z,l122dh - ld c,25 -l122dh: - call p_fill_space + ld c,19 + call p_align_@_sym 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: - 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 @@ -3606,13 +3620,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 @@ -3634,12 +3648,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 @@ -3647,6 +3663,7 @@ as.store_3: ld (iy+002h),h ld c,003h ret + l13c2h: cp 020h jr z,l13d0h @@ -3659,6 +3676,7 @@ l13c9h: l13d0h: ld b,022h jr as.store_3 + l13d4h: ld b,a call assert_comma @@ -3674,10 +3692,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 @@ -3687,7 +3706,7 @@ l13f0h: rlca add a,046h cp 076h - jp z,ERROR + jr z,error60 l1400h: ld b,a @@ -3698,21 +3717,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 @@ -3738,15 +3759,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 @@ -3758,7 +3783,7 @@ l1471h: call arg.r_HL_A jr nc,l1483h cp 006h - jp z,ERROR + jr z,error60 add a,070h jp l1400h @@ -3791,14 +3816,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 @@ -3810,9 +3837,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 @@ -3822,7 +3851,7 @@ l14e8h: jp as.store_3 l14f5h: call assert_comma - ld a,(de) + call get_char_upper cp '(' jr nz,l1509h inc de @@ -3830,21 +3859,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 @@ -3858,7 +3890,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 @@ -3881,7 +3913,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 @@ -3894,6 +3926,7 @@ l156ch: l156eh: ld b,a jr gen.opc.ED2 + as.ADD: ld hl,t_HL.AF call sub_0318h @@ -3908,7 +3941,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 @@ -3916,11 +3949,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 @@ -3952,7 +3986,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 @@ -3982,7 +4016,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 @@ -4182,7 +4216,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 @@ -4223,7 +4257,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 @@ -4278,7 +4312,7 @@ arg.j_displ: ret arg.addr_8bit: - ld a,(de) + call get_char_upper cp '(' jr nz,arg.imm_8bit inc de @@ -4362,7 +4396,7 @@ l1852h: arg.IDX_displcmnt: push hl push bc - ld a,(de) + call get_char_upper cp '(' jr nz,l18a1h push de @@ -4377,14 +4411,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 @@ -4398,9 +4432,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 @@ -4440,13 +4474,13 @@ 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 @@ -4457,8 +4491,6 @@ cmd_L: jr nc,l18dbh ld hl,(last_L) l18dbh: - push hl - pop iy call next_arg call get_range jr nc,l1905h @@ -4466,45 +4498,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 @@ -4514,12 +4536,16 @@ p_disas_line: call outbl sub a ld (con_col),a + push hl + pop iy call p_disas_instr - and a ret z - ld c,16 - call p_fill_space + ld c,15 + call p_goto_col + call p_offset + call outbl + jp p_symbol p_offset: ld de,(var.@) @@ -4531,27 +4557,33 @@ p_offset: 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 @@ -4723,14 +4755,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) @@ -4756,6 +4785,7 @@ lookup_opc: and a jr nz,lookup_opc ret + l1aa8h: inc hl ld c,(hl) @@ -4763,8 +4793,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 @@ -4788,7 +4819,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: @@ -4846,7 +4877,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 @@ -4867,18 +4898,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 @@ -5102,12 +5133,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 @@ -5119,6 +5150,7 @@ l1d1ah: inc hl inc hl jr l1d4eh + l1d29h: call p_A_comma sub_1d2ch: @@ -5138,26 +5170,27 @@ 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 p_char_A: @@ -5165,7 +5198,7 @@ p_char_A: jr outchar1 p_arg_a_addr: call p_A_comma - jp sub_1e13h + jp p_arg_addr l1d85h: ld a,'0' jr outchar1 @@ -5224,14 +5257,14 @@ 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_bitop: ld a,(isprefix_ixiy) @@ -5264,7 +5297,7 @@ l1e0eh: l1e11h: jr p_arg_r0 -sub_1e13h: +p_arg_addr: call p_char_lparen ld l,(iy+001h) ld h,(iy+002h) @@ -5356,13 +5389,6 @@ p_arg: call sel_dc_string jp pstr -p_mnemonic: - ld a,(con_col) - add a,5 - ld c,a - call pstr - jp p_fill_space - t_MNEMONICS: DC 'ADC' DC 'ADD' @@ -5528,7 +5554,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 @@ -5685,7 +5711,7 @@ l2115h: ret cmd_C: ld hl,cmd_C - ld a,001h + ld a,1 jr l2122h cmd_T: xor a @@ -5693,13 +5719,13 @@ 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 @@ -5766,7 +5792,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' @@ -5964,12 +5990,15 @@ isprefix_ixiy: db 0 last_L: dw TPA -l1ffbh: +disas_arg_16: dw 0 -l1ffdh: +disas_argtype: db 0 -symlen_max: ;max length of symbols read so far +pbl_loop_adr: + dw 0 + +symlen_cur: ;max length of symbols read so far db 0 cur_fcb: dw 0